Added a examples of virtual size use for setting scrollbars

both 'manually' and via sizer layout to scroll sample.
Tweaked it for various 2.4 idioms that have arisen since
it was written.

Replaced GenericScrolledWin's DoSetVirtualSize, it really is
needed for everything to work for both the user and lib.
Don't call it from default scrolledwindow OnSize handlers
unless AutoLayout is enabled though, and use the larger of
best and client size.  Hopefully this will fix any earlier
troubles this caused with M.

Purged (many) stray tabs &co from sizer.cpp

Changed DoGetBestSize to return wxDefaultSize when no useful
best size can be determined.  If GetBestSize is intended to
return the minimum undistorted size a window can take, we
must be able to discriminate between valid and 'best guess'
sizes, else the best guess windows can only grow.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2002-11-09 13:29:26 +00:00
parent 8b1632ebe7
commit 9064852f8e
8 changed files with 376 additions and 186 deletions

View File

@@ -340,9 +340,11 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
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();
m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
if (do_refresh && !noRefresh)
m_targetWindow->Refresh(TRUE, GetRect());
@@ -867,17 +869,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() );
if( m_win->GetAutoLayout() )
{
if ( m_targetWindow != m_win )
m_targetWindow->FitInside();
m_win->SetVirtualSize( m_win->GetClientSize() );
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
@@ -1171,6 +1175,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