Mercurial > mercurial > hgweb_renren.cgi
view src/myframe.cpp @ 0:00c5161d67b8 default tip
first release.
author | pyon@macmini |
---|---|
date | Tue, 29 Oct 2013 19:23:03 +0900 |
parents | |
children |
line wrap: on
line source
// Filename : myframe.cpp // Last Change: 29-Oct-2013. // #include "myframe.h" MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); wxGridSizer* gSizer = new wxGridSizer( 0, 3, 0, 0 ); m_textCtrl1l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl1l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_button1 = new wxButton( this, ID_BTN1, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); gSizer->Add( m_button1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_textCtrl1r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl1r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_textCtrl2l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl2l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_button2 = new wxButton( this, ID_BTN2, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); gSizer->Add( m_button2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_textCtrl2r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl2r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_textCtrl3l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl3l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); m_button3 = new wxButton( this, ID_BTN3, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); gSizer->Add( m_button3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_textCtrl3r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); gSizer->Add( m_textCtrl3r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); this->SetSizer( gSizer ); this->Layout(); this->Centre( wxBOTH ); } MyFrame::~MyFrame() { } // Event Table BEGIN_EVENT_TABLE( MyFrame, wxFrame ) EVT_BUTTON( ID_BTN1, MyFrame::OnButton1 ) EVT_BUTTON( ID_BTN2, MyFrame::OnButton2 ) EVT_BUTTON( ID_BTN3, MyFrame::OnButton3 ) END_EVENT_TABLE() // Event Handlers & Functions void MyFrame::OnButton1( wxCommandEvent& WXUNUSED(event) ) { Exchange( m_textCtrl1l, m_textCtrl1r, state1 ); state1 = !state1; } void MyFrame::OnButton2( wxCommandEvent& WXUNUSED(event) ) { Exchange( m_textCtrl2l, m_textCtrl2r, state2 ); state2 = !state2; } void MyFrame::OnButton3( wxCommandEvent& WXUNUSED(event) ) { Exchange( m_textCtrl3l, m_textCtrl3r, state3 ); state3 = !state3; } void MyFrame::InitControl( void ) { wxString file = wxT( "Z1400000.dta" ); m_textCtrl1r->SetValue( file ); m_textCtrl2r->SetValue( file ); m_textCtrl3r->SetValue( file ); wxDir dir( wxGetCwd() ); if ( !dir.IsOpened() ) return; bool cout = dir.GetFirst( &file, wxT("*.dta"), wxDIR_FILES ); if ( cout ) { m_textCtrl1l->SetValue( file ); cout = dir.GetNext( &file ); } if ( cout ) { m_textCtrl2l->SetValue( file ); cout = dir.GetNext( &file ); } if ( cout ) { m_textCtrl3l->SetValue( file ); cout = dir.GetNext( &file ); } state1 = true; state2 = true; state3 = true; } void MyFrame::Exchange( wxTextCtrl* left, wxTextCtrl* right, bool sw ) { wxString from, to; if ( sw ) { from = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue(); to = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue(); left->SetBackgroundColour( *wxYELLOW ); } else { from = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue(); to = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue(); right->SetBackgroundColour( *wxYELLOW ); } Refresh( true, NULL ); wxRenameFile( from, to, false ); }