From 304862976530be1315f3861157168f6edea2195e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 15 Mar 2002 00:21:47 +0000 Subject: [PATCH] Give wxScrolledWindow its own Layout method that takes into account the virtual size and scrolled offset of the window. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/scrolwin.h | 3 +++ include/wx/gtk/scrolwin.h | 3 +++ include/wx/gtk1/scrolwin.h | 3 +++ src/generic/scrlwing.cpp | 20 +++++++++++++++----- src/gtk/scrolwin.cpp | 27 ++++++++++++++++++++++----- src/gtk1/scrolwin.cpp | 27 ++++++++++++++++++++++----- 6 files changed, 68 insertions(+), 15 deletions(-) diff --git a/include/wx/generic/scrolwin.h b/include/wx/generic/scrolwin.h index 5e092a91a9..0808cbb2b3 100644 --- a/include/wx/generic/scrolwin.h +++ b/include/wx/generic/scrolwin.h @@ -66,6 +66,9 @@ public: virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } + // lay out the window and its children + virtual bool Layout(); + protected: // this is needed for wxEVT_PAINT processing hack described in // wxScrollHelperEvtHandler::ProcessEvent() diff --git a/include/wx/gtk/scrolwin.h b/include/wx/gtk/scrolwin.h index c6dc418547..96688d1ab9 100644 --- a/include/wx/gtk/scrolwin.h +++ b/include/wx/gtk/scrolwin.h @@ -108,6 +108,9 @@ public: // automatically change the origin according to the scroll position. virtual void PrepareDC(wxDC& dc); + // lay out the window and its children + virtual bool Layout(); + // Adjust the scrollbars virtual void AdjustScrollbars(); diff --git a/include/wx/gtk1/scrolwin.h b/include/wx/gtk1/scrolwin.h index c6dc418547..96688d1ab9 100644 --- a/include/wx/gtk1/scrolwin.h +++ b/include/wx/gtk1/scrolwin.h @@ -108,6 +108,9 @@ public: // automatically change the origin according to the scroll position. virtual void PrepareDC(wxDC& dc); + // lay out the window and its children + virtual bool Layout(); + // Adjust the scrollbars virtual void AdjustScrollbars(); diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index cf18c3bf8c..c17909a709 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -836,11 +836,6 @@ void wxScrollHelper::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) cons // Default OnSize resets scrollbars, if any void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) { -#if wxUSE_CONSTRAINTS - if ( m_win->GetAutoLayout() ) - m_win->Layout(); -#endif - AdjustScrollbars(); } @@ -1109,6 +1104,21 @@ wxGenericScrolledWindow::~wxGenericScrolledWindow() { } +bool wxGenericScrolledWindow::Layout() +{ + if (GetSizer()) + { + // Take into account the virtual size and scrolled position of the window + int x, y, w, h; + CalcScrolledPosition(0,0, &x,&y); + GetVirtualSize(&w, &h); + GetSizer()->SetDimension(x, y, w, h); + return TRUE; + } + else + return wxPanel::Layout(); // fall back to default for LayoutConstraints +} + void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event) { // the user code didn't really draw the window if we got here, so set this diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 1d2378e79b..579d2b7b6d 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -33,6 +33,7 @@ #include "wx/scrolwin.h" #include "wx/panel.h" +#include "wx/sizer.h" #include "wx/gtk/private.h" #include "wx/gtk/win_gtk.h" @@ -308,7 +309,7 @@ bool wxScrolledWindow::Create(wxWindow *parent, if (m_parent) m_parent->DoAddChild( this ); - + m_focusWidget = m_wxwindow; PostCreation(); @@ -332,7 +333,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, { int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; - + m_xScrollPixelsPerLine = pixelsPerUnitX; m_yScrollPixelsPerLine = pixelsPerUnitY; m_xScrollLines = noUnitsX; @@ -351,14 +352,14 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, m_vAdjust->value = yPos; m_vAdjust->step_increment = 1.0; m_vAdjust->page_increment = 2.0; - + AdjustScrollbars(); - + if (!noRefresh) { int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; - + m_targetWindow->ScrollWindow( old_x-new_x, old_y-new_y ); } } @@ -760,6 +761,22 @@ void wxScrolledWindow::GtkVDisconnectEvent() (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); } + +bool wxScrolledWindow::Layout() +{ + if (GetSizer()) + { + // Take into account the virtual size and scrolled position of the window + int x, y, w, h; + CalcScrolledPosition(0,0, &x,&y); + GetVirtualSize(&w, &h); + GetSizer()->SetDimension(x, y, w, h); + return TRUE; + } + else + return wxPanel::Layout(); // fall back to default for LayoutConstraints +} + // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index 1d2378e79b..579d2b7b6d 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -33,6 +33,7 @@ #include "wx/scrolwin.h" #include "wx/panel.h" +#include "wx/sizer.h" #include "wx/gtk/private.h" #include "wx/gtk/win_gtk.h" @@ -308,7 +309,7 @@ bool wxScrolledWindow::Create(wxWindow *parent, if (m_parent) m_parent->DoAddChild( this ); - + m_focusWidget = m_wxwindow; PostCreation(); @@ -332,7 +333,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, { int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; - + m_xScrollPixelsPerLine = pixelsPerUnitX; m_yScrollPixelsPerLine = pixelsPerUnitY; m_xScrollLines = noUnitsX; @@ -351,14 +352,14 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, m_vAdjust->value = yPos; m_vAdjust->step_increment = 1.0; m_vAdjust->page_increment = 2.0; - + AdjustScrollbars(); - + if (!noRefresh) { int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; - + m_targetWindow->ScrollWindow( old_x-new_x, old_y-new_y ); } } @@ -760,6 +761,22 @@ void wxScrolledWindow::GtkVDisconnectEvent() (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); } + +bool wxScrolledWindow::Layout() +{ + if (GetSizer()) + { + // Take into account the virtual size and scrolled position of the window + int x, y, w, h; + CalcScrolledPosition(0,0, &x,&y); + GetVirtualSize(&w, &h); + GetSizer()->SetDimension(x, y, w, h); + return TRUE; + } + else + return wxPanel::Layout(); // fall back to default for LayoutConstraints +} + // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- -- 2.45.2