// fits the window around the children
void wxWindowBase::Fit()
{
- if ( !GetChildren().empty() )
- {
- SetSize(GetBestSize());
- }
- //else: do nothing if we have no children
+ SetSize(GetBestSize());
}
// fits virtual size (ie. scrolled area etc.) around children
void wxWindowBase::FitInside()
{
- if ( GetChildren().GetCount() > 0 )
- {
- SetVirtualSize( GetBestVirtualSize() );
- }
+ SetVirtualSize( GetBestVirtualSize() );
}
// On Mac, scrollbars are explicitly children.
// it to be used
wxSize size = DoGetBestClientSize();
if ( size != wxDefaultSize )
- {
size += DoGetBorderSize();
+ else
+ size = DoGetBestSize();
- CacheBestSize(size);
- return size;
- }
+ // Ensure that the best size is at least as large as min size.
+ size.IncTo(GetMinSize());
- return DoGetBestSize();
+ // And not larger than max size.
+ size.DecToIfSpecified(GetMaxSize());
+
+ // Finally cache result and return.
+ CacheBestSize(size);
+ return size;
}
int wxWindowBase::GetBestHeight(int width) const
{
m_minWidth = minSize.x;
m_minHeight = minSize.y;
+
+ InvalidateBestSize();
}
void wxWindowBase::SetMaxSize(const wxSize& maxSize)
{
m_maxWidth = maxSize.x;
m_maxHeight = maxSize.y;
+
+ InvalidateBestSize();
}
void wxWindowBase::SetInitialSize(const wxSize& size)
{
const wxWindowBase * const parent = wxGetTopLevelParent((wxWindow*)this);
+ wxCHECK_MSG( parent, wxDefaultSize, wxS("Must have TLW parent") );
+
if ( !parent->m_font.IsOk() )
{
// Default GUI font is used. This is the most common case, so