From 61bb5a9c1b200a43f1446c3873cfc1d5acda0e28 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Apr 2006 02:00:48 +0000 Subject: [PATCH] implement Layout() so that sizers work correctly when the window is scrolled (1st part of the patch 1439905) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/vscroll.h | 2 ++ src/generic/vscroll.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/wx/vscroll.h b/include/wx/vscroll.h index b24615f27e..1d29f56405 100644 --- a/include/wx/vscroll.h +++ b/include/wx/vscroll.h @@ -135,6 +135,8 @@ public: // is kept for backwards compatibility size_t GetLastVisibleLine() const { return GetVisibleEnd() - 1; } + // layout the children (including the sizer if needed) + virtual bool Layout(); protected: // this function must be overridden in the derived class and it should diff --git a/src/generic/vscroll.cpp b/src/generic/vscroll.cpp index 3fc8a940d5..bce13cb38d 100644 --- a/src/generic/vscroll.cpp +++ b/src/generic/vscroll.cpp @@ -282,6 +282,27 @@ void wxVScrolledWindow::RefreshAll() Refresh(); } +bool wxVScrolledWindow::Layout() +{ + if ( GetSizer() ) + { + // adjust the sizer dimensions/position taking into account the + // virtual size and scrolled position of the window. + + int w, h; + GetVirtualSize(&w, &h); + + // x is always 0 so no variable needed + int y = -GetLinesHeight(0, GetFirstVisibleLine()); + + GetSizer()->SetDimension(0, y, w, h); + return true; + } + + // fall back to default for LayoutConstraints + return wxPanel::Layout(); +} + int wxVScrolledWindow::HitTest(wxCoord WXUNUSED(x), wxCoord y) const { const size_t lineMax = GetVisibleEnd(); -- 2.47.2