X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0cf5b09998e7d4606387975a56b6a954a98fd7b7..19e30148e18cc99296b26503c155e5cef59045f4:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index cf18c3bf8c..904104e371 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -40,6 +40,7 @@ #include "wx/scrolwin.h" #include "wx/panel.h" #include "wx/timer.h" +#include "wx/sizer.h" #ifdef __WXMSW__ #include // for DLGC_WANTARROWS @@ -798,10 +799,24 @@ void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll) void wxScrollHelper::GetVirtualSize (int *x, int *y) const { + wxSize sz(0, 0); + if (m_targetWindow) + sz = m_targetWindow->GetClientSize(); + if ( x ) - *x = m_xScrollPixelsPerLine * m_xScrollLines; + { + if (m_xScrollPixelsPerLine == 0) + *x = sz.x; + else + *x = m_xScrollPixelsPerLine * m_xScrollLines; + } if ( y ) - *y = m_yScrollPixelsPerLine * m_yScrollLines; + { + if (m_yScrollPixelsPerLine == 0) + *y = sz.y; + else + *y = m_yScrollPixelsPerLine * m_yScrollLines; + } } // Where the current view starts from @@ -813,7 +828,7 @@ void wxScrollHelper::GetViewStart (int *x, int *y) const *y = m_yScrollPosition; } -void wxScrollHelper::CalcScrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; @@ -821,7 +836,7 @@ void wxScrollHelper::CalcScrolledPosition(int x, int y, int *xx, int *yy) const *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } -void wxScrollHelper::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; @@ -836,11 +851,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 +1119,22 @@ 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; + } + + // fall back to default for LayoutConstraints + return wxPanel::Layout(); +} + void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event) { // the user code didn't really draw the window if we got here, so set this