-bool wxGenericScrolledWindow::Layout()
-{
- if (GetSizer() && m_targetWindow == this)
- {
- // If we're the scroll target, 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::DoSetVirtualSize(int x, int y)
-{
- wxPanel::DoSetVirtualSize( x, y );
- AdjustScrollbars();
-
- if (GetAutoLayout())
- Layout();
-}
-
-// wxWindow's GetBestVirtualSize returns the actual window size,
-// whereas we want to return the virtual size
-wxSize wxGenericScrolledWindow::GetBestVirtualSize() const
-{
- wxSize clientSize( GetClientSize() );
- if (GetSizer())
- {
- wxSize minSize( GetSizer()->CalcMin() );
-
- return wxSize( wxMax( clientSize.x, minSize.x ), wxMax( clientSize.y, minSize.y ) );
- }
- else
- return clientSize;
-}
-
-// return the size best suited for the current window
-// (this isn't a virtual size, this is a sensible size for the window)
-wxSize wxGenericScrolledWindow::DoGetBestSize() const
-{
- wxSize best;
-
- if ( GetSizer() )
- {
- wxSize b = GetSizer()->GetMinSize();
-
- // Only use the content to set the window size in the direction
- // where there's no scrolling; otherwise we're going to get a huge
- // window in the direction in which scrolling is enabled
- int ppuX, ppuY;
- GetScrollPixelsPerUnit(& ppuX, & ppuY);
-
- wxSize minSize;
- if ( GetMinSize().IsFullySpecified() )
- minSize = GetMinSize();
- else
- minSize = GetSize();
-
- if (ppuX > 0)
- b.x = minSize.x;
- if (ppuY > 0)
- b.y = minSize.y;
- best = b;
- }
- else
- return wxWindow::DoGetBestSize();
-
- // Add any difference between size and client size
- wxSize diff = GetSize() - GetClientSize();
- best.x += wxMax(0, diff.x);
- best.y += wxMax(0, diff.y);
-
- return best;
-}
-
-void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event)