X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b056ef54f29582e2a5154bf148f7ebc5877b51b..008a56c968ed7e0694e32e93c2dbf95dde2ba5c8:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 489db5bbf7..8c40ecb853 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -340,16 +340,28 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX, m_xScrollPosition = xPos; m_yScrollPosition = yPos; + // For better backward compatibility we set persisting limits + // here not just the size. It makes SetScrollbars 'sticky' + // emulating the old non-autoscroll behaviour. + m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); - AdjustScrollbars(); + // The above should arguably be deprecated, this however we still need. + + m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); if (do_refresh && !noRefresh) m_targetWindow->Refresh(TRUE, GetRect()); + // TODO: check if we can use AdjustScrollbars always. +#ifdef __WXUNIVERSAL__ + AdjustScrollbars(); +#else + // This is also done by AdjustScrollbars, above #ifdef __WXMAC__ m_targetWindow->MacUpdateImmediately() ; #endif +#endif } // ---------------------------------------------------------------------------- @@ -867,17 +879,19 @@ void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) co // Default OnSize resets scrollbars, if any void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) { - if ( m_targetWindow != m_win ) - m_targetWindow->SetVirtualSize( m_targetWindow->GetClientSize() ); - - m_win->SetVirtualSize( m_win->GetClientSize() ); + if( m_win->GetAutoLayout() ) + { + if ( m_targetWindow != m_win ) + m_targetWindow->FitInside(); - AdjustScrollbars(); + m_win->FitInside(); #if wxUSE_CONSTRAINTS - if (m_win->GetAutoLayout()) m_win->Layout(); #endif + } + else + AdjustScrollbars(); } // This calls OnDraw, having adjusted the origin according to the current @@ -1084,10 +1098,6 @@ void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event) #if wxUSE_MOUSEWHEEL -#ifndef WHEEL_PAGESCROLL -#define WHEEL_PAGESCROLL (UINT_MAX) // signifies to scroll a page -#endif - void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) { m_wheelRotation += event.GetWheelRotation(); @@ -1103,7 +1113,7 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) newEvent.SetOrientation(wxVERTICAL); newEvent.m_eventObject = m_win; - if (event.GetLinesPerAction() == WHEEL_PAGESCROLL) + if (event.IsPageScroll()) { if (lines > 0) newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; @@ -1175,6 +1185,17 @@ bool wxGenericScrolledWindow::Layout() return wxPanel::Layout(); } +void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y) +{ + wxPanel::DoSetVirtualSize( x, y ); + AdjustScrollbars(); + +#if wxUSE_CONSTRAINTS + if (GetAutoLayout()) + Layout(); +#endif +} + void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event) { // the user code didn't really draw the window if we got here, so set this