0
|
1 // Filename : myframe.cpp
|
4
|
2 // Last Change: 11-Sep-2013.
|
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 #include "index.h"
|
4
|
10 #include "param.h"
|
2
|
11 #include "marksheet.h"
|
|
12 #include "myframe.h"
|
|
13 #include "bprint.h"
|
0
|
14
|
1
|
15 ///////////////////////////////////////////////////////////////
|
|
16 // カスタム検索ボックス
|
|
17 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style )
|
|
18 : wxSearchCtrl( parent, id, value, pos, size, style )
|
|
19 {
|
|
20 }
|
|
21
|
|
22 MySearchBox::~MySearchBox()
|
|
23 {
|
|
24 }
|
|
25
|
|
26 // Event Table
|
|
27 BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl )
|
|
28 EVT_CHAR( MySearchBox::OnKey )
|
|
29 END_EVENT_TABLE()
|
|
30
|
|
31 // Event Handlers & Functions
|
|
32 void MySearchBox::OnKey( wxKeyEvent& event )
|
|
33 {
|
|
34 wxString s = GetValue();
|
|
35 // statustext( s.Len() );
|
|
36
|
|
37 if ( event.GetKeyCode() == 45 ) { // テンキーの '-' キーで1文字削除
|
|
38 wxString t = GetStringSelection();
|
|
39 if ( t.IsEmpty() ) {
|
|
40 long p = GetInsertionPoint();
|
|
41 if ( p > 0 ) Remove( p - 1, p );
|
|
42 }
|
|
43 else {
|
|
44 Cut();
|
|
45 }
|
|
46 return;
|
|
47 }
|
|
48
|
2
|
49 if ( event.GetKeyCode() == WXK_ESCAPE ) { // clear by ESC
|
|
50 this->Clear();
|
1
|
51 return;
|
|
52 }
|
|
53
|
|
54 event.Skip();
|
|
55 }
|
|
56
|
2
|
57
|
1
|
58 ///////////////////////////////////////////////////////////////
|
|
59 // メインフレーム
|
2
|
60 #define WINL_W 480
|
0
|
61 #define LOGO_W 200
|
|
62 #define LOGO_H 92
|
|
63
|
|
64 // resources
|
|
65 #if !defined(__WXMSW__) && !defined(__WXPM__)
|
|
66 #include "sample.xpm"
|
|
67 #endif
|
|
68
|
|
69 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
70 : wxFrame( parent, id, title, pos, size, style )
|
|
71 {
|
|
72 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize );
|
2
|
73 this->SetMinSize( wxSize( WINL_W, 500 ) );
|
0
|
74 this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
|
|
75 //this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
|
|
76
|
|
77 // set the frame icon
|
|
78 SetIcon(wxICON(sample));
|
|
79
|
|
80 // メニューバー Menu
|
|
81 m_menubar = new wxMenuBar( 0 );
|
|
82 m_menuFile = new wxMenu();
|
|
83
|
2
|
84 wxMenuItem* m_menuItemBPrintMode = new wxMenuItem( m_menuFile, ID_MNBPNT, wxString( wxT("バッチ印刷モード\tF12") ) , wxT("Batch Print Mode"), wxITEM_NORMAL );
|
|
85 m_menuFile->Append( m_menuItemBPrintMode );
|
|
86
|
|
87 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL );
|
|
88 m_menuFile->Append( m_menuItemIndex );
|
0
|
89
|
|
90 m_menuFile->AppendSeparator(); // ----
|
|
91
|
2
|
92 wxMenuItem* m_menuItemViewStyle = new wxMenuItem( m_menuFile, ID_MNVIEW, wxString( wxT("ビュースタイル\tF10") ) , wxT("Toggle ViewStyle"), wxITEM_CHECK );
|
|
93 m_menuFile->Append( m_menuItemViewStyle );
|
|
94
|
|
95 m_menuFile->AppendSeparator(); // ----
|
0
|
96
|
2
|
97 wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL );
|
|
98 m_menuFile->Append( m_menuItemBkup );
|
|
99
|
4
|
100 // params
|
|
101 m_menuParam = new wxMenu();
|
|
102 wxMenuItem* m_menuItemMask = new wxMenuItem( m_menuParam, ID_MNMASKPARAM, wxString( wxT("マスク(&M)") ) , wxT("Setup mask parameters"), wxITEM_NORMAL );
|
|
103 m_menuParam->Append( m_menuItemMask );
|
0
|
104
|
4
|
105 wxMenuItem* m_menuItemMark = new wxMenuItem( m_menuParam, ID_MNMARKPARAM, wxString( wxT("マークシート(&S)") ) , wxT("Setup marksheet parameters"), wxITEM_NORMAL );
|
|
106 m_menuParam->Append( m_menuItemMark );
|
|
107
|
|
108 m_menuFile->Append( -1, wxT("パラメータ(&P)"), m_menuParam );
|
|
109
|
|
110 //
|
2
|
111 wxMenuItem* m_menuItemAppDir = new wxMenuItem( m_menuFile, ID_MNAPPDIR, wxString( wxT("アプリケーションフォルダを開く(&O)") ) , wxT("Open application directory"), wxITEM_NORMAL );
|
0
|
112 m_menuFile->Append( m_menuItemAppDir );
|
|
113
|
|
114 m_menuFile->AppendSeparator(); // ----
|
|
115
|
|
116 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL );
|
|
117 m_menuFile->Append( m_menuItemAbout );
|
|
118
|
|
119 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") );
|
|
120
|
|
121 this->SetMenuBar( m_menubar );
|
|
122
|
|
123 //
|
|
124 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
125
|
|
126 m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
|
2
|
127 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL );
|
0
|
128
|
1
|
129 // left-pane
|
2
|
130 m_panelMain = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
0
|
131
|
|
132 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
|
|
133 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
|
2
|
134 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 );
|
|
135 bSizerMain->Add( m_bitmap, 0, wxALL, 5 );
|
0
|
136
|
2
|
137 m_textCtrlName = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 );
|
|
138 bSizerMain->Add( m_textCtrlName, 0, wxALL, 5 );
|
0
|
139
|
2
|
140 m_textCtrlAddr = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 );
|
|
141 bSizerMain->Add( m_textCtrlAddr, 0, wxALL, 5 );
|
0
|
142
|
2
|
143 m_listCtrl = new wxListCtrl( m_panelMain, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
|
0
|
144 wxListItem itemCol;
|
|
145 itemCol.SetText( wxT("通番") );
|
|
146 m_listCtrl->InsertColumn( 0, itemCol );
|
|
147 m_listCtrl->SetColumnWidth( 0, 50 );
|
|
148 itemCol.SetText( wxT("年月日") );
|
|
149 m_listCtrl->InsertColumn( 1, itemCol );
|
|
150 m_listCtrl->SetColumnWidth( 1, 80 );
|
|
151 itemCol.SetText( wxT("場所") );
|
|
152 m_listCtrl->InsertColumn( 2, itemCol );
|
|
153 m_listCtrl->SetColumnWidth( 2, 300 );
|
2
|
154 bSizerMain->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
0
|
155
|
|
156 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL );
|
|
157
|
2
|
158 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
159 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
160
|
2
|
161 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
0
|
162 #ifndef __WXMAC__
|
1
|
163 m_searchBox->ShowSearchButton( true );
|
0
|
164 #endif
|
1
|
165 m_searchBox->ShowCancelButton( false );
|
|
166 m_searchBox->SetFocus();
|
2
|
167 bSizerCmd->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
168
|
2
|
169 m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 );
|
1
|
170 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 );
|
0
|
171
|
2
|
172 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 );
|
0
|
173 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 );
|
|
174
|
2
|
175 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 );
|
0
|
176
|
2
|
177 m_panelMain->SetSizer( bSizerMain );
|
|
178 m_panelMain->Layout();
|
|
179 bSizerMain->Fit( m_panelMain );
|
0
|
180
|
1
|
181 // right-pane
|
2
|
182 m_panelView = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
|
183 wxBoxSizer* bSizerView = new wxBoxSizer( wxHORIZONTAL );
|
|
184
|
|
185 m_bitmapView = new wxStaticBitmap( m_panelView, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
|
186 bSizerView->Add( m_bitmapView, 1, wxALL|wxEXPAND, 5 );
|
0
|
187
|
2
|
188 m_listCtrlThumb = new wxListCtrl( m_panelView, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
|
|
189 bSizerView->Add( m_listCtrlThumb, 0, wxALL|wxEXPAND, 5 );
|
0
|
190
|
2
|
191 m_panelView->SetSizer( bSizerView );
|
|
192 m_panelView->Layout();
|
|
193 bSizerView->Fit( m_panelView );
|
0
|
194
|
2
|
195 m_panelView->Show( false );
|
|
196 //
|
|
197 m_splitter->Initialize( m_panelMain );
|
0
|
198 bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 );
|
|
199
|
|
200 this->SetSizer( bSizerTop );
|
|
201 this->Layout();
|
|
202
|
|
203 // ステータスバー Statusbar
|
1
|
204 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP );
|
2
|
205 int widths[] = { 200, -1, 10, 90 };
|
1
|
206 m_statusBar->SetFieldsCount( 4, widths );
|
|
207 this->SetStatusBar( m_statusBar );
|
|
208 SetStatusText( wxT("被保番を入力してスタート!") );
|
0
|
209
|
|
210 this->Centre( wxBOTH );
|
4
|
211 LoadParam();
|
0
|
212 }
|
|
213
|
|
214 MyFrame::~MyFrame()
|
|
215 {
|
|
216 }
|
|
217
|
|
218 // Event Table
|
|
219 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
|
|
220 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout )
|
|
221 EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
|
2
|
222 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode )
|
|
223 EVT_MENU( ID_MNVIEW, MyFrame::OnViewStyle )
|
0
|
224 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex )
|
2
|
225 EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup )
|
0
|
226 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam )
|
4
|
227 EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMarkParam )
|
0
|
228 EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir )
|
2
|
229 EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnSelectHhsDir )
|
0
|
230 EVT_BUTTON( ID_KANA, MyFrame::OnKana )
|
|
231 EVT_BUTTON( ID_HIST, MyFrame::OnHistory )
|
|
232 EVT_SIZE( MyFrame::OnWinSize )
|
|
233 EVT_MOVE( MyFrame::OnWinMove )
|
|
234 EVT_CLOSE( MyFrame::SaveConfig )
|
2
|
235 EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand )
|
0
|
236 END_EVENT_TABLE()
|
|
237
|
|
238 // Event Handlers & Functions
|
2
|
239 /* エンターキーフック */
|
|
240 void MyFrame::OnCommand( wxCommandEvent& event )
|
0
|
241 {
|
2
|
242 wxString s = m_searchBox->GetValue();
|
|
243
|
|
244 if ( s.IsSameAs( wxT("99") ) ) {
|
|
245 Close();
|
|
246 return;
|
|
247 }
|
|
248
|
|
249 if ( s.IsSameAs( wxT("+") ) ) {
|
|
250 PrintImages( m_hhsno );
|
|
251 return;
|
|
252 }
|
|
253
|
|
254 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") );
|
|
255 if ( reHhs.Matches( s ) ) {
|
|
256 m_hhsno = s;
|
|
257 UpdateList( m_hhsno );
|
|
258 return;
|
|
259 }
|
|
260
|
|
261 wxRegEx reNo( wxT("^[0-9]{1,2}$") );
|
|
262 if ( reNo.Matches( s ) ) {
|
|
263 long n;
|
|
264 s.ToLong( &n, 10 );
|
|
265 n--;
|
|
266 OpenHhsDir( (int)n );
|
|
267 return;
|
|
268 }
|
|
269
|
|
270 SetStatusMessage( wxT("不適切な入力です."), 0 );
|
|
271 return;
|
|
272
|
|
273 event.Skip();
|
0
|
274 }
|
4
|
275 /* パラメータを設定ファイルから読み込む */
|
|
276 void MyFrame::LoadParam( void )
|
1
|
277 {
|
|
278 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf");
|
|
279 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
280
|
|
281 int x, y, w, h;
|
|
282
|
|
283 config->SetPath( wxT("/Mask") );
|
|
284
|
|
285 config->Read( wxT("x1"), &x );
|
|
286 config->Read( wxT("y1"), &y );
|
|
287 config->Read( wxT("w1"), &w );
|
|
288 config->Read( wxT("h1"), &h );
|
|
289 m_mask1.SetPosition( wxPoint( x, y ) );
|
|
290 m_mask1.SetSize( wxSize( w, h ) );
|
|
291
|
|
292 config->Read( wxT("x2"), &x );
|
|
293 config->Read( wxT("y2"), &y );
|
|
294 config->Read( wxT("w2"), &w );
|
|
295 config->Read( wxT("h2"), &h );
|
|
296 m_mask2.SetPosition( wxPoint( x, y ) );
|
|
297 m_mask2.SetSize( wxSize( w, h ) );
|
|
298
|
|
299 config->Read( wxT("x3"), &x );
|
|
300 config->Read( wxT("y3"), &y );
|
|
301 config->Read( wxT("w3"), &w );
|
|
302 config->Read( wxT("h3"), &h );
|
|
303 m_mask3.SetPosition( wxPoint( x, y ) );
|
|
304 m_mask3.SetSize( wxSize( w, h ) );
|
|
305
|
2
|
306 config->Read( wxT("x1o"), &x );
|
|
307 config->Read( wxT("y1o"), &y );
|
|
308 config->Read( wxT("w1o"), &w );
|
|
309 config->Read( wxT("h1o"), &h );
|
|
310 m_mask1old.SetPosition( wxPoint( x, y ) );
|
|
311 m_mask1old.SetSize( wxSize( w, h ) );
|
|
312
|
|
313 config->Read( wxT("x2o"), &x );
|
|
314 config->Read( wxT("y2o"), &y );
|
|
315 config->Read( wxT("w2o"), &w );
|
|
316 config->Read( wxT("h2o"), &h );
|
|
317 m_mask2old.SetPosition( wxPoint( x, y ) );
|
|
318 m_mask2old.SetSize( wxSize( w, h ) );
|
|
319
|
|
320 config->Read( wxT("x3o"), &x );
|
|
321 config->Read( wxT("y3o"), &y );
|
|
322 config->Read( wxT("w3o"), &w );
|
|
323 config->Read( wxT("h3o"), &h );
|
|
324 m_mask3old.SetPosition( wxPoint( x, y ) );
|
|
325 m_mask3old.SetSize( wxSize( w, h ) );
|
|
326 }
|
|
327 /* 印刷 */
|
|
328 void MyFrame::PrintImages( wxString hhsno )
|
|
329 {
|
|
330 // 印刷用の html を作成
|
|
331 wxArrayString path = GetPathByHhsNo( hhsno );
|
|
332 if ( path.IsEmpty() ) return;
|
|
333
|
|
334 wxDir dir( path[0] );
|
|
335 if ( !dir.IsOpened() ) return;
|
|
336
|
|
337 wxString html;
|
|
338 html = html + wxT("<html><body>\n");
|
|
339
|
|
340 wxString file;
|
|
341 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES );
|
4
|
342 bool notyet_mask = true;
|
2
|
343 int n = 0;
|
|
344 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH;
|
|
345 while ( cout ) {
|
|
346 file = path[0] + wxFILE_SEP_PATH + file;
|
|
347 file.Replace( wxFILE_SEP_PATH, wxT("/") );
|
|
348 wxString tmpjpg = wxString::Format( wxT("%stmp%d.jpg"), tmpdir, n );
|
4
|
349
|
|
350 double zmin = 0.095713;
|
|
351 double zmax = 0.147142;
|
|
352 long lmin = 2072393;
|
|
353 long lmax = 2472318;
|
2
|
354
|
4
|
355 if ( notyet_mask && IsMarksheet( file, zmin, zmax, lmin, lmax ) ) { // マークシート表面をマスクする
|
2
|
356 wxImage img_org( file, wxBITMAP_TYPE_JPEG );
|
|
357 int ver = GetMarksheetVersion( file );
|
|
358 if ( ver == 2 ) {
|
|
359 img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name
|
|
360 img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no.
|
|
361 img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode
|
|
362 }
|
|
363 else { // 古いマークシート ver == 1
|
|
364 img_org.SetRGB( m_mask1old, 255, 255, 255 ); // cm name
|
|
365 img_org.SetRGB( m_mask2old, 255, 255, 255 ); // cm no.
|
|
366 img_org.SetRGB( m_mask3old, 255, 255, 255 ); // barcode
|
|
367 }
|
|
368 img_org.SaveFile( tmpjpg );
|
4
|
369 notyet_mask = false;
|
2
|
370 }
|
|
371 else {
|
|
372 wxCopyFile( file, tmpjpg, true );
|
|
373 }
|
|
374 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>");
|
|
375 cout = dir.GetNext( &file );
|
|
376 n++;
|
|
377 }
|
|
378 html = html + wxT("</body></html>");
|
|
379
|
|
380 // start printing
|
|
381 wxHtmlPrintout hpout( wxT("Searcher03") );
|
|
382 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
383 wxPrintDialogData pd;
|
|
384 wxPrinter p( &pd );
|
|
385
|
|
386 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
387 p.Print( NULL, &hpout, true );
|
|
388
|
|
389 // end
|
|
390 SetStatusMessage( wxT("被保番かフォルダ番号を."), 0 );
|
|
391 }
|
|
392 /* 一括印刷モード */
|
|
393 void MyFrame::OnBPrintMode( wxCommandEvent& WXUNUSED(event) )
|
|
394 {
|
3
|
395 FrameBatchPrint* bp = new FrameBatchPrint( this, wxID_ANY, wxT("一括印刷"), wxDefaultPosition, wxSize( 680, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR );
|
2
|
396 bp->SetMask1( m_mask1 );
|
|
397 bp->SetMask2( m_mask2 );
|
|
398 bp->SetMask3( m_mask3 );
|
|
399 bp->SetMask1Old( m_mask1old );
|
|
400 bp->SetMask2Old( m_mask2old );
|
|
401 bp->SetMask3Old( m_mask3old );
|
|
402 bp->Show( true );
|
|
403 }
|
|
404 /* インデックス作成ダイアログ */
|
|
405 void MyFrame::OnIndex( wxCommandEvent& WXUNUSED(event) )
|
|
406 {
|
|
407 wxString rootdir;
|
|
408 config->SetPath( wxT("/Index") );
|
|
409 config->Read( wxT("rootdir"), &rootdir );
|
|
410
|
|
411 IndexDialog* index = new IndexDialog( this, wxID_ANY, wxT("インデックス作成"), wxDefaultPosition, wxSize( 700, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
|
|
412 index->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
|
|
413 index->SetRootdir( rootdir );
|
|
414 index->ShowModal();
|
1
|
415 }
|
4
|
416 /* マークシートパラメータ設定ダイアログ */
|
|
417 void MyFrame::OnMarkParam( wxCommandEvent& WXUNUSED(event) )
|
|
418 {
|
|
419 ParamDialog* param = new ParamDialog( this, wxID_ANY, wxT("マークシート判定パラメータの指定"), wxDefaultPosition, wxSize( 350, 250 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
|
|
420 }
|
0
|
421 /* マスクパラメータ設定ダイアログ */
|
|
422 void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) )
|
|
423 {
|
4
|
424 ParamDialog* param = new ParamDialog( this, wxID_ANY, wxT("マスク位置とサイズの指定"), wxDefaultPosition, wxSize( 350, 250 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
|
|
425 param->SetMask1( m_mask1 );
|
|
426 param->SetMask2( m_mask2 );
|
|
427 param->SetMask3( m_mask3 );
|
|
428 param->SetMask1Old( m_mask1old );
|
|
429 param->SetMask2Old( m_mask2old );
|
|
430 param->SetMask3Old( m_mask3old );
|
|
431 param->LoadParams();
|
|
432 param->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
|
1
|
433
|
4
|
434 if ( param->ShowModal() == wxID_OK ) {
|
|
435 m_mask1 = param->GetMask1();
|
|
436 m_mask2 = param->GetMask2();
|
|
437 m_mask3 = param->GetMask3();
|
|
438 m_mask1old = param->GetMask1Old();
|
|
439 m_mask2old = param->GetMask2Old();
|
|
440 m_mask3old = param->GetMask3Old();
|
1
|
441
|
|
442 config->SetPath( wxT("/Mask") );
|
|
443
|
|
444 config->Write( wxT("x1"), m_mask1.GetX() );
|
|
445 config->Write( wxT("y1"), m_mask1.GetY() );
|
|
446 config->Write( wxT("w1"), m_mask1.GetWidth() );
|
|
447 config->Write( wxT("h1"), m_mask1.GetHeight() );
|
|
448
|
|
449 config->Write( wxT("x2"), m_mask2.GetX() );
|
|
450 config->Write( wxT("y2"), m_mask2.GetY() );
|
|
451 config->Write( wxT("w2"), m_mask2.GetWidth() );
|
|
452 config->Write( wxT("h2"), m_mask2.GetHeight() );
|
|
453
|
|
454 config->Write( wxT("x3"), m_mask3.GetX() );
|
|
455 config->Write( wxT("y3"), m_mask3.GetY() );
|
|
456 config->Write( wxT("w3"), m_mask3.GetWidth() );
|
|
457 config->Write( wxT("h3"), m_mask3.GetHeight() );
|
|
458
|
2
|
459 config->Write( wxT("x1o"), m_mask1old.GetX() );
|
|
460 config->Write( wxT("y1o"), m_mask1old.GetY() );
|
|
461 config->Write( wxT("w1o"), m_mask1old.GetWidth() );
|
|
462 config->Write( wxT("h1o"), m_mask1old.GetHeight() );
|
|
463
|
|
464 config->Write( wxT("x2o"), m_mask2old.GetX() );
|
|
465 config->Write( wxT("y2o"), m_mask2old.GetY() );
|
|
466 config->Write( wxT("w2o"), m_mask2old.GetWidth() );
|
|
467 config->Write( wxT("h2o"), m_mask2old.GetHeight() );
|
|
468
|
|
469 config->Write( wxT("x3o"), m_mask3old.GetX() );
|
|
470 config->Write( wxT("y3o"), m_mask3old.GetY() );
|
|
471 config->Write( wxT("w3o"), m_mask3old.GetWidth() );
|
|
472 config->Write( wxT("h3o"), m_mask3old.GetHeight() );
|
|
473
|
|
474 config->Flush( false );
|
1
|
475 }
|
0
|
476 }
|
2
|
477 /* データベースファイルのバックアップ */
|
|
478 void MyFrame::OnDBBackup( wxCommandEvent& WXUNUSED(event) )
|
|
479 {
|
|
480 wxDateTime now = wxDateTime::Now();
|
|
481 wxString str = now.Format( wxT("%Y%m%d%H%M%S") );
|
|
482
|
|
483 wxString org, bk;
|
|
484 wxString dbdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("db");
|
|
485
|
|
486 org = dbdir + wxFILE_SEP_PATH + wxT("hhs.db");
|
|
487 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_hhs.db");
|
|
488 wxCopyFile( org, bk, false );
|
|
489
|
|
490 org = dbdir + wxFILE_SEP_PATH + wxT("ccn.db");
|
|
491 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_ccn.db");
|
|
492 wxCopyFile( org, bk, false );
|
|
493
|
|
494 wxMessageBox( wxT("バックアップ終了.") );
|
|
495 return;
|
|
496 }
|
0
|
497 /* アプリフォルダを開く */
|
|
498 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) )
|
|
499 {
|
|
500 wxString appdir = wxGetCwd();
|
|
501 wxString execmd = wxT("explorer ") + appdir;
|
|
502 wxExecute( execmd );
|
|
503 }
|
2
|
504 /* ビューの切替え */
|
|
505 void MyFrame::OnViewStyle( wxCommandEvent& event )
|
0
|
506 {
|
|
507 if ( event.IsChecked() ) {
|
|
508 int x, y;
|
|
509 GetSize( &x, &y );
|
|
510 SetSize( WINL_W + 500, y );
|
2
|
511 m_splitter->SplitVertically( m_panelMain, m_panelView, 0 );
|
0
|
512 }
|
|
513 else {
|
|
514 m_splitter->Unsplit();
|
|
515 SetSize( WINL_W, -1 );
|
|
516 }
|
|
517 }
|
|
518 /* 被保険者フォルダを開く */
|
2
|
519 void MyFrame::OnSelectHhsDir( wxListEvent& event )
|
0
|
520 {
|
|
521 int i = event.GetIndex();
|
2
|
522 OpenHhsDir( i );
|
|
523 }
|
|
524 /* 番号で指定したフォルダを開く */
|
|
525 void MyFrame::OpenHhsDir( int n )
|
|
526 {
|
0
|
527 wxListItem item;
|
2
|
528 item.SetId( n );
|
|
529 item.SetColumn( 2 );
|
|
530 item.SetMask( wxLIST_MASK_TEXT );
|
|
531 m_listCtrl->GetItem( item );
|
|
532 wxString dir = item.GetText();
|
|
533 wxString execmd = wxT("explorer ") + dir;
|
|
534 wxExecute( execmd );
|
0
|
535 }
|
1
|
536
|
0
|
537 /* カナ検索ダイアログ */
|
|
538 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) )
|
|
539 {
|
2
|
540 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 640, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
|
0
|
541 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
|
1
|
542
|
|
543 if ( kana->ShowModal() == wxID_OK ) {
|
2
|
544 m_hhsno = kana->GetHhsNo();
|
|
545 UpdateList( m_hhsno );
|
1
|
546 }
|
0
|
547 }
|
|
548 /* 検索履歴検索ダイアログ */
|
|
549 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) )
|
|
550 {
|
2
|
551 HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 600, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL );
|
0
|
552 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM );
|
1
|
553
|
|
554 if ( hist->ShowModal() == wxID_OK ) {
|
2
|
555 m_hhsno = hist->GetHhsNo();
|
|
556 UpdateList( m_hhsno );
|
1
|
557 }
|
|
558 }
|
|
559
|
|
560 /* 検索結果をリストアップ */
|
2
|
561 void MyFrame::UpdateList( wxString hhsno )
|
1
|
562 {
|
|
563 m_listCtrl->DeleteAllItems();
|
2
|
564 for ( int i = 0; i < m_statusBar->GetFieldsCount(); i++ ) {
|
|
565 SetStatusMessage( wxEmptyString, i );
|
|
566 }
|
|
567
|
|
568 //
|
|
569 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' );
|
|
570 wxString history;
|
|
571 if ( s.IsEmpty() ) {
|
|
572 SetStatusMessage( wxT("データベースに存在しない被保険者です."), 0 );
|
|
573 history = hhsno + wxT("###");
|
|
574 }
|
|
575 else {
|
|
576 m_textCtrlName->SetValue( s[0] );
|
|
577 m_textCtrlAddr->SetValue( s[1] );
|
|
578 history = hhsno + wxT("#") + s[0] + wxT("#") + s[1] + wxT("#");
|
|
579 }
|
|
580 m_searchBox->SetValue( hhsno );
|
|
581 m_searchBox->SelectAll();
|
|
582 m_searchBox->SetFocus();
|
|
583
|
|
584 wxArrayString path = GetPathByHhsNo( hhsno );
|
|
585 if ( path.IsEmpty() ) {
|
|
586 SetStatusMessage( wxT("審査会履歴がありません."), 1 );
|
|
587 return;
|
|
588 }
|
|
589
|
|
590 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)"));
|
|
591 for ( int i = 0; i < path.GetCount(); i++ ) {
|
|
592 wxString date = path[i];
|
|
593 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") );
|
|
594
|
|
595 m_listCtrl->InsertItem( i, -1 );
|
|
596 m_listCtrl->SetItem( i, 0,wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No
|
|
597 m_listCtrl->SetItem( i, 1, date, -1 );
|
|
598 m_listCtrl->SetItem( i, 2, path[i], -1 );
|
|
599
|
|
600 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) );
|
|
601 }
|
|
602
|
|
603 SetStatusMessage( wxT("「+」キーで通番1を印刷."), 0 );
|
|
604
|
|
605 //
|
|
606 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history");
|
|
607 wxDateTime now = wxDateTime::Now();
|
|
608 history = history + now.Format( wxT("%Y-%m-%d %H:%M:%S") );
|
|
609
|
|
610 wxTextFile hist( filename );
|
|
611 hist.Open();
|
|
612 hist.RemoveLine( 20 );
|
|
613 hist.InsertLine( history, 0 );
|
|
614 hist.Write();
|
|
615 hist.Close();
|
1
|
616 }
|
|
617 /* ステータスバーにメッセージを出力 */
|
|
618 void MyFrame::SetStatusMessage( wxString msg, long n )
|
|
619 {
|
|
620 if ( GetStatusBar() )
|
|
621 SetStatusText( msg, n );
|
0
|
622 }
|
|
623
|
|
624 /* サイズ変更 */
|
|
625 void MyFrame::OnWinSize( wxSizeEvent& event )
|
|
626 {
|
|
627 this->Refresh( true, NULL );
|
|
628 TellLocation();
|
|
629 event.Skip();
|
|
630 }
|
|
631 /* ウィンドウ移動 */
|
|
632 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) )
|
|
633 {
|
|
634 TellLocation();
|
|
635 return;
|
|
636 }
|
|
637 /* ウィンドウ位置とサイズを表示 */
|
|
638 void MyFrame::TellLocation( void )
|
|
639 {
|
|
640 wxRect r = this->GetRect();
|
|
641 int x = r.GetX();
|
|
642 int y = r.GetY();
|
|
643 int w = r.GetWidth();
|
|
644 int h = r.GetHeight();
|
1
|
645
|
|
646 if ( GetStatusBar() )
|
|
647 SetStatusText( wxString::Format(wxT( "(%d,%d) %dx%d"),x,y,w,h ), 3 );
|
0
|
648 }
|
|
649 /* 終了 */
|
|
650 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
|
|
651 {
|
|
652 Close( true );
|
|
653 }
|
|
654 /* 設定を保存 */
|
|
655 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )
|
|
656 {
|
|
657 if ( !IsIconized() && !IsMaximized() ) {
|
|
658 wxGetApp().rect = this->GetRect();
|
|
659 }
|
|
660 Destroy();
|
|
661 }
|
|
662 /* アバウトダイアログ */
|
|
663 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
|
|
664 {
|
|
665 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP );
|
|
666 aboutDlg->ShowModal();
|
|
667 }
|
|
668
|