Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/rsearcher.cpp @ 5:e3b10fb860b3
release v1.0.
| author | pyon@macmini |
|---|---|
| date | Mon, 22 Oct 2018 22:17:02 +0900 |
| parents | 06342fc544e4 |
| children | 9a8b581c1993 |
comparison
equal
deleted
inserted
replaced
| 4:06342fc544e4 | 5:e3b10fb860b3 |
|---|---|
| 1 // Filename : rsearcher.cpp | 1 // Filename : rsearcher.cpp |
| 2 // Last Change: 2018-10-12 ‹à 16:40:12. | 2 // Last Change: 2018-10-22 ŒŽ 16:20:03. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include <wx/arrstr.h> | 5 #include <wx/arrstr.h> |
| 6 #include <wx/html/htmprint.h> | 6 #include <wx/html/htmprint.h> |
| 7 #include <wx/clipbrd.h> | |
| 7 #include "id.h" | 8 #include "id.h" |
| 8 #include "rsearcher.h" | 9 #include "rsearcher.h" |
| 9 #include "main.h" | 10 #include "main.h" |
| 11 | |
| 12 | |
| 13 /********************/ | |
| 14 /** HhsClass **/ | |
| 15 /********************/ | |
| 16 HhsClass::HhsClass( wxArrayString& buf ) | |
| 17 { | |
| 18 no = buf[0]; | |
| 19 birth = buf[1]; | |
| 20 name = buf[2]; | |
| 21 kana = buf[3]; | |
| 22 addr = buf[4]; | |
| 23 sex = buf[5]; | |
| 24 } | |
| 10 | 25 |
| 11 /********************/ | 26 /********************/ |
| 12 /** MySearchCtrl **/ | 27 /** MySearchCtrl **/ |
| 13 /********************/ | 28 /********************/ |
| 14 MySearchCtrl::MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) | 29 MySearchCtrl::MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) |
| 124 SetCursor( wxCursor( wxCURSOR_ARROW ) ); | 139 SetCursor( wxCursor( wxCURSOR_ARROW ) ); |
| 125 } | 140 } |
| 126 | 141 |
| 127 void MyStaticBitmap::OnMotion( wxMouseEvent& event ) | 142 void MyStaticBitmap::OnMotion( wxMouseEvent& event ) |
| 128 { | 143 { |
| 144 if ( event.RightIsDown() ) return; | |
| 129 if ( event.Dragging() ) { | 145 if ( event.Dragging() ) { |
| 130 int xv, yv, x, y; | 146 int xv, yv, x, y; |
| 131 m_parent->GetViewStart( &xv, &yv ); | 147 m_parent->GetViewStart( &xv, &yv ); |
| 132 | 148 |
| 133 event.GetPosition( &x, &y ); | 149 event.GetPosition( &x, &y ); |
| 171 else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) { | 187 else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) { |
| 172 ChangeBook( -1 ); | 188 ChangeBook( -1 ); |
| 173 } | 189 } |
| 174 // to up-right | 190 // to up-right |
| 175 else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) { | 191 else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) { |
| 192 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); | |
| 193 mf->Close(); | |
| 176 } | 194 } |
| 177 // down | 195 // down |
| 178 else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) { | 196 else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) { |
| 179 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); | 197 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); |
| 180 mf->PrintImages(); | 198 mf->PrintImages(); |
| 201 /********************/ | 219 /********************/ |
| 202 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 220 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 203 : wxFrame( parent, id, title, pos, size, style ) | 221 : wxFrame( parent, id, title, pos, size, style ) |
| 204 { | 222 { |
| 205 CreateControls(); | 223 CreateControls(); |
| 206 LoadDB(); | 224 SetAccelerator(); |
| 207 LoadBitmaps( wxEmptyString ); | 225 LoadBitmaps( wxEmptyString, false ); |
| 208 m_timer.SetOwner( this, ID_TIMER ); | 226 m_timer.SetOwner( this, ID_TIMER ); |
| 209 } | 227 } |
| 210 | 228 |
| 211 MainFrame::~MainFrame() | 229 MainFrame::~MainFrame() |
| 212 { | 230 { |
| 219 BEGIN_EVENT_TABLE( MainFrame, wxFrame ) | 237 BEGIN_EVENT_TABLE( MainFrame, wxFrame ) |
| 220 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected ) | 238 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected ) |
| 221 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) | 239 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) |
| 222 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) | 240 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) |
| 223 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint ) | 241 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint ) |
| 242 EVT_BUTTON( ID_PSEARCH, MainFrame::OnPasteSearch ) | |
| 243 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) | |
| 224 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) | 244 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) |
| 225 EVT_BUTTON( ID_TEST, MainFrame::OnTestButton ) | |
| 226 EVT_CLOSE( MainFrame::OnClose ) | 245 EVT_CLOSE( MainFrame::OnClose ) |
| 227 EVT_IDLE( MainFrame::OnIdle ) | 246 EVT_IDLE( MainFrame::OnIdle ) |
| 228 EVT_TIMER( ID_TIMER, MainFrame::OnTimer ) | 247 EVT_TIMER( ID_TIMER, MainFrame::OnTimer ) |
| 229 END_EVENT_TABLE() | 248 END_EVENT_TABLE() |
| 230 | 249 |
| 235 int r = m_dataViewListCtrl->GetSelectedRow(); | 254 int r = m_dataViewListCtrl->GetSelectedRow(); |
| 236 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 ); | 255 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 ); |
| 237 if ( ready.IsSameAs( wxT( "OK" ), true ) ) { | 256 if ( ready.IsSameAs( wxT( "OK" ), true ) ) { |
| 238 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); | 257 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); |
| 239 date.Replace( wxT( "-" ), wxEmptyString, true ); | 258 date.Replace( wxT( "-" ), wxEmptyString, true ); |
| 240 LoadBitmaps( date ); | 259 LoadBitmaps( date, false ); |
| 241 } else { | 260 } else { |
| 242 LoadBitmaps( wxEmptyString ); | 261 LoadBitmaps( wxEmptyString, false ); |
| 243 } | 262 } |
| 244 } | 263 } |
| 245 | 264 |
| 246 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) ) | 265 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) ) |
| 247 { | 266 { |
| 250 if ( status.IsSameAs( wxT( "OK" ), true ) ) return; | 269 if ( status.IsSameAs( wxT( "OK" ), true ) ) return; |
| 251 | 270 |
| 252 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); | 271 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); |
| 253 date.Replace( wxT( "-" ), wxEmptyString, true ); | 272 date.Replace( wxT( "-" ), wxEmptyString, true ); |
| 254 GetImages( m_hhs, date ); | 273 GetImages( m_hhs, date ); |
| 255 LoadBitmaps( date ); | 274 if ( LoadBitmaps( date, true ) ) |
| 256 | 275 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 ); |
| 257 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 ); | |
| 258 } | 276 } |
| 259 | 277 |
| 260 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) ) | 278 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) ) |
| 261 { | 279 { |
| 262 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) { | 280 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) { |
| 265 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); | 283 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); |
| 266 } | 284 } |
| 267 | 285 |
| 268 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) // save config | 286 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) // save config |
| 269 { | 287 { |
| 288 WriteLog( wxT( "[logout]" ) ); | |
| 270 if ( !IsIconized() && !IsMaximized() ) { | 289 if ( !IsIconized() && !IsMaximized() ) { |
| 271 wxGetApp().rect = this->GetRect(); | 290 wxGetApp().rect = this->GetRect(); |
| 272 } | 291 } |
| 273 Destroy(); | 292 Destroy(); |
| 274 } | 293 } |
| 275 | 294 |
| 295 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) ) | |
| 296 { | |
| 297 PasteSeaarch(); | |
| 298 } | |
| 299 | |
| 276 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) ) | 300 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) ) |
| 277 { | 301 { |
| 278 PrintImages(); | 302 PrintImages(); |
| 303 } | |
| 304 | |
| 305 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) ) | |
| 306 { | |
| 307 wxString version, build; | |
| 308 version = wxString::Format( wxT( "Re:Searcher-- version %s / %s\n\n" ), RSVER, RSRELEASE ); | |
| 309 build = wxString::Format( wxT( "build with %s\nrunning under %s." ), wxVERSION_STRING, wxGetOsDescription() ); | |
| 310 | |
| 311 wxMessageBox( version + build, wxT( "Help" ) ); | |
| 312 return; | |
| 279 } | 313 } |
| 280 | 314 |
| 281 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) ) | 315 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) ) |
| 282 { | 316 { |
| 283 wxMessageBox("logout"); | 317 wxMessageBox("logout"); |
| 284 return; | 318 return; |
| 285 } | 319 } |
| 286 | 320 |
| 287 void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) ) | |
| 288 { | |
| 289 return; | |
| 290 } | |
| 291 | |
| 292 | |
| 293 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) ) | 321 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) ) |
| 294 { | 322 { |
| 295 wxMessageBox( "timer !" ); | 323 //wxMessageBox( "timer !" ); |
| 296 // logout | 324 // logout |
| 297 } | 325 } |
| 298 | 326 |
| 299 void MainFrame::OnIdle( wxIdleEvent& event ) | 327 void MainFrame::OnIdle( wxIdleEvent& event ) |
| 300 { | 328 { |
| 308 // Functions | 336 // Functions |
| 309 void MainFrame::CreateControls( void ) | 337 void MainFrame::CreateControls( void ) |
| 310 { | 338 { |
| 311 this->SetIcon( wxIcon( wxT( "sample" ) ) ); | 339 this->SetIcon( wxIcon( wxT( "sample" ) ) ); |
| 312 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | 340 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
| 313 //this->SetBackgroundColour( wxColour( 0, 150, 230 ) ); | 341 this->SetBackgroundColour( wxColour( 30, 80, 40 ) ); |
| 314 this->SetBackgroundColour( wxColour( 153, 153, 153 ) ); | 342 //this->SetBackgroundColour( wxColour( 153, 153, 153 ) ); |
| 315 | 343 |
| 316 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); | 344 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); |
| 317 | 345 |
| 318 // Left | 346 // Left |
| 319 wxImageList* imgList = new wxImageList( 16, 16, false, 1 ); | 347 wxImageList* imgList = new wxImageList( 16, 16, false, 1 ); |
| 356 | 384 |
| 357 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER ); | 385 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER ); |
| 358 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 ); | 386 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 ); |
| 359 m_searchCtrl->SetFocus(); | 387 m_searchCtrl->SetFocus(); |
| 360 | 388 |
| 361 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); | 389 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), wxTE_READONLY ); |
| 362 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) ); | 390 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) ); |
| 363 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 ); | 391 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 ); |
| 364 | 392 |
| 365 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), 0 ); | 393 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), wxTE_READONLY ); |
| 366 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) ); | 394 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) ); |
| 367 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 ); | 395 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 ); |
| 368 | 396 |
| 369 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE ); | 397 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE ); |
| 370 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE ); | 398 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE ); |
| 377 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 ); | 405 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 ); |
| 378 | 406 |
| 379 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL ); | 407 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL ); |
| 380 bSizerRight->Add( m_slider, 0, wxALL, 5 ); | 408 bSizerRight->Add( m_slider, 0, wxALL, 5 ); |
| 381 | 409 |
| 410 m_buttonPsearch = new wxButton( this, ID_PSEARCH, wxT( "Paste-Search" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 411 bSizerRight->Add( m_buttonPsearch, 0, wxALL, 5 ); | |
| 412 | |
| 382 m_buttonPrint = new wxButton( this, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 ); | 413 m_buttonPrint = new wxButton( this, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 383 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 ); | 414 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 ); |
| 384 | 415 |
| 416 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 417 bSizerRight->Add( m_buttonHelp, 0, wxALL, 5 ); | |
| 418 | |
| 385 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 ); | 419 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 386 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 ); | 420 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 ); |
| 387 | |
| 388 m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 389 bSizerRight->Add( m_buttonTest, 0, wxALL, 5 ); | |
| 390 | 421 |
| 391 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); | 422 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); |
| 392 | 423 |
| 393 this->SetSizer( bSizerTop ); | 424 this->SetSizer( bSizerTop ); |
| 394 this->Layout(); | 425 this->Layout(); |
| 400 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | 431 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); |
| 401 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | 432 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); |
| 402 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | 433 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); |
| 403 } | 434 } |
| 404 | 435 |
| 436 void MainFrame::SetAccelerator( void ) | |
| 437 { | |
| 438 wxAcceleratorEntry entries[2]; | |
| 439 entries[0].Set( wxACCEL_CTRL, (int) 'P', wxID_PRINT ); | |
| 440 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); | |
| 441 /* | |
| 442 entries[1].Set( wxACCEL_CTRL, (int) 'X', wxID_EXIT ); | |
| 443 entries[2].Set( wxACCEL_SHIFT, (int) 'A', ID_ABOUT); | |
| 444 entries[3].Set( wxACCEL_NORMAL, WXK_DELETE, wxID_CUT); | |
| 445 */ | |
| 446 wxAcceleratorTable accel( 2, entries ); | |
| 447 SetAcceleratorTable( accel ); | |
| 448 } | |
| 449 | |
| 405 void MainFrame::Cmd( wxString cmd ) | 450 void MainFrame::Cmd( wxString cmd ) |
| 406 { | 451 { |
| 407 m_dataViewListCtrl->DeleteAllItems(); | 452 m_dataViewListCtrl->DeleteAllItems(); |
| 408 LoadBitmaps( wxEmptyString ); | 453 LoadBitmaps( wxEmptyString, false ); |
| 454 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) ); | |
| 409 | 455 |
| 410 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) { | 456 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) { |
| 411 Close(); | 457 Close(); |
| 412 return; | 458 return; |
| 413 } | 459 } |
| 414 | 460 |
| 415 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) { | 461 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) { |
| 416 Close(); | |
| 417 return; | 462 return; |
| 418 } | 463 } |
| 419 | 464 |
| 420 if ( cmd.IsSameAs( wxT( "k" ), true ) ) { | 465 if ( cmd.IsSameAs( wxT( "k" ), true ) ) { |
| 421 // hiragana kensaku | 466 // hiragana kensaku |
| 428 wxExecute( execmd ); | 473 wxExecute( execmd ); |
| 429 return; | 474 return; |
| 430 } | 475 } |
| 431 | 476 |
| 432 if ( cmd.IsSameAs( wxT( "*" ), false ) ) { | 477 if ( cmd.IsSameAs( wxT( "*" ), false ) ) { |
| 433 // cmd = clipboard // paste clipboard | 478 PasteSeaarch(); |
| 479 return; | |
| 434 } | 480 } |
| 435 | 481 |
| 436 if ( cmd.IsSameAs( wxT( "+" ), false ) ) { | 482 if ( cmd.IsSameAs( wxT( "+" ), false ) ) { |
| 437 // print | 483 PrintImages(); |
| 438 return; | 484 return; |
| 439 } | 485 } |
| 440 | 486 |
| 441 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) ); | |
| 442 if ( reHhs.Matches( cmd ) ) { | 487 if ( reHhs.Matches( cmd ) ) { |
| 443 m_hhs = m_searchCtrl->GetValue(); | 488 m_hhs = m_searchCtrl->GetValue(); |
| 444 Search(); | 489 Search(); |
| 445 return; | 490 return; |
| 446 } | 491 } |
| 447 | 492 |
| 448 wxMessageBox( wxT( "Bad Input !!" ) ); | 493 wxMessageBox( wxT( "Bad Input !!" ) ); |
| 449 } | 494 } |
| 450 | 495 |
| 451 void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file ) | 496 bool MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file ) |
| 452 { | 497 { |
| 498 sb->SetBitmap( wxNullBitmap ); | |
| 499 sc->Scroll( 0, 0 ); | |
| 500 | |
| 501 bool ok = true; | |
| 453 if ( startup ) { | 502 if ( startup ) { |
| 454 file = wxT( "image/hw201810.jpg" ); | 503 file = wxT( "image/hello.jpg" ); |
| 455 startup = false; | 504 startup = false; |
| 456 } | 505 } |
| 457 if ( !wxFileExists( file ) ) file = wxT( "image/testpattern.jpg" ); | 506 if ( !wxFileExists( file ) ) { |
| 507 file = wxT( "image/testpattern.jpg" ); | |
| 508 ok = false; | |
| 509 } | |
| 458 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG ); | 510 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG ); |
| 459 int width = bmp.GetWidth(); | 511 int width = bmp.GetWidth(); |
| 460 int height = bmp.GetHeight(); | 512 int height = bmp.GetHeight(); |
| 461 wxImage img = bmp.ConvertToImage(); | 513 wxImage img = bmp.ConvertToImage(); |
| 462 | 514 |
| 464 sc->GetSize( &ww, &wh ); | 516 sc->GetSize( &ww, &wh ); |
| 465 | 517 |
| 466 float w = ww - 30; | 518 float w = ww - 30; |
| 467 float h = w * height / width; | 519 float h = w * height / width; |
| 468 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); | 520 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); |
| 469 sc->SetScrollbars( 10, 10, w / 10, h / 10 ); | 521 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 ); |
| 470 | 522 |
| 471 for ( int i = 0; i < 5; i++ ) { | 523 return ok; |
| 472 w *= 1.1; | 524 } |
| 473 h *= 1.1; | 525 |
| 474 //sb->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); | 526 bool MainFrame::LoadBitmaps( wxString date, bool reload ) |
| 475 } | 527 { |
| 476 } | 528 bool ok; |
| 477 | 529 ok = LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) ); |
| 478 void MainFrame::LoadBitmaps( wxString date ) | 530 ok = LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) ); |
| 479 { | 531 ok = LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) ); |
| 480 LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) ); | 532 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) ); |
| 481 LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) ); | 533 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) ); |
| 482 LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) ); | 534 |
| 483 LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) ); | 535 if ( !ok && reload ) { |
| 484 LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) ); | 536 wxSleep( 5 ); |
| 537 LoadBitmaps( date, false ); | |
| 538 } | |
| 539 return ok; | |
| 485 } | 540 } |
| 486 | 541 |
| 487 void MainFrame::GetImages( wxString hhs, wxString date ) | 542 void MainFrame::GetImages( wxString hhs, wxString date ) |
| 488 { | 543 { |
| 489 wxArrayString args; // http get | 544 wxArrayString args; // http get |
| 490 args.Add( wxT( "client.exe" ) ); | 545 args.Add( wxT( "client.exe" ) ); |
| 491 args.Add( m_server ); | 546 args.Add( m_server ); |
| 492 args.Add( hhs ); | 547 args.Add( hhs ); |
| 493 args.Add( date ); | 548 args.Add( date ); |
| 494 | 549 |
| 495 //wxMessageBox( wxJoin( args, ' ', '\\' ) ); | |
| 496 int estimate = 5; | 550 int estimate = 5; |
| 497 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | 551 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); |
| 498 pd.SetSize( wxSize( 320, 140 ) ); | 552 pd.SetSize( wxSize( 320, 140 ) ); |
| 499 | 553 |
| 500 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE ); | 554 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE ); |
| 504 } | 558 } |
| 505 } | 559 } |
| 506 | 560 |
| 507 void MainFrame::Search( void ) | 561 void MainFrame::Search( void ) |
| 508 { | 562 { |
| 563 // hhs info | |
| 564 if ( hhash.count( m_hhs ) ) { | |
| 565 m_textCtrlName->SetValue( hhash[ m_hhs ]->name ); | |
| 566 m_textCtrlAddr->SetValue( hhash[ m_hhs ]->addr ); | |
| 567 } | |
| 568 | |
| 569 // index | |
| 509 wxString date; | 570 wxString date; |
| 510 int match_cnt = 0; | 571 int match_cnt = 0; |
| 511 for ( int i = 0; i < m_index.GetCount(); i++ ) { | 572 for ( int i = 0; i < m_index.GetCount(); i++ ) { |
| 512 if ( m_index[i].StartsWith( m_hhs, &date ) ) { | 573 if ( m_index[i].StartsWith( m_hhs, &date ) ) { |
| 513 wxVector<wxVariant> data; | 574 wxVector<wxVariant> data; |
| 517 data.push_back( wxEmptyString ); | 578 data.push_back( wxEmptyString ); |
| 518 m_dataViewListCtrl->AppendItem( data ); | 579 m_dataViewListCtrl->AppendItem( data ); |
| 519 data.clear(); | 580 data.clear(); |
| 520 } | 581 } |
| 521 } | 582 } |
| 522 if ( match_cnt == 0 ) wxMessageBox( wxT( "Not Matched !!" ) ); | 583 |
| 584 if ( match_cnt == 0 ) { | |
| 585 wxMessageBox( wxT( "Not Matched !!" ) ); | |
| 586 } else { | |
| 587 wxString date = m_dataViewListCtrl->GetTextValue( 0, 1 ); | |
| 588 date.Replace( wxT( "-" ), wxEmptyString, true ); | |
| 589 GetImages( m_hhs, date ); | |
| 590 if ( LoadBitmaps( date, true ) ) { | |
| 591 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), 0, 2 ); | |
| 592 m_dataViewListCtrl->SelectRow( 0 ); | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 WriteLog( wxT( "[search] " ) + m_hhs ); | |
| 523 } | 597 } |
| 524 | 598 |
| 525 void MainFrame::LoadDB( void ) | 599 void MainFrame::LoadDB( void ) |
| 526 { | 600 { |
| 601 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
| 602 pd.SetSize( wxSize( 320, 140 ) ); | |
| 603 | |
| 604 // index | |
| 527 wxTextFile file; | 605 wxTextFile file; |
| 528 file.Open( wxT( "index.db" ) ); | 606 file.Open( wxT( "index.db" ) ); |
| 529 for ( int i = 0; i < file.GetLineCount(); i++ ) | 607 for ( int i = 0; i < file.GetLineCount(); i++ ) |
| 530 m_index.Add( file.GetLine( i ) ); | 608 m_index.Add( file.GetLine( i ) ); |
| 531 file.Close(); | 609 file.Close(); |
| 532 m_index.Sort( true ); | 610 m_index.Sort( true ); |
| 533 | 611 |
| 534 /* | 612 // decrypto |
| 535 file.Open( wxT( "hhs.db" ) ); | 613 wxString key = wxT( "12345678900123456789abcdefabcdef" ); |
| 536 for ( int i = 0; i < file.GetLineCount(); i++ ) { | 614 wxArrayString args; |
| 537 // | 615 args.Add( wxT( "crypto.exe" ) ); |
| 538 } | 616 args.Add( wxT( "-d" ) ); |
| 539 file.Close(); | 617 args.Add( wxT( "hhs.db" ) ); |
| 540 */ | 618 args.Add( wxT( "-k" ) ); |
| 619 args.Add( key ); | |
| 620 | |
| 621 wxArrayString output, errors; | |
| 622 wxExecute( wxJoin( args, ' ', '\\' ), output, errors ); | |
| 623 | |
| 624 for ( int i = 0; i < 100; i++ ) { | |
| 625 wxMilliSleep( 2 ); | |
| 626 pd.Update( i, wxString::Format( wxT( "Now loding ... ( %0.1f %% )" ), (float)i ) ); | |
| 627 } | |
| 628 if ( errors.GetCount() > 0 ) { | |
| 629 wxMessageBox( errors[0] ); | |
| 630 return; | |
| 631 } | |
| 632 for ( int i = 0; i < output.GetCount(); i++ ) { | |
| 633 wxArrayString buf = wxSplit( output[i], ',', '\\' ); | |
| 634 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex | |
| 635 } | |
| 636 } | |
| 637 | |
| 638 void MainFrame::PasteSeaarch( void ) | |
| 639 { | |
| 640 wxString s; | |
| 641 if ( wxTheClipboard->Open() ) { | |
| 642 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) { | |
| 643 wxTextDataObject data; | |
| 644 wxTheClipboard->GetData( data ); | |
| 645 s = data.GetText(); | |
| 646 } | |
| 647 wxTheClipboard->Close(); | |
| 648 } | |
| 649 | |
| 650 s.Replace( wxT(" "), wxT(""), true ); | |
| 651 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) ); | |
| 652 if ( reHhs.Matches( s ) ) { | |
| 653 m_searchCtrl->SetValue( s ); | |
| 654 m_hhs = m_searchCtrl->GetValue(); | |
| 655 Search(); | |
| 656 return; | |
| 657 } | |
| 658 wxMessageBox( wxT( "Bad Input !!" ) ); | |
| 541 } | 659 } |
| 542 | 660 |
| 543 void MainFrame::PrintImages( void ) | 661 void MainFrame::PrintImages( void ) |
| 544 { | 662 { |
| 545 int r = m_dataViewListCtrl->GetSelectedRow(); | 663 int r = m_dataViewListCtrl->GetSelectedRow(); |
| 576 wxPrintDialogData pd; | 694 wxPrintDialogData pd; |
| 577 wxPrinter p( &pd ); | 695 wxPrinter p( &pd ); |
| 578 | 696 |
| 579 hpout.SetHtmlText( html, wxEmptyString, false ); | 697 hpout.SetHtmlText( html, wxEmptyString, false ); |
| 580 p.Print( NULL, &hpout, true ); | 698 p.Print( NULL, &hpout, true ); |
| 699 | |
| 700 WriteLog( wxT( "[print]" ) ); | |
| 581 } | 701 } |
| 582 | 702 |
| 583 void MainFrame::RemoveFile( wxString pattern ) | 703 void MainFrame::RemoveFile( wxString pattern ) |
| 584 { | 704 { |
| 585 wxString file = wxFindFirstFile( pattern ); | 705 wxString file = wxFindFirstFile( pattern ); |
| 587 wxRemoveFile( file ); | 707 wxRemoveFile( file ); |
| 588 file = wxFindNextFile(); | 708 file = wxFindNextFile(); |
| 589 } | 709 } |
| 590 } | 710 } |
| 591 | 711 |
| 712 void MainFrame::WriteLog( wxString msg ) | |
| 713 { | |
| 714 wxDateTime now = wxDateTime::Now(); | |
| 715 wxString file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "log" ) + wxFILE_SEP_PATH + now.Format( wxT( "%Y%m%d" ) ) + wxT( ".log" ); | |
| 716 | |
| 717 wxTextFile logfile; | |
| 718 if ( !wxFileExists( file ) ) logfile.Create( file ); | |
| 719 | |
| 720 logfile.Open( file ); | |
| 721 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg ); | |
| 722 logfile.Write(); | |
| 723 logfile.Close(); | |
| 724 } | |
| 725 | |
| 592 void MainFrame::InDevelop( bool flag ) | 726 void MainFrame::InDevelop( bool flag ) |
| 593 { | 727 { |
| 594 if ( !flag ) return; | 728 if ( !flag ) return; |
| 595 | 729 |
| 730 bool he = false; | |
| 731 m_buttonHelp->Enable( he ); | |
| 732 m_buttonHelp->Show( he ); | |
| 733 | |
| 596 bool lo = false; | 734 bool lo = false; |
| 597 m_buttonLogout->Enable( lo ); | 735 m_buttonLogout->Enable( lo ); |
| 598 m_buttonLogout->Show( lo ); | 736 m_buttonLogout->Show( lo ); |
| 599 | 737 |
| 600 bool sl = false; | 738 bool sl = false; |
| 601 m_slider->Enable( sl ); | 739 m_slider->Enable( sl ); |
| 602 m_slider->Show( sl ); | 740 m_slider->Show( sl ); |
| 603 | 741 |
| 604 bool tb = false; | |
| 605 m_buttonTest->Enable( tb ); | |
| 606 m_buttonTest->Show( tb ); | |
| 607 | |
| 608 return; | 742 return; |
| 609 | 743 } |
| 610 // search | 744 |
| 611 m_searchCtrl->SetValue( wxT( "0100122642" ) ); | |
| 612 } | |
| 613 |
