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