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

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