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