]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed background appearance for the controls with changed foreground colour
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Dec 2004 20:15:43 +0000 (20:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 19 Dec 2004 20:15:43 +0000 (20:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/control.h
src/msw/control.cpp

index 960c3a994871eea29bfa5aeb19cf5f50d8658742..74000ed3e2d43f350d5e7703bdf7567e13788354 100644 (file)
@@ -120,18 +120,12 @@ protected:
     virtual WXHBRUSH MSWControlColor(WXHDC pDC);
 
     // call this from the derived class MSWControlColor() if you want to show
-    // the control greyed out
+    // the control greyed out (and opaque)
     WXHBRUSH MSWControlColorDisabled(WXHDC pDC);
 
     // call this from the derived class MSWControlColor() if you want to always
     // paint the background (as all opaque controls do)
-    WXHBRUSH MSWControlColorSolid(WXHDC pDC)
-    {
-        return MSWControlColorSolid(pDC, GetBackgroundColour());
-    }
-
-    // common part of the 3 methods above
-    WXHBRUSH MSWControlColorSolid(WXHDC pDC, wxColour colBg);
+    WXHBRUSH MSWControlColorSolid(WXHDC pDC, wxColour colBg = wxNullColour);
 
     // another WM_CTLCOLOR-related function: override this to return the brush
     // which should be used to paint the control background by default
index d32372b29ff15225c84d976a1a189f19458fe9ac..1561c9d470c7085718f58635e4ec6975f2b6cff1 100644 (file)
@@ -337,34 +337,30 @@ WXHBRUSH wxControl::MSWControlColorSolid(WXHDC pDC, wxColour colBg)
     if ( m_hasFgCol )
     {
         ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
-        if ( !colBg.Ok() )
-            colBg = GetBackgroundColour();
     }
 
+    // use the background colour override if a valid colour is given
+    WXHBRUSH hbr;
     if ( colBg.Ok() )
     {
-        ::SetBkColor(hdc, wxColourToRGB(colBg));
-
+        // draw children with the same colour as the parent
         wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg, wxSOLID);
 
-        return (WXHBRUSH)brush->GetResourceHandle();
+        hbr = (WXHBRUSH)brush->GetResourceHandle();
+    }
+    else // use our own background colour and recurse upwards if necessary
+    {
+        hbr = MSWGetBgBrush(pDC);
     }
 
-    return 0;
+    return hbr;
 }
 
 WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
 {
-    WXHBRUSH hbr = MSWControlColorSolid(pDC, m_hasBgCol ? m_backgroundColour
-                                                        : wxNullColour);
-    if ( hbr )
-        return hbr;
-
     ::SetBkMode((HDC)pDC, TRANSPARENT);
 
-    hbr = MSWGetBgBrush(pDC);
-
-    return hbr ? hbr : MSWGetDefaultBgBrush();
+    return MSWControlColorSolid(pDC);
 }
 
 WXHBRUSH wxControl::MSWControlColorDisabled(WXHDC pDC)