]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/control.cpp
reverted, the problem is deeper than that
[wxWidgets.git] / src / msw / control.cpp
index ef6dfe5b9850f356ec63fff425351c22c03429fa..30bc08f49805b45ea0428e4bf5ab2bd4c377ef6a 100644 (file)
 
 #include "wx/control.h"
 
+#if wxUSE_NOTEBOOK
+    #include "wx/notebook.h"
+#endif // wxUSE_NOTEBOOK
+
 #include "wx/msw/private.h"
+#include "wx/msw/uxtheme.h"
 
 #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
     #include <commctrl.h>
 
 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
 
-BEGIN_EVENT_TABLE(wxControl, wxWindow)
-    EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground)
-END_EVENT_TABLE()
-
 // ============================================================================
 // wxControl implementation
 // ============================================================================
@@ -326,60 +327,60 @@ bool wxControl::MSWOnNotify(int idCtrl,
 }
 #endif // Win95
 
-void wxControl::OnEraseBackground(wxEraseEvent& event)
+WXHBRUSH wxControl::MSWControlColorSolid(WXHDC pDC, wxColour colBg)
 {
-    // notice that this 'dumb' implementation may cause flicker for some of the
-    // controls in which case they should intercept wxEraseEvent and process it
-    // themselves somehow
-
-    RECT rect;
-    ::GetClientRect(GetHwnd(), &rect);
+    HDC hdc = (HDC)pDC;
+    if ( m_hasFgCol )
+        ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
 
-    HBRUSH hBrush = ::CreateSolidBrush(wxColourToRGB(GetBackgroundColour()));
+    if ( colBg.Ok() )
+    {
+        ::SetBkColor(hdc, wxColourToRGB(colBg));
 
-    HDC hdc = GetHdcOf((*event.GetDC()));
+        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg, wxSOLID);
 
-#ifndef __WXWINCE__
-    int mode = ::SetMapMode(hdc, MM_TEXT);
-#endif
-
-    ::FillRect(hdc, &rect, hBrush);
-    ::DeleteObject(hBrush);
+        return (WXHBRUSH)brush->GetResourceHandle();
+    }
 
-#ifndef __WXWINCE__
-    ::SetMapMode(hdc, mode);
-#endif
+    return 0;
 }
 
-WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
-#if wxUSE_CTL3D
-                               WXUINT message,
-                               WXWPARAM wParam,
-                               WXLPARAM lParam
-#else
-                               WXUINT WXUNUSED(message),
-                               WXWPARAM WXUNUSED(wParam),
-                               WXLPARAM WXUNUSED(lParam)
-#endif
-    )
+WXHBRUSH wxControl::MSWControlColor(WXHDC pDC)
 {
-#if wxUSE_CTL3D
-    if ( m_useCtl3D )
-    {
-        HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
-        return (WXHBRUSH) hbrush;
-    }
-#endif // wxUSE_CTL3D
+    WXHBRUSH hbr = MSWControlColorSolid(pDC, m_hasBgCol ? m_backgroundColour
+                                                        : wxNullColour);
+    if ( hbr )
+        return hbr;
 
-    HDC hdc = (HDC)pDC;
-    wxColour colBack = GetBackgroundColour();
+    ::SetBkMode((HDC)pDC, TRANSPARENT);
 
-    ::SetBkColor(hdc, wxColourToRGB(colBack));
-    ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
+#if wxUSE_UXTHEME && wxUSE_NOTEBOOK
+    if ( wxUxThemeEngine::GetIfActive() )
+    {
+        for ( wxWindow *win = this; win; win = win->GetParent() )
+        {
+            wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
+            if ( nbook )
+            {
+                // return value may be NULL but it is ok: if the first parent
+                // notebook doesn't use themes, then we don't have to process
+                // this message at all, so let default processing take place
+                return nbook->GetThemeBackgroundBrush(pDC, this);
+            }
+        }
+    }
+#endif // wxUSE_UXTHEME
 
-    wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
+    return ::GetStockObject(NULL_BRUSH);
+}
 
-    return (WXHBRUSH)brush->GetResourceHandle();
+WXHBRUSH wxControl::MSWControlColorDisabled(WXHDC pDC)
+{
+    return MSWControlColorSolid
+           (
+                pDC,
+                wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)
+           );
 }
 
 // ---------------------------------------------------------------------------