Mercurial > mercurial > hgweb_searcher03.cgi
annotate src/myframe.cpp @ 19:3bb803d8c1d7
Implement Mini-mode.
author | pyon@macmini |
---|---|
date | Sun, 07 Dec 2014 20:48:05 +0900 |
parents | a8e6e5769e3b |
children | 226774bf49fc |
rev | line source |
---|---|
0 | 1 // Filename : myframe.cpp |
19 | 2 // Last Change: 04-Dec-2014. |
0 | 3 // |
4 #include "main.h" | |
1 | 5 #include "db.h" |
0 | 6 #include "about.h" |
7 #include "kana.h" | |
8 #include "hist.h" | |
9 | 9 #include "preview.h" |
0 | 10 #include "index.h" |
13 | 11 #include "hhsdb.h" |
11 | 12 #include "cache.h" |
4 | 13 #include "param.h" |
2 | 14 #include "marksheet.h" |
15 #include "myframe.h" | |
16 #include "bprint.h" | |
16 | 17 #include "update.h" |
9 | 18 |
1 | 19 /////////////////////////////////////////////////////////////// |
20 // カスタム検索ボックス | |
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 ) | |
23 { | |
24 } | |
25 | |
26 MySearchBox::~MySearchBox() | |
27 { | |
28 } | |
29 | |
9 | 30 void MySearchBox::SetMessage( wxString msg ) |
31 { | |
32 wxFrame* p = (wxFrame*)FindWindowById( ID_MAIN ); | |
33 p->SetStatusText( msg, 0 ); | |
34 } | |
35 | |
1 | 36 // Event Table |
37 BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl ) | |
38 EVT_CHAR( MySearchBox::OnKey ) | |
39 END_EVENT_TABLE() | |
40 | |
41 // Event Handlers & Functions | |
42 void MySearchBox::OnKey( wxKeyEvent& event ) | |
43 { | |
9 | 44 int kc = event.GetKeyCode(); |
1 | 45 wxString s = GetValue(); |
46 | |
9 | 47 if ( kc == 13 ) { |
48 event.Skip(); | |
49 return; | |
50 } | |
51 | |
52 if ( kc == 45 ) { // テンキーの '-' キーで1文字削除 | |
1 | 53 wxString t = GetStringSelection(); |
54 if ( t.IsEmpty() ) { | |
55 long p = GetInsertionPoint(); | |
56 if ( p > 0 ) Remove( p - 1, p ); | |
57 } | |
58 else { | |
59 Cut(); | |
60 } | |
61 return; | |
62 } | |
63 | |
9 | 64 if ( kc == WXK_ESCAPE ) { // clear by ESC |
2 | 65 this->Clear(); |
1 | 66 return; |
67 } | |
68 | |
9 | 69 // auto-complete |
70 Cut(); | |
71 if ( kc >=48 && kc<=57 ) { // [0-9] | |
72 kc -= 48; | |
73 wxString input = GetValue() + wxString::Format( wxT("%d"), kc ); | |
74 if ( input.Len() < 5 ) { | |
75 event.Skip(); | |
76 return; | |
77 } | |
78 for ( unsigned int i = 0; i < m_jhhsno.GetCount(); i++ ) { | |
79 if ( m_jhhsno[i].StartsWith( input ) ) { | |
80 ChangeValue( m_jhhsno[i] ); | |
81 SetSelection( input.Len(), 10 ); | |
82 | |
83 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( m_jhhsno[i] ), '_', '\\' ); | |
17 | 84 if ( !s.IsEmpty() ) { |
85 wxString msg = wxT("もしかして... ") + s[0] + wxT(" ?!"); | |
86 SetMessage( msg ); | |
87 } | |
9 | 88 return; |
89 } | |
90 SetMessage( wxEmptyString ); | |
91 } | |
92 event.Skip(); | |
93 return; | |
94 } | |
1 | 95 event.Skip(); |
96 } | |
97 | |
9 | 98 /////////////////////////////////////////////////////////////// |
99 // サムネイルパネル | |
100 #define THUMB_W 60 | |
101 #define THUMB_H 75 | |
102 ThumbnailPanel::ThumbnailPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) | |
103 : wxPanel( parent, id, pos, size, style ) | |
104 { | |
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
105 m_parent = (MyFrame*)parent; |
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
106 |
9 | 107 wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL ); |
108 this->SetBackgroundColour( wxColour( 192, 192, 192 ) ); | |
109 | |
110 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
111 wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG ); | |
112 | |
10 | 113 m_bitmap0 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 114 bSizer->Add( m_bitmap0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
115 m_bitmap0->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); | |
116 | |
10 | 117 m_bitmap1 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 118 bSizer->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
119 m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); | |
120 | |
10 | 121 m_bitmap2 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 122 bSizer->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
123 m_bitmap2->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); | |
124 | |
10 | 125 m_bitmap3 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 126 bSizer->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
127 m_bitmap3->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); | |
128 | |
10 | 129 m_bitmap4 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 130 bSizer->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
131 m_bitmap4->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | |
132 | |
10 | 133 m_bitmap5 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
9 | 134 bSizer->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
135 m_bitmap5->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | |
136 | |
137 this->SetSizer( bSizer ); | |
138 this->Layout(); | |
139 } | |
140 | |
141 ThumbnailPanel::~ThumbnailPanel() | |
142 { | |
143 m_bitmap0->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); | |
144 m_bitmap1->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); | |
145 m_bitmap2->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); | |
146 m_bitmap3->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); | |
147 m_bitmap4->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | |
148 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | |
149 } | |
150 | |
151 // Functions | |
152 /* サムネイル表示 */ | |
10 | 153 void ThumbnailPanel::SetCacheImages( wxString dirpath ) |
9 | 154 { |
15 | 155 wxBitmap bmp; |
156 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
157 | |
9 | 158 wxDir dir( dirpath ); |
159 if ( !dir.IsOpened() ) return; | |
10 | 160 |
9 | 161 m_imagefiles.Clear(); |
162 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); | |
163 | |
15 | 164 m_cachefiles.Clear(); |
9 | 165 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); |
166 wxDir cdir( cachedir ); | |
15 | 167 if ( !cdir.IsOpened() ) { |
168 bmp.LoadFile( thumb, wxBITMAP_TYPE_PNG ); | |
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; | |
176 } | |
9 | 177 |
10 | 178 wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); |
9 | 179 |
10 | 180 int n = m_cachefiles.GetCount(); |
9 | 181 if ( n < 6 ) { |
182 while ( n < 6 ) { | |
10 | 183 m_cachefiles.Add( thumb ); |
9 | 184 n++; |
185 } | |
186 } | |
187 | |
10 | 188 bmp.LoadFile( m_cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); |
189 bmp.LoadFile( m_cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); | |
190 bmp.LoadFile( m_cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); | |
191 bmp.LoadFile( m_cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); | |
192 bmp.LoadFile( m_cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); | |
193 bmp.LoadFile( m_cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); | |
9 | 194 } |
10 | 195 /* 画像クリックダブルで拡大表示 */ |
196 void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 0 ); } | |
197 void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 1 ); } | |
198 void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 2 ); } | |
199 void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 3 ); } | |
200 void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 4 ); } | |
201 void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 5 ); } | |
202 void ThumbnailPanel::DoPreview( int n ) | |
9 | 203 { |
10 | 204 if ( m_imagefiles.GetCount() < n + 1 ) return; |
9 | 205 |
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
206 PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); |
9 | 207 pd->Show(); |
208 pd->Maximize( true ); | |
13 | 209 pd->SetFiles( m_imagefiles, m_cachefiles, n ); |
10 | 210 pd->SetPreviewImage( n ); |
9 | 211 } |
2 | 212 |
1 | 213 /////////////////////////////////////////////////////////////// |
214 // メインフレーム | |
2 | 215 #define WINL_W 480 |
0 | 216 #define LOGO_W 200 |
217 #define LOGO_H 92 | |
218 | |
219 // resources | |
220 #if !defined(__WXMSW__) && !defined(__WXPM__) | |
221 #include "sample.xpm" | |
222 #endif | |
223 | |
224 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
225 : wxFrame( parent, id, title, pos, size, style ) | |
226 { | |
227 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); | |
9 | 228 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); |
229 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | |
0 | 230 |
231 // set the frame icon | |
232 SetIcon(wxICON(sample)); | |
233 | |
234 // メニューバー Menu | |
235 m_menubar = new wxMenuBar( 0 ); | |
236 m_menuFile = new wxMenu(); | |
237 | |
2 | 238 wxMenuItem* m_menuItemBPrintMode = new wxMenuItem( m_menuFile, ID_MNBPNT, wxString( wxT("バッチ印刷モード\tF12") ) , wxT("Batch Print Mode"), wxITEM_NORMAL ); |
239 m_menuFile->Append( m_menuItemBPrintMode ); | |
240 | |
241 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); | |
242 m_menuFile->Append( m_menuItemIndex ); | |
0 | 243 |
11 | 244 wxMenuItem* m_menuItemCache = new wxMenuItem( m_menuFile, ID_MNCACHE, wxString( wxT("キャッシュ\tF9") ) , wxT("Make cache"), wxITEM_NORMAL ); |
245 m_menuFile->Append( m_menuItemCache ); | |
246 | |
0 | 247 m_menuFile->AppendSeparator(); // ---- |
248 | |
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
249 wxMenuItem* m_menuItemHhsdb = new wxMenuItem( m_menuFile, ID_MNHHSDB, wxString( wxT("被保険者DB更新(&U)") ) , wxT("Update HHS databases"), wxITEM_NORMAL ); |
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
250 m_menuFile->Append( m_menuItemHhsdb ); |
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
251 |
2 | 252 wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); |
253 m_menuFile->Append( m_menuItemBkup ); | |
254 | |
4 | 255 // params |
256 m_menuParam = new wxMenu(); | |
257 wxMenuItem* m_menuItemMask = new wxMenuItem( m_menuParam, ID_MNMASKPARAM, wxString( wxT("マスク(&M)") ) , wxT("Setup mask parameters"), wxITEM_NORMAL ); | |
258 m_menuParam->Append( m_menuItemMask ); | |
0 | 259 |
4 | 260 wxMenuItem* m_menuItemMark = new wxMenuItem( m_menuParam, ID_MNMARKPARAM, wxString( wxT("マークシート(&S)") ) , wxT("Setup marksheet parameters"), wxITEM_NORMAL ); |
261 m_menuParam->Append( m_menuItemMark ); | |
262 | |
263 m_menuFile->Append( -1, wxT("パラメータ(&P)"), m_menuParam ); | |
264 | |
265 // | |
2 | 266 wxMenuItem* m_menuItemAppDir = new wxMenuItem( m_menuFile, ID_MNAPPDIR, wxString( wxT("アプリケーションフォルダを開く(&O)") ) , wxT("Open application directory"), wxITEM_NORMAL ); |
0 | 267 m_menuFile->Append( m_menuItemAppDir ); |
268 | |
269 m_menuFile->AppendSeparator(); // ---- | |
270 | |
271 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL ); | |
272 m_menuFile->Append( m_menuItemAbout ); | |
273 | |
274 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); | |
275 | |
276 this->SetMenuBar( m_menubar ); | |
277 | |
278 // | |
279 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
280 | |
9 | 281 m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
282 | |
2 | 283 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); |
0 | 284 |
285 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); | |
286 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); | |
2 | 287 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); |
288 bSizerMain->Add( m_bitmap, 0, wxALL, 5 ); | |
0 | 289 |
2 | 290 m_textCtrlName = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 ); |
291 bSizerMain->Add( m_textCtrlName, 0, wxALL, 5 ); | |
0 | 292 |
2 | 293 m_textCtrlAddr = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 ); |
294 bSizerMain->Add( m_textCtrlAddr, 0, wxALL, 5 ); | |
0 | 295 |
2 | 296 m_listCtrl = new wxListCtrl( m_panelMain, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); |
0 | 297 wxListItem itemCol; |
298 itemCol.SetText( wxT("通番") ); | |
299 m_listCtrl->InsertColumn( 0, itemCol ); | |
300 m_listCtrl->SetColumnWidth( 0, 50 ); | |
301 itemCol.SetText( wxT("年月日") ); | |
302 m_listCtrl->InsertColumn( 1, itemCol ); | |
303 m_listCtrl->SetColumnWidth( 1, 80 ); | |
304 itemCol.SetText( wxT("場所") ); | |
305 m_listCtrl->InsertColumn( 2, itemCol ); | |
306 m_listCtrl->SetColumnWidth( 2, 300 ); | |
9 | 307 bSizerMain->Add( m_listCtrl, 1, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); |
308 | |
309 m_thumbPanel = new ThumbnailPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), wxSUNKEN_BORDER ); | |
310 bSizerMain->Add( m_thumbPanel, 0, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); | |
0 | 311 |
9 | 312 // |
0 | 313 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); |
314 | |
2 | 315 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); |
1 | 316 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
0 | 317 |
2 | 318 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); |
9 | 319 m_searchBox->SetJudgedHhs( GetJudgedHhsNo() ); |
0 | 320 #ifndef __WXMAC__ |
1 | 321 m_searchBox->ShowSearchButton( true ); |
0 | 322 #endif |
1 | 323 m_searchBox->ShowCancelButton( false ); |
324 m_searchBox->SetFocus(); | |
2 | 325 bSizerCmd->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); |
0 | 326 |
15 | 327 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 ); | |
329 | |
2 | 330 m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
15 | 331 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); |
0 | 332 |
2 | 333 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
0 | 334 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); |
335 | |
9 | 336 // |
2 | 337 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); |
0 | 338 |
2 | 339 m_panelMain->SetSizer( bSizerMain ); |
340 m_panelMain->Layout(); | |
341 bSizerMain->Fit( m_panelMain ); | |
9 | 342 bSizerTop->Add( m_panelMain, 1, wxEXPAND|wxALL, 5 ); |
2 | 343 |
344 // | |
0 | 345 this->SetSizer( bSizerTop ); |
346 this->Layout(); | |
347 | |
348 // ステータスバー Statusbar | |
1 | 349 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); |
2 | 350 int widths[] = { 200, -1, 10, 90 }; |
1 | 351 m_statusBar->SetFieldsCount( 4, widths ); |
352 this->SetStatusBar( m_statusBar ); | |
353 SetStatusText( wxT("被保番を入力してスタート!") ); | |
0 | 354 |
355 this->Centre( wxBOTH ); | |
4 | 356 LoadParam(); |
16 | 357 CheckNewFiles( m_shared ); |
0 | 358 } |
359 | |
360 MyFrame::~MyFrame() | |
361 { | |
362 } | |
363 | |
364 // Event Table | |
365 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
9 | 366 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
367 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | |
368 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) | |
369 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) | |
13 | 370 EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) |
11 | 371 EVT_MENU( ID_MNCACHE, MyFrame::OnCache ) |
9 | 372 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) |
0 | 373 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) |
5 | 374 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) |
9 | 375 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) |
376 EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) | |
377 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) | |
15 | 378 EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) |
379 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) | |
380 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) | |
9 | 381 EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand ) |
0 | 382 EVT_SIZE( MyFrame::OnWinSize ) |
383 EVT_MOVE( MyFrame::OnWinMove ) | |
384 EVT_CLOSE( MyFrame::SaveConfig ) | |
385 END_EVENT_TABLE() | |
386 | |
387 // Event Handlers & Functions | |
2 | 388 /* エンターキーフック */ |
389 void MyFrame::OnCommand( wxCommandEvent& event ) | |
0 | 390 { |
9 | 391 wxString s = m_searchBox->GetLineText(0); |
392 | |
393 if ( s.IsSameAs( wxT(".") ) ) { | |
394 OpenAppDir(); | |
395 return; | |
396 } | |
2 | 397 |
398 if ( s.IsSameAs( wxT("99") ) ) { | |
399 Close(); | |
400 return; | |
401 } | |
402 | |
403 if ( s.IsSameAs( wxT("+") ) ) { | |
404 PrintImages( m_hhsno ); | |
405 return; | |
406 } | |
407 | |
408 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | |
409 if ( reHhs.Matches( s ) ) { | |
410 m_hhsno = s; | |
411 UpdateList( m_hhsno ); | |
9 | 412 UpdateThumbmail( 0 ); |
2 | 413 return; |
414 } | |
415 | |
416 wxRegEx reNo( wxT("^[0-9]{1,2}$") ); | |
417 if ( reNo.Matches( s ) ) { | |
418 long n; | |
419 s.ToLong( &n, 10 ); | |
420 n--; | |
421 OpenHhsDir( (int)n ); | |
422 return; | |
423 } | |
424 | |
425 SetStatusMessage( wxT("不適切な入力です."), 0 ); | |
426 return; | |
427 | |
428 event.Skip(); | |
0 | 429 } |
4 | 430 /* パラメータを設定ファイルから読み込む */ |
431 void MyFrame::LoadParam( void ) | |
1 | 432 { |
433 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); | |
434 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); | |
435 | |
436 int x, y, w, h; | |
437 | |
16 | 438 // Shaerd |
439 config->SetPath( wxT("/Index") ); | |
440 config->Read( wxT("shared"), &m_shared ); | |
441 | |
442 // Mask | |
1 | 443 config->SetPath( wxT("/Mask") ); |
444 | |
445 config->Read( wxT("x1"), &x ); | |
446 config->Read( wxT("y1"), &y ); | |
447 config->Read( wxT("w1"), &w ); | |
448 config->Read( wxT("h1"), &h ); | |
449 m_mask1.SetPosition( wxPoint( x, y ) ); | |
450 m_mask1.SetSize( wxSize( w, h ) ); | |
451 | |
452 config->Read( wxT("x2"), &x ); | |
453 config->Read( wxT("y2"), &y ); | |
454 config->Read( wxT("w2"), &w ); | |
455 config->Read( wxT("h2"), &h ); | |
456 m_mask2.SetPosition( wxPoint( x, y ) ); | |
457 m_mask2.SetSize( wxSize( w, h ) ); | |
458 | |
459 config->Read( wxT("x3"), &x ); | |
460 config->Read( wxT("y3"), &y ); | |
461 config->Read( wxT("w3"), &w ); | |
462 config->Read( wxT("h3"), &h ); | |
463 m_mask3.SetPosition( wxPoint( x, y ) ); | |
464 m_mask3.SetSize( wxSize( w, h ) ); | |
465 | |
2 | 466 config->Read( wxT("x1o"), &x ); |
467 config->Read( wxT("y1o"), &y ); | |
468 config->Read( wxT("w1o"), &w ); | |
469 config->Read( wxT("h1o"), &h ); | |
470 m_mask1old.SetPosition( wxPoint( x, y ) ); | |
471 m_mask1old.SetSize( wxSize( w, h ) ); | |
472 | |
473 config->Read( wxT("x2o"), &x ); | |
474 config->Read( wxT("y2o"), &y ); | |
475 config->Read( wxT("w2o"), &w ); | |
476 config->Read( wxT("h2o"), &h ); | |
477 m_mask2old.SetPosition( wxPoint( x, y ) ); | |
478 m_mask2old.SetSize( wxSize( w, h ) ); | |
479 | |
480 config->Read( wxT("x3o"), &x ); | |
481 config->Read( wxT("y3o"), &y ); | |
482 config->Read( wxT("w3o"), &w ); | |
483 config->Read( wxT("h3o"), &h ); | |
484 m_mask3old.SetPosition( wxPoint( x, y ) ); | |
485 m_mask3old.SetSize( wxSize( w, h ) ); | |
5 | 486 |
16 | 487 // Marksheet |
5 | 488 config->SetPath( wxT("/Marksheet") ); |
489 | |
490 config->Read( wxT("lmin"), &lmin ); | |
491 config->Read( wxT("lmax"), &lmax ); | |
492 config->Read( wxT("zmin"), &zmin ); | |
493 config->Read( wxT("zmax"), &zmax ); | |
9 | 494 |
2 | 495 } |
496 /* 印刷 */ | |
497 void MyFrame::PrintImages( wxString hhsno ) | |
498 { | |
7 | 499 bool mask_flag = false; |
9 | 500 wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); |
7 | 501 if ( md.ShowModal() == wxID_YES ) { |
502 mask_flag = true; | |
503 } | |
504 | |
2 | 505 // 印刷用の html を作成 |
506 wxArrayString path = GetPathByHhsNo( hhsno ); | |
507 if ( path.IsEmpty() ) return; | |
508 | |
509 wxDir dir( path[0] ); | |
510 if ( !dir.IsOpened() ) return; | |
511 | |
512 wxString html; | |
513 html = html + wxT("<html><body>\n"); | |
514 | |
515 wxString file; | |
516 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); | |
4 | 517 bool notyet_mask = true; |
2 | 518 int n = 0; |
519 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; | |
520 while ( cout ) { | |
521 file = path[0] + wxFILE_SEP_PATH + file; | |
522 file.Replace( wxFILE_SEP_PATH, wxT("/") ); | |
523 wxString tmpjpg = wxString::Format( wxT("%stmp%d.jpg"), tmpdir, n ); | |
4 | 524 |
525 if ( notyet_mask && IsMarksheet( file, zmin, zmax, lmin, lmax ) ) { // マークシート表面をマスクする | |
2 | 526 wxImage img_org( file, wxBITMAP_TYPE_JPEG ); |
7 | 527 if ( mask_flag ) { |
528 int ver = GetMarksheetVersion( file ); | |
529 if ( ver == 2 ) { | |
530 img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name | |
531 img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. | |
532 img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode | |
533 } | |
534 else { // 古いマークシート ver == 1 | |
535 img_org.SetRGB( m_mask1old, 255, 255, 255 ); // cm name | |
536 img_org.SetRGB( m_mask2old, 255, 255, 255 ); // cm no. | |
537 img_org.SetRGB( m_mask3old, 255, 255, 255 ); // barcode | |
538 } | |
2 | 539 } |
540 img_org.SaveFile( tmpjpg ); | |
4 | 541 notyet_mask = false; |
2 | 542 } |
543 else { | |
544 wxCopyFile( file, tmpjpg, true ); | |
545 } | |
546 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); | |
18 | 547 html = html + wxT("<div align=right><font size=-2><u>") + hhsno + wxT("</u></font></div>"); |
2 | 548 cout = dir.GetNext( &file ); |
549 n++; | |
550 } | |
551 html = html + wxT("</body></html>"); | |
552 | |
553 // start printing | |
554 wxHtmlPrintout hpout( wxT("Searcher03") ); | |
555 hpout.SetMargins( 0, 0, 0, 0, 0 ); | |
556 wxPrintDialogData pd; | |
557 wxPrinter p( &pd ); | |
558 | |
559 hpout.SetHtmlText( html, wxEmptyString, false ); | |
560 p.Print( NULL, &hpout, true ); | |
561 | |
562 // end | |
563 SetStatusMessage( wxT("被保番かフォルダ番号を."), 0 ); | |
564 } | |
565 /* 一括印刷モード */ | |
566 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) ) | |
567 { | |
8 | 568 FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 700, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR ); |
2 | 569 bp->SetMask1( m_mask1 ); |
570 bp->SetMask2( m_mask2 ); | |
571 bp->SetMask3( m_mask3 ); | |
572 bp->SetMask1Old( m_mask1old ); | |
573 bp->SetMask2Old( m_mask2old ); | |
574 bp->SetMask3Old( m_mask3old ); | |
5 | 575 bp->SetMark( lmin, lmax, zmin, zmax ); |
2 | 576 bp->Show( true ); |
577 } | |
578 /* インデックス作成ダイアログ */ | |
579 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) ) | |
580 { | |
581 wxString rootdir; | |
582 config->SetPath( wxT("/Index") ); | |
583 config->Read( wxT("rootdir"), &rootdir ); | |
584 | |
7 | 585 IndexDialog* index = new IndexDialog( this, wxID_ANY, wxT("インデックス作成"), wxDefaultPosition, wxSize( 700, 600 ), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); |
8 | 586 index->SetRootdir( rootdir ); |
7 | 587 index->ShowModal(); |
1 | 588 } |
11 | 589 /* キャッシュ作成ダイアログ */ |
590 void MyFrame::OnCache( wxCommandEvent& WXUNUSED(event) ) | |
591 { | |
592 wxString rootdir; | |
593 config->SetPath( wxT("/Index") ); | |
594 config->Read( wxT("rootdir"), &rootdir ); | |
595 | |
596 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); | |
597 cache->Setting( rootdir, THUMB_W, THUMB_H ); | |
598 cache->ShowModal(); | |
599 } | |
13 | 600 /* 被保険者DB更新 */ |
601 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) | |
602 { | |
603 HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); | |
604 hd->Show(); | |
605 } | |
4 | 606 /* マークシートパラメータ設定ダイアログ */ |
607 void MyFrame::OnMarkParam( wxCommandEvent& WXUNUSED(event) ) | |
608 { | |
5 | 609 SetParams( 2 ); |
4 | 610 } |
0 | 611 /* マスクパラメータ設定ダイアログ */ |
612 void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) ) | |
613 { | |
5 | 614 SetParams( 0 ); |
615 } | |
616 /* 設定を保存 */ | |
617 void MyFrame::SetParams( int tab ) | |
618 { | |
619 ParamDialog* param = new ParamDialog( this, wxID_ANY, wxT("各種パラメータの指定"), wxDefaultPosition, wxSize( 350, 250 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); | |
4 | 620 param->SetMask1( m_mask1 ); |
621 param->SetMask2( m_mask2 ); | |
622 param->SetMask3( m_mask3 ); | |
623 param->SetMask1Old( m_mask1old ); | |
624 param->SetMask2Old( m_mask2old ); | |
625 param->SetMask3Old( m_mask3old ); | |
5 | 626 param->SetMark( lmin, lmax, zmin, zmax ); |
4 | 627 param->LoadParams(); |
628 param->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | |
5 | 629 param->SelectTAb( tab ); |
1 | 630 |
4 | 631 if ( param->ShowModal() == wxID_OK ) { |
632 m_mask1 = param->GetMask1(); | |
633 m_mask2 = param->GetMask2(); | |
634 m_mask3 = param->GetMask3(); | |
635 m_mask1old = param->GetMask1Old(); | |
636 m_mask2old = param->GetMask2Old(); | |
637 m_mask3old = param->GetMask3Old(); | |
5 | 638 lmin = param->GetLmin(); |
639 lmax = param->GetLmax(); | |
640 zmin = param->GetZmin(); | |
641 zmax = param->GetZmax(); | |
1 | 642 |
643 config->SetPath( wxT("/Mask") ); | |
644 | |
645 config->Write( wxT("x1"), m_mask1.GetX() ); | |
646 config->Write( wxT("y1"), m_mask1.GetY() ); | |
647 config->Write( wxT("w1"), m_mask1.GetWidth() ); | |
648 config->Write( wxT("h1"), m_mask1.GetHeight() ); | |
649 | |
650 config->Write( wxT("x2"), m_mask2.GetX() ); | |
651 config->Write( wxT("y2"), m_mask2.GetY() ); | |
652 config->Write( wxT("w2"), m_mask2.GetWidth() ); | |
653 config->Write( wxT("h2"), m_mask2.GetHeight() ); | |
654 | |
655 config->Write( wxT("x3"), m_mask3.GetX() ); | |
656 config->Write( wxT("y3"), m_mask3.GetY() ); | |
657 config->Write( wxT("w3"), m_mask3.GetWidth() ); | |
658 config->Write( wxT("h3"), m_mask3.GetHeight() ); | |
659 | |
2 | 660 config->Write( wxT("x1o"), m_mask1old.GetX() ); |
661 config->Write( wxT("y1o"), m_mask1old.GetY() ); | |
662 config->Write( wxT("w1o"), m_mask1old.GetWidth() ); | |
663 config->Write( wxT("h1o"), m_mask1old.GetHeight() ); | |
664 | |
665 config->Write( wxT("x2o"), m_mask2old.GetX() ); | |
666 config->Write( wxT("y2o"), m_mask2old.GetY() ); | |
667 config->Write( wxT("w2o"), m_mask2old.GetWidth() ); | |
668 config->Write( wxT("h2o"), m_mask2old.GetHeight() ); | |
669 | |
670 config->Write( wxT("x3o"), m_mask3old.GetX() ); | |
671 config->Write( wxT("y3o"), m_mask3old.GetY() ); | |
672 config->Write( wxT("w3o"), m_mask3old.GetWidth() ); | |
673 config->Write( wxT("h3o"), m_mask3old.GetHeight() ); | |
674 | |
5 | 675 config->SetPath( wxT("/Marksheet") ); |
676 | |
677 config->Write( wxT("lmin"), lmin ); | |
678 config->Write( wxT("lmax"), lmax ); | |
679 config->Write( wxT("zmin"), zmin ); | |
680 config->Write( wxT("zmax"), zmax ); | |
681 | |
2 | 682 config->Flush( false ); |
1 | 683 } |
0 | 684 } |
2 | 685 /* データベースファイルのバックアップ */ |
686 void MyFrame::OnDBBackup( wxCommandEvent& WXUNUSED(event) ) | |
687 { | |
688 wxDateTime now = wxDateTime::Now(); | |
689 wxString str = now.Format( wxT("%Y%m%d%H%M%S") ); | |
690 | |
691 wxString org, bk; | |
692 wxString dbdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("db"); | |
693 | |
694 org = dbdir + wxFILE_SEP_PATH + wxT("hhs.db"); | |
695 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_hhs.db"); | |
696 wxCopyFile( org, bk, false ); | |
697 | |
698 org = dbdir + wxFILE_SEP_PATH + wxT("ccn.db"); | |
699 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_ccn.db"); | |
700 wxCopyFile( org, bk, false ); | |
701 | |
702 wxMessageBox( wxT("バックアップ終了.") ); | |
703 return; | |
704 } | |
0 | 705 /* アプリフォルダを開く */ |
706 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) | |
707 { | |
9 | 708 OpenAppDir(); |
709 } | |
710 void MyFrame::OpenAppDir( ) | |
711 { | |
0 | 712 wxString appdir = wxGetCwd(); |
713 wxString execmd = wxT("explorer ") + appdir; | |
714 wxExecute( execmd ); | |
715 } | |
716 /* 被保険者フォルダを開く */ | |
9 | 717 void MyFrame::OnDClickItem( wxListEvent& event ) |
0 | 718 { |
719 int i = event.GetIndex(); | |
2 | 720 OpenHhsDir( i ); |
9 | 721 UpdateThumbmail( i ); |
2 | 722 } |
723 /* 番号で指定したフォルダを開く */ | |
724 void MyFrame::OpenHhsDir( int n ) | |
725 { | |
0 | 726 wxListItem item; |
2 | 727 item.SetId( n ); |
728 item.SetColumn( 2 ); | |
729 item.SetMask( wxLIST_MASK_TEXT ); | |
730 m_listCtrl->GetItem( item ); | |
731 wxString dir = item.GetText(); | |
732 wxString execmd = wxT("explorer ") + dir; | |
733 wxExecute( execmd ); | |
0 | 734 } |
1 | 735 |
15 | 736 /* 貼付検索 */ |
737 void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) | |
738 { | |
739 wxString s; | |
740 if ( wxTheClipboard->Open() ) { | |
741 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { | |
742 wxTextDataObject data; | |
743 wxTheClipboard->GetData( data ); | |
744 s = data.GetText(); | |
745 } | |
746 wxTheClipboard->Close(); | |
747 } | |
748 | |
18 | 749 s.Replace( wxT(" "), wxT(""), true ); |
15 | 750 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); |
751 if ( reHhs.Matches( s ) ) { | |
752 m_hhsno = s; | |
753 UpdateList( m_hhsno ); | |
754 UpdateThumbmail( 0 ); | |
755 return; | |
756 } | |
757 else { | |
758 wxMessageBox( wxT("被保険者番号ではありません.") ); | |
759 } | |
760 } | |
761 | |
0 | 762 /* カナ検索ダイアログ */ |
763 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) | |
764 { | |
2 | 765 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 640, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
0 | 766 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
1 | 767 |
768 if ( kana->ShowModal() == wxID_OK ) { | |
2 | 769 m_hhsno = kana->GetHhsNo(); |
770 UpdateList( m_hhsno ); | |
9 | 771 UpdateThumbmail( 0 ); |
1 | 772 } |
0 | 773 } |
774 /* 検索履歴検索ダイアログ */ | |
775 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) | |
776 { | |
2 | 777 HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 600, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
0 | 778 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
1 | 779 |
780 if ( hist->ShowModal() == wxID_OK ) { | |
2 | 781 m_hhsno = hist->GetHhsNo(); |
782 UpdateList( m_hhsno ); | |
9 | 783 UpdateThumbmail( 0 ); |
1 | 784 } |
785 } | |
786 | |
787 /* 検索結果をリストアップ */ | |
2 | 788 void MyFrame::UpdateList( wxString hhsno ) |
1 | 789 { |
790 m_listCtrl->DeleteAllItems(); | |
2 | 791 for ( int i = 0; i < m_statusBar->GetFieldsCount(); i++ ) { |
792 SetStatusMessage( wxEmptyString, i ); | |
793 } | |
794 | |
795 // | |
796 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
797 wxString history; | |
798 if ( s.IsEmpty() ) { | |
799 SetStatusMessage( wxT("データベースに存在しない被保険者です."), 0 ); | |
800 history = hhsno + wxT("###"); | |
801 } | |
802 else { | |
803 m_textCtrlName->SetValue( s[0] ); | |
804 m_textCtrlAddr->SetValue( s[1] ); | |
805 history = hhsno + wxT("#") + s[0] + wxT("#") + s[1] + wxT("#"); | |
806 } | |
807 m_searchBox->SetValue( hhsno ); | |
808 m_searchBox->SelectAll(); | |
809 m_searchBox->SetFocus(); | |
810 | |
811 wxArrayString path = GetPathByHhsNo( hhsno ); | |
812 if ( path.IsEmpty() ) { | |
813 SetStatusMessage( wxT("審査会履歴がありません."), 1 ); | |
814 return; | |
815 } | |
816 | |
817 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); | |
818 for ( int i = 0; i < path.GetCount(); i++ ) { | |
819 wxString date = path[i]; | |
820 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); | |
821 | |
822 m_listCtrl->InsertItem( i, -1 ); | |
823 m_listCtrl->SetItem( i, 0,wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No | |
824 m_listCtrl->SetItem( i, 1, date, -1 ); | |
825 m_listCtrl->SetItem( i, 2, path[i], -1 ); | |
826 | |
827 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) ); | |
828 } | |
829 | |
830 SetStatusMessage( wxT("「+」キーで通番1を印刷."), 0 ); | |
831 | |
832 // | |
833 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history"); | |
834 wxDateTime now = wxDateTime::Now(); | |
835 history = history + now.Format( wxT("%Y-%m-%d %H:%M:%S") ); | |
836 | |
837 wxTextFile hist( filename ); | |
838 hist.Open(); | |
839 hist.RemoveLine( 20 ); | |
840 hist.InsertLine( history, 0 ); | |
841 hist.Write(); | |
842 hist.Close(); | |
1 | 843 } |
9 | 844 /* フォルダを選択したとき */ |
845 void MyFrame::OnSelectItem( wxListEvent& event ) | |
846 { | |
847 UpdateThumbmail( event.GetIndex() ); | |
848 } | |
849 /* サムネイルを更新 */ | |
850 void MyFrame::UpdateThumbmail( int n ) | |
851 { | |
852 wxListItem item; | |
853 item.SetId( n ); | |
854 | |
855 item.SetColumn( 2 ); | |
856 item.SetMask( wxLIST_MASK_TEXT ); | |
857 m_listCtrl->GetItem( item ); | |
858 | |
10 | 859 m_thumbPanel->SetCacheImages( item.GetText() ); |
9 | 860 } |
1 | 861 /* ステータスバーにメッセージを出力 */ |
862 void MyFrame::SetStatusMessage( wxString msg, long n ) | |
863 { | |
864 if ( GetStatusBar() ) | |
865 SetStatusText( msg, n ); | |
0 | 866 } |
867 | |
868 /* サイズ変更 */ | |
869 void MyFrame::OnWinSize( wxSizeEvent& event ) | |
870 { | |
871 this->Refresh( true, NULL ); | |
872 TellLocation(); | |
873 event.Skip(); | |
874 } | |
875 /* ウィンドウ移動 */ | |
876 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) | |
877 { | |
878 TellLocation(); | |
879 return; | |
880 } | |
881 /* ウィンドウ位置とサイズを表示 */ | |
882 void MyFrame::TellLocation( void ) | |
883 { | |
884 wxRect r = this->GetRect(); | |
885 int x = r.GetX(); | |
886 int y = r.GetY(); | |
887 int w = r.GetWidth(); | |
888 int h = r.GetHeight(); | |
1 | 889 |
890 if ( GetStatusBar() ) | |
891 SetStatusText( wxString::Format(wxT( "(%d,%d) %dx%d"),x,y,w,h ), 3 ); | |
0 | 892 } |
893 /* 終了 */ | |
894 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) | |
895 { | |
896 Close( true ); | |
897 } | |
898 /* 設定を保存 */ | |
899 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) | |
900 { | |
901 if ( !IsIconized() && !IsMaximized() ) { | |
902 wxGetApp().rect = this->GetRect(); | |
903 } | |
9 | 904 delete config; |
0 | 905 Destroy(); |
906 } | |
907 /* アバウトダイアログ */ | |
908 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
909 { | |
910 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); | |
911 aboutDlg->ShowModal(); | |
912 } | |
913 |