Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/myframe.cpp @ 21:a2ad87cad48b
Enhanced the convenience of Cache dialog.
author | pyon@macmini |
---|---|
date | Wed, 17 Dec 2014 00:52:43 +0900 |
parents | 226774bf49fc |
children | 92188f60323d |
comparison
equal
deleted
inserted
replaced
20:226774bf49fc | 21:a2ad87cad48b |
---|---|
1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
2 // Last Change: 08-Dec-2014. | 2 // Last Change: 16-Dec-2014. |
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" |
19 /////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////// |
20 // カスタム検索ボックス | 20 // カスタム検索ボックス |
21 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) | 21 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 ) | 22 : wxSearchCtrl( parent, id, value, pos, size, style ) |
23 { | 23 { |
24 SetMaxLength( 10 ); | |
25 #ifndef __WXMAC__ | |
26 ShowSearchButton( true ); | |
27 #endif | |
28 ShowCancelButton( false ); | |
29 | |
30 wxFont font( 12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); | |
31 SetFont( font ); | |
24 } | 32 } |
25 | 33 |
26 MySearchBox::~MySearchBox() | 34 MySearchBox::~MySearchBox() |
27 { | 35 { |
28 } | 36 } |
147 m_bitmap4->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | 155 m_bitmap4->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); |
148 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | 156 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); |
149 } | 157 } |
150 | 158 |
151 // Functions | 159 // Functions |
160 /* 初期化 */ | |
161 void ThumbnailPanel::Initialize( void ) | |
162 { | |
163 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
164 wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG ); | |
165 | |
166 m_bitmap0->SetBitmap( bmp ); | |
167 m_bitmap1->SetBitmap( bmp ); | |
168 m_bitmap2->SetBitmap( bmp ); | |
169 m_bitmap3->SetBitmap( bmp ); | |
170 m_bitmap4->SetBitmap( bmp ); | |
171 m_bitmap5->SetBitmap( bmp ); | |
172 } | |
152 /* サムネイル表示 */ | 173 /* サムネイル表示 */ |
153 void ThumbnailPanel::SetCacheImages( wxString dirpath ) | 174 void ThumbnailPanel::SetCacheImages( wxString dirpath ) |
154 { | 175 { |
155 wxBitmap bmp; | 176 wxBitmap bmp; |
156 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | 177 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); |
157 | 178 |
158 wxDir dir( dirpath ); | 179 wxDir dir( dirpath ); |
159 if ( !dir.IsOpened() ) return; | 180 if ( !dir.IsOpened() ) { |
181 Initialize(); | |
182 return; | |
183 } | |
160 | 184 |
161 m_imagefiles.Clear(); | 185 m_imagefiles.Clear(); |
162 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); | 186 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); |
163 | 187 |
164 m_cachefiles.Clear(); | 188 m_cachefiles.Clear(); |
165 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); | 189 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); |
166 wxDir cdir( cachedir ); | 190 wxDir cdir( cachedir ); |
167 if ( !cdir.IsOpened() ) { | 191 if ( !cdir.IsOpened() ) { |
168 bmp.LoadFile( thumb, wxBITMAP_TYPE_PNG ); | 192 Initialize(); |
169 m_bitmap0->SetBitmap( bmp ); | |
170 m_bitmap1->SetBitmap( bmp ); | |
171 m_bitmap2->SetBitmap( bmp ); | |
172 m_bitmap3->SetBitmap( bmp ); | |
173 m_bitmap4->SetBitmap( bmp ); | |
174 m_bitmap5->SetBitmap( bmp ); | |
175 return; | 193 return; |
176 } | 194 } |
177 | 195 |
178 wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); | 196 wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); |
179 | 197 |
313 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); | 331 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); |
314 | 332 |
315 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); | 333 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); |
316 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 334 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
317 | 335 |
318 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); | 336 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER ); |
319 m_searchBox->SetJudgedHhs( GetJudgedHhsNo() ); | 337 m_searchBox->SetJudgedHhs( GetJudgedHhsNo() ); |
320 #ifndef __WXMAC__ | |
321 m_searchBox->ShowSearchButton( true ); | |
322 #endif | |
323 m_searchBox->ShowCancelButton( false ); | |
324 m_searchBox->SetFocus(); | 338 m_searchBox->SetFocus(); |
325 bSizerCmd->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); | 339 bSizerCmd->Add( m_searchBox, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); |
326 | 340 |
327 m_buttonPaste = new wxButton( m_panelMain, ID_PASTE, wxT("貼付検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); | 341 m_buttonPaste = new wxButton( m_panelMain, ID_PASTE, wxT("貼付検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
328 bSizerCmd->Add( m_buttonPaste, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 10 ); | 342 bSizerCmd->Add( m_buttonPaste, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 10 ); |
329 | 343 |
330 m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); | 344 m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
331 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); | 345 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); |
332 | 346 |
333 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); | 347 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
334 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); | 348 bSizerCmd->Add( m_buttonHist, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
335 | 349 |
336 // | 350 // |
337 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); | 351 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); |
338 | 352 |
339 m_panelMain->SetSizer( bSizerMain ); | 353 m_panelMain->SetSizer( bSizerMain ); |
594 config->SetPath( wxT("/Index") ); | 608 config->SetPath( wxT("/Index") ); |
595 config->Read( wxT("rootdir"), &rootdir ); | 609 config->Read( wxT("rootdir"), &rootdir ); |
596 | 610 |
597 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); | 611 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); |
598 cache->Setting( rootdir, THUMB_W, THUMB_H ); | 612 cache->Setting( rootdir, THUMB_W, THUMB_H ); |
613 cache->Listup(); | |
599 cache->ShowModal(); | 614 cache->ShowModal(); |
600 } | 615 } |
601 /* 被保険者DB更新 */ | 616 /* 被保険者DB更新 */ |
602 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) | 617 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) |
603 { | 618 { |
761 } | 776 } |
762 | 777 |
763 /* カナ検索ダイアログ */ | 778 /* カナ検索ダイアログ */ |
764 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) | 779 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) |
765 { | 780 { |
766 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 640, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); | 781 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 680, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
767 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | 782 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
768 | 783 |
769 if ( kana->ShowModal() == wxID_OK ) { | 784 if ( kana->ShowModal() == wxID_OK ) { |
770 m_hhsno = kana->GetHhsNo(); | 785 m_hhsno = kana->GetHhsNo(); |
771 UpdateList( m_hhsno ); | 786 UpdateList( m_hhsno ); |
813 if ( path.IsEmpty() ) { | 828 if ( path.IsEmpty() ) { |
814 SetStatusMessage( wxT("審査会履歴がありません."), 1 ); | 829 SetStatusMessage( wxT("審査会履歴がありません."), 1 ); |
815 return; | 830 return; |
816 } | 831 } |
817 | 832 |
818 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); | 833 wxRegEx reDate( wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-1][0-9])([0-3][0-9])(.*$)") ); |
819 for ( int i = 0; i < path.GetCount(); i++ ) { | 834 for ( int i = 0; i < path.GetCount(); i++ ) { |
820 wxString date = path[i]; | 835 wxString date = path[i]; |
821 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); | 836 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); |
822 | 837 |
823 m_listCtrl->InsertItem( i, -1 ); | 838 m_listCtrl->InsertItem( i, -1 ); |
824 m_listCtrl->SetItem( i, 0,wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No | 839 m_listCtrl->SetItem( i, 0, wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No |
825 m_listCtrl->SetItem( i, 1, date, -1 ); | 840 m_listCtrl->SetItem( i, 1, date, -1 ); |
826 m_listCtrl->SetItem( i, 2, path[i], -1 ); | 841 m_listCtrl->SetItem( i, 2, path[i], -1 ); |
827 | 842 |
828 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) ); | 843 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) ); |
829 } | 844 } |
906 Destroy(); | 921 Destroy(); |
907 } | 922 } |
908 /* アバウトダイアログ */ | 923 /* アバウトダイアログ */ |
909 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | 924 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) |
910 { | 925 { |
911 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); | 926 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize( 360, 280 ), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); |
912 aboutDlg->ShowModal(); | 927 aboutDlg->ShowModal(); |
913 } | 928 } |
914 | 929 |