]> git.saurik.com Git - wxWidgets.git/commitdiff
call GetTextExtent() after selecting the correct font into DC in PaintForeground...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Mar 2007 02:25:25 +0000 (02:25 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Mar 2007 02:25:25 +0000 (02:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45007 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/statbox.cpp

index 40b841f56ac450b575abe69a2d60c71f488970b3..ffb1b61f2de70d0d21f7bcb75f70b337a0132b62 100644 (file)
@@ -402,37 +402,6 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc)
 
         // Get dimensions of the label
         const wxString label = GetLabel();
-        int width, height;
-        dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics),
-                         &width, &height);
-
-        int x;
-        int y = height;
-
-        // first we need to correctly paint the background of the label
-        // as Windows ignores the brush offset when doing it
-        //
-        // FIXME: value of x is hardcoded as this is what it is on my system,
-        //        no idea if it's true everywhere
-        RECT dimensions = {0, 0, 0, y};
-        if ( !rtl )
-        {
-            x = 9;
-            dimensions.left = x;
-            dimensions.right = x + width;
-        }
-        else
-        {
-            x = rc.right - 7;
-            dimensions.left = x - width;
-            dimensions.right = x;
-        }
-
-        // need to adjust the rectangle to cover all the label background
-        dimensions.left -= 2;
-        dimensions.right += 2;
-        dimensions.bottom += 2;
-        PaintBackground(dc, dimensions);
 
         // choose the correct font
         AutoHFONT font;
@@ -482,6 +451,40 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc)
             }
         }
 
+        // Get the font extent
+        int width, height;
+        dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics),
+                         &width, &height);
+
+        int x;
+        int y = height;
+
+        // first we need to correctly paint the background of the label
+        // as Windows ignores the brush offset when doing it
+        //
+        // FIXME: value of x is hardcoded as this is what it is on my system,
+        //        no idea if it's true everywhere
+        RECT dimensions = {0, 0, 0, y};
+        if ( !rtl )
+        {
+            x = 9;
+            dimensions.left = x;
+            dimensions.right = x + width;
+        }
+        else
+        {
+            x = rc.right - 7;
+            dimensions.left = x - width;
+            dimensions.right = x;
+        }
+
+        // need to adjust the rectangle to cover all the label background
+        dimensions.left -= 2;
+        dimensions.right += 2;
+        dimensions.bottom += 2;
+
+        PaintBackground(dc, dimensions);
+
         // now draw the text
         if ( !rtl )
         {