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