Mercurial > mercurial > hgweb_searcher03.cgi
annotate src/myframe.cpp @ 20:226774bf49fc
Small fix.
author | pyon@macmini |
---|---|
date | Mon, 08 Dec 2014 19:47:42 +0900 |
parents | 3bb803d8c1d7 |
children | a2ad87cad48b |
rev | line source |
---|---|
0 | 1 // Filename : myframe.cpp |
20 | 2 // Last Change: 08-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(); |
20 | 357 if ( CheckNewFiles( m_shared ) != 0 ) |
358 Close(); | |
0 | 359 } |
360 | |
361 MyFrame::~MyFrame() | |
362 { | |
363 } | |
364 | |
365 // Event Table | |
366 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
9 | 367 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
368 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | |
369 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) | |
370 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) | |
13 | 371 EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) |
11 | 372 EVT_MENU( ID_MNCACHE, MyFrame::OnCache ) |
9 | 373 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup ) |
0 | 374 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam ) |
5 | 375 EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam ) |
9 | 376 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir ) |
377 EVT_LIST_ITEM_SELECTED( ID_LIST, MyFrame::OnSelectItem ) | |
378 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem ) | |
15 | 379 EVT_BUTTON( ID_PASTE, MyFrame::OnPaste ) |
380 EVT_BUTTON( ID_KANA, MyFrame::OnKana ) | |
381 EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) | |
9 | 382 EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand ) |
0 | 383 EVT_SIZE( MyFrame::OnWinSize ) |
384 EVT_MOVE( MyFrame::OnWinMove ) | |
385 EVT_CLOSE( MyFrame::SaveConfig ) | |
386 END_EVENT_TABLE() | |
387 | |
388 // Event Handlers & Functions | |
2 | 389 /* エンターキーフック */ |
390 void MyFrame::OnCommand( wxCommandEvent& event ) | |
0 | 391 { |
9 | 392 wxString s = m_searchBox->GetLineText(0); |
393 | |
394 if ( s.IsSameAs( wxT(".") ) ) { | |
395 OpenAppDir(); | |
396 return; | |
397 } | |
2 | 398 |
399 if ( s.IsSameAs( wxT("99") ) ) { | |
400 Close(); | |
401 return; | |
402 } | |
403 | |
404 if ( s.IsSameAs( wxT("+") ) ) { | |
405 PrintImages( m_hhsno ); | |
406 return; | |
407 } | |
408 | |
409 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | |
410 if ( reHhs.Matches( s ) ) { | |
411 m_hhsno = s; | |
412 UpdateList( m_hhsno ); | |
9 | 413 UpdateThumbmail( 0 ); |
2 | 414 return; |
415 } | |
416 | |
417 wxRegEx reNo( wxT("^[0-9]{1,2}$") ); | |
418 if ( reNo.Matches( s ) ) { | |
419 long n; | |
420 s.ToLong( &n, 10 ); | |
421 n--; | |
422 OpenHhsDir( (int)n ); | |
423 return; | |
424 } | |
425 | |
426 SetStatusMessage( wxT("不適切な入力です."), 0 ); | |
427 return; | |
428 | |
429 event.Skip(); | |
0 | 430 } |
4 | 431 /* パラメータを設定ファイルから読み込む */ |
432 void MyFrame::LoadParam( void ) | |
1 | 433 { |
434 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); | |
435 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); | |
436 | |
437 int x, y, w, h; | |
438 | |
16 | 439 // Shaerd |
440 config->SetPath( wxT("/Index") ); | |
441 config->Read( wxT("shared"), &m_shared ); | |
442 | |
443 // Mask | |
1 | 444 config->SetPath( wxT("/Mask") ); |
445 | |
446 config->Read( wxT("x1"), &x ); | |
447 config->Read( wxT("y1"), &y ); | |
448 config->Read( wxT("w1"), &w ); | |
449 config->Read( wxT("h1"), &h ); | |
450 m_mask1.SetPosition( wxPoint( x, y ) ); | |
451 m_mask1.SetSize( wxSize( w, h ) ); | |
452 | |
453 config->Read( wxT("x2"), &x ); | |
454 config->Read( wxT("y2"), &y ); | |
455 config->Read( wxT("w2"), &w ); | |
456 config->Read( wxT("h2"), &h ); | |
457 m_mask2.SetPosition( wxPoint( x, y ) ); | |
458 m_mask2.SetSize( wxSize( w, h ) ); | |
459 | |
460 config->Read( wxT("x3"), &x ); | |
461 config->Read( wxT("y3"), &y ); | |
462 config->Read( wxT("w3"), &w ); | |
463 config->Read( wxT("h3"), &h ); | |
464 m_mask3.SetPosition( wxPoint( x, y ) ); | |
465 m_mask3.SetSize( wxSize( w, h ) ); | |
466 | |
2 | 467 config->Read( wxT("x1o"), &x ); |
468 config->Read( wxT("y1o"), &y ); | |
469 config->Read( wxT("w1o"), &w ); | |
470 config->Read( wxT("h1o"), &h ); | |
471 m_mask1old.SetPosition( wxPoint( x, y ) ); | |
472 m_mask1old.SetSize( wxSize( w, h ) ); | |
473 | |
474 config->Read( wxT("x2o"), &x ); | |
475 config->Read( wxT("y2o"), &y ); | |
476 config->Read( wxT("w2o"), &w ); | |
477 config->Read( wxT("h2o"), &h ); | |
478 m_mask2old.SetPosition( wxPoint( x, y ) ); | |
479 m_mask2old.SetSize( wxSize( w, h ) ); | |
480 | |
481 config->Read( wxT("x3o"), &x ); | |
482 config->Read( wxT("y3o"), &y ); | |
483 config->Read( wxT("w3o"), &w ); | |
484 config->Read( wxT("h3o"), &h ); | |
485 m_mask3old.SetPosition( wxPoint( x, y ) ); | |
486 m_mask3old.SetSize( wxSize( w, h ) ); | |
5 | 487 |
16 | 488 // Marksheet |
5 | 489 config->SetPath( wxT("/Marksheet") ); |
490 | |
491 config->Read( wxT("lmin"), &lmin ); | |
492 config->Read( wxT("lmax"), &lmax ); | |
493 config->Read( wxT("zmin"), &zmin ); | |
494 config->Read( wxT("zmax"), &zmax ); | |
9 | 495 |
2 | 496 } |
497 /* 印刷 */ | |
498 void MyFrame::PrintImages( wxString hhsno ) | |
499 { | |
7 | 500 bool mask_flag = false; |
9 | 501 wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition ); |
7 | 502 if ( md.ShowModal() == wxID_YES ) { |
503 mask_flag = true; | |
504 } | |
505 | |
2 | 506 // 印刷用の html を作成 |
507 wxArrayString path = GetPathByHhsNo( hhsno ); | |
508 if ( path.IsEmpty() ) return; | |
509 | |
510 wxDir dir( path[0] ); | |
511 if ( !dir.IsOpened() ) return; | |
512 | |
513 wxString html; | |
514 html = html + wxT("<html><body>\n"); | |
515 | |
516 wxString file; | |
517 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); | |
4 | 518 bool notyet_mask = true; |
2 | 519 int n = 0; |
520 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; | |
521 while ( cout ) { | |
522 file = path[0] + wxFILE_SEP_PATH + file; | |
523 file.Replace( wxFILE_SEP_PATH, wxT("/") ); | |
524 wxString tmpjpg = wxString::Format( wxT("%stmp%d.jpg"), tmpdir, n ); | |
4 | 525 |
526 if ( notyet_mask && IsMarksheet( file, zmin, zmax, lmin, lmax ) ) { // マークシート表面をマスクする | |
2 | 527 wxImage img_org( file, wxBITMAP_TYPE_JPEG ); |
7 | 528 if ( mask_flag ) { |
529 int ver = GetMarksheetVersion( file ); | |
530 if ( ver == 2 ) { | |
531 img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name | |
532 img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. | |
533 img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode | |
534 } | |
535 else { // 古いマークシート ver == 1 | |
536 img_org.SetRGB( m_mask1old, 255, 255, 255 ); // cm name | |
537 img_org.SetRGB( m_mask2old, 255, 255, 255 ); // cm no. | |
538 img_org.SetRGB( m_mask3old, 255, 255, 255 ); // barcode | |
539 } | |
2 | 540 } |
541 img_org.SaveFile( tmpjpg ); | |
4 | 542 notyet_mask = false; |
2 | 543 } |
544 else { | |
545 wxCopyFile( file, tmpjpg, true ); | |
546 } | |
547 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); | |
18 | 548 html = html + wxT("<div align=right><font size=-2><u>") + hhsno + wxT("</u></font></div>"); |
2 | 549 cout = dir.GetNext( &file ); |
550 n++; | |
551 } | |
552 html = html + wxT("</body></html>"); | |
553 | |
554 // start printing | |
555 wxHtmlPrintout hpout( wxT("Searcher03") ); | |
556 hpout.SetMargins( 0, 0, 0, 0, 0 ); | |
557 wxPrintDialogData pd; | |
558 wxPrinter p( &pd ); | |
559 | |
560 hpout.SetHtmlText( html, wxEmptyString, false ); | |
561 p.Print( NULL, &hpout, true ); | |
562 | |
563 // end | |
564 SetStatusMessage( wxT("被保番かフォルダ番号を."), 0 ); | |
565 } | |
566 /* 一括印刷モード */ | |
567 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) ) | |
568 { | |
8 | 569 FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 700, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR ); |
2 | 570 bp->SetMask1( m_mask1 ); |
571 bp->SetMask2( m_mask2 ); | |
572 bp->SetMask3( m_mask3 ); | |
573 bp->SetMask1Old( m_mask1old ); | |
574 bp->SetMask2Old( m_mask2old ); | |
575 bp->SetMask3Old( m_mask3old ); | |
5 | 576 bp->SetMark( lmin, lmax, zmin, zmax ); |
2 | 577 bp->Show( true ); |
578 } | |
579 /* インデックス作成ダイアログ */ | |
580 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) ) | |
581 { | |
582 wxString rootdir; | |
583 config->SetPath( wxT("/Index") ); | |
584 config->Read( wxT("rootdir"), &rootdir ); | |
585 | |
7 | 586 IndexDialog* index = new IndexDialog( this, wxID_ANY, wxT("インデックス作成"), wxDefaultPosition, wxSize( 700, 600 ), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); |
8 | 587 index->SetRootdir( rootdir ); |
7 | 588 index->ShowModal(); |
1 | 589 } |
11 | 590 /* キャッシュ作成ダイアログ */ |
591 void MyFrame::OnCache( wxCommandEvent& WXUNUSED(event) ) | |
592 { | |
593 wxString rootdir; | |
594 config->SetPath( wxT("/Index") ); | |
595 config->Read( wxT("rootdir"), &rootdir ); | |
596 | |
597 CacheDialog* cache = new CacheDialog( this, wxID_ANY, wxT("キャッシュ作成"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxSTAY_ON_TOP ); | |
598 cache->Setting( rootdir, THUMB_W, THUMB_H ); | |
599 cache->ShowModal(); | |
600 } | |
13 | 601 /* 被保険者DB更新 */ |
602 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) | |
603 { | |
604 HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); | |
605 hd->Show(); | |
606 } | |
4 | 607 /* マークシートパラメータ設定ダイアログ */ |
608 void MyFrame::OnMarkParam( wxCommandEvent& WXUNUSED(event) ) | |
609 { | |
5 | 610 SetParams( 2 ); |
4 | 611 } |
0 | 612 /* マスクパラメータ設定ダイアログ */ |
613 void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) ) | |
614 { | |
5 | 615 SetParams( 0 ); |
616 } | |
617 /* 設定を保存 */ | |
618 void MyFrame::SetParams( int tab ) | |
619 { | |
620 ParamDialog* param = new ParamDialog( this, wxID_ANY, wxT("各種パラメータの指定"), wxDefaultPosition, wxSize( 350, 250 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); | |
4 | 621 param->SetMask1( m_mask1 ); |
622 param->SetMask2( m_mask2 ); | |
623 param->SetMask3( m_mask3 ); | |
624 param->SetMask1Old( m_mask1old ); | |
625 param->SetMask2Old( m_mask2old ); | |
626 param->SetMask3Old( m_mask3old ); | |
5 | 627 param->SetMark( lmin, lmax, zmin, zmax ); |
4 | 628 param->LoadParams(); |
629 param->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | |
5 | 630 param->SelectTAb( tab ); |
1 | 631 |
4 | 632 if ( param->ShowModal() == wxID_OK ) { |
633 m_mask1 = param->GetMask1(); | |
634 m_mask2 = param->GetMask2(); | |
635 m_mask3 = param->GetMask3(); | |
636 m_mask1old = param->GetMask1Old(); | |
637 m_mask2old = param->GetMask2Old(); | |
638 m_mask3old = param->GetMask3Old(); | |
5 | 639 lmin = param->GetLmin(); |
640 lmax = param->GetLmax(); | |
641 zmin = param->GetZmin(); | |
642 zmax = param->GetZmax(); | |
1 | 643 |
644 config->SetPath( wxT("/Mask") ); | |
645 | |
646 config->Write( wxT("x1"), m_mask1.GetX() ); | |
647 config->Write( wxT("y1"), m_mask1.GetY() ); | |
648 config->Write( wxT("w1"), m_mask1.GetWidth() ); | |
649 config->Write( wxT("h1"), m_mask1.GetHeight() ); | |
650 | |
651 config->Write( wxT("x2"), m_mask2.GetX() ); | |
652 config->Write( wxT("y2"), m_mask2.GetY() ); | |
653 config->Write( wxT("w2"), m_mask2.GetWidth() ); | |
654 config->Write( wxT("h2"), m_mask2.GetHeight() ); | |
655 | |
656 config->Write( wxT("x3"), m_mask3.GetX() ); | |
657 config->Write( wxT("y3"), m_mask3.GetY() ); | |
658 config->Write( wxT("w3"), m_mask3.GetWidth() ); | |
659 config->Write( wxT("h3"), m_mask3.GetHeight() ); | |
660 | |
2 | 661 config->Write( wxT("x1o"), m_mask1old.GetX() ); |
662 config->Write( wxT("y1o"), m_mask1old.GetY() ); | |
663 config->Write( wxT("w1o"), m_mask1old.GetWidth() ); | |
664 config->Write( wxT("h1o"), m_mask1old.GetHeight() ); | |
665 | |
666 config->Write( wxT("x2o"), m_mask2old.GetX() ); | |
667 config->Write( wxT("y2o"), m_mask2old.GetY() ); | |
668 config->Write( wxT("w2o"), m_mask2old.GetWidth() ); | |
669 config->Write( wxT("h2o"), m_mask2old.GetHeight() ); | |
670 | |
671 config->Write( wxT("x3o"), m_mask3old.GetX() ); | |
672 config->Write( wxT("y3o"), m_mask3old.GetY() ); | |
673 config->Write( wxT("w3o"), m_mask3old.GetWidth() ); | |
674 config->Write( wxT("h3o"), m_mask3old.GetHeight() ); | |
675 | |
5 | 676 config->SetPath( wxT("/Marksheet") ); |
677 | |
678 config->Write( wxT("lmin"), lmin ); | |
679 config->Write( wxT("lmax"), lmax ); | |
680 config->Write( wxT("zmin"), zmin ); | |
681 config->Write( wxT("zmax"), zmax ); | |
682 | |
2 | 683 config->Flush( false ); |
1 | 684 } |
0 | 685 } |
2 | 686 /* データベースファイルのバックアップ */ |
687 void MyFrame::OnDBBackup( wxCommandEvent& WXUNUSED(event) ) | |
688 { | |
689 wxDateTime now = wxDateTime::Now(); | |
690 wxString str = now.Format( wxT("%Y%m%d%H%M%S") ); | |
691 | |
692 wxString org, bk; | |
693 wxString dbdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("db"); | |
694 | |
695 org = dbdir + wxFILE_SEP_PATH + wxT("hhs.db"); | |
696 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_hhs.db"); | |
697 wxCopyFile( org, bk, false ); | |
698 | |
699 org = dbdir + wxFILE_SEP_PATH + wxT("ccn.db"); | |
700 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_ccn.db"); | |
701 wxCopyFile( org, bk, false ); | |
702 | |
703 wxMessageBox( wxT("バックアップ終了.") ); | |
704 return; | |
705 } | |
0 | 706 /* アプリフォルダを開く */ |
707 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) | |
708 { | |
9 | 709 OpenAppDir(); |
710 } | |
711 void MyFrame::OpenAppDir( ) | |
712 { | |
0 | 713 wxString appdir = wxGetCwd(); |
714 wxString execmd = wxT("explorer ") + appdir; | |
715 wxExecute( execmd ); | |
716 } | |
717 /* 被保険者フォルダを開く */ | |
9 | 718 void MyFrame::OnDClickItem( wxListEvent& event ) |
0 | 719 { |
720 int i = event.GetIndex(); | |
2 | 721 OpenHhsDir( i ); |
9 | 722 UpdateThumbmail( i ); |
2 | 723 } |
724 /* 番号で指定したフォルダを開く */ | |
725 void MyFrame::OpenHhsDir( int n ) | |
726 { | |
0 | 727 wxListItem item; |
2 | 728 item.SetId( n ); |
729 item.SetColumn( 2 ); | |
730 item.SetMask( wxLIST_MASK_TEXT ); | |
731 m_listCtrl->GetItem( item ); | |
732 wxString dir = item.GetText(); | |
733 wxString execmd = wxT("explorer ") + dir; | |
734 wxExecute( execmd ); | |
0 | 735 } |
1 | 736 |
15 | 737 /* 貼付検索 */ |
738 void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) ) | |
739 { | |
740 wxString s; | |
741 if ( wxTheClipboard->Open() ) { | |
742 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { | |
743 wxTextDataObject data; | |
744 wxTheClipboard->GetData( data ); | |
745 s = data.GetText(); | |
746 } | |
747 wxTheClipboard->Close(); | |
748 } | |
749 | |
18 | 750 s.Replace( wxT(" "), wxT(""), true ); |
15 | 751 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); |
752 if ( reHhs.Matches( s ) ) { | |
753 m_hhsno = s; | |
754 UpdateList( m_hhsno ); | |
755 UpdateThumbmail( 0 ); | |
756 return; | |
757 } | |
758 else { | |
759 wxMessageBox( wxT("被保険者番号ではありません.") ); | |
760 } | |
761 } | |
762 | |
0 | 763 /* カナ検索ダイアログ */ |
764 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) | |
765 { | |
2 | 766 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 640, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
0 | 767 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
1 | 768 |
769 if ( kana->ShowModal() == wxID_OK ) { | |
2 | 770 m_hhsno = kana->GetHhsNo(); |
771 UpdateList( m_hhsno ); | |
9 | 772 UpdateThumbmail( 0 ); |
1 | 773 } |
0 | 774 } |
775 /* 検索履歴検索ダイアログ */ | |
776 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) | |
777 { | |
2 | 778 HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 600, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
0 | 779 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
1 | 780 |
781 if ( hist->ShowModal() == wxID_OK ) { | |
2 | 782 m_hhsno = hist->GetHhsNo(); |
783 UpdateList( m_hhsno ); | |
9 | 784 UpdateThumbmail( 0 ); |
1 | 785 } |
786 } | |
787 | |
788 /* 検索結果をリストアップ */ | |
2 | 789 void MyFrame::UpdateList( wxString hhsno ) |
1 | 790 { |
791 m_listCtrl->DeleteAllItems(); | |
2 | 792 for ( int i = 0; i < m_statusBar->GetFieldsCount(); i++ ) { |
793 SetStatusMessage( wxEmptyString, i ); | |
794 } | |
795 | |
796 // | |
797 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
798 wxString history; | |
799 if ( s.IsEmpty() ) { | |
800 SetStatusMessage( wxT("データベースに存在しない被保険者です."), 0 ); | |
801 history = hhsno + wxT("###"); | |
802 } | |
803 else { | |
804 m_textCtrlName->SetValue( s[0] ); | |
805 m_textCtrlAddr->SetValue( s[1] ); | |
806 history = hhsno + wxT("#") + s[0] + wxT("#") + s[1] + wxT("#"); | |
807 } | |
808 m_searchBox->SetValue( hhsno ); | |
809 m_searchBox->SelectAll(); | |
810 m_searchBox->SetFocus(); | |
811 | |
812 wxArrayString path = GetPathByHhsNo( hhsno ); | |
813 if ( path.IsEmpty() ) { | |
814 SetStatusMessage( wxT("審査会履歴がありません."), 1 ); | |
815 return; | |
816 } | |
817 | |
818 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); | |
819 for ( int i = 0; i < path.GetCount(); i++ ) { | |
820 wxString date = path[i]; | |
821 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); | |
822 | |
823 m_listCtrl->InsertItem( i, -1 ); | |
824 m_listCtrl->SetItem( i, 0,wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No | |
825 m_listCtrl->SetItem( i, 1, date, -1 ); | |
826 m_listCtrl->SetItem( i, 2, path[i], -1 ); | |
827 | |
828 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) ); | |
829 } | |
830 | |
831 SetStatusMessage( wxT("「+」キーで通番1を印刷."), 0 ); | |
832 | |
833 // | |
834 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history"); | |
835 wxDateTime now = wxDateTime::Now(); | |
836 history = history + now.Format( wxT("%Y-%m-%d %H:%M:%S") ); | |
837 | |
838 wxTextFile hist( filename ); | |
839 hist.Open(); | |
840 hist.RemoveLine( 20 ); | |
841 hist.InsertLine( history, 0 ); | |
842 hist.Write(); | |
843 hist.Close(); | |
1 | 844 } |
9 | 845 /* フォルダを選択したとき */ |
846 void MyFrame::OnSelectItem( wxListEvent& event ) | |
847 { | |
848 UpdateThumbmail( event.GetIndex() ); | |
849 } | |
850 /* サムネイルを更新 */ | |
851 void MyFrame::UpdateThumbmail( int n ) | |
852 { | |
853 wxListItem item; | |
854 item.SetId( n ); | |
855 | |
856 item.SetColumn( 2 ); | |
857 item.SetMask( wxLIST_MASK_TEXT ); | |
858 m_listCtrl->GetItem( item ); | |
859 | |
10 | 860 m_thumbPanel->SetCacheImages( item.GetText() ); |
9 | 861 } |
1 | 862 /* ステータスバーにメッセージを出力 */ |
863 void MyFrame::SetStatusMessage( wxString msg, long n ) | |
864 { | |
865 if ( GetStatusBar() ) | |
866 SetStatusText( msg, n ); | |
0 | 867 } |
868 | |
869 /* サイズ変更 */ | |
870 void MyFrame::OnWinSize( wxSizeEvent& event ) | |
871 { | |
872 this->Refresh( true, NULL ); | |
873 TellLocation(); | |
874 event.Skip(); | |
875 } | |
876 /* ウィンドウ移動 */ | |
877 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) | |
878 { | |
879 TellLocation(); | |
880 return; | |
881 } | |
882 /* ウィンドウ位置とサイズを表示 */ | |
883 void MyFrame::TellLocation( void ) | |
884 { | |
885 wxRect r = this->GetRect(); | |
886 int x = r.GetX(); | |
887 int y = r.GetY(); | |
888 int w = r.GetWidth(); | |
889 int h = r.GetHeight(); | |
1 | 890 |
891 if ( GetStatusBar() ) | |
892 SetStatusText( wxString::Format(wxT( "(%d,%d) %dx%d"),x,y,w,h ), 3 ); | |
0 | 893 } |
894 /* 終了 */ | |
895 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) | |
896 { | |
897 Close( true ); | |
898 } | |
899 /* 設定を保存 */ | |
900 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) | |
901 { | |
902 if ( !IsIconized() && !IsMaximized() ) { | |
903 wxGetApp().rect = this->GetRect(); | |
904 } | |
9 | 905 delete config; |
0 | 906 Destroy(); |
907 } | |
908 /* アバウトダイアログ */ | |
909 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
910 { | |
911 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); | |
912 aboutDlg->ShowModal(); | |
913 } | |
914 |