Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/rsearcher.cpp @ 9:ae89ce4793d8
add satellite-view.
| author | pyon@macmini |
|---|---|
| date | Wed, 31 Oct 2018 20:10:29 +0900 |
| parents | 82f9af6aa7e4 |
| children | 36811fd22bd2 |
comparison
equal
deleted
inserted
replaced
| 8:82f9af6aa7e4 | 9:ae89ce4793d8 |
|---|---|
| 1 // Filename : rsearcher.cpp | 1 // Filename : rsearcher.cpp |
| 2 // Last Change: 2018-10-30 ‰Î 11:19:28. | 2 // Last Change: 2018-10-31 æ°´ 16:39:35. |
| 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> |
| 89 /********************/ | 89 /********************/ |
| 90 MyStaticBitmap::MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) | 90 MyStaticBitmap::MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) |
| 91 : wxStaticBitmap( parent, id, label, pos, size, style, name ) | 91 : wxStaticBitmap( parent, id, label, pos, size, style, name ) |
| 92 { | 92 { |
| 93 m_parent = parent; | 93 m_parent = parent; |
| 94 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this ); | 94 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this ); |
| 95 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this ); | 95 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this ); |
| 96 Connect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this ); | 96 Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( OnLeftDClick ), NULL, this ); |
| 97 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this ); | 97 Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( OnRightDClick ), NULL, this ); |
| 98 | 98 Connect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this ); |
| 99 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this ); | 99 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this ); |
| 100 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this ); | 100 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this ); |
| 101 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this ); | |
| 101 } | 102 } |
| 102 | 103 |
| 103 MyStaticBitmap::~MyStaticBitmap() | 104 MyStaticBitmap::~MyStaticBitmap() |
| 104 { | 105 { |
| 105 Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this ); | 106 Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this ); |
| 106 Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this ); | 107 Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this ); |
| 107 Disconnect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this ); | 108 Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( OnLeftDClick ), NULL, this ); |
| 108 Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this ); | 109 Disconnect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( OnRightDClick ), NULL, this ); |
| 109 | 110 Disconnect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this ); |
| 110 Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this ); | 111 Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this ); |
| 111 Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this ); | 112 Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this ); |
| 113 Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this ); | |
| 112 } | 114 } |
| 113 | 115 |
| 114 // Event Handlers | 116 // Event Handlers |
| 115 void MyStaticBitmap::OnWheel( wxMouseEvent& event ) | 117 void MyStaticBitmap::OnWheel( wxMouseEvent& event ) |
| 116 { | 118 { |
| 119 /* | |
| 117 if ( event.ControlDown() ) { | 120 if ( event.ControlDown() ) { |
| 118 if ( event.GetWheelRotation() < 0 ) { | 121 if ( event.GetWheelRotation() < 0 ) { |
| 119 //if ( m_zoom < 4 ) m_zoom++; | |
| 120 } | 122 } |
| 121 else { | 123 else { |
| 122 //if ( m_zoom > 0 ) m_zoom--; | |
| 123 } | 124 } |
| 124 return; | 125 return; |
| 125 } | 126 } |
| 126 event.Skip(); | 127 event.Skip(); |
| 128 */ | |
| 127 } | 129 } |
| 128 | 130 |
| 129 void MyStaticBitmap::OnLeftDown( wxMouseEvent& event ) | 131 void MyStaticBitmap::OnLeftDown( wxMouseEvent& event ) |
| 130 { | 132 { |
| 131 event.GetPosition( &m_dragx, &m_dragy ); | 133 event.GetPosition( &m_dragx, &m_dragy ); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) ) | 137 void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) ) |
| 136 { | 138 { |
| 137 SetCursor( wxCursor( wxCURSOR_ARROW ) ); | 139 SetCursor( wxCursor( wxCURSOR_ARROW ) ); |
| 140 } | |
| 141 | |
| 142 void MyStaticBitmap::OnLeftDClick( wxMouseEvent& event ) | |
| 143 { | |
| 144 if ( with_stl ) return; | |
| 145 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); | |
| 146 mf->ChangeCZoom( 1 ); | |
| 147 } | |
| 148 | |
| 149 void MyStaticBitmap::OnRightDClick( wxMouseEvent& event ) | |
| 150 { | |
| 151 if ( with_stl ) return; | |
| 152 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); | |
| 153 mf->ChangeCZoom( -1 ); | |
| 138 } | 154 } |
| 139 | 155 |
| 140 void MyStaticBitmap::OnMotion( wxMouseEvent& event ) | 156 void MyStaticBitmap::OnMotion( wxMouseEvent& event ) |
| 141 { | 157 { |
| 142 if ( event.RightIsDown() ) return; | 158 if ( event.RightIsDown() ) return; |
| 167 } | 183 } |
| 168 | 184 |
| 169 /* right-gesture: judge */ | 185 /* right-gesture: judge */ |
| 170 void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event ) | 186 void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event ) |
| 171 { | 187 { |
| 188 if ( with_stl ) return; | |
| 172 int x, y; | 189 int x, y; |
| 173 event.GetPosition( &x, &y ); | 190 event.GetPosition( &x, &y ); |
| 174 | 191 |
| 175 int dx = x - cx; | 192 int dx = x - cx; |
| 176 int dy = y - cy; | 193 int dy = y - cy; |
| 208 nb->SetSelection( ++n ); | 225 nb->SetSelection( ++n ); |
| 209 } else { | 226 } else { |
| 210 if ( n == 0 ) return; | 227 if ( n == 0 ) return; |
| 211 nb->SetSelection( --n ); | 228 nb->SetSelection( --n ); |
| 212 } | 229 } |
| 230 } | |
| 231 | |
| 232 /********************/ | |
| 233 /** SatteliteView **/ | |
| 234 /********************/ | |
| 235 StlFrame::StlFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
| 236 : wxFrame( parent, id, title, pos, size, style ) | |
| 237 { | |
| 238 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); | |
| 239 | |
| 240 m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); | |
| 241 m_scrolledWindow->SetScrollRate( 5, 5 ); | |
| 242 | |
| 243 m_staticBitmap = new MyStaticBitmap( m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | |
| 244 m_staticBitmap->WithSatellite( true ); | |
| 245 | |
| 246 bSizerTop->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 0 ); | |
| 247 | |
| 248 this->SetSizer( bSizerTop ); | |
| 249 this->Layout(); | |
| 250 } | |
| 251 | |
| 252 StlFrame::~StlFrame() | |
| 253 { | |
| 213 } | 254 } |
| 214 | 255 |
| 215 /********************/ | 256 /********************/ |
| 216 /** Main Frame **/ | 257 /** Main Frame **/ |
| 217 /********************/ | 258 /********************/ |
| 242 // shortcut-key | 283 // shortcut-key |
| 243 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus ) | 284 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus ) |
| 244 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom ) | 285 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom ) |
| 245 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom ) | 286 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom ) |
| 246 EVT_BUTTON( ID_DARK, MainFrame::OnDark ) | 287 EVT_BUTTON( ID_DARK, MainFrame::OnDark ) |
| 288 EVT_BUTTON( ID_SWIN, MainFrame::OnSatellite ) | |
| 247 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) | 289 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp ) |
| 248 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose ) | 290 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose ) |
| 249 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) | 291 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout ) |
| 250 END_EVENT_TABLE() | 292 END_EVENT_TABLE() |
| 251 | 293 |
| 252 | 294 |
| 253 // Event Handler | 295 // Event Handler |
| 254 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) ) | 296 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) ) |
| 255 { | 297 { |
| 256 int r = m_dataViewListCtrl->GetSelectedRow(); | 298 int r = m_dataViewListCtrl->GetSelectedRow(); |
| 299 if ( r == wxNOT_FOUND ) return; | |
| 300 | |
| 257 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 ); | 301 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 ); |
| 258 if ( ready.IsSameAs( wxT( "OK" ), true ) ) { | 302 if ( ready.IsSameAs( wxT( "OK" ), true ) ) { |
| 259 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); | 303 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 ); |
| 260 date.Replace( wxT( "-" ), wxEmptyString, true ); | 304 date.Replace( wxT( "-" ), wxEmptyString, true ); |
| 261 LoadBitmaps( date, false ); | 305 LoadBitmaps( date, false ); |
| 329 ChangeColor( m_staticBitmap2 ); | 373 ChangeColor( m_staticBitmap2 ); |
| 330 ChangeColor( m_staticBitmap3 ); | 374 ChangeColor( m_staticBitmap3 ); |
| 331 ChangeColor( m_staticBitmap4 ); | 375 ChangeColor( m_staticBitmap4 ); |
| 332 ChangeColor( m_staticBitmap5 ); | 376 ChangeColor( m_staticBitmap5 ); |
| 333 m_dark = !m_dark; | 377 m_dark = !m_dark; |
| 378 } | |
| 379 | |
| 380 void MainFrame::OnSatellite( wxCommandEvent& WXUNUSED(event ) ) | |
| 381 { | |
| 382 int n = m_notebook->GetSelection(); | |
| 383 StlFrame *stl = new StlFrame( this, wxID_ANY, wxT( "Re:Searcher - satellite view" ), wxPoint( 0, 0 ), wxSize( 500, 600 ), wxFRAME_NO_TASKBAR|wxCLOSE_BOX|wxCAPTION|wxRESIZE_BORDER ); | |
| 384 wxBitmap bmp; | |
| 385 if ( n == 0 ) bmp = m_staticBitmap1->GetBitmap(); | |
| 386 if ( n == 1 ) bmp = m_staticBitmap2->GetBitmap(); | |
| 387 if ( n == 2 ) bmp = m_staticBitmap3->GetBitmap(); | |
| 388 if ( n == 3 ) bmp = m_staticBitmap4->GetBitmap(); | |
| 389 if ( n == 4 ) bmp = m_staticBitmap5->GetBitmap(); | |
| 390 stl->SetBitmap( bmp ); | |
| 391 | |
| 392 int w = bmp.GetWidth(); | |
| 393 int h = bmp.GetHeight(); | |
| 394 stl->SetScroll( w, h ); | |
| 395 | |
| 396 stl->Show(); | |
| 334 } | 397 } |
| 335 | 398 |
| 336 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) ) | 399 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) ) |
| 337 { | 400 { |
| 338 wxString version, build; | 401 wxString version, build; |
| 454 m_buttonPzoom->Hide(); | 517 m_buttonPzoom->Hide(); |
| 455 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 ); | 518 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 456 m_buttonMzoom->Hide(); | 519 m_buttonMzoom->Hide(); |
| 457 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 ); | 520 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 458 m_buttonDark->Hide(); | 521 m_buttonDark->Hide(); |
| 522 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 523 m_buttonSatellite->Hide(); | |
| 459 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 ); | 524 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 460 m_buttonClose->Hide(); | 525 m_buttonClose->Hide(); |
| 461 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); | 526 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 ); |
| 462 m_buttonHelp->Hide(); | 527 m_buttonHelp->Hide(); |
| 463 | 528 |
| 475 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); | 540 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); |
| 476 } | 541 } |
| 477 | 542 |
| 478 void MainFrame::SetAccelerator( void ) | 543 void MainFrame::SetAccelerator( void ) |
| 479 { | 544 { |
| 480 wxAcceleratorEntry entries[8]; | 545 wxAcceleratorEntry entries[9]; |
| 481 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT ); | 546 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT ); |
| 482 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); | 547 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP ); |
| 483 entries[2].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS ); | 548 entries[2].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS ); |
| 484 entries[3].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM ); | 549 entries[3].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM ); |
| 485 entries[4].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM ); | 550 entries[4].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM ); |
| 486 entries[5].Set( wxACCEL_NORMAL, (int)'D', ID_DARK ); | 551 entries[5].Set( wxACCEL_NORMAL, (int)'D', ID_DARK ); |
| 487 entries[6].Set( wxACCEL_SHIFT, (int)'Q', wxID_CLOSE ); | 552 entries[6].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE ); |
| 488 entries[7].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout ) | 553 entries[7].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN ); |
| 554 entries[8].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout ) | |
| 489 wxAcceleratorTable accel( 8, entries ); | 555 wxAcceleratorTable accel( 8, entries ); |
| 490 SetAcceleratorTable( accel ); | 556 SetAcceleratorTable( accel ); |
| 491 } | 557 } |
| 492 | 558 |
| 493 void MainFrame::Cmd( wxString cmd ) | 559 void MainFrame::Cmd( wxString cmd ) |
| 642 sb->SetBitmap( wxBitmap( img ) ); | 708 sb->SetBitmap( wxBitmap( img ) ); |
| 643 } | 709 } |
| 644 | 710 |
| 645 void MainFrame::GetImages( wxString hhs, wxString date ) | 711 void MainFrame::GetImages( wxString hhs, wxString date ) |
| 646 { | 712 { |
| 647 //GetImages2( hhs, date); return; // here comment out ( by client.exe & return ) | |
| 648 | |
| 649 int estimate = http.GetImagesSize( hhs, date ) / 1000000; | 713 int estimate = http.GetImagesSize( hhs, date ) / 1000000; |
| 650 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | 714 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); |
| 651 pd.SetSize( wxSize( 320, 140 ) ); | 715 pd.SetSize( wxSize( 320, 140 ) ); |
| 652 | 716 |
| 653 http.GetImages( hhs, date ); | 717 http.GetImages( hhs, date ); |
| 654 for ( int i = 0; i < estimate; i++ ) { | 718 for ( int i = 0; i < estimate; i++ ) { |
| 655 wxMilliSleep( 1 ); | 719 wxMilliSleep( 1 ); |
| 656 pd.Update( i, wxT( "Now Loading..." ) ); | |
| 657 } | |
| 658 } | |
| 659 | |
| 660 void MainFrame::GetImages2( wxString hhs, wxString date ) | |
| 661 { | |
| 662 wxArrayString args; // http get | |
| 663 args.Add( wxT( "client.exe" ) ); | |
| 664 args.Add( m_server ); | |
| 665 args.Add( hhs ); | |
| 666 args.Add( date ); | |
| 667 | |
| 668 int estimate = 5; | |
| 669 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
| 670 pd.SetSize( wxSize( 320, 140 ) ); | |
| 671 | |
| 672 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE ); | |
| 673 for ( int i = 0; i < estimate; i++ ) { | |
| 674 wxSleep( 1 ); | |
| 675 pd.Update( i, wxT( "Now Loading..." ) ); | 720 pd.Update( i, wxT( "Now Loading..." ) ); |
| 676 } | 721 } |
| 677 } | 722 } |
| 678 | 723 |
| 679 void MainFrame::Search( void ) | 724 void MainFrame::Search( void ) |
