m_xScrollPosition = xPos;
m_yScrollPosition = yPos;
- m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
+ // For better backward compatibility we set persisting limits
+ // here not just the size. It makes SetScrollbars 'sticky'
+ // emulating the old non-autoscroll behaviour.
- AdjustScrollbars();
+ wxSize sz = m_targetWindow->GetClientSize();
+#if 1
+ int x = wxMax(noUnitsX * pixelsPerUnitX, sz.x);
+ int y = wxMax(noUnitsY * pixelsPerUnitY, sz.y);
+#else
+ int x = noUnitsX * pixelsPerUnitX;
+ int y = noUnitsY * pixelsPerUnitY;
+#endif
+ m_targetWindow->SetVirtualSizeHints( x, y );
+
+ // The above should arguably be deprecated, this however we still need.
+
+ m_targetWindow->SetVirtualSize( x, y );
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
}
// ----------------------------------------------------------------------------
// 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
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