From 7a0e7e55d82e9c897c4bb1deff46967d52db29cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Jul 2005 23:25:08 +0000 Subject: [PATCH] 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 --- docs/changes.txt | 1 + src/msw/stattext.cpp | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 645b134a33..e7bdd42415 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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: diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index cc4b995d2d..7eaa18b562 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -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; -- 2.45.2