X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b29903d4854625650ae678c0515acc76facba1ee..81f5836b8953c11551767e7bf16467824432c0a3:/samples/scrollsub/scrollsub.cpp diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp index 7f90285eb7..f8620259de 100644 --- a/samples/scrollsub/scrollsub.cpp +++ b/samples/scrollsub/scrollsub.cpp @@ -36,11 +36,11 @@ class MyApp; class MyScrolledWindow: public wxScrolledWindow { public: - MyScrolledWindow() {} + MyScrolledWindow(){}; MyScrolledWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size ); - ~MyScrolledWindow(); + ~MyScrolledWindow(){}; void OnPaint( wxPaintEvent &event ); - + void OnSize( wxSizeEvent &event ); private: MyCanvas *m_canvas; @@ -87,10 +87,10 @@ private: class MyCanvas: public wxPanel { public: - MyCanvas() {} + MyCanvas(){}; MyCanvas( wxScrolledWindow *parent, MyTopLabels *top, MyRightLabels *right, wxWindowID id, const wxPoint &pos, const wxSize &size ); - ~MyCanvas(); + ~MyCanvas(){}; void OnPaint( wxPaintEvent &event ); void ScrollWindow( int dx, int dy, const wxRect *rect ); @@ -141,7 +141,8 @@ IMPLEMENT_APP(MyApp) IMPLEMENT_DYNAMIC_CLASS(MyScrolledWindow, wxScrolledWindow) BEGIN_EVENT_TABLE(MyScrolledWindow, wxScrolledWindow) - EVT_PAINT( MyScrolledWindow::OnPaint) + EVT_PAINT( MyScrolledWindow::OnPaint) + EVT_SIZE( MyScrolledWindow::OnSize) END_EVENT_TABLE() MyScrolledWindow::MyScrolledWindow( wxWindow *parent, wxWindowID id, @@ -177,8 +178,18 @@ MyScrolledWindow::MyScrolledWindow( wxWindow *parent, wxWindowID id, SetSizer( mainsizer ); } -MyScrolledWindow::~MyScrolledWindow() +void MyScrolledWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) { + // We need to override OnSize so that our scrolled + // window a) does call Layout() to use sizers for + // positioning the controls but b) does not query + // the sizer for their size and use that for setting + // the scrollable area as set that ourselves by + // calling SetScrollbar() further down. + + Layout(); + + AdjustScrollbars(); } void MyScrolledWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) @@ -296,10 +307,6 @@ MyCanvas::MyCanvas( wxScrolledWindow *parent, MyTopLabels *top, MyRightLabels *r SetCursor( wxCursor( wxCURSOR_IBEAM ) ); } -MyCanvas::~MyCanvas() -{ -} - void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) { wxPaintDC dc( this ); @@ -367,9 +374,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 )