Provided GetBestVirtualSize and DoGetBestSize implementations for
generic and GTK+ wxScrolledWindow. wxWindowBase::DoGetBestSize was returning a virtual size if there were child controls, which was then used to set the scrolled window actual size. Similarly, wxWindowBase::GetBestVirtualSize was returning the actual window size; now we return the virtual size for dimensions that have scrolling (e.g. vertical scrolling direction), or the minimum/actual size for those that don't (e.g. the maximum control width if there is no horizontal scrolling). This allows the scrolled window to be properly sized, whereas before it would start off at the virtual size (giving enormous layouts). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32866 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1283,6 +1283,60 @@ void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y)
|
||||
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)
|
||||
{
|
||||
// the user code didn't really draw the window if we got here, so set this
|
||||
|
Reference in New Issue
Block a user