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