]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/stattext.cpp
Don't call StartingKey if the key was F2
[wxWidgets.git] / src / msw / stattext.cpp
index 59725f6c38f04366612d114e57cf4353734b8869..466fb5484d981a815ee5523f67e20a60a6081e22 100644 (file)
 #if wxUSE_STATTEXT
 
 #ifndef WX_PRECOMP
-#include "wx/event.h"
-#include "wx/app.h"
-#include "wx/brush.h"
+    #include "wx/event.h"
+    #include "wx/app.h"
+    #include "wx/brush.h"
+    #include "wx/dcclient.h"
+    #include "wx/settings.h"
 #endif
 
 #include "wx/stattext.h"
 #include "wx/msw/private.h"
-#include <stdio.h>
 
 #if wxUSE_EXTENDED_RTTI
 WX_DEFINE_FLAGS( wxStaticTextStyle )
@@ -125,10 +126,35 @@ WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
     return msStyle;
 }
 
+WXHBRUSH wxStaticText::DoMSWControlColor(WXHDC pDC, wxColour colBg)
+{
+    // If this control has a non-standard fg colour but still has the standard
+    // bg then we need to also give it a non-standard bg otherwise the fg
+    // setting has no effect.
+    WXHBRUSH hbr = wxControl::DoMSWControlColor(pDC, colBg);
+    if (!hbr && m_hasFgCol)
+    {
+        hbr = MSWGetBgBrushForChild(pDC, this);
+        if (!hbr)
+        {
+            HDC hdc = (HDC)pDC;
+            wxColour bg = GetBackgroundColour();
+            ::SetBkColor(hdc, wxColourToRGB(bg));
+            wxBrush *brush = wxTheBrushList->FindOrCreateBrush(bg, wxSOLID);
+            hbr = (WXHBRUSH)brush->GetResourceHandle();
+        }
+    }
+    return hbr;
+}
+
 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);