Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/myframe.cpp @ 22:92188f60323d default tip
Implement Masking function on Preview Dialog.
author | pyon@macmini |
---|---|
date | Sat, 04 Apr 2015 17:23:46 +0900 |
parents | a2ad87cad48b |
children |
comparison
equal
deleted
inserted
replaced
21:a2ad87cad48b | 22:92188f60323d |
---|---|
1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
2 // Last Change: 16-Dec-2014. | 2 // Last Change: 2015-04-04 10:29:14. |
3 // | 3 // |
4 #include "main.h" | 4 #include "main.h" |
5 #include "db.h" | 5 #include "db.h" |
6 #include "about.h" | 6 #include "about.h" |
7 #include "kana.h" | 7 #include "kana.h" |
13 #include "param.h" | 13 #include "param.h" |
14 #include "marksheet.h" | 14 #include "marksheet.h" |
15 #include "myframe.h" | 15 #include "myframe.h" |
16 #include "bprint.h" | 16 #include "bprint.h" |
17 #include "update.h" | 17 #include "update.h" |
18 #include "dndfile.h" | |
18 | 19 |
19 /////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////// |
20 // カスタム検索ボックス | 21 // カスタム検索ボックス |
21 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) | 22 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) |
22 : wxSearchCtrl( parent, id, value, pos, size, style ) | 23 : wxSearchCtrl( parent, id, value, pos, size, style ) |
220 void ThumbnailPanel::DoPreview( int n ) | 221 void ThumbnailPanel::DoPreview( int n ) |
221 { | 222 { |
222 if ( m_imagefiles.GetCount() < n + 1 ) return; | 223 if ( m_imagefiles.GetCount() < n + 1 ) return; |
223 | 224 |
224 PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); | 225 PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); |
226 | |
225 pd->Show(); | 227 pd->Show(); |
226 pd->Maximize( true ); | 228 pd->Maximize( true ); |
227 pd->SetFiles( m_imagefiles, m_cachefiles, n ); | 229 pd->SetFiles( m_imagefiles, m_cachefiles, n ); |
230 | |
231 if ( n == 0 ) pd->EnableMaskButton( true ); | |
232 else pd->EnableMaskButton( false ); | |
228 pd->SetPreviewImage( n ); | 233 pd->SetPreviewImage( n ); |
234 | |
235 MyFrame* p = (MyFrame*)FindWindowById( ID_MAIN ); | |
236 pd->SetMask1( p->GetMask1() ); | |
237 pd->SetMask2( p->GetMask2() ); | |
238 pd->SetMask3( p->GetMask3() ); | |
239 pd->SetMask1Old( p->GetMask1Old() ); | |
240 pd->SetMask2Old( p->GetMask2Old() ); | |
241 pd->SetMask3Old( p->GetMask3Old() ); | |
229 } | 242 } |
230 | 243 |
231 /////////////////////////////////////////////////////////////// | 244 /////////////////////////////////////////////////////////////// |
232 // メインフレーム | 245 // メインフレーム |
233 #define WINL_W 480 | 246 #define WINL_W 480 |
234 #define LOGO_W 200 | 247 #define WINL_H 500 |
235 #define LOGO_H 92 | |
236 | 248 |
237 // resources | 249 // resources |
238 #if !defined(__WXMSW__) && !defined(__WXPM__) | 250 #if !defined(__WXMSW__) && !defined(__WXPM__) |
239 #include "sample.xpm" | 251 #include "sample.xpm" |
240 #endif | 252 #endif |
241 | 253 |
242 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 254 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
243 : wxFrame( parent, id, title, pos, size, style ) | 255 : wxFrame( parent, id, title, pos, size, style ) |
244 { | 256 { |
245 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); | 257 this->SetSizeHints( wxSize( WINL_W, WINL_H ), wxDefaultSize ); |
246 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); | 258 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); |
247 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | 259 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); |
248 | 260 |
249 // set the frame icon | 261 // set the frame icon |
250 SetIcon(wxICON(sample)); | 262 SetIcon(wxICON(sample)); |
259 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); | 271 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); |
260 m_menuFile->Append( m_menuItemIndex ); | 272 m_menuFile->Append( m_menuItemIndex ); |
261 | 273 |
262 wxMenuItem* m_menuItemCache = new wxMenuItem( m_menuFile, ID_MNCACHE, wxString( wxT("キャッシュ\tF9") ) , wxT("Make cache"), wxITEM_NORMAL ); | 274 wxMenuItem* m_menuItemCache = new wxMenuItem( m_menuFile, ID_MNCACHE, wxString( wxT("キャッシュ\tF9") ) , wxT("Make cache"), wxITEM_NORMAL ); |
263 m_menuFile->Append( m_menuItemCache ); | 275 m_menuFile->Append( m_menuItemCache ); |
276 | |
277 m_menuFile->AppendSeparator(); // ---- | |
278 | |
279 wxMenuItem* m_menuItemMover = new wxMenuItem( m_menuFile, ID_MNMOVER, wxString( wxT("Mover 起動(&V)") ) , wxT("Start Mover"), wxITEM_NORMAL ); | |
280 m_menuFile->Append( m_menuItemMover ); | |
264 | 281 |
265 m_menuFile->AppendSeparator(); // ---- | 282 m_menuFile->AppendSeparator(); // ---- |
266 | 283 |
267 wxMenuItem* m_menuItemHhsdb = new wxMenuItem( m_menuFile, ID_MNHHSDB, wxString( wxT("被保険者DB更新(&U)") ) , wxT("Update HHS databases"), wxITEM_NORMAL ); | 284 wxMenuItem* m_menuItemHhsdb = new wxMenuItem( m_menuFile, ID_MNHHSDB, wxString( wxT("被保険者DB更新(&U)") ) , wxT("Update HHS databases"), wxITEM_NORMAL ); |
268 m_menuFile->Append( m_menuItemHhsdb ); | 285 m_menuFile->Append( m_menuItemHhsdb ); |
295 | 312 |
296 // | 313 // |
297 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | 314 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); |
298 | 315 |
299 m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); | 316 m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
300 | |
301 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); | 317 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); |
318 | |
319 wxBoxSizer* bSizerLogo = new wxBoxSizer( wxHORIZONTAL ); | |
302 | 320 |
303 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); | 321 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); |
304 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); | 322 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); |
305 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); | 323 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxDefaultSize, 0 ); |
306 bSizerMain->Add( m_bitmap, 0, wxALL, 5 ); | 324 bSizerLogo->Add( m_bitmap, 0, wxALIGN_CENTER_VERTICAL, 0 ); |
307 | 325 |
326 bSizerLogo->AddStretchSpacer(); | |
327 | |
328 logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("to_mover.png"); | |
329 bmp.LoadFile( logo, wxBITMAP_TYPE_PNG ); | |
330 m_mvButton = new wxBitmapButton( m_panelMain, ID_MOVER, bmp, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); | |
331 bSizerLogo->Add( m_mvButton, 0, wxALIGN_TOP, 0 ); | |
332 | |
333 bSizerMain->Add( bSizerLogo, 0, wxEXPAND|wxALL, 5 ); | |
334 | |
308 m_textCtrlName = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 ); | 335 m_textCtrlName = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 ); |
309 bSizerMain->Add( m_textCtrlName, 0, wxALL, 5 ); | 336 bSizerMain->Add( m_textCtrlName, 0, wxALL, 5 ); |
310 | 337 |
311 m_textCtrlAddr = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 ); | 338 m_textCtrlAddr = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 ); |
312 bSizerMain->Add( m_textCtrlAddr, 0, wxALL, 5 ); | 339 bSizerMain->Add( m_textCtrlAddr, 0, wxALL, 5 ); |
358 // | 385 // |
359 this->SetSizer( bSizerTop ); | 386 this->SetSizer( bSizerTop ); |
360 this->Layout(); | 387 this->Layout(); |
361 | 388 |
362 // ステータスバー Statusbar | 389 // ステータスバー Statusbar |
363 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); | 390 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); |
364 int widths[] = { 200, -1, 10, 90 }; | 391 int widths[] = { 200, -1, 10, 90 }; |
365 m_statusBar->SetFieldsCount( 4, widths ); | 392 m_statusBar->SetFieldsCount( 4, widths ); |
366 this->SetStatusBar( m_statusBar ); | 393 this->SetStatusBar( m_statusBar ); |
367 SetStatusText( wxT("被保番を入力してスタート!") ); | 394 SetStatusText( wxT("被保番を入力してスタート!") ); |
368 | 395 |
396 m_panelMain->SetDropTarget( new DnDFile2( this ) ); | |
397 // | |
369 this->Centre( wxBOTH ); | 398 this->Centre( wxBOTH ); |
370 LoadParam(); | 399 LoadParam(); |
371 if ( CheckNewFiles( m_shared ) != 0 ) | 400 if ( CheckNewFiles( m_shared ) != 0 ) |
372 Close(); | 401 Close(); |
402 | |
373 } | 403 } |
374 | 404 |
375 MyFrame::~MyFrame() | 405 MyFrame::~MyFrame() |
376 { | 406 { |
377 } | 407 } |
378 | 408 |
379 // Event Table | 409 // Event Table |
380 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | 410 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) |
381 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) | 411 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
382 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | 412 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) |
413 EVT_MENU( ID_MNMOVER, MyFrame::OnMover ) | |
383 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) | 414 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) |
384 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) | 415 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) |
385 EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) | 416 EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) |
386 EVT_MENU( ID_MNCACHE, MyFrame::OnCache ) | 417 EVT_MENU( ID_MNCACHE, MyFrame::OnCache ) |
387 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) | 418 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) |
388 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) | 419 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) |
389 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) | 420 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) |
390 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) | 421 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) |
422 EVT_BUTTON( ID_MOVER, MyFrame::OnMover ) | |
391 EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) | 423 EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) |
392 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) | 424 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) |
393 EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) | 425 EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) |
394 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) | 426 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) |
395 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) | 427 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) |
414 Close(); | 446 Close(); |
415 return; | 447 return; |
416 } | 448 } |
417 | 449 |
418 if ( s.IsSameAs( wxT("+") ) ) { | 450 if ( s.IsSameAs( wxT("+") ) ) { |
419 PrintImages( m_hhsno ); | 451 if ( !m_hhsno.IsEmpty() ) { |
452 PrintImages( m_hhsno, 0 ); | |
453 } | |
454 else { | |
455 SetStatusMessage( wxT("被保険者番号がセットされていません."), 0 ); | |
456 m_searchBox->SelectAll(); | |
457 } | |
420 return; | 458 return; |
421 } | 459 } |
422 | 460 |
423 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | 461 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); |
424 if ( reHhs.Matches( s ) ) { | 462 if ( reHhs.Matches( s ) ) { |
507 config->Read( wxT("zmin"), &zmin ); | 545 config->Read( wxT("zmin"), &zmin ); |
508 config->Read( wxT("zmax"), &zmax ); | 546 config->Read( wxT("zmax"), &zmax ); |
509 | 547 |
510 } | 548 } |
511 /* 印刷 */ | 549 /* 印刷 */ |
512 void MyFrame::PrintImages( wxString hhsno ) | 550 void MyFrame::PrintImages( wxString hhsno, int pn ) |
513 { | 551 { |
514 bool mask_flag = false; | 552 bool mask_flag = false; |
515 wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); | 553 wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); |
516 if ( md.ShowModal() == wxID_YES ) { | 554 if ( md.ShowModal() == wxID_YES ) { |
517 mask_flag = true; | 555 mask_flag = true; |
519 | 557 |
520 // 印刷用の html を作成 | 558 // 印刷用の html を作成 |
521 wxArrayString path = GetPathByHhsNo( hhsno ); | 559 wxArrayString path = GetPathByHhsNo( hhsno ); |
522 if ( path.IsEmpty() ) return; | 560 if ( path.IsEmpty() ) return; |
523 | 561 |
524 wxDir dir( path[0] ); | 562 wxDir dir( path[pn] ); |
525 if ( !dir.IsOpened() ) return; | 563 |
564 if ( !dir.IsOpened() ) { | |
565 SetStatusMessage( wxT("変な入力がされました."), 0 ); | |
566 return; | |
567 } | |
526 | 568 |
527 wxString html; | 569 wxString html; |
528 html = html + wxT("<html><body>\n"); | 570 html = html + wxT("<html><body>\n"); |
529 | 571 |
530 wxString file; | 572 wxString file; |
578 SetStatusMessage( wxT("被保番かフォルダ番号を."), 0 ); | 620 SetStatusMessage( wxT("被保番かフォルダ番号を."), 0 ); |
579 } | 621 } |
580 /* 一括印刷モード */ | 622 /* 一括印刷モード */ |
581 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) ) | 623 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) ) |
582 { | 624 { |
625 ShowBPrintFrame( wxEmptyString ); | |
626 } | |
627 void MyFrame::ShowBPrintFrame( wxString csv ) | |
628 { | |
583 FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 700, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR ); | 629 FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 700, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR ); |
584 bp->SetMask1( m_mask1 ); | 630 bp->SetMask1( m_mask1 ); |
585 bp->SetMask2( m_mask2 ); | 631 bp->SetMask2( m_mask2 ); |
586 bp->SetMask3( m_mask3 ); | 632 bp->SetMask3( m_mask3 ); |
587 bp->SetMask1Old( m_mask1old ); | 633 bp->SetMask1Old( m_mask1old ); |
588 bp->SetMask2Old( m_mask2old ); | 634 bp->SetMask2Old( m_mask2old ); |
589 bp->SetMask3Old( m_mask3old ); | 635 bp->SetMask3Old( m_mask3old ); |
590 bp->SetMark( lmin, lmax, zmin, zmax ); | 636 bp->SetMark( lmin, lmax, zmin, zmax ); |
591 bp->Show( true ); | 637 bp->Show( true ); |
638 | |
639 if ( !csv.IsEmpty() ) bp->LoadCSV( csv ); | |
592 } | 640 } |
593 /* インデックス作成ダイアログ */ | 641 /* インデックス作成ダイアログ */ |
594 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) ) | 642 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) ) |
595 { | 643 { |
596 wxString rootdir; | 644 wxString rootdir; |
610 | 658 |
611 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); | 659 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); |
612 cache->Setting( rootdir, THUMB_W, THUMB_H ); | 660 cache->Setting( rootdir, THUMB_W, THUMB_H ); |
613 cache->Listup(); | 661 cache->Listup(); |
614 cache->ShowModal(); | 662 cache->ShowModal(); |
663 } | |
664 /* Mover 禁止 */ | |
665 void MyFrame::DisableMover( void ) | |
666 { | |
667 wxMenuItem *mi = m_menuFile->FindItem( ID_MNMOVER ); | |
668 mi->Enable( false ); | |
669 m_mvButton->Show( false ); | |
670 m_mvButton->Enable( false ); | |
615 } | 671 } |
616 /* 被保険者DB更新 */ | 672 /* 被保険者DB更新 */ |
617 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) | 673 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) |
618 { | 674 { |
619 HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); | 675 HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); |
746 m_listCtrl->GetItem( item ); | 802 m_listCtrl->GetItem( item ); |
747 wxString dir = item.GetText(); | 803 wxString dir = item.GetText(); |
748 wxString execmd = wxT("explorer ") + dir; | 804 wxString execmd = wxT("explorer ") + dir; |
749 wxExecute( execmd ); | 805 wxExecute( execmd ); |
750 } | 806 } |
807 /* Mover を起動 */ | |
808 void MyFrame::OnMover( wxCommandEvent& WXUNUSED(event) ) | |
809 { | |
810 wxMessageBox(wxT("a")); | |
811 } | |
751 | 812 |
752 /* 貼付検索 */ | 813 /* 貼付検索 */ |
753 void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) | 814 void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) |
754 { | 815 { |
755 wxString s; | 816 wxString s; |