1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/** \file
\brief Contains the members of the TextImportDialog class
*/
#include "TextImportDialog.h"
BEGIN_EVENT_TABLE(TextImportDialog, wxDialog )
EVT_BUTTON(TID_OK,TextImportDialog::OnOK)
EVT_BUTTON(TID_CANCEL,TextImportDialog::OnCancel)
EVT_CHAR_HOOK(TextImportDialog::OnCharHook)
END_EVENT_TABLE()
TextImportDialog::TextImportDialog(wxWindow *parent, const wxString& title )
: wxDialog ( parent , -1 , title , wxDefaultPosition , wxSize ( 600 , 450 ) )
{
myapp()->frame->push_help ( _T("GENtle:Enter sequence") ) ;
int w , h ;
int bo = 5 , lh = 22 ;
GetClientSize ( &w , &h ) ;
wxStaticText *s1 = new wxStaticText ( this , -1 , txt("title") , wxPoint ( bo , bo+2 ) ) ;
wxRect r = s1->GetRect() ;
name = new wxTextCtrl ( this , -1 , _T("") ,
wxPoint ( r.GetRight() + bo , bo ) ,
wxSize ( w * 2 / 3 - r.GetRight() - bo , lh ) ) ;
type = new wxChoice ( this , -1 ,
wxPoint ( w * 2 / 3 + bo , bo ) ,
wxSize ( w / 4 , lh ) ) ;
sequence = new wxTextCtrl ( this , -1 , _T("") ,
wxPoint ( bo , bo*2 + lh ) ,
wxSize ( w - bo*2 , h - bo*4 - lh*2 ) ,
wxTE_MULTILINE ) ;
wxButton *OK = new wxButton ( this , TID_OK , txt("b_ok") ,
wxPoint ( bo , h - lh - bo ) ,
wxSize ( w/4 , lh ) ) ;
new wxButton ( this , TID_CANCEL , txt("b_cancel") ,
wxPoint ( w*3/4 - bo , h - lh - bo ) ,
wxSize ( w/4 , lh ) ) ;
type->Append ( txt("dna") ) ;
type->Append ( txt("amino_acid") ) ;
type->Append ( txt("t_genbank_format") ) ;
type->Append ( txt("t_xml") ) ;
type->Append ( txt("t_primer") ) ;
type->SetSelection ( 0 ) ;
sequence->SetMaxLength ( 0 ) ; // Text length only limited by native gadget now
Center () ;
OK->SetDefault () ;
name->SetFocus() ;
}
TextImportDialog::~TextImportDialog ()
{
myapp()->frame->pop_help () ;
}
void TextImportDialog::OnCharHook(wxKeyEvent& event)
{
int k = event.GetKeyCode () ;
wxCommandEvent ev ;
if ( k == WXK_ESCAPE ) OnCancel ( ev ) ;
else if ( k == WXK_F1 ) myapp()->frame->OnHelp(ev) ;
else event.Skip() ;
}
void TextImportDialog::OnOK ( wxCommandEvent &ev )
{
sName = name->GetValue () ;
sSequence = _T("") ;
wxString s = sequence->GetValue() ;
for ( int a = 0 ; a < s.length() ; a++ )
{
if ( s.GetChar(a) >= 'a' && s.GetChar(a) <= 'z' ) sSequence += s.GetChar(a)-'a'+'A' ;
else if ( s.GetChar(a) >= 'A' && s.GetChar(a) <= 'Z' ) sSequence += s.GetChar(a) ;
}
EndModal ( wxID_OK ) ; // wxDialog::OnOK ( ev ) ;
}
void TextImportDialog::OnCancel ( wxCommandEvent &ev )
{
EndModal ( wxID_CANCEL ) ; // wxDialog::OnCancel ( ev ) ;
}
|