]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/stattext.cpp
added GetCurrentSelection(); made GetSelection() behave as documented (and not as...
[wxWidgets.git] / src / msw / stattext.cpp
index 89538fc88481e375411f2eb4ad5b7ac9796499b1..7eaa18b562f7638180c40fcb94065205469913c9 100644 (file)
@@ -129,7 +129,11 @@ WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
 wxSize wxStaticText::DoGetBestSize() const
 {
     wxClientDC dc(wx_const_cast(wxStaticText *, this));
 wxSize wxStaticText::DoGetBestSize() const
 {
     wxClientDC dc(wx_const_cast(wxStaticText *, this));
-    dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+    wxFont font(GetFont());
+    if (!font.Ok())
+        font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+
+    dc.SetFont(font);
 
     wxCoord widthTextMax, heightTextTotal;
     dc.GetMultiLineTextExtent(GetLabel(), &widthTextMax, &heightTextTotal);
 
     wxCoord widthTextMax, heightTextTotal;
     dc.GetMultiLineTextExtent(GetLabel(), &widthTextMax, &heightTextTotal);
@@ -139,7 +143,40 @@ wxSize wxStaticText::DoGetBestSize() const
         widthTextMax += 2;
 #endif // __WXWINCE__
 
         widthTextMax += 2;
 #endif // __WXWINCE__
 
-    return wxSize(widthTextMax, heightTextTotal);
+    // 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;
 }
 
 void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags)
 }
 
 void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags)