Mercurial > mercurial > hgweb_mover.cgi
comparison src/myframe.cpp @ 4:a505f7417742
v0.1 release
| author | pyon@macmini |
|---|---|
| date | Thu, 06 Oct 2011 07:56:12 +0900 |
| parents | a5bddd859104 |
| children | 3b734fd6ee2b |
comparison
equal
deleted
inserted
replaced
| 3:a5bddd859104 | 4:a505f7417742 |
|---|---|
| 1 // Filename : mainframe.cpp | 1 // Filename : mainframe.cpp |
| 2 // Last Change: 03-Oct-2011. | 2 // Last Change: 05-Oct-2011. |
| 3 // | 3 // |
| 4 #include "symbol.h" | 4 #include "symbol.h" |
| 5 #include "common.h" | 5 #include "common.h" |
| 6 #include "myframe.h" | 6 #include "myframe.h" |
| 7 #include "delwhite.h" | 7 #include "delwhite.h" |
| 8 #include "marksheet.h" | |
| 8 #include "main.h" | 9 #include "main.h" |
| 9 | 10 |
| 10 // resources | 11 // resources |
| 11 // the application icon (under Windows and OS/2 it is in resources and even | 12 // 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 // though we could still include the XPM here it would be unused) |
| 45 | 46 |
| 46 // メニューバー | 47 // メニューバー |
| 47 m_menubar = new wxMenuBar(); | 48 m_menubar = new wxMenuBar(); |
| 48 | 49 |
| 49 m_menuFile = new wxMenu(); | 50 m_menuFile = new wxMenu(); |
| 51 m_menuFile->Append( ID_OPWORK, wxT("作業フォルダを開く"), wxT("Open work folder") ); | |
| 52 m_menuFile->AppendSeparator(); //---- | |
| 50 m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") ); | 53 m_menuFile->Append( wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about dialog") ); |
| 51 //m_menuFile->AppendSeparator(); //---- | 54 m_menuFile->AppendSeparator(); //---- |
| 52 m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") ); | 55 m_menuFile->Append( wxID_EXIT, wxT("終了(&X)\tAlt-X"), wxT("Quit this program") ); |
| 53 | 56 |
| 54 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); | 57 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); |
| 55 | 58 |
| 56 this->SetMenuBar( m_menubar ); | 59 this->SetMenuBar( m_menubar ); |
| 124 m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); | 127 m_textCtrlMoveDir->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); |
| 125 | 128 |
| 126 bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 129 bSizerDoMove->Add( m_textCtrlMoveDir, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 127 | 130 |
| 128 m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 ); | 131 m_buttonDoMove = new wxButton( this, ID_DOMOVE, wxT("画像移動"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 129 m_buttonDoMove->Enable( false ); | |
| 130 | 132 |
| 131 bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); | 133 bSizerDoMove->Add( m_buttonDoMove, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); |
| 132 | 134 |
| 133 bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 ); | 135 bSizerTop->Add( bSizerDoMove, 0, wxEXPAND, 5 ); |
| 134 | 136 |
| 135 m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); | 137 m_listCtrl = new wxListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); |
| 138 wxListItem itemCol; | |
| 139 itemCol.SetText( wxT("通番") ); | |
| 140 m_listCtrl->InsertColumn( 0, itemCol ); | |
| 141 m_listCtrl->SetColumnWidth( 0, 100 ); | |
| 142 itemCol.SetText( wxT("被保険者番号") ); | |
| 143 m_listCtrl->InsertColumn( 1, itemCol ); | |
| 144 m_listCtrl->SetColumnWidth( 1, 180 ); | |
| 145 itemCol.SetText( wxT("ファイル数") ); | |
| 146 m_listCtrl->InsertColumn( 2, itemCol ); | |
| 147 m_listCtrl->SetColumnWidth( 1, 100 ); | |
| 136 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); | 148 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); |
| 137 | 149 |
| 138 this->SetSizer( bSizerTop ); | 150 this->SetSizer( bSizerTop ); |
| 139 this->Layout(); | 151 this->Layout(); |
| 140 | 152 |
| 141 this->Centre( wxBOTH ); | 153 this->Centre( wxBOTH ); |
| 142 //this->SetDefaultItem(m_buttonDetWhite); | |
| 143 m_buttonDetWhite->SetFocus(); | 154 m_buttonDetWhite->SetFocus(); |
| 144 } | 155 } |
| 145 | 156 |
| 146 // destructor | 157 // destructor |
| 147 MyFrame::~MyFrame() | 158 MyFrame::~MyFrame() |
| 152 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | 163 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) |
| 153 EVT_SIZE( MyFrame::OnSize ) | 164 EVT_SIZE( MyFrame::OnSize ) |
| 154 EVT_MOVE( MyFrame::OnMove ) | 165 EVT_MOVE( MyFrame::OnMove ) |
| 155 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 166 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
| 156 EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) | 167 EVT_MENU( wxID_ABOUT, MyFrame::OnAbout ) |
| 168 EVT_MENU( ID_OPWORK, MyFrame::OnOpenWorkDir ) | |
| 157 EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite ) | 169 EVT_BUTTON( ID_DTWHITE, MyFrame::OnDetectWhite ) |
| 158 EVT_BUTTON( ID_STDIR, MyFrame::SetDir ) | 170 EVT_BUTTON( ID_STDIR, MyFrame::SetDir ) |
| 159 EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir ) | 171 EVT_BUTTON( ID_MKDIR, MyFrame::MakeDir ) |
| 172 EVT_BUTTON( ID_DOMOVE, MyFrame::MoveImages ) | |
| 160 EVT_CLOSE( MyFrame::SaveConfig ) | 173 EVT_CLOSE( MyFrame::SaveConfig ) |
| 161 END_EVENT_TABLE() | 174 END_EVENT_TABLE() |
| 162 | 175 |
| 163 // Event Handlers | 176 // Event Handlers |
| 164 /* サイズ変更 */ | 177 /* サイズ変更 */ |
| 227 dir.Append( wxFILE_SEP_PATH ); | 240 dir.Append( wxFILE_SEP_PATH ); |
| 228 dir.Append( m_comboBoxCcn->GetValue() ); | 241 dir.Append( m_comboBoxCcn->GetValue() ); |
| 229 m_textCtrlMoveDir->SetValue( dir ); | 242 m_textCtrlMoveDir->SetValue( dir ); |
| 230 } | 243 } |
| 231 | 244 |
| 245 /* 移動先フォルダ作成 */ | |
| 232 void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event)) | 246 void MyFrame::MakeDir(wxCommandEvent& WXUNUSED(event)) |
| 233 { | 247 { |
| 234 } | 248 wxString dirname = m_textCtrlMoveDir->GetValue(); |
| 235 | 249 wxString ccn = m_comboBoxCcn->GetValue(); |
| 236 /* アプリケーションフォルダを開く */ | 250 if ( dirname.Len() < 15 || ccn.IsEmpty() ) { |
| 237 /* | 251 wxMessageBox(wxT("フォルダを指定してください.")); |
| 238 void MyFrame::OnOpenAppDir(wxCommandEvent& WXUNUSED(event)) | 252 return; |
| 239 { | 253 } |
| 240 wxStandardPaths appdir; | 254 |
| 241 wxString execmd = wxT("explorer ") + appdir.GetDataDir(); | 255 wxStringTokenizer tkz( dirname, wxFILE_SEP_PATH ); |
| 256 wxString d; | |
| 257 while ( tkz.HasMoreTokens() ) { | |
| 258 d.Append( tkz.GetNextToken() ); | |
| 259 d.Append( wxFILE_SEP_PATH ); | |
| 260 if ( !wxDirExists( d ) ) wxMkdir( d ); | |
| 261 } | |
| 262 } | |
| 263 | |
| 264 /* 画像移動 */ | |
| 265 void MyFrame::MoveImages(wxCommandEvent& WXUNUSED(event)) | |
| 266 { | |
| 267 wxString dirname = m_textCtrlMoveDir->GetValue(); | |
| 268 wxString ccn = m_comboBoxCcn->GetValue(); | |
| 269 if ( dirname.IsEmpty() || ccn.IsEmpty() ) { | |
| 270 wxMessageBox(wxT("フォルダを指定してください.")); | |
| 271 return; | |
| 272 } | |
| 273 | |
| 274 dirname.Append( wxFILE_SEP_PATH ); | |
| 275 if ( !wxDirExists( dirname ) ) { | |
| 276 wxMessageBox(wxT("フォルダが存在しません.")); | |
| 277 return; | |
| 278 } | |
| 279 | |
| 280 wxString workdir = m_dirPickerWork->GetPath(); | |
| 281 wxDir dir( workdir ); | |
| 282 if ( !dir.IsOpened() ) return; | |
| 283 | |
| 284 wxString filename; | |
| 285 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES ); | |
| 286 | |
| 287 int cnt=0, r=0; | |
| 288 wxString hhs; | |
| 289 m_listCtrl->DeleteAllItems(); | |
| 290 while ( cout ) { | |
| 291 wxString from = workdir + wxFILE_SEP_PATH + filename; | |
| 292 if ( IsMarksheet( from ) ) { | |
| 293 hhs = GuessHhs( from ); | |
| 294 wxString d = dirname + hhs; | |
| 295 wxMkdir( d ); | |
| 296 m_listCtrl->InsertItem( r, wxString::Format(wxT("%d"),r+1) ); | |
| 297 m_listCtrl->SetItem( r, 1, hhs, -1 ); // 被保険者番号 | |
| 298 m_listCtrl->SetItem( r-1, 2, wxString::Format(wxT("%d"),cnt), -1 ); // ファイル数 | |
| 299 if ( r % 2 ) m_listCtrl->SetItemBackgroundColour( r, wxColour(wxT("WHEAT")) ); | |
| 300 r++; | |
| 301 cnt=0; | |
| 302 } | |
| 303 if ( hhs.IsEmpty() ) { | |
| 304 wxMessageBox(wxT("マークシートの画像ファイルを確認してください.")); | |
| 305 return; | |
| 306 } | |
| 307 wxString to = dirname + wxFILE_SEP_PATH + hhs + wxFILE_SEP_PATH + filename; | |
| 308 wxRenameFile( from, to, false ); | |
| 309 // write log | |
| 310 cout = dir.GetNext( &filename ); | |
| 311 cnt++; | |
| 312 } | |
| 313 m_listCtrl->SetItem( r-1, 2, wxString::Format(wxT("%d"),cnt), -1 ); // ファイル数 | |
| 314 if ( cnt < 5 ) m_listCtrl->SetItemTextColour( r, *wxRED ); | |
| 315 | |
| 316 wxString cmd = wxT("explorer ") + dirname; | |
| 317 wxExecute( cmd ); | |
| 318 } | |
| 319 | |
| 320 /* 作業フォルダを開く */ | |
| 321 void MyFrame::OnOpenWorkDir(wxCommandEvent& WXUNUSED(event)) | |
| 322 { | |
| 323 wxString workdir = m_dirPickerWork->GetPath(); | |
| 324 wxString execmd = wxT("explorer ") + workdir; | |
| 242 wxExecute( execmd ); | 325 wxExecute( execmd ); |
| 243 return; | 326 return; |
| 244 } | 327 } |
| 245 */ | |
| 246 | 328 |
| 247 | 329 |
| 248 /* 設定を保存 */ | 330 /* 設定を保存 */ |
| 249 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event)) | 331 void MyFrame::SaveConfig(wxCloseEvent& WXUNUSED(event)) |
| 250 { | 332 { |
