Mercurial > mercurial > hgweb_mover2.cgi
comparison src/myframe.cpp @ 5:52697c869ce8
delete move&detect button.
| author | pyon@macmini |
|---|---|
| date | Tue, 18 Oct 2011 07:53:48 +0900 |
| parents | 964129946db6 |
| children | 9c85d71cad7c |
comparison
equal
deleted
inserted
replaced
| 4:964129946db6 | 5:52697c869ce8 |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 16-Oct-2011. | 2 // Last Change: 18-Oct-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "main.h" | 5 #include "main.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "param.h" | |
| 7 #include "marksheet.h" | 8 #include "marksheet.h" |
| 9 | |
| 10 // resources | |
| 11 // the application icon (under Windows and OS/2 it is in resources and even | |
| 12 // though we could still include the XPM here it would be unused) | |
| 13 #if !defined(__WXMSW__) && !defined(__WXPM__) | |
| 14 #include "sample.xpm" | |
| 15 #endif | |
| 8 | 16 |
| 9 ////////////////////////////////////////////////////////////////////////// | 17 ////////////////////////////////////////////////////////////////////////// |
| 10 // frame constructor | 18 // frame constructor |
| 11 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) | 19 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) |
| 12 { | 20 { |
| 13 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | 21 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); |
| 14 // set the frame icon | 22 // set the frame icon |
| 15 //SetIcon(wxICON(sample)); | 23 SetIcon(wxICON(sample)); |
| 16 | 24 |
| 17 // メニューバー | 25 // メニューバー |
| 18 m_menubarFile = new wxMenuBar(); | 26 m_menubarFile = new wxMenuBar(); |
| 19 m_menuFile = new wxMenu(); | 27 m_menuFile = new wxMenu(); |
| 20 wxMenuItem* m_menuItemParam; | 28 wxMenuItem* m_menuItemParam; |
| 88 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 ); | 96 bSizerDist->Add( m_comboBoxCcn, 0, wxALL, 5 ); |
| 89 | 97 |
| 90 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 ); | 98 m_buttonMkDir = new wxButton( this, ID_BUTTONMKDIR, wxT("適用"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 91 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 ); | 99 bSizerDist->Add( m_buttonMkDir, 0, wxALL, 5 ); |
| 92 | 100 |
| 93 | |
| 94 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 ); | 101 bSizerTop->Add( bSizerDist, 0, wxEXPAND, 5 ); |
| 95 | 102 |
| 96 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL ); | 103 wxBoxSizer* bSizerManip = new wxBoxSizer( wxHORIZONTAL ); |
| 97 | 104 |
| 98 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); | 105 wxBoxSizer* bSizerGuess = new wxBoxSizer( wxVERTICAL ); |
| 120 bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 ); | 127 bSizerManip->Add( bSizerGuess, 0, wxEXPAND, 5 ); |
| 121 | 128 |
| 122 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); | 129 m_listCtrlView = new wxListCtrl( this, ID_LISTCTRLVIEW, wxDefaultPosition, wxDefaultSize, wxLC_ICON ); |
| 123 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); | 130 m_listCtrlView->SetBackgroundColour(wxT("LIGHT GREY")); |
| 124 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); | 131 bSizerManip->Add( m_listCtrlView, 1, wxALL|wxEXPAND, 5 ); |
| 125 m_imageList = new wxImageList( 189, 267 ); | 132 m_imageList = new wxImageList( 160, 226 ); |
| 126 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); | 133 m_listCtrlView->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL ); |
| 127 | 134 |
| 128 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); | 135 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); |
| 129 | 136 |
| 130 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); | 137 m_buttonDetect = new wxButton( this, ID_BUTTONDETECT, wxT("検知"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 131 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); | 138 bSizerButton->Add( m_buttonDetect, 0, wxALL, 5 ); |
| 132 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 ); | 139 m_buttonMove = new wxButton( this, ID_BUTTONMOVE, wxT("移動"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 133 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 ); | 140 bSizerButton->Add( m_buttonMove, 0, wxALL, 5 ); |
| 134 m_buttonMove->Enable(false); | 141 m_buttonMove->Enable(false); |
| 135 m_buttonMD = new wxButton( this, ID_BUTTONMD, wxT("移動&検知"), wxDefaultPosition, wxDefaultSize, 0 ); | 142 |
| 136 bSizerButton->Add( m_buttonMD, 0, wxALL, 5 ); | |
| 137 m_buttonMD->Enable(false); | |
| 138 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); | 143 m_buttonDel = new wxButton( this, ID_BUTTONDEL, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 139 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 ); | 144 bSizerButton->Add( m_buttonDel, 0, wxALL, 5 ); |
| 140 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 ); | 145 m_buttonUndo = new wxButton( this, ID_BUTTONUNDO, wxT("戻す"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 141 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 ); | 146 bSizerButton->Add( m_buttonUndo, 0, wxALL, 5 ); |
| 142 m_buttonUndo->Enable(false); | 147 m_buttonUndo->Enable(false); |
| 170 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) | 175 EVT_MENU( ID_MENUITEMAPPDIR, MyFrame::OnOpenAppDir ) |
| 171 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 176 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
| 172 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) | 177 EVT_BUTTON( ID_BUTTONMKDIR, MyFrame::OnMakeDir ) |
| 173 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) | 178 EVT_BUTTON( ID_BUTTONDETECT, MyFrame::OnDetect ) |
| 174 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) | 179 EVT_BUTTON( ID_BUTTONMOVE, MyFrame::OnMove ) |
| 175 EVT_BUTTON( ID_BUTTONMD, MyFrame::OnMoveAndDetect ) | |
| 176 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) | 180 EVT_BUTTON( ID_BUTTONDEL, MyFrame::OnDelete ) |
| 177 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo ) | 181 EVT_BUTTON( ID_BUTTONUNDO, MyFrame::OnUndo ) |
| 178 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) | 182 EVT_LIST_ITEM_SELECTED( ID_LISTCTRLVIEW, MyFrame::GetImageInfo ) |
| 179 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) | 183 EVT_LIST_ITEM_ACTIVATED( ID_LISTCTRLVIEW, MyFrame::ViewLarge ) |
| 180 EVT_CLOSE( MyFrame::SaveConfig ) | 184 EVT_CLOSE( MyFrame::SaveConfig ) |
| 205 d.Append( tkz.GetNextToken() ); | 209 d.Append( tkz.GetNextToken() ); |
| 206 d.Append( wxFILE_SEP_PATH ); | 210 d.Append( wxFILE_SEP_PATH ); |
| 207 if ( !wxDirExists( d ) ) wxMkdir( d ); | 211 if ( !wxDirExists( d ) ) wxMkdir( d ); |
| 208 } | 212 } |
| 209 m_buttonMove->Enable(true); | 213 m_buttonMove->Enable(true); |
| 210 m_buttonMD->Enable(true); | |
| 211 | 214 |
| 212 wxMessageBox(wxT("移動先フォルダ準備完了")); | 215 wxMessageBox(wxT("移動先フォルダ準備完了")); |
| 213 wxString cmd = wxT("explorer ") + to; | 216 wxString cmd = wxT("explorer ") + to; |
| 214 wxExecute( cmd ); | 217 wxExecute( cmd ); |
| 215 } | 218 } |
| 216 | |
| 217 /* 移動 */ | |
| 218 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) | |
| 219 { | |
| 220 MoveImage(); | |
| 221 m_buttonUndo->Enable(true); | |
| 222 } | |
| 223 /* 検知 */ | 219 /* 検知 */ |
| 224 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) | 220 void MyFrame::OnDetect(wxCommandEvent& WXUNUSED(event)) |
| 225 { | 221 { |
| 226 ReadyImage(); | 222 ReadyImage(); |
| 227 } | 223 } |
| 228 /* 移動し検知 */ | 224 |
| 229 void MyFrame::OnMoveAndDetect(wxCommandEvent& WXUNUSED(event)) | |
| 230 { | |
| 231 MoveImage(); | |
| 232 ReadyImage(); | |
| 233 } | |
| 234 /* 選択したファイルを移動 */ | 225 /* 選択したファイルを移動 */ |
| 235 void MyFrame::MoveImage() | 226 void MyFrame::OnMove(wxCommandEvent& WXUNUSED(event)) |
| 236 { | 227 { |
| 237 m_undo.Clear(); | 228 m_undo.Clear(); |
| 238 wxString workdir = m_dirPickerWork->GetPath(); | 229 wxString workdir = m_dirPickerWork->GetPath(); |
| 239 wxString distdir = m_textCtrlDist->GetValue(); | 230 wxString distdir = m_textCtrlDist->GetValue(); |
| 240 long item = -1; | 231 long item = -1; |
| 241 for ( ;; ) { | 232 for ( ;; ) { |
| 242 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); | 233 item = m_listCtrlView->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); |
| 243 if ( item == -1 ) break; | 234 if ( item == -1 ) break; |
| 244 wxString file = m_listCtrlView->GetItemText( item ); | 235 wxString hhsno = m_textCtrlGuess->GetValue(); |
| 236 if ( !wxDirExists( distdir + wxFILE_SEP_PATH + hhsno ) ) wxMkdir( distdir + wxFILE_SEP_PATH + hhsno ); | |
| 237 | |
| 238 wxString file = m_listCtrlView->GetItemText( item ); | |
| 245 wxString from = workdir + wxFILE_SEP_PATH + file; | 239 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 246 wxString to = distdir + wxFILE_SEP_PATH + file; | 240 wxString to = distdir + wxFILE_SEP_PATH + hhsno + wxFILE_SEP_PATH + file; |
| 247 wxRenameFile( from, to, true ); | 241 wxRenameFile( from, to, true ); |
| 248 m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); | 242 m_undo.Insert( wxT("move ") + to + wxT(" ") + from, 0 ); |
| 249 } | 243 } |
| 250 ReadyImage(); | 244 ReadyImage(); |
| 251 m_buttonUndo->Enable(true); | 245 m_buttonUndo->Enable(true); |
| 252 } | 246 } |
| 253 /* 選択したファイルを削除 */ | 247 /* 選択したファイルを削除 */ |
| 262 if ( item == -1 ) break; | 256 if ( item == -1 ) break; |
| 263 wxString file = m_listCtrlView->GetItemText( item ); | 257 wxString file = m_listCtrlView->GetItemText( item ); |
| 264 wxString from = workdir + wxFILE_SEP_PATH + file; | 258 wxString from = workdir + wxFILE_SEP_PATH + file; |
| 265 wxString to = trash + wxFILE_SEP_PATH + file; | 259 wxString to = trash + wxFILE_SEP_PATH + file; |
| 266 wxRenameFile( from, to, true ); | 260 wxRenameFile( from, to, true ); |
| 267 m_undo.Insert( wxT("mv ") + to + wxT(" ") + from, 0 ); | 261 m_undo.Insert( wxT("move ") + to + wxT(" ") + from, 0 ); |
| 268 } | 262 } |
| 269 ReadyImage(); | 263 ReadyImage(); |
| 270 m_buttonUndo->Enable(true); | 264 m_buttonUndo->Enable(true); |
| 271 } | 265 } |
| 272 /* アンドゥ */ | 266 /* アンドゥ */ |
| 310 | 304 |
| 311 m_listCtrlView->InsertItem( i, filename ); | 305 m_listCtrlView->InsertItem( i, filename ); |
| 312 m_listCtrlView->SetItem( i, 0, filename, i ); | 306 m_listCtrlView->SetItem( i, 0, filename, i ); |
| 313 | 307 |
| 314 wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); | 308 wxImage image( imagefile, wxBITMAP_TYPE_JPEG ); |
| 315 wxBitmap bmp( image.Scale( 189, 267, wxIMAGE_QUALITY_HIGH ) ); | 309 wxBitmap bmp( image.Scale( 160, 226, wxIMAGE_QUALITY_HIGH ) ); |
| 316 m_imageList->Add( bmp ); | 310 m_imageList->Add( bmp ); |
| 317 | 311 |
| 318 if ( i == 0 ) { | 312 if ( i == 0 ) { |
| 319 IsMarksheet( imagefile, &b, &l ); | 313 IsMarksheet( imagefile, &b, &l ); |
| 320 first = imagefile; | 314 first = imagefile; |
| 388 } | 382 } |
| 389 | 383 |
| 390 /* パラメータダイアログ */ | 384 /* パラメータダイアログ */ |
| 391 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) | 385 void MyFrame::OnParam(wxCommandEvent& WXUNUSED(event)) |
| 392 { | 386 { |
| 387 ParamDialog* pd = new ParamDialog( NULL, wxID_ANY, wxT("Setting Parameters") ); | |
| 388 if ( pd->ShowModal() == wxID_OK ) { | |
| 389 wxGetApp().lmin; | |
| 390 wxGetApp().lmax; | |
| 391 wxGetApp().zmin; | |
| 392 wxGetApp().zmax; | |
| 393 } | |
| 394 pd->Destroy(); | |
| 393 } | 395 } |
| 394 | 396 |
| 395 // 以下,定型もの | 397 // 以下,定型もの |
| 396 /* アプリフォルダを開く */ | 398 /* アプリフォルダを開く */ |
| 397 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) | 399 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) |
| 398 { | 400 { |
| 399 wxString appdir = m_dirPickerWork->GetPath(); | 401 wxString appdir = wxGetCwd(); |
| 400 wxString execmd = wxT("explorer ") + appdir; | 402 wxString execmd = wxT("explorer ") + appdir; |
| 401 wxExecute( execmd ); | 403 wxExecute( execmd ); |
| 402 } | 404 } |
| 403 | 405 |
| 404 /* サイズ変更 */ | 406 /* サイズ変更 */ |
