Include the size of any window borders (size vs. clientsize

differences) in the window's bestsize


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2005-02-03 22:11:43 +00:00
parent 4719e58dc1
commit 08a19f6407
2 changed files with 21 additions and 6 deletions

View File

@ -39,6 +39,11 @@ All:
- wxGetPowerType() and wxGetBatteryState() addition
- wxSystemSettings::GetSystem*() members deprecated and replaced with
wxSystemSettings::Get*()
- wxWindowBase::DoGetBestSize now includes the difference (if any) between
the client size and total size of the window. Code that sets the
client size using the best size, or that added extra space to sizers
to compensate for this bug may need to be changed.
All (GUI):

View File

@ -508,7 +508,7 @@ void wxWindowBase::Fit()
{
if ( GetChildren().GetCount() > 0 )
{
SetClientSize(GetBestSize());
SetSize(GetBestSize());
}
//else: do nothing if we have no children
}
@ -553,9 +553,11 @@ void wxWindowBase::InvalidateBestSize()
// return the size best suited for the current window
wxSize wxWindowBase::DoGetBestSize() const
{
wxSize best;
if ( m_windowSizer )
{
return m_windowSizer->GetMinSize();
best = m_windowSizer->GetMinSize();
}
#if wxUSE_CONSTRAINTS
else if ( m_constraints )
@ -591,7 +593,7 @@ wxSize wxWindowBase::DoGetBestSize() const
// will never return a size bigger than the current one :-(
}
return wxSize(maxX, maxY);
best = wxSize(maxX, maxY);
}
#endif // wxUSE_CONSTRAINTS
else if ( !GetChildren().empty()
@ -643,17 +645,25 @@ wxSize wxWindowBase::DoGetBestSize() const
maxX += 7;
maxY += 14;
return wxSize(maxX, maxY);
best = wxSize(maxX, maxY);
}
else // ! has children
{
// for a generic window there is no natural best size - just use either the
// minimum size if there is one, or the current size
// For a generic window there is no natural best size - just use
// either the minimum size if there is one, or the current size.
// These are returned as-is, unadjusted by the client size difference.
if ( GetMinSize().IsFullySpecified() )
return GetMinSize();
else
return GetSize();
}
// 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;
}