Mercurial > mercurial > hgweb_searcher03.cgi
annotate src/myframe.cpp @ 13:bbd65edf71d4
Implement Hhs DB update dialog.
| author | pyon@macmini |
|---|---|
| date | Sat, 24 May 2014 10:25:13 +0900 |
| parents | 52958cd4a073 |
| children | de222bc84e48 |
| rev | line source |
|---|---|
| 0 | 1 // Filename : myframe.cpp |
| 13 | 2 // Last Change: 23-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" |
| 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 { |
| 154 wxDir dir( dirpath ); | |
| 155 if ( !dir.IsOpened() ) return; | |
| 10 | 156 |
| 9 | 157 m_imagefiles.Clear(); |
| 158 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); | |
| 159 | |
| 160 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); | |
| 161 wxDir cdir( cachedir ); | |
| 162 if ( !cdir.IsOpened() ) return; | |
| 163 | |
| 10 | 164 m_cachefiles.Clear(); |
| 165 wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); | |
| 9 | 166 |
| 167 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | |
| 10 | 168 int n = m_cachefiles.GetCount(); |
| 9 | 169 if ( n < 6 ) { |
| 170 while ( n < 6 ) { | |
| 10 | 171 m_cachefiles.Add( thumb ); |
| 9 | 172 n++; |
| 173 } | |
| 174 } | |
| 175 | |
| 176 wxBitmap bmp; | |
| 10 | 177 bmp.LoadFile( m_cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); |
| 178 bmp.LoadFile( m_cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); | |
| 179 bmp.LoadFile( m_cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); | |
| 180 bmp.LoadFile( m_cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); | |
| 181 bmp.LoadFile( m_cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); | |
| 182 bmp.LoadFile( m_cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); | |
| 9 | 183 } |
| 10 | 184 /* 画像クリックダブルで拡大表示 */ |
| 185 void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 0 ); } | |
| 186 void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 1 ); } | |
| 187 void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 2 ); } | |
| 188 void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 3 ); } | |
| 189 void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 4 ); } | |
| 190 void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 5 ); } | |
| 191 void ThumbnailPanel::DoPreview( int n ) | |
| 9 | 192 { |
| 10 | 193 if ( m_imagefiles.GetCount() < n + 1 ) return; |
| 9 | 194 |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
11
diff
changeset
|
195 PreviewDialog* pd = new PreviewDialog( m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); |
| 9 | 196 pd->Show(); |
| 197 pd->Maximize( true ); | |
| 13 | 198 pd->SetFiles( m_imagefiles, m_cachefiles, n ); |
| 10 | 199 pd->SetPreviewImage( n ); |
| 9 | 200 } |
| 2 | 201 |
| 1 | 202 /////////////////////////////////////////////////////////////// |
| 203 // メインフレーム | |
| 2 | 204 #define WINL_W 480 |
| 0 | 205 #define LOGO_W 200 |
| 206 #define LOGO_H 92 | |
| 207 | |
| 208 // resources | |
| 209 #if !defined(__WXMSW__) && !defined(__WXPM__) | |
| 210 #include "sample.xpm" | |
| 211 #endif | |
| 212 | |
| 213 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
| 214 : wxFrame( parent, id, title, pos, size, style ) | |
| 215 { | |
| 216 this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize ); | |
| 9 | 217 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); |
| 218 this->SetBackgroundColour( wxColour(wxT("WHEAT")) ); | |
| 0 | 219 |
| 220 // set the frame icon | |
| 221 SetIcon(wxICON(sample)); | |
| 222 | |
| 223 // メニューバー Menu | |
| 224 m_menubar = new wxMenuBar( 0 ); | |
| 225 m_menuFile = new wxMenu(); | |
| 226 | |
| 2 | 227 wxMenuItem* m_menuItemBPrintMode = new wxMenuItem( m_menuFile, ID_MNBPNT, wxString( wxT("バッチ印刷モード\tF12") ) , wxT("Batch Print Mode"), wxITEM_NORMAL ); |
| 228 m_menuFile->Append( m_menuItemBPrintMode ); | |
| 229 | |
| 230 wxMenuItem* m_menuItemIndex = new wxMenuItem( m_menuFile, ID_MNINDEX, wxString( wxT("インデックス\tF11") ) , wxT("Update index"), wxITEM_NORMAL ); | |
| 231 m_menuFile->Append( m_menuItemIndex ); | |
| 0 | 232 |
| 11 | 233 wxMenuItem* m_menuItemCache = new wxMenuItem( m_menuFile, ID_MNCACHE, wxString( wxT("キャッシュ\tF9") ) , wxT("Make cache"), wxITEM_NORMAL ); |
| 234 m_menuFile->Append( m_menuItemCache ); | |
| 235 | |
| 0 | 236 m_menuFile->AppendSeparator(); // ---- |
| 237 | |
|
12
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 |
| 2 | 241 wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL ); |
| 242 m_menuFile->Append( m_menuItemBkup ); | |
| 243 | |
| 4 | 244 // params |
| 245 m_menuParam = new wxMenu(); | |
| 246 wxMenuItem* m_menuItemMask = new wxMenuItem( m_menuParam, ID_MNMASKPARAM, wxString( wxT("マスク(&M)") ) , wxT("Setup mask parameters"), wxITEM_NORMAL ); | |
| 247 m_menuParam->Append( m_menuItemMask ); | |
| 0 | 248 |
| 4 | 249 wxMenuItem* m_menuItemMark = new wxMenuItem( m_menuParam, ID_MNMARKPARAM, wxString( wxT("マークシート(&S)") ) , wxT("Setup marksheet parameters"), wxITEM_NORMAL ); |
| 250 m_menuParam->Append( m_menuItemMark ); | |
| 251 | |
| 252 m_menuFile->Append( -1, wxT("パラメータ(&P)"), m_menuParam ); | |
| 253 | |
| 254 // | |
| 2 | 255 wxMenuItem* m_menuItemAppDir = new wxMenuItem( m_menuFile, ID_MNAPPDIR, wxString( wxT("アプリケーションフォルダを開く(&O)") ) , wxT("Open application directory"), wxITEM_NORMAL ); |
| 0 | 256 m_menuFile->Append( m_menuItemAppDir ); |
| 257 | |
| 258 m_menuFile->AppendSeparator(); // ---- | |
| 259 | |
| 260 wxMenuItem* m_menuItemAbout = new wxMenuItem( m_menuFile, ID_MNABOUT, wxString( wxT("&About...\tF1") ) , wxT("Show about dialog"), wxITEM_NORMAL ); | |
| 261 m_menuFile->Append( m_menuItemAbout ); | |
| 262 | |
| 263 m_menubar->Append( m_menuFile, wxT("ファイル(&F)") ); | |
| 264 | |
| 265 this->SetMenuBar( m_menubar ); | |
| 266 | |
| 267 // | |
| 268 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); | |
| 269 | |
| 9 | 270 m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); |
| 271 | |
| 2 | 272 wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL ); |
| 0 | 273 |
| 274 wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); | |
| 275 wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); | |
| 2 | 276 m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 ); |
| 277 bSizerMain->Add( m_bitmap, 0, wxALL, 5 ); | |
| 0 | 278 |
| 2 | 279 m_textCtrlName = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200, -1 ), 0 ); |
| 280 bSizerMain->Add( m_textCtrlName, 0, wxALL, 5 ); | |
| 0 | 281 |
| 2 | 282 m_textCtrlAddr = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 380, -1 ), 0 ); |
| 283 bSizerMain->Add( m_textCtrlAddr, 0, wxALL, 5 ); | |
| 0 | 284 |
| 2 | 285 m_listCtrl = new wxListCtrl( m_panelMain, ID_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); |
| 0 | 286 wxListItem itemCol; |
| 287 itemCol.SetText( wxT("通番") ); | |
| 288 m_listCtrl->InsertColumn( 0, itemCol ); | |
| 289 m_listCtrl->SetColumnWidth( 0, 50 ); | |
| 290 itemCol.SetText( wxT("年月日") ); | |
| 291 m_listCtrl->InsertColumn( 1, itemCol ); | |
| 292 m_listCtrl->SetColumnWidth( 1, 80 ); | |
| 293 itemCol.SetText( wxT("場所") ); | |
| 294 m_listCtrl->InsertColumn( 2, itemCol ); | |
| 295 m_listCtrl->SetColumnWidth( 2, 300 ); | |
| 9 | 296 bSizerMain->Add( m_listCtrl, 1, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); |
| 297 | |
| 298 m_thumbPanel = new ThumbnailPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), wxSUNKEN_BORDER ); | |
| 299 bSizerMain->Add( m_thumbPanel, 0, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 ); | |
| 0 | 300 |
| 9 | 301 // |
| 0 | 302 wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); |
| 303 | |
| 2 | 304 m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 1 | 305 bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 0 | 306 |
| 2 | 307 m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); |
| 9 | 308 m_searchBox->SetJudgedHhs( GetJudgedHhsNo() ); |
| 0 | 309 #ifndef __WXMAC__ |
| 1 | 310 m_searchBox->ShowSearchButton( true ); |
| 0 | 311 #endif |
| 1 | 312 m_searchBox->ShowCancelButton( false ); |
| 313 m_searchBox->SetFocus(); | |
| 2 | 314 bSizerCmd->Add( m_searchBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); |
| 0 | 315 |
| 2 | 316 m_buttonKana = new wxButton( m_panelMain, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
| 1 | 317 bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); |
| 0 | 318 |
| 2 | 319 m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); |
| 0 | 320 bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); |
| 321 | |
| 9 | 322 // |
| 2 | 323 bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 ); |
| 0 | 324 |
| 2 | 325 m_panelMain->SetSizer( bSizerMain ); |
| 326 m_panelMain->Layout(); | |
| 327 bSizerMain->Fit( m_panelMain ); | |
| 9 | 328 bSizerTop->Add( m_panelMain, 1, wxEXPAND|wxALL, 5 ); |
| 2 | 329 |
| 330 // | |
| 0 | 331 this->SetSizer( bSizerTop ); |
| 332 this->Layout(); | |
| 333 | |
| 334 // ステータスバー Statusbar | |
| 1 | 335 m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); |
| 2 | 336 int widths[] = { 200, -1, 10, 90 }; |
| 1 | 337 m_statusBar->SetFieldsCount( 4, widths ); |
| 338 this->SetStatusBar( m_statusBar ); | |
| 339 SetStatusText( wxT("被保番を入力してスタート!") ); | |
| 0 | 340 |
| 341 this->Centre( wxBOTH ); | |
| 4 | 342 LoadParam(); |
| 0 | 343 } |
| 344 | |
| 345 MyFrame::~MyFrame() | |
| 346 { | |
| 347 } | |
| 348 | |
| 349 // Event Table | |
| 350 BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
| 9 | 351 EVT_MENU( ID_MNABOUT, MyFrame::OnAbout ) |
| 352 EVT_MENU( wxID_EXIT, MyFrame::OnQuit ) | |
| 353 EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode ) | |
| 354 EVT_MENU( ID_MNINDEX, MyFrame::OnIndex ) | |
| 13 | 355 EVT_MENU( ID_MNHHSDB, MyFrame::OnUpdateHhs ) |
| 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 } | |
| 13 | 578 /* 被保険者DB更新 */ |
| 579 void MyFrame::OnUpdateHhs( wxCommandEvent& WXUNUSED(event) ) | |
| 580 { | |
| 581 HhsDialog* hd = new HhsDialog( this, wxID_ANY, wxT("被保険者DB更新"), wxDefaultPosition, wxSize( 500, 100 ), wxCAPTION|wxFRAME_NO_TASKBAR ); | |
| 582 hd->Show(); | |
| 583 } | |
| 4 | 584 /* マークシートパラメータ設定ダイアログ */ |
| 585 void MyFrame::OnMarkParam( wxCommandEvent& WXUNUSED(event) ) | |
| 586 { | |
| 5 | 587 SetParams( 2 ); |
| 4 | 588 } |
| 0 | 589 /* マスクパラメータ設定ダイアログ */ |
| 590 void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) ) | |
| 591 { | |
| 5 | 592 SetParams( 0 ); |
| 593 } | |
| 594 /* 設定を保存 */ | |
| 595 void MyFrame::SetParams( int tab ) | |
| 596 { | |
| 597 ParamDialog* param = new ParamDialog( this, wxID_ANY, wxT("各種パラメータの指定"), wxDefaultPosition, wxSize( 350, 250 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); | |
| 4 | 598 param->SetMask1( m_mask1 ); |
| 599 param->SetMask2( m_mask2 ); | |
| 600 param->SetMask3( m_mask3 ); | |
| 601 param->SetMask1Old( m_mask1old ); | |
| 602 param->SetMask2Old( m_mask2old ); | |
| 603 param->SetMask3Old( m_mask3old ); | |
| 5 | 604 param->SetMark( lmin, lmax, zmin, zmax ); |
| 4 | 605 param->LoadParams(); |
| 606 param->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); | |
| 5 | 607 param->SelectTAb( tab ); |
| 1 | 608 |
| 4 | 609 if ( param->ShowModal() == wxID_OK ) { |
| 610 m_mask1 = param->GetMask1(); | |
| 611 m_mask2 = param->GetMask2(); | |
| 612 m_mask3 = param->GetMask3(); | |
| 613 m_mask1old = param->GetMask1Old(); | |
| 614 m_mask2old = param->GetMask2Old(); | |
| 615 m_mask3old = param->GetMask3Old(); | |
| 5 | 616 lmin = param->GetLmin(); |
| 617 lmax = param->GetLmax(); | |
| 618 zmin = param->GetZmin(); | |
| 619 zmax = param->GetZmax(); | |
| 1 | 620 |
| 621 config->SetPath( wxT("/Mask") ); | |
| 622 | |
| 623 config->Write( wxT("x1"), m_mask1.GetX() ); | |
| 624 config->Write( wxT("y1"), m_mask1.GetY() ); | |
| 625 config->Write( wxT("w1"), m_mask1.GetWidth() ); | |
| 626 config->Write( wxT("h1"), m_mask1.GetHeight() ); | |
| 627 | |
| 628 config->Write( wxT("x2"), m_mask2.GetX() ); | |
| 629 config->Write( wxT("y2"), m_mask2.GetY() ); | |
| 630 config->Write( wxT("w2"), m_mask2.GetWidth() ); | |
| 631 config->Write( wxT("h2"), m_mask2.GetHeight() ); | |
| 632 | |
| 633 config->Write( wxT("x3"), m_mask3.GetX() ); | |
| 634 config->Write( wxT("y3"), m_mask3.GetY() ); | |
| 635 config->Write( wxT("w3"), m_mask3.GetWidth() ); | |
| 636 config->Write( wxT("h3"), m_mask3.GetHeight() ); | |
| 637 | |
| 2 | 638 config->Write( wxT("x1o"), m_mask1old.GetX() ); |
| 639 config->Write( wxT("y1o"), m_mask1old.GetY() ); | |
| 640 config->Write( wxT("w1o"), m_mask1old.GetWidth() ); | |
| 641 config->Write( wxT("h1o"), m_mask1old.GetHeight() ); | |
| 642 | |
| 643 config->Write( wxT("x2o"), m_mask2old.GetX() ); | |
| 644 config->Write( wxT("y2o"), m_mask2old.GetY() ); | |
| 645 config->Write( wxT("w2o"), m_mask2old.GetWidth() ); | |
| 646 config->Write( wxT("h2o"), m_mask2old.GetHeight() ); | |
| 647 | |
| 648 config->Write( wxT("x3o"), m_mask3old.GetX() ); | |
| 649 config->Write( wxT("y3o"), m_mask3old.GetY() ); | |
| 650 config->Write( wxT("w3o"), m_mask3old.GetWidth() ); | |
| 651 config->Write( wxT("h3o"), m_mask3old.GetHeight() ); | |
| 652 | |
| 5 | 653 config->SetPath( wxT("/Marksheet") ); |
| 654 | |
| 655 config->Write( wxT("lmin"), lmin ); | |
| 656 config->Write( wxT("lmax"), lmax ); | |
| 657 config->Write( wxT("zmin"), zmin ); | |
| 658 config->Write( wxT("zmax"), zmax ); | |
| 659 | |
| 2 | 660 config->Flush( false ); |
| 1 | 661 } |
| 0 | 662 } |
| 2 | 663 /* データベースファイルのバックアップ */ |
| 664 void MyFrame::OnDBBackup( wxCommandEvent& WXUNUSED(event) ) | |
| 665 { | |
| 666 wxDateTime now = wxDateTime::Now(); | |
| 667 wxString str = now.Format( wxT("%Y%m%d%H%M%S") ); | |
| 668 | |
| 669 wxString org, bk; | |
| 670 wxString dbdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("db"); | |
| 671 | |
| 672 org = dbdir + wxFILE_SEP_PATH + wxT("hhs.db"); | |
| 673 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_hhs.db"); | |
| 674 wxCopyFile( org, bk, false ); | |
| 675 | |
| 676 org = dbdir + wxFILE_SEP_PATH + wxT("ccn.db"); | |
| 677 bk = dbdir + wxFILE_SEP_PATH + str + wxT("_ccn.db"); | |
| 678 wxCopyFile( org, bk, false ); | |
| 679 | |
| 680 wxMessageBox( wxT("バックアップ終了.") ); | |
| 681 return; | |
| 682 } | |
| 0 | 683 /* アプリフォルダを開く */ |
| 684 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) | |
| 685 { | |
| 9 | 686 OpenAppDir(); |
| 687 } | |
| 688 void MyFrame::OpenAppDir( ) | |
| 689 { | |
| 0 | 690 wxString appdir = wxGetCwd(); |
| 691 wxString execmd = wxT("explorer ") + appdir; | |
| 692 wxExecute( execmd ); | |
| 693 } | |
| 694 /* 被保険者フォルダを開く */ | |
| 9 | 695 void MyFrame::OnDClickItem( wxListEvent& event ) |
| 0 | 696 { |
| 697 int i = event.GetIndex(); | |
| 2 | 698 OpenHhsDir( i ); |
| 9 | 699 UpdateThumbmail( i ); |
| 2 | 700 } |
| 701 /* 番号で指定したフォルダを開く */ | |
| 702 void MyFrame::OpenHhsDir( int n ) | |
| 703 { | |
| 0 | 704 wxListItem item; |
| 2 | 705 item.SetId( n ); |
| 706 item.SetColumn( 2 ); | |
| 707 item.SetMask( wxLIST_MASK_TEXT ); | |
| 708 m_listCtrl->GetItem( item ); | |
| 709 wxString dir = item.GetText(); | |
| 710 wxString execmd = wxT("explorer ") + dir; | |
| 711 wxExecute( execmd ); | |
| 0 | 712 } |
| 1 | 713 |
| 0 | 714 /* カナ検索ダイアログ */ |
| 715 void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) | |
| 716 { | |
| 2 | 717 KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 640, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
| 0 | 718 kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
| 1 | 719 |
| 720 if ( kana->ShowModal() == wxID_OK ) { | |
| 2 | 721 m_hhsno = kana->GetHhsNo(); |
| 722 UpdateList( m_hhsno ); | |
| 9 | 723 UpdateThumbmail( 0 ); |
| 1 | 724 } |
| 0 | 725 } |
| 726 /* 検索履歴検索ダイアログ */ | |
| 727 void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) | |
| 728 { | |
| 2 | 729 HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 600, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); |
| 0 | 730 hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); |
| 1 | 731 |
| 732 if ( hist->ShowModal() == wxID_OK ) { | |
| 2 | 733 m_hhsno = hist->GetHhsNo(); |
| 734 UpdateList( m_hhsno ); | |
| 9 | 735 UpdateThumbmail( 0 ); |
| 1 | 736 } |
| 737 } | |
| 738 | |
| 739 /* 検索結果をリストアップ */ | |
| 2 | 740 void MyFrame::UpdateList( wxString hhsno ) |
| 1 | 741 { |
| 742 m_listCtrl->DeleteAllItems(); | |
| 2 | 743 for ( int i = 0; i < m_statusBar->GetFieldsCount(); i++ ) { |
| 744 SetStatusMessage( wxEmptyString, i ); | |
| 745 } | |
| 746 | |
| 747 // | |
| 748 wxArrayString s = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
| 749 wxString history; | |
| 750 if ( s.IsEmpty() ) { | |
| 751 SetStatusMessage( wxT("データベースに存在しない被保険者です."), 0 ); | |
| 752 history = hhsno + wxT("###"); | |
| 753 } | |
| 754 else { | |
| 755 m_textCtrlName->SetValue( s[0] ); | |
| 756 m_textCtrlAddr->SetValue( s[1] ); | |
| 757 history = hhsno + wxT("#") + s[0] + wxT("#") + s[1] + wxT("#"); | |
| 758 } | |
| 759 m_searchBox->SetValue( hhsno ); | |
| 760 m_searchBox->SelectAll(); | |
| 761 m_searchBox->SetFocus(); | |
| 762 | |
| 763 wxArrayString path = GetPathByHhsNo( hhsno ); | |
| 764 if ( path.IsEmpty() ) { | |
| 765 SetStatusMessage( wxT("審査会履歴がありません."), 1 ); | |
| 766 return; | |
| 767 } | |
| 768 | |
| 769 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); | |
| 770 for ( int i = 0; i < path.GetCount(); i++ ) { | |
| 771 wxString date = path[i]; | |
| 772 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); | |
| 773 | |
| 774 m_listCtrl->InsertItem( i, -1 ); | |
| 775 m_listCtrl->SetItem( i, 0,wxString::Format( wxT("%d"), i + 1 ) , -1 ); // No | |
| 776 m_listCtrl->SetItem( i, 1, date, -1 ); | |
| 777 m_listCtrl->SetItem( i, 2, path[i], -1 ); | |
| 778 | |
| 779 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) ); | |
| 780 } | |
| 781 | |
| 782 SetStatusMessage( wxT("「+」キーで通番1を印刷."), 0 ); | |
| 783 | |
| 784 // | |
| 785 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history"); | |
| 786 wxDateTime now = wxDateTime::Now(); | |
| 787 history = history + now.Format( wxT("%Y-%m-%d %H:%M:%S") ); | |
| 788 | |
| 789 wxTextFile hist( filename ); | |
| 790 hist.Open(); | |
| 791 hist.RemoveLine( 20 ); | |
| 792 hist.InsertLine( history, 0 ); | |
| 793 hist.Write(); | |
| 794 hist.Close(); | |
| 1 | 795 } |
| 9 | 796 /* フォルダを選択したとき */ |
| 797 void MyFrame::OnSelectItem( wxListEvent& event ) | |
| 798 { | |
| 799 UpdateThumbmail( event.GetIndex() ); | |
| 800 } | |
| 801 /* サムネイルを更新 */ | |
| 802 void MyFrame::UpdateThumbmail( int n ) | |
| 803 { | |
| 804 wxListItem item; | |
| 805 item.SetId( n ); | |
| 806 | |
| 807 item.SetColumn( 2 ); | |
| 808 item.SetMask( wxLIST_MASK_TEXT ); | |
| 809 m_listCtrl->GetItem( item ); | |
| 810 | |
| 10 | 811 m_thumbPanel->SetCacheImages( item.GetText() ); |
| 9 | 812 } |
| 1 | 813 /* ステータスバーにメッセージを出力 */ |
| 814 void MyFrame::SetStatusMessage( wxString msg, long n ) | |
| 815 { | |
| 816 if ( GetStatusBar() ) | |
| 817 SetStatusText( msg, n ); | |
| 0 | 818 } |
| 819 | |
| 820 /* サイズ変更 */ | |
| 821 void MyFrame::OnWinSize( wxSizeEvent& event ) | |
| 822 { | |
| 823 this->Refresh( true, NULL ); | |
| 824 TellLocation(); | |
| 825 event.Skip(); | |
| 826 } | |
| 827 /* ウィンドウ移動 */ | |
| 828 void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) ) | |
| 829 { | |
| 830 TellLocation(); | |
| 831 return; | |
| 832 } | |
| 833 /* ウィンドウ位置とサイズを表示 */ | |
| 834 void MyFrame::TellLocation( void ) | |
| 835 { | |
| 836 wxRect r = this->GetRect(); | |
| 837 int x = r.GetX(); | |
| 838 int y = r.GetY(); | |
| 839 int w = r.GetWidth(); | |
| 840 int h = r.GetHeight(); | |
| 1 | 841 |
| 842 if ( GetStatusBar() ) | |
| 843 SetStatusText( wxString::Format(wxT( "(%d,%d) %dx%d"),x,y,w,h ), 3 ); | |
| 0 | 844 } |
| 845 /* 終了 */ | |
| 846 void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) | |
| 847 { | |
| 848 Close( true ); | |
| 849 } | |
| 850 /* 設定を保存 */ | |
| 851 void MyFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) | |
| 852 { | |
| 853 if ( !IsIconized() && !IsMaximized() ) { | |
| 854 wxGetApp().rect = this->GetRect(); | |
| 855 } | |
| 9 | 856 delete config; |
| 0 | 857 Destroy(); |
| 858 } | |
| 859 /* アバウトダイアログ */ | |
| 860 void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) | |
| 861 { | |
| 862 AboutDialog* aboutDlg = new AboutDialog( this, wxID_ANY, wxT("About this Software"), wxDefaultPosition, wxSize(320,280), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); | |
| 863 aboutDlg->ShowModal(); | |
| 864 } | |
| 865 |
