Honour window min and max sizes in wxWindow::GetBestSize().

The best size of the window should be at least as large as its min size and
less than its max size. This allows to override the windows own best size
determination with an explicit SetMinSize() or SetMaxSize() call.

See #11497.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-08-15 23:34:18 +00:00
parent 7d17499993
commit 054fdb68eb
3 changed files with 46 additions and 6 deletions

View File

@@ -906,14 +906,19 @@ wxSize wxWindowBase::GetBestSize() const
// 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
@@ -938,12 +943,16 @@ void wxWindowBase::SetMinSize(const wxSize& minSize)
{
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)