Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/rsearcher.cpp @ 7:29829e98d510
add net.cpp
| author | pyon@macmini |
|---|---|
| date | Fri, 26 Oct 2018 21:05:11 +0900 |
| parents | 9a8b581c1993 |
| children | 82f9af6aa7e4 |
comparison
equal
deleted
inserted
replaced
| 6:9a8b581c1993 | 7:29829e98d510 |
|---|---|
| 1 // Filename : rsearcher.cpp | 1 // Filename : rsearcher.cpp |
| 2 // Last Change: 2018-10-23 ‰Î 13:09:30. | 2 // Last Change: 2018-10-26 ‹à 15:12:02. |
| 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 <wx/clipbrd.h> |
| 216 /** Main Frame **/ | 216 /** Main Frame **/ |
| 217 /********************/ | 217 /********************/ |
| 218 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 218 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 219 : wxFrame( parent, id, title, pos, size, style ) | 219 : wxFrame( parent, id, title, pos, size, style ) |
| 220 { | 220 { |
| 221 http = RsHttp(); | |
| 221 CreateControls(); | 222 CreateControls(); |
| 222 SetAccelerator(); | 223 SetAccelerator(); |
| 223 LoadBitmaps( wxEmptyString, false ); | 224 LoadBitmaps( wxEmptyString, false ); |
| 224 m_timer.SetOwner( this, ID_TIMER ); | 225 m_timer.SetOwner( this, ID_TIMER ); |
| 225 } | 226 } |
| 231 // Event Table | 232 // Event Table |
| 232 BEGIN_EVENT_TABLE( MainFrame, wxFrame ) | 233 BEGIN_EVENT_TABLE( MainFrame, wxFrame ) |
| 233 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected ) | 234 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected ) |
| 234 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) | 235 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) |
| 235 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) | 236 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) |
| 237 EVT_BUTTON( ID_PSEARCH, MainFrame::OnPasteSearch ) | |
| 236 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint ) | 238 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint ) |
| 237 EVT_BUTTON( ID_PSEARCH, MainFrame::OnPasteSearch ) | 239 EVT_CLOSE( MainFrame::OnClose ) |
| 240 EVT_IDLE( MainFrame::OnIdle ) | |
| 241 EVT_TIMER( ID_TIMER, MainFrame::OnTimer ) | |
| 242 // shortcut-key | |
| 243 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus ) | |
| 238 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom ) | 244 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom ) |
| 239 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom ) | 245 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom ) |
| 240 EVT_BUTTON( ID_DARK, MainFrame::OnDark ) | 246 EVT_BUTTON( ID_DARK, MainFrame::OnDark ) |
| 241 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) | 247 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) |
| 248 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose ) | |
| 242 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) | 249 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) |
| 243 EVT_CLOSE( MainFrame::OnClose ) | |
| 244 EVT_IDLE( MainFrame::OnIdle ) | |
| 245 EVT_TIMER( ID_TIMER, MainFrame::OnTimer ) | |
| 246 END_EVENT_TABLE() | 250 END_EVENT_TABLE() |
| 247 | 251 |
| 248 | 252 |
| 249 // Event Handler | 253 // Event Handler |
| 250 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) ) | 254 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) ) |
| 279 m_notebook->SetPageImage( i, 1 ); | 283 m_notebook->SetPageImage( i, 1 ); |
| 280 } | 284 } |
| 281 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); | 285 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); |
| 282 } | 286 } |
| 283 | 287 |
| 284 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) // save config | 288 void MainFrame::OnBClose( wxCommandEvent& WXUNUSED(event) ) |
| 285 { | 289 { |
| 286 WriteLog( wxT( "[logout]" ) ); | 290 Close(); |
| 287 if ( !IsIconized() && !IsMaximized() ) { | 291 } |
| 288 wxGetApp().rect = this->GetRect(); | 292 |
| 289 } | 293 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) |
| 290 Destroy(); | 294 { |
| 295 Close(); | |
| 296 } | |
| 297 | |
| 298 void MainFrame::OnFocus( wxCommandEvent& WXUNUSED(event) ) | |
| 299 { | |
| 300 m_searchCtrl->SetFocus(); | |
| 291 } | 301 } |
| 292 | 302 |
| 293 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) ) | 303 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) ) |
| 294 { | 304 { |
| 295 PasteSeaarch(); | 305 PasteSeaarch(); |
| 433 | 443 |
| 434 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 ); | 444 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 435 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 ); | 445 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 ); |
| 436 | 446 |
| 437 // invisible buttons for shortcut-key | 447 // invisible buttons for shortcut-key |
| 448 m_buttonFocus = new wxButton( this, ID_FOCUS, wxT( "Focus" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 449 m_buttonFocus->Hide(); | |
| 438 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 ); | 450 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 439 m_buttonPzoom->Hide(); | 451 m_buttonPzoom->Hide(); |
| 440 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 ); | 452 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 441 m_buttonMzoom->Hide(); | 453 m_buttonMzoom->Hide(); |
| 442 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 ); | 454 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 443 m_buttonDark->Hide(); | 455 m_buttonDark->Hide(); |
| 456 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 457 m_buttonClose->Hide(); | |
| 444 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); | 458 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 445 m_buttonHelp->Hide(); | 459 m_buttonHelp->Hide(); |
| 446 | 460 |
| 447 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); | 461 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); |
| 448 | 462 |
| 458 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | 472 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); |
| 459 } | 473 } |
| 460 | 474 |
| 461 void MainFrame::SetAccelerator( void ) | 475 void MainFrame::SetAccelerator( void ) |
| 462 { | 476 { |
| 463 wxAcceleratorEntry entries[5]; | 477 wxAcceleratorEntry entries[8]; |
| 464 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT ); | 478 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT ); |
| 465 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); | 479 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); |
| 466 entries[2].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM ); | 480 entries[2].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS ); |
| 467 entries[3].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM ); | 481 entries[3].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM ); |
| 468 entries[4].Set( wxACCEL_NORMAL, (int)'D', ID_DARK ); | 482 entries[4].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM ); |
| 469 wxAcceleratorTable accel( 5, entries ); | 483 entries[5].Set( wxACCEL_NORMAL, (int)'D', ID_DARK ); |
| 484 entries[6].Set( wxACCEL_SHIFT, (int)'Q', wxID_CLOSE ); | |
| 485 entries[7].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout ) | |
| 486 wxAcceleratorTable accel( 8, entries ); | |
| 470 SetAcceleratorTable( accel ); | 487 SetAcceleratorTable( accel ); |
| 471 } | 488 } |
| 472 | 489 |
| 473 void MainFrame::Cmd( wxString cmd ) | 490 void MainFrame::Cmd( wxString cmd ) |
| 474 { | 491 { |
| 560 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) ); | 577 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) ); |
| 561 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) ); | 578 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) ); |
| 562 | 579 |
| 563 if ( !ok && reload ) { | 580 if ( !ok && reload ) { |
| 564 wxSleep( 5 ); | 581 wxSleep( 5 ); |
| 565 LoadBitmaps( date, false ); | 582 ok = LoadBitmaps( date, false ); |
| 566 } | 583 } |
| 567 return ok; | 584 return ok; |
| 568 } | 585 } |
| 569 | 586 |
| 570 void MainFrame::ChangeCZoom( int z ) | 587 void MainFrame::ChangeCZoom( int z ) |
| 620 } | 637 } |
| 621 sb->SetBitmap( wxBitmap( img ) ); | 638 sb->SetBitmap( wxBitmap( img ) ); |
| 622 } | 639 } |
| 623 | 640 |
| 624 void MainFrame::GetImages( wxString hhs, wxString date ) | 641 void MainFrame::GetImages( wxString hhs, wxString date ) |
| 642 { | |
| 643 GetImages2( hhs, date); return; // here comment out | |
| 644 | |
| 645 int estimate = 5; | |
| 646 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
| 647 pd.SetSize( wxSize( 320, 140 ) ); | |
| 648 | |
| 649 http.GetImages( hhs, date ); | |
| 650 for ( int i = 0; i < estimate; i++ ) { | |
| 651 wxSleep( 1 ); | |
| 652 pd.Update( i, wxT( "Now Loading..." ) ); | |
| 653 } | |
| 654 } | |
| 655 | |
| 656 void MainFrame::GetImages2( wxString hhs, wxString date ) | |
| 625 { | 657 { |
| 626 wxArrayString args; // http get | 658 wxArrayString args; // http get |
| 627 args.Add( wxT( "client.exe" ) ); | 659 args.Add( wxT( "client.exe" ) ); |
| 628 args.Add( m_server ); | 660 args.Add( m_server ); |
| 629 args.Add( hhs ); | 661 args.Add( hhs ); |
| 794 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg ); | 826 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg ); |
| 795 logfile.Write(); | 827 logfile.Write(); |
| 796 logfile.Close(); | 828 logfile.Close(); |
| 797 } | 829 } |
| 798 | 830 |
| 831 void MainFrame::Close( void ) | |
| 832 { | |
| 833 WriteLog( wxT( "[logout]" ) ); | |
| 834 if ( !IsIconized() && !IsMaximized() ) { | |
| 835 wxGetApp().rect = this->GetRect(); | |
| 836 } | |
| 837 Destroy(); | |
| 838 } | |
| 839 | |
| 799 void MainFrame::InDevelop( bool flag ) | 840 void MainFrame::InDevelop( bool flag ) |
| 800 { | 841 { |
| 801 if ( !flag ) return; | 842 if ( !flag ) return; |
| 802 | 843 |
| 803 bool lo = false; | 844 bool lo = false; |
