X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/45e6e6f8ab806b337dffeb3b52fec7eba3c845ef..160f78e09db9fff2f7c3a1484514835f1d83eb8e:/samples/scrollsub/scrollsub.cpp?ds=sidebyside diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp index e26edd550f..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 @@ -421,7 +434,6 @@ MyFrame::MyFrame() topsizer->Add( m_log, 0, wxEXPAND ); #endif // wxUSE_LOG - SetAutoLayout( true ); SetSizer( topsizer ); }