X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c376d80f4090ca681e91a96b6947ce299e5a950c..160f78e09db9fff2f7c3a1484514835f1d83eb8e:/samples/scrollsub/scrollsub.cpp diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp index 71e4ba8b01..d1f400d426 100644 --- a/samples/scrollsub/scrollsub.cpp +++ b/samples/scrollsub/scrollsub.cpp @@ -36,11 +36,15 @@ class MyApp; class MyScrolledWindow: public wxScrolledWindow { public: - MyScrolledWindow(){}; + MyScrolledWindow() {} MyScrolledWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ); - ~MyScrolledWindow(){}; + void OnPaint( wxPaintEvent &event ); void OnSize( wxSizeEvent &event ); + +protected: + virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); + private: MyCanvas *m_canvas; @@ -174,10 +178,19 @@ MyScrolledWindow::MyScrolledWindow( wxWindow *parent, wxWindowID id, mainsizer->Add( middlesizer, 1, wxEXPAND ); - SetAutoLayout( true ); SetSizer( mainsizer ); } +wxSize MyScrolledWindow::GetSizeAvailableForScrollTarget(const wxSize& size) +{ + // decrease the total size by the size of the non-scrollable parts above/to + // the left of the canvas + wxSize sizeCanvas(size); + sizeCanvas.x -= 60; + sizeCanvas.y -= 25; + return sizeCanvas; +} + void MyScrolledWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) { // We need to override OnSize so that our scrolled @@ -374,9 +387,9 @@ void MyCanvas::ScrollWindow( int dx, int dy, const wxRect *rect ) // MyFrame -const int ID_QUIT = 108; +const int ID_QUIT = wxID_EXIT; const int ID_FULL = 109; -const int ID_ABOUT = 110; +const int ID_ABOUT = wxID_ABOUT; IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) @@ -421,7 +434,6 @@ MyFrame::MyFrame() topsizer->Add( m_log, 0, wxEXPAND ); #endif // wxUSE_LOG - SetAutoLayout( true ); SetSizer( topsizer ); } @@ -448,6 +460,9 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) bool MyApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + wxFrame *frame = new MyFrame(); frame->Show( true );