annotate src/myframe.cpp @ 0:00c5161d67b8 default tip

first release.
author pyon@macmini
date Tue, 29 Oct 2013 19:23:03 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
1 // Filename : myframe.cpp
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
2 // Last Change: 29-Oct-2013.
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
3 //
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
4 #include "myframe.h"
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
5
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
6 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
7 : wxFrame( parent, id, title, pos, size, style )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
8 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
9 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
10
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
11 wxGridSizer* gSizer = new wxGridSizer( 0, 3, 0, 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
12
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
13 m_textCtrl1l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
14 gSizer->Add( m_textCtrl1l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
15
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
16 m_button1 = new wxButton( this, ID_BTN1, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
17 gSizer->Add( m_button1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
18
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
19 m_textCtrl1r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
20 gSizer->Add( m_textCtrl1r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
21
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
22 m_textCtrl2l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
23 gSizer->Add( m_textCtrl2l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
24
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
25 m_button2 = new wxButton( this, ID_BTN2, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
26 gSizer->Add( m_button2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
27
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
28 m_textCtrl2r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
29 gSizer->Add( m_textCtrl2r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
30
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
31 m_textCtrl3l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
32 gSizer->Add( m_textCtrl3l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
33
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
34 m_button3 = new wxButton( this, ID_BTN3, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
35 gSizer->Add( m_button3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
36
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
37 m_textCtrl3r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
38 gSizer->Add( m_textCtrl3r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
39
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
40
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
41 this->SetSizer( gSizer );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
42 this->Layout();
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
43
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
44 this->Centre( wxBOTH );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
45 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
46
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
47 MyFrame::~MyFrame()
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
48 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
49 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
50
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
51 // Event Table
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
52 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
53 EVT_BUTTON( ID_BTN1, MyFrame::OnButton1 )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
54 EVT_BUTTON( ID_BTN2, MyFrame::OnButton2 )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
55 EVT_BUTTON( ID_BTN3, MyFrame::OnButton3 )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
56 END_EVENT_TABLE()
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
57
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
58 // Event Handlers & Functions
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
59 void MyFrame::OnButton1( wxCommandEvent& WXUNUSED(event) )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
60 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
61 Exchange( m_textCtrl1l, m_textCtrl1r, state1 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
62 state1 = !state1;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
63 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
64
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
65 void MyFrame::OnButton2( wxCommandEvent& WXUNUSED(event) )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
66 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
67 Exchange( m_textCtrl2l, m_textCtrl2r, state2 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
68 state2 = !state2;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
69 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
70
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
71 void MyFrame::OnButton3( wxCommandEvent& WXUNUSED(event) )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
72 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
73 Exchange( m_textCtrl3l, m_textCtrl3r, state3 );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
74 state3 = !state3;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
75 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
76
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
77 void MyFrame::InitControl( void )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
78 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
79 wxString file = wxT( "Z1400000.dta" );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
80 m_textCtrl1r->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
81 m_textCtrl2r->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
82 m_textCtrl3r->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
83
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
84 wxDir dir( wxGetCwd() );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
85 if ( !dir.IsOpened() ) return;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
86
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
87 bool cout = dir.GetFirst( &file, wxT("*.dta"), wxDIR_FILES );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
88 if ( cout ) {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
89 m_textCtrl1l->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
90 cout = dir.GetNext( &file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
91 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
92 if ( cout ) {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
93 m_textCtrl2l->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
94 cout = dir.GetNext( &file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
95 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
96 if ( cout ) {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
97 m_textCtrl3l->SetValue( file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
98 cout = dir.GetNext( &file );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
99 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
100
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
101 state1 = true;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
102 state2 = true;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
103 state3 = true;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
104 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
105
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
106 void MyFrame::Exchange( wxTextCtrl* left, wxTextCtrl* right, bool sw )
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
107 {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
108 wxString from, to;
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
109
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
110 if ( sw ) {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
111 from = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue();
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
112 to = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue();
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
113 left->SetBackgroundColour( *wxYELLOW );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
114 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
115 else {
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
116 from = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue();
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
117 to = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue();
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
118 right->SetBackgroundColour( *wxYELLOW );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
119 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
120 Refresh( true, NULL );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
121 wxRenameFile( from, to, false );
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
122 }
00c5161d67b8 first release.
pyon@macmini
parents:
diff changeset
123