Mercurial > mercurial > hgweb_hanzen.cgi
comparison myframe.cpp @ 0:79a92ddc3546
first release.
| author | pyon@macmini |
|---|---|
| date | Wed, 16 Apr 2014 01:08:11 +0900 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:79a92ddc3546 |
|---|---|
| 1 // Filename : myframe.cpp | |
| 2 // Last Change: 15-Apr-2014. | |
| 3 // | |
| 4 | |
| 5 #include "myframe.h" | |
| 6 #include "sample.xpm" | |
| 7 | |
| 8 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
| 9 : wxFrame( parent, id, title, pos, size, style ) | |
| 10 { | |
| 11 this->SetIcon( wxIcon( wxT("sample") ) ); | |
| 12 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | |
| 13 this->SetBackgroundColour( wxColour( 23, 181, 63 ) ); | |
| 14 | |
| 15 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
| 16 | |
| 17 wxBoxSizer* bSizerButton = new wxBoxSizer( wxHORIZONTAL ); | |
| 18 | |
| 19 m_buttonPaste = new wxButton( this, ID_PASTE, wxT("Paste"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 20 bSizerButton->Add( m_buttonPaste, 0, wxALL, 5 ); | |
| 21 | |
| 22 m_comboBoxDirection = new wxComboBox( this, wxID_ANY, wxT("select direction !"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); | |
| 23 m_comboBoxDirection->Append( wxT("Zenkaku to Hankaku") ); | |
| 24 m_comboBoxDirection->Append( wxT("Hankaku to Zenkaku") ); | |
| 25 bSizerButton->Add( m_comboBoxDirection, 0, wxALL, 5 ); | |
| 26 | |
| 27 m_buttonConvert = new wxButton( this, ID_CONVERT, wxT("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 28 bSizerButton->Add( m_buttonConvert, 0, wxALL, 5 ); | |
| 29 | |
| 30 m_buttonCopy = new wxButton( this, ID_COPY, wxT("Copy"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 31 bSizerButton->Add( m_buttonCopy, 0, wxALL, 5 ); | |
| 32 | |
| 33 m_buttonClear = new wxButton( this, ID_CLEAR, wxT("Clear"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 34 bSizerButton->Add( m_buttonClear, 0, wxALL, 5 ); | |
| 35 | |
| 36 bSizerTop->Add( bSizerButton, 0, wxEXPAND, 5 ); | |
| 37 | |
| 38 m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); | |
| 39 bSizerTop->Add( m_textCtrl, 1, wxALL|wxEXPAND, 5 ); | |
| 40 | |
| 41 this->SetSizer( bSizerTop ); | |
| 42 this->Layout(); | |
| 43 | |
| 44 this->Centre( wxBOTH ); | |
| 45 } | |
| 46 | |
| 47 MyFrame::~MyFrame() | |
| 48 { | |
| 49 } | |
| 50 | |
| 51 // Event Table | |
| 52 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
| 53 EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) | |
| 54 EVT_BUTTON( ID_CONVERT, MyFrame::OnConvert ) | |
| 55 EVT_BUTTON( ID_COPY, MyFrame::OnCopy ) | |
| 56 EVT_BUTTON( ID_CLEAR, MyFrame::OnClear ) | |
| 57 END_EVENT_TABLE() | |
| 58 | |
| 59 // Functions | |
| 60 void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) | |
| 61 { | |
| 62 m_textCtrl->Clear(); | |
| 63 if ( wxTheClipboard->Open() ) { | |
| 64 if( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { | |
| 65 wxTextDataObject data; | |
| 66 wxTheClipboard->GetData( data ); | |
| 67 m_textCtrl->ChangeValue( data.GetText() ); | |
| 68 } | |
| 69 wxTheClipboard->Close(); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 void MyFrame::OnConvert( wxCommandEvent& WXUNUSED(event) ) | |
| 74 { | |
| 75 wxArrayString han, zen; | |
| 76 han.Add( wxT("0") ); zen.Add( wxT("0") ); | |
| 77 han.Add( wxT("1") ); zen.Add( wxT("1") ); | |
| 78 han.Add( wxT("2") ); zen.Add( wxT("2") ); | |
| 79 han.Add( wxT("3") ); zen.Add( wxT("3") ); | |
| 80 han.Add( wxT("4") ); zen.Add( wxT("4") ); | |
| 81 han.Add( wxT("5") ); zen.Add( wxT("5") ); | |
| 82 han.Add( wxT("6") ); zen.Add( wxT("6") ); | |
| 83 han.Add( wxT("7") ); zen.Add( wxT("7") ); | |
| 84 han.Add( wxT("8") ); zen.Add( wxT("8") ); | |
| 85 han.Add( wxT("9") ); zen.Add( wxT("9") ); | |
| 86 han.Add( wxT("-") ); zen.Add( wxT("-") ); | |
| 87 //han.Add( wxT("+") ); zen.Add( wxT("+") ); | |
| 88 han.Add( wxT("=") ); zen.Add( wxT("=") ); | |
| 89 han.Add( wxT("/") ); zen.Add( wxT("/") ); | |
| 90 han.Add( wxT("@") ); zen.Add( wxT("@") ); | |
| 91 //han.Add( wxT("(") ); zen.Add( wxT("(") ); | |
| 92 //han.Add( wxT(")") ); zen.Add( wxT(")") ); | |
| 93 han.Add( wxT("<") ); zen.Add( wxT("<") ); | |
| 94 han.Add( wxT(">") ); zen.Add( wxT(">") ); | |
| 95 //han.Add( wxT("*") ); zen.Add( wxT("*") ); | |
| 96 han.Add( wxT("#") ); zen.Add( wxT("#") ); | |
| 97 han.Add( wxT("!") ); zen.Add( wxT("!") ); | |
| 98 //han.Add( wxT("?") ); zen.Add( wxT("?") ); | |
| 99 han.Add( wxT(":") ); zen.Add( wxT(":") ); | |
| 100 han.Add( wxT(";") ); zen.Add( wxT(";") ); | |
| 101 //han.Add( wxT(".") ); zen.Add( wxT(".") ); | |
| 102 //han.Add( wxT(",") ); zen.Add( wxT(",") ); | |
| 103 | |
| 104 wxString buf = m_textCtrl->GetValue(); | |
| 105 | |
| 106 // Z -> H ok | |
| 107 if ( m_comboBoxDirection->GetSelection() == 0 ) { | |
| 108 for ( int i = 0; i < zen.GetCount(); i++ ) { | |
| 109 wxRegEx z( zen[i] ); | |
| 110 z.ReplaceAll( &buf, han[i] ); | |
| 111 } | |
| 112 } | |
| 113 // H -> Z | |
| 114 else if ( m_comboBoxDirection->GetSelection() == 1 ){ | |
| 115 for ( int i = 0; i < han.GetCount(); i++ ) { | |
| 116 wxRegEx h( han[i] ); | |
| 117 h.ReplaceAll( &buf, zen[i] ); | |
| 118 } | |
| 119 } | |
| 120 else { | |
| 121 return; | |
| 122 } | |
| 123 | |
| 124 m_textCtrl->ChangeValue( buf ); | |
| 125 } | |
| 126 | |
| 127 void MyFrame::OnCopy( wxCommandEvent& WXUNUSED(event) ) | |
| 128 { | |
| 129 m_textCtrl->SelectAll(); | |
| 130 m_textCtrl->Copy(); | |
| 131 } | |
| 132 | |
| 133 void MyFrame::OnClear( wxCommandEvent& WXUNUSED(event) ) | |
| 134 { | |
| 135 m_textCtrl->Clear(); | |
| 136 } | |
| 137 |
