Mercurial > mercurial > hgweb_dw.cgi
comparison src/myframe.cpp @ 3:eea479fc2a28 default tip
redesign form.
| author | pyon@macmini |
|---|---|
| date | Sun, 25 Nov 2012 12:59:11 +0900 |
| parents | deaf3f2d54b2 |
| children |
comparison
equal
deleted
inserted
replaced
| 2:deaf3f2d54b2 | 3:eea479fc2a28 |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 20-Oct-2012. | 2 // Last Change: 25-Nov-2012. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "main.h" | 5 #include "main.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "about.h" | 7 #include "about.h" |
| 9 // resources | 9 // resources |
| 10 #if !defined(__WXMSW__) && !defined(__WXPM__) | 10 #if !defined(__WXMSW__) && !defined(__WXPM__) |
| 11 #include "sample.xpm" | 11 #include "sample.xpm" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 14 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 15 : wxFrame( parent, id, title, pos, size, style ) | 15 : wxFrame( parent, id, title, pos, size, style ) |
| 16 { | 16 { |
| 17 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | 17 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
| 18 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | 18 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); |
| 19 // set the frame icon | 19 // set the frame icon |
| 20 SetIcon(wxICON(sample)); | 20 SetIcon(wxICON(sample)); |
| 21 | 21 |
| 22 // メニューバー Menu | 22 // Menubar here |
| 23 m_menubar = new wxMenuBar(); | 23 m_menubar = new wxMenuBar( 0 ); |
| 24 m_menuFile = new wxMenu(); | 24 m_menuFile = new wxMenu(); |
| 25 | 25 |
| 26 wxMenuItem* m_menuItemSetup = new wxMenuItem( m_menuFile, ID_MNSETUP, wxString( wxT("&Setup...") ) , wxT("Setup parameters"), wxITEM_NORMAL ); | 26 wxMenuItem* m_menuItemSetup = new wxMenuItem( m_menuFile, ID_MNSETUP, wxString( wxT("Setup") ) , wxEmptyString, wxITEM_NORMAL ); |
| 27 m_menuFile->Append( m_menuItemSetup ); | 27 m_menuFile->Append( m_menuItemSetup ); |
| 28 | 28 |
| 29 wxMenuItem* m_menuItemSave = new wxMenuItem( m_menuFile, ID_MNSAVE, wxString( wxT("Save setting...") ) , wxT("Save parameters"), wxITEM_NORMAL ); | 29 wxMenuItem* m_menuItemSave = new wxMenuItem( m_menuFile, ID_MNSAVE, wxString( wxT("Save") ) , wxEmptyString, wxITEM_NORMAL ); |
| 30 m_menuFile->Append( m_menuItemSave ); | 30 m_menuFile->Append( m_menuItemSave ); |
| 31 | 31 |
| 32 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL ); | 32 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL ); |
| 33 m_menuFile->Append( m_menuItemAbout ); | 33 m_menuFile->Append( m_menuItemAbout ); |
| 34 | 34 |
| 35 m_menubar->Append( m_menuFile, wxT("File(&F)") ); | 35 m_menubar->Append( m_menuFile, wxT("File") ); |
| 36 | 36 |
| 37 this->SetMenuBar( m_menubar ); | 37 this->SetMenuBar( m_menubar ); |
| 38 | 38 |
| 39 // | 39 // Controls here |
| 40 wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 4, 0, 0 ); | 40 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); |
| 41 fgSizer->SetFlexibleDirection( wxBOTH ); | 41 |
| 42 fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); | 42 wxGridBagSizer* gbSizerWatchDir = new wxGridBagSizer( 0, 0 ); |
| 43 | 43 gbSizerWatchDir->SetFlexibleDirection( wxBOTH ); |
| 44 m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Folder"), wxDefaultPosition, wxDefaultSize, 0 ); | 44 gbSizerWatchDir->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); |
| 45 fgSizer->Add( m_staticText1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 45 |
| 46 | 46 m_searchCtrlFile = new wxSearchCtrl( this, wxID_ANY, wxT("Input Filename"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 47 m_dirPickerWatch = new wxDirPickerCtrl( this, ID_WATCHDIR, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); | 47 #ifndef __WXMAC__ |
| 48 fgSizer->Add( m_dirPickerWatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 48 m_searchCtrlFile->ShowSearchButton( true ); |
| 49 | 49 #endif |
| 50 m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Filename"), wxDefaultPosition, wxDefaultSize, 0 ); | 50 m_searchCtrlFile->ShowCancelButton( false ); |
| 51 fgSizer->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 51 gbSizerWatchDir->Add( m_searchCtrlFile, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); |
| 52 | 52 |
| 53 m_textCtrlFile = new wxTextCtrl( this, ID_FILENAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 53 m_dirPickerWatchDir = new wxDirPickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); |
| 54 fgSizer->Add( m_textCtrlFile, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); | 54 gbSizerWatchDir->Add( m_dirPickerWatchDir, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); |
| 55 | 55 |
| 56 m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("Command"), wxDefaultPosition, wxDefaultSize, 0 ); | 56 m_listCtrlWatchDir = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); |
| 57 fgSizer->Add( m_staticText3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 57 gbSizerWatchDir->Add( m_listCtrlWatchDir, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALL, 5 ); |
| 58 | 58 |
| 59 m_textCtrlCommand = new wxTextCtrl( this, ID_COMMAND, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 59 bSizerTop->Add( gbSizerWatchDir, 0, wxEXPAND, 5 ); |
| 60 fgSizer->Add( m_textCtrlCommand, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); | 60 |
| 61 | 61 wxStaticBoxSizer* sbSizerFound = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("If Find File") ), wxVERTICAL ); |
| 62 m_staticText4 = new wxStaticText( this, wxID_ANY, wxT("wait [sec]"), wxDefaultPosition, wxDefaultSize, 0 ); | 62 |
| 63 fgSizer->Add( m_staticText4, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 63 wxStaticBoxSizer* sbSizerMove = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Move/Copy") ), wxVERTICAL ); |
| 64 | 64 |
| 65 m_textCtrlWait = new wxTextCtrl( this, ID_WAIT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 65 wxBoxSizer* bSizerMove = new wxBoxSizer( wxHORIZONTAL ); |
| 66 fgSizer->Add( m_textCtrlWait, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); | 66 |
| 67 | 67 wxString m_choiceMoveChoices[] = { wxT("Nop"), wxT("Move"), wxT("Copy") }; |
| 68 m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("MoveTo"), wxDefaultPosition, wxDefaultSize, 0 ); | 68 int m_choiceMoveNChoices = sizeof( m_choiceMoveChoices ) / sizeof( wxString ); |
| 69 fgSizer->Add( m_staticText5, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 69 m_choiceMove = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceMoveNChoices, m_choiceMoveChoices, 0 ); |
| 70 | 70 m_choiceMove->SetSelection( 0 ); |
| 71 m_dirPickerMove = new wxDirPickerCtrl( this, ID_MOVEDIR, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); | 71 bSizerMove->Add( m_choiceMove, 0, wxALL, 5 ); |
| 72 fgSizer->Add( m_dirPickerMove, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 72 |
| 73 | 73 m_staticText0 = new wxStaticText( this, wxID_ANY, wxT("Suffix"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 74 m_staticText6 = new wxStaticText( this, wxID_ANY, wxT("copy"), wxDefaultPosition, wxDefaultSize, 0 ); | 74 bSizerMove->Add( m_staticText0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 75 fgSizer->Add( m_staticText6, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 75 |
| 76 | 76 wxString m_choiceSuffixChoices[] = { wxT("NoChange"), wxT("Date & Time"), wxT("Date"), wxT("Time") }; |
| 77 m_checkBoxCopy = new wxCheckBox( this, ID_COPY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 77 int m_choiceSuffixNChoices = sizeof( m_choiceSuffixChoices ) / sizeof( wxString ); |
| 78 fgSizer->Add( m_checkBoxCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 78 m_choiceSuffix = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceSuffixNChoices, m_choiceSuffixChoices, 0 ); |
| 79 | 79 m_choiceSuffix->SetSelection( 0 ); |
| 80 m_staticText7 = new wxStaticText( this, wxID_ANY, wxT("suffix"), wxDefaultPosition, wxDefaultSize, 0 ); | 80 bSizerMove->Add( m_choiceSuffix, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 81 fgSizer->Add( m_staticText7, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 81 |
| 82 | 82 m_dirPickerMoveTo = new wxDirPickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE ); |
| 83 wxArrayString suffix; | 83 bSizerMove->Add( m_dirPickerMoveTo, 0, wxALL|wxEXPAND, 5 ); |
| 84 suffix.Add( wxT("Date & Time") ); | 84 |
| 85 m_comboSuffix = new wxComboBox( this, ID_SUFFIX, wxEmptyString, wxDefaultPosition, wxDefaultSize, suffix, 0 ); | 85 sbSizerMove->Add( bSizerMove, 1, wxEXPAND, 5 ); |
| 86 fgSizer->Add( m_comboSuffix, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 86 |
| 87 | 87 m_listCtrlMove = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); |
| 88 m_staticTextDummy1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 88 sbSizerMove->Add( m_listCtrlMove, 0, wxALL|wxEXPAND, 5 ); |
| 89 fgSizer->Add( m_staticTextDummy1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 89 |
| 90 | 90 sbSizerFound->Add( sbSizerMove, 1, wxEXPAND, 5 ); |
| 91 m_staticTextDummy2 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 91 |
| 92 fgSizer->Add( m_staticTextDummy2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 92 wxStaticBoxSizer* sbSizerCmd = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Command") ), wxVERTICAL ); |
| 93 | 93 |
| 94 m_staticText8 = new wxStaticText( this, wxID_ANY, wxT("Exit"), wxDefaultPosition, wxDefaultSize, 0 ); | 94 wxFlexGridSizer* fgSizerCmd = new wxFlexGridSizer( 3, 3, 0, 0 ); |
| 95 fgSizer->Add( m_staticText8, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 95 fgSizerCmd->SetFlexibleDirection( wxBOTH ); |
| 96 | 96 fgSizerCmd->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); |
| 97 m_checkBoxExit = new wxCheckBox( this, ID_EXIT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 97 |
| 98 fgSizer->Add( m_checkBoxExit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 98 m_staticTextCmd0 = new wxStaticText( this, wxID_ANY, wxT("Command 0"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 99 | 99 fgSizerCmd->Add( m_staticTextCmd0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 100 m_staticTextDummy3 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | 100 |
| 101 fgSizer->Add( m_staticTextDummy3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); | 101 m_textCtrlCmd0 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); |
| 102 | 102 fgSizerCmd->Add( m_textCtrlCmd0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 103 m_toggleBtn = new wxToggleButton( this, ID_TOGGLEWATCH, wxT("Start Watching"), wxDefaultPosition, wxDefaultSize, 0 ); | 103 |
| 104 fgSizer->Add( m_toggleBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); | 104 wxString m_choiceCmd0Choices[] = { wxT("After"), wxT("Before") }; |
| 105 | 105 int m_choiceCmd0NChoices = sizeof( m_choiceCmd0Choices ) / sizeof( wxString ); |
| 106 this->SetSizer( fgSizer ); | 106 m_choiceCmd0 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCmd0NChoices, m_choiceCmd0Choices, 0 ); |
| 107 m_choiceCmd0->SetSelection( 0 ); | |
| 108 fgSizerCmd->Add( m_choiceCmd0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 109 | |
| 110 m_staticTextCmd1 = new wxStaticText( this, wxID_ANY, wxT("Command 1"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 111 fgSizerCmd->Add( m_staticTextCmd1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 112 | |
| 113 m_textCtrlCmd1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | |
| 114 fgSizerCmd->Add( m_textCtrlCmd1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 115 | |
| 116 wxString m_choiceCmd1Choices[] = { wxT("After"), wxT("Before") }; | |
| 117 int m_choiceCmd1NChoices = sizeof( m_choiceCmd1Choices ) / sizeof( wxString ); | |
| 118 m_choiceCmd1 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCmd1NChoices, m_choiceCmd1Choices, 0 ); | |
| 119 m_choiceCmd1->SetSelection( 0 ); | |
| 120 fgSizerCmd->Add( m_choiceCmd1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 121 | |
| 122 m_staticTextCmd2 = new wxStaticText( this, wxID_ANY, wxT("Command 2"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 123 fgSizerCmd->Add( m_staticTextCmd2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 124 | |
| 125 m_textCtrlCmd2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | |
| 126 fgSizerCmd->Add( m_textCtrlCmd2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 127 | |
| 128 wxString m_choiceCmd2Choices[] = { wxT("After"), wxT("Before") }; | |
| 129 int m_choiceCmd2NChoices = sizeof( m_choiceCmd2Choices ) / sizeof( wxString ); | |
| 130 m_choiceCmd2 = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCmd2NChoices, m_choiceCmd2Choices, 0 ); | |
| 131 m_choiceCmd2->SetSelection( 0 ); | |
| 132 fgSizerCmd->Add( m_choiceCmd2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 133 | |
| 134 sbSizerCmd->Add( fgSizerCmd, 1, wxEXPAND, 5 ); | |
| 135 | |
| 136 sbSizerFound->Add( sbSizerCmd, 0, wxEXPAND, 5 ); | |
| 137 | |
| 138 wxString m_choiceFoundChoices[] = { wxT("Continue"), wxT("Stop Watching"), wxT("Exit Program") }; | |
| 139 int m_choiceFoundNChoices = sizeof( m_choiceFoundChoices ) / sizeof( wxString ); | |
| 140 m_choiceFound = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceFoundNChoices, m_choiceFoundChoices, 0 ); | |
| 141 m_choiceFound->SetSelection( 0 ); | |
| 142 sbSizerFound->Add( m_choiceFound, 0, wxALL|wxALIGN_RIGHT, 5 ); | |
| 143 | |
| 144 bSizerTop->Add( sbSizerFound, 0, wxEXPAND, 5 ); | |
| 145 | |
| 146 wxStaticBoxSizer* sbSizerNotFound = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Else") ), wxHORIZONTAL ); | |
| 147 | |
| 148 m_textCtrlWait = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); | |
| 149 sbSizerNotFound->Add( m_textCtrlWait, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 150 | |
| 151 m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("[sec] after"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 152 sbSizerNotFound->Add( m_staticText1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 153 | |
| 154 wxString m_choiceNotFoundChoices[] = { wxT("Stop Watching"), wxT("Exit Program") }; | |
| 155 int m_choiceNotFoundNChoices = sizeof( m_choiceNotFoundChoices ) / sizeof( wxString ); | |
| 156 m_choiceNotFound = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceNotFoundNChoices, m_choiceNotFoundChoices, 0 ); | |
| 157 m_choiceNotFound->SetSelection( 0 ); | |
| 158 sbSizerNotFound->Add( m_choiceNotFound, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 159 | |
| 160 bSizerTop->Add( sbSizerNotFound, 0, wxEXPAND, 5 ); | |
| 161 | |
| 162 m_toggleBtn = new wxToggleButton( this, ID_TGLWATCH, wxT("Start Watching"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 163 m_toggleBtn->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); | |
| 164 | |
| 165 bSizerTop->Add( m_toggleBtn, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); | |
| 166 | |
| 167 this->SetSizer( bSizerTop ); | |
| 107 this->Layout(); | 168 this->Layout(); |
| 108 | 169 |
| 109 this->Centre( wxBOTH ); | 170 this->Centre( wxBOTH ); |
| 110 } | 171 } |
| 111 | 172 |
| 112 MyFrame::~MyFrame() | 173 MyFrame::~MyFrame() |
| 113 { | 174 { |
| 114 delete m_watcher; | |
| 115 } | 175 } |
| 116 | 176 |
| 117 // Event Table | 177 // Event Table |
| 118 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | 178 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) |
| 119 EVT_SIZE( MyFrame::OnWinSize ) | |
| 120 EVT_MOVE( MyFrame::OnWinMove ) | |
| 121 EVT_MENU( ID_MNSETUP, MyFrame::OnSetup ) | 179 EVT_MENU( ID_MNSETUP, MyFrame::OnSetup ) |
| 122 EVT_MENU( ID_MNSAVE, MyFrame::OnSaveParams ) | 180 EVT_MENU( ID_MNSAVE, MyFrame::OnSaveParams ) |
| 123 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) | 181 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
| 124 //EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 182 // EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
| 125 EVT_TOGGLEBUTTON( ID_TOGGLEWATCH, MyFrame::OnWatch ) | 183 EVT_TOGGLEBUTTON( ID_TGLWATCH, MyFrame::OnWatch ) |
| 184 EVT_SIZE( MyFrame::OnWinSize ) | |
| 185 EVT_MOVE( MyFrame::OnWinMove ) | |
| 126 EVT_CLOSE( MyFrame::SaveConfig ) | 186 EVT_CLOSE( MyFrame::SaveConfig ) |
| 127 END_EVENT_TABLE() | 187 END_EVENT_TABLE() |
| 128 | 188 |
| 129 // Event Handlers & Functions | 189 // Event Handlers & Functions |
| 130 /* フォルダ監視開始/停止スイッチ */ | 190 /* $B%U%)%k%@4F;k3+;O(B/$BDd;_%9%$%C%A(B */ |
| 131 void MyFrame::OnWatch( wxCommandEvent& WXUNUSED(event) ) | 191 void MyFrame::OnWatch( wxCommandEvent& WXUNUSED(event) ) |
| 132 { | 192 { |
| 133 Connect( wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler( MyFrame::OnFileSystemEvent ) ); | 193 Connect( wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler( MyFrame::OnFileSystemEvent ) ); |
| 134 | 194 |
| 135 static bool enabled = false; | 195 static bool enabled = false; |
| 138 if ( enabled ) { | 198 if ( enabled ) { |
| 139 m_toggleBtn->SetLabelText( wxT("Stop Watching") ); | 199 m_toggleBtn->SetLabelText( wxT("Stop Watching") ); |
| 140 m_watcher = new wxFileSystemWatcher(); | 200 m_watcher = new wxFileSystemWatcher(); |
| 141 m_watcher->SetOwner( this ); | 201 m_watcher->SetOwner( this ); |
| 142 | 202 |
| 143 m_watcher->Add( m_dirPickerWatch->GetPath(), wxFSW_EVENT_CREATE ); | 203 m_watcher->Add( m_dirPickerWatchDir->GetPath(), wxFSW_EVENT_CREATE ); |
| 144 } | 204 } |
| 145 else { | 205 else { |
| 146 m_toggleBtn->SetLabelText( wxT("Start Watching") ); | 206 m_toggleBtn->SetLabelText( wxT("Start Watching") ); |
| 147 wxDELETE( m_watcher ); | 207 wxDELETE( m_watcher ); |
| 148 } | 208 } |
| 149 } | 209 } |
| 150 | 210 |
| 151 /* フォルダ監視 */ | 211 /* $B%U%)%k%@4F;k(B */ |
| 152 void MyFrame::OnFileSystemEvent( wxFileSystemWatcherEvent& event ) | 212 void MyFrame::OnFileSystemEvent( wxFileSystemWatcherEvent& event ) |
| 153 { | 213 { |
| 154 wxMilliSleep( 1500 ); | 214 wxMilliSleep( 1500 ); |
| 155 | 215 |
| 156 wxString watchdir = m_dirPickerWatch->GetPath(); | 216 wxString watchdir = m_dirPickerWatchDir->GetPath(); |
| 157 wxString filename = m_textCtrlFile->GetValue(); | 217 wxString filename = m_searchCtrlFile->GetValue(); |
| 158 wxString command = m_textCtrlCommand->GetValue(); | 218 wxString command0 = m_textCtrlCmd0->GetValue(); |
| 159 wxString movedir = m_dirPickerMove->GetPath(); | 219 wxString command1 = m_textCtrlCmd1->GetValue(); |
| 220 wxString command2 = m_textCtrlCmd2->GetValue(); | |
| 221 wxString movedir = m_dirPickerMoveTo->GetPath(); | |
| 160 | 222 |
| 161 wxString from; | 223 wxString from; |
| 162 wxString to; | 224 wxString to; |
| 163 | 225 |
| 164 wxString file; | 226 wxString file; |
| 165 wxDir dir( watchdir ); | 227 wxDir dir( watchdir ); |
| 166 bool cont = dir.GetFirst( &file, filename, wxDIR_FILES ); | 228 bool cont = dir.GetFirst( &file, filename, wxDIR_FILES ); |
| 167 while ( cont ) { | 229 while ( cont ) { |
| 168 | 230 |
| 231 /* | |
| 169 if ( !command.IsEmpty() ) { | 232 if ( !command.IsEmpty() ) { |
| 170 wxExecute( command ); | 233 wxExecute( command ); |
| 171 wxSleep( 2 ); | 234 wxSleep( 2 ); |
| 172 } | 235 } |
| 173 | 236 |
| 174 if ( !movedir.IsEmpty() ) { | 237 if ( !movedir.IsEmpty() ) { |
| 175 from = watchdir + wxFILE_SEP_PATH + filename; | 238 from = watchdir + wxFILE_SEP_PATH + filename; |
| 176 wxFileName f( from ); | 239 wxFileName f( from ); |
| 177 | 240 |
| 178 // ファイル名をどうするか | 241 // $B%U%!%$%kL>$r$I$&$9$k$+(B |
| 179 if ( m_comboSuffix->GetCurrentSelection() == 0 ) { | 242 if ( m_comboSuffix->GetCurrentSelection() == 0 ) { |
| 180 wxDateTime now = wxDateTime::Now(); | 243 wxDateTime now = wxDateTime::Now(); |
| 181 to = movedir + wxFILE_SEP_PATH + f.GetName() + wxT("_") + now.Format(wxT("%Y%m%d%H%M%S")) + wxT(".") + f.GetExt(); | 244 to = movedir + wxFILE_SEP_PATH + f.GetName() + wxT("_") + now.Format(wxT("%Y%m%d%H%M%S")) + wxT(".") + f.GetExt(); |
| 182 } | 245 } |
| 183 else { | 246 else { |
| 184 to = movedir + wxFILE_SEP_PATH + filename; | 247 to = movedir + wxFILE_SEP_PATH + filename; |
| 185 } | 248 } |
| 186 | 249 |
| 187 // オリジナルを残すか | 250 // $B%*%j%8%J%k$r;D$9$+(B |
| 188 if ( m_checkBoxCopy->IsChecked() ) | 251 if ( m_checkBoxCopy->IsChecked() ) |
| 189 wxCopyFile( from, to, false ); | 252 wxCopyFile( from, to, false ); |
| 190 else | 253 else |
| 191 wxRenameFile( from, to, false ); | 254 wxRenameFile( from, to, false ); |
| 192 } | 255 } |
| 193 | 256 |
| 194 cont = dir.GetNext( &file ); | 257 cont = dir.GetNext( &file ); |
| 258 */ | |
| 195 } | 259 } |
| 196 if ( m_checkBoxExit->IsChecked() ) Close( true ); | 260 //if ( m_checkBoxExit->IsChecked() ) Close( true ); |
| 197 } | 261 } |
| 198 | 262 |
| 199 /* セットアップ */ | 263 /* $B%;%C%H%"%C%W(B */ |
| 200 void MyFrame::OnSetup( wxCommandEvent& WXUNUSED(event) ) | 264 void MyFrame::OnSetup( wxCommandEvent& WXUNUSED(event) ) |
| 201 { | 265 { |
| 202 wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws"); | 266 wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws"); |
| 203 wxFileDialog fd( this, wxT("Open Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); | 267 wxFileDialog fd( this, wxT("Open Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); |
| 204 if ( fd.ShowModal() == wxID_CANCEL ) return; // the user changed idea... | 268 if ( fd.ShowModal() == wxID_CANCEL ) return; // the user changed idea... |
| 205 | 269 |
| 206 wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); | 270 wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); |
| 207 | 271 |
| 208 wxString p_folder, p_filename, p_command, p_wait, p_moveto; | 272 wxString p_watchdir, p_filename, p_moveto, p_command0, p_command1, p_command2, p_wait; |
| 209 bool p_copy, p_exit; | 273 long p_move, p_suffix, p_found, p_notfound; |
| 210 long p_suffix; | |
| 211 config->SetPath( wxT("/Parameter") ); | 274 config->SetPath( wxT("/Parameter") ); |
| 212 config->Read( wxT("Folder"), &p_folder ); | |
| 213 config->Read( wxT("Filename"), &p_filename ); | 275 config->Read( wxT("Filename"), &p_filename ); |
| 214 config->Read( wxT("Command"), &p_command ); | 276 config->Read( wxT("Watchdir"), &p_watchdir ); |
| 277 config->Read( wxT("Move"), &p_move ); | |
| 278 config->Read( wxT("Suffix"), &p_suffix ); | |
| 279 config->Read( wxT("MoveTo"), &p_moveto ); | |
| 280 config->Read( wxT("Command0"), &p_command0 ); | |
| 281 config->Read( wxT("Command1"), &p_command1 ); | |
| 282 config->Read( wxT("Command2"), &p_command2 ); | |
| 283 config->Read( wxT("Found"), &p_found ); | |
| 215 config->Read( wxT("Wait"), &p_wait ); | 284 config->Read( wxT("Wait"), &p_wait ); |
| 216 config->Read( wxT("MoveTo"), &p_moveto ); | 285 config->Read( wxT("Notfound"), &p_notfound ); |
| 217 config->Read( wxT("Copy"), p_copy ); | 286 |
| 218 config->Read( wxT("Suffix"), &p_suffix ); | 287 m_dirPickerWatchDir->SetPath( p_watchdir ); |
| 219 config->Read( wxT("Exit"), p_exit ); | 288 m_searchCtrlFile->SetValue( p_filename ); |
| 220 | 289 m_choiceMove->SetSelection( p_move ); |
| 221 m_dirPickerWatch->SetPath( p_folder ); | 290 m_choiceSuffix->SetSelection( p_suffix ); |
| 222 m_textCtrlFile->SetValue( p_filename ); | 291 m_dirPickerMoveTo->SetPath( p_moveto ); |
| 223 m_textCtrlCommand->SetValue( p_command ); | 292 m_textCtrlCmd0->SetValue( p_command0 ); |
| 293 m_textCtrlCmd1->SetValue( p_command1 ); | |
| 294 m_textCtrlCmd2->SetValue( p_command2 ); | |
| 295 m_choiceFound->SetSelection( p_found ); | |
| 224 m_textCtrlWait->SetValue( p_wait ); | 296 m_textCtrlWait->SetValue( p_wait ); |
| 225 m_dirPickerMove->SetPath( p_moveto ); | 297 m_choiceNotFound->SetSelection( p_notfound ); |
| 226 m_checkBoxCopy->SetValue( p_copy ); | |
| 227 m_comboSuffix->SetSelection( (int)p_suffix ); | |
| 228 m_checkBoxExit->SetValue( p_exit ); | |
| 229 | 298 |
| 230 delete config; | 299 delete config; |
| 231 } | 300 } |
| 232 /* パラーメータを保存 */ | 301 /* $B%Q%i!<%a!<%?$rJ]B8(B */ |
| 233 void MyFrame::OnSaveParams( wxCommandEvent& WXUNUSED(event) ) | 302 void MyFrame::OnSaveParams( wxCommandEvent& WXUNUSED(event) ) |
| 234 { | 303 { |
| 235 wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws"); | 304 wxString dws_dir = wxGetCwd() + wxFILE_SEP_PATH + wxT("dws"); |
| 236 wxFileDialog fd( this, wxT("Save Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT ); | 305 wxFileDialog fd( this, wxT("Save Setup file"), dws_dir , wxEmptyString, wxT("Setup files (*.dws)|*.dws"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT ); |
| 237 if ( fd.ShowModal() == wxID_CANCEL ) return; // the user changed idea... | 306 if ( fd.ShowModal() == wxID_CANCEL ) return; // the user changed idea... |
| 238 | 307 |
| 239 wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); | 308 wxFileConfig* config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), fd.GetPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); |
| 240 | 309 |
| 241 config->SetPath( wxT("/Parameter") ); | 310 config->SetPath( wxT("/Parameter") ); |
| 242 config->Write( wxT("Folder"), m_dirPickerWatch->GetPath() ); | 311 config->Write( wxT("Filename"), m_searchCtrlFile->GetValue() ); |
| 243 config->Write( wxT("Filename"), m_textCtrlFile->GetValue() ); | 312 config->Write( wxT("Watchdir"), m_dirPickerWatchDir->GetPath() ); |
| 244 config->Write( wxT("Command"), m_textCtrlCommand->GetValue() ); | 313 config->Write( wxT("Move"), m_choiceMove->GetSelection() ); |
| 245 config->Write( wxT("Wait"), m_textCtrlWait->GetValue() ); | 314 config->Write( wxT("Suffix"), m_choiceSuffix->GetSelection() ); |
| 246 config->Write( wxT("MoveTo"), m_dirPickerMove->GetPath() ); | 315 config->Write( wxT("MoveTo"), m_dirPickerMoveTo->GetPath() ); |
| 247 config->Write( wxT("Copy"), m_checkBoxCopy->GetValue() ); | 316 config->Write( wxT("Command0"), m_textCtrlCmd0->GetValue() ); |
| 248 config->Write( wxT("Suffix"), m_comboSuffix->GetSelection() ); | 317 config->Write( wxT("Command1"), m_textCtrlCmd1->GetValue() ); |
| 249 config->Write( wxT("Exit"), m_checkBoxExit->GetValue() ); | 318 config->Write( wxT("Command2"), m_textCtrlCmd2->GetValue() ); |
| 319 config->Write( wxT("Found"), m_choiceFound->GetSelection() ); | |
| 320 config->Write( wxT("Wait"), m_textCtrlWait->GetValue() ); | |
| 321 config->Write( wxT("Notfound"), m_choiceNotFound->GetSelection() ); | |
| 250 | 322 |
| 251 delete config; | 323 delete config; |
| 252 } | 324 } |
| 253 | 325 |
| 254 /* サイズ変更 */ | 326 /* $B%5%$%:JQ99(B */ |
| 255 void MyFrame::OnWinSize( wxSizeEvent& event ) | 327 void MyFrame::OnWinSize( wxSizeEvent& event ) |
| 256 { | 328 { |
| 257 this->Refresh( true, NULL ); | 329 this->Refresh( true, NULL ); |
| 258 TellLocation(); | 330 TellLocation(); |
| 259 event.Skip(); | 331 event.Skip(); |
| 260 } | 332 } |
| 261 /* ウィンドウ移動 */ | 333 /* $B%&%#%s%I%&0\F0(B */ |
| 262 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) | 334 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) |
| 263 { | 335 { |
| 264 TellLocation(); | 336 TellLocation(); |
| 265 return; | 337 return; |
| 266 } | 338 } |
| 267 /* ウィンドウ位置とサイズを表示 */ | 339 /* $B%&%#%s%I%&0LCV$H%5%$%:$rI=<((B */ |
| 268 void MyFrame::TellLocation( void ) | 340 void MyFrame::TellLocation( void ) |
| 269 { | 341 { |
| 270 wxRect r = this->GetRect(); | 342 wxRect r = this->GetRect(); |
| 271 int x = r.GetX(); | 343 int x = r.GetX(); |
| 272 int y = r.GetY(); | 344 int y = r.GetY(); |
| 273 int w = r.GetWidth(); | 345 int w = r.GetWidth(); |
| 274 int h = r.GetHeight(); | 346 int h = r.GetHeight(); |
| 275 //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 ); | 347 //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 ); |
| 276 } | 348 } |
| 277 /* 終了 */ | 349 /* $B=*N;(B */ |
| 278 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) | 350 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) |
| 279 { | 351 { |
| 280 Close( true ); | 352 Close( true ); |
| 281 } | 353 } |
| 282 /* 設定を保存 */ | 354 /* $B@_Dj$rJ]B8(B */ |
| 283 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) | 355 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) |
| 284 { | 356 { |
| 285 if ( !IsIconized() && !IsMaximized() ) { | 357 if ( !IsIconized() && !IsMaximized() ) { |
| 286 wxGetApp().rect = this->GetRect(); | 358 wxGetApp().rect = this->GetRect(); |
| 287 } | 359 } |
| 288 Destroy(); | 360 Destroy(); |
| 289 } | 361 } |
| 290 /* アバウトダイアログ */ | 362 /* $B%"%P%&%H%@%$%"%m%0(B */ |
| 291 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | 363 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) |
| 292 { | 364 { |
| 293 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); | 365 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); |
| 294 aboutDlg->ShowModal(); | 366 aboutDlg->ShowModal(); |
| 295 } | 367 } |
