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