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