take border into account in best size calculations

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35006 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-07-29 23:25:08 +00:00
parent 4fa8085100
commit 7a0e7e55d8
2 changed files with 33 additions and 1 deletions

View File

@ -33,6 +33,7 @@ wxMSW:
- Handle absence of wxListCtrl column image better (Zbigniew Zagórski)
- Fixed asynchronous playback of large sound files in wxSound
- Added wxDynamicLibrary::GetSymbolAorW()
- Fixed default size of wxStaticText controls with border being too small
wxWinCE:

View File

@ -132,7 +132,7 @@ wxSize wxStaticText::DoGetBestSize() const
wxFont font(GetFont());
if (!font.Ok())
font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
dc.SetFont(font);
wxCoord widthTextMax, heightTextTotal;
@ -143,6 +143,37 @@ wxSize wxStaticText::DoGetBestSize() const
widthTextMax += 2;
#endif // __WXWINCE__
// border takes extra space
//
// TODO: this is probably not wxStaticText-specific and should be moved
wxCoord border;
switch ( GetBorder() )
{
case wxBORDER_STATIC:
case wxBORDER_SIMPLE:
border = 1;
break;
case wxBORDER_SUNKEN:
border = 2;
break;
case wxBORDER_RAISED:
case wxBORDER_DOUBLE:
border = 3;
break;
default:
wxFAIL_MSG( _T("unknown border style") );
// fall through
case wxBORDER_NONE:
border = 0;
}
widthTextMax += 2*border;
heightTextTotal += 2*border;
wxSize best(widthTextMax, heightTextTotal);
CacheBestSize(best);
return best;