]> git.saurik.com Git - wxWidgets.git/commitdiff
removed (unused) nCtlColor parameter of OnCtlColor(); added MSWControlColor(); implem...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Nov 2004 18:37:42 +0000 (18:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 19 Nov 2004 18:37:42 +0000 (18:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 5862700b8be0bf604aa23e79b11ac07a709fff7c..e3669c8c0803979c768a84c95746041abc8faae9 100644 (file)
@@ -70,8 +70,7 @@ public:
 
     const wxArrayLong& GetSubcontrols() const { return m_subControls; }
 
-    virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
-            WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
+    virtual WXHBRUSH MSWControlColor(WXHDC pDC);
 
 protected:
     // choose the default border for this window
index d0a8877e372f2938220b4d07b7b43a2e6eb86e76..996e063f8a4b2e856ff86691ee952988a4c70541 100644 (file)
@@ -257,7 +257,7 @@ public:
     void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
                       WXWORD *code, WXWORD *pos, WXHWND *hwnd);
     void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
-                        WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd);
+                        WXHDC *hdc, WXHWND *hwnd);
     void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
                           WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
 
@@ -308,7 +308,6 @@ public:
     bool HandleCtlColor(WXHBRUSH *hBrush,
                         WXHDC hdc,
                         WXHWND hWnd,
-                        WXUINT nCtlColor,
                         WXUINT message,
                         WXWPARAM wParam,
                         WXLPARAM lParam);
@@ -368,6 +367,9 @@ public:
 
     // this function should return the brush to paint the window background
     // with or 0 for the default brush
+    virtual WXHBRUSH MSWControlColor(WXHDC hDC);
+
+    // deprecated, for compatibility only: override MSWControlColor instead
     virtual WXHBRUSH OnCtlColor(WXHDC hDC,
                                 WXHWND hWnd,
                                 WXUINT nCtlColor,
index d268cc6a5dad7c195c7ec19bbf0b2ddb91be976e..2dc7d3e0e909325ba0340eff098d54f8908e1f66 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>
@@ -322,35 +327,49 @@ bool wxControl::MSWOnNotify(int idCtrl,
 }
 #endif // Win95
 
-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 )
+    HDC hdc = (HDC)pDC;
+    if ( m_hasFgCol )
+        ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
+
+    if ( m_hasBgCol )
     {
-        HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
-        return (WXHBRUSH) hbrush;
-    }
-#endif // wxUSE_CTL3D
+        wxColour colBack = GetBackgroundColour();
 
-    HDC hdc = (HDC)pDC;
-    wxColour colBack = GetBackgroundColour();
+        ::SetBkColor(hdc, wxColourToRGB(colBack));
 
-    ::SetBkColor(hdc, wxColourToRGB(colBack));
-    ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
+        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
+
+        return (WXHBRUSH)brush->GetResourceHandle();
+    }
 
-    wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
+    SetBkMode(hdc, TRANSPARENT);
+
+#if wxUSE_UXTHEME && wxUSE_NOTEBOOK
+    if ( wxUxThemeEngine::GetIfActive() )
+    {
+        for ( wxWindow *win = this; win; win = win->GetParent() )
+        {
+            wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
+            if ( nbook )
+            {
+                WXHBRUSH hbr = nbook->GetThemeBackgroundBrush();
+                if ( hbr )
+                {
+                    RECT rc;
+                    GetWindowRect(GetHwnd(), &rc);
+
+                    MapWindowPoints(NULL, GetHwndOf(nbook), (POINT *)&rc, 1);
+                    SetBrushOrgEx(hdc, -rc.left, -rc.top, NULL);
+                    return hbr;
+                }
+            }
+        }
+    }
+#endif // wxUSE_UXTHEME
 
-    return (WXHBRUSH)brush->GetResourceHandle();
+    return GetStockObject(NULL_BRUSH);
 }
 
 // ---------------------------------------------------------------------------
index 70f74831c8063ff4a9a0abfaa43c4a2971bfc0f8..ec18e90f2558c0fa658a94de16bdd4e76978a00e 100644 (file)
@@ -1814,7 +1814,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
 
         // here we try to do all the job which ::IsDialogMessage() usually does
         // internally
-#if 1
         if ( msg->message == WM_KEYDOWN )
         {
             bool bCtrlDown = wxIsCtrlDown();
@@ -1971,35 +1970,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                 }
             }
         }
-#else // 0
-        // let ::IsDialogMessage() do almost everything and handle just the
-        // things it doesn't here: Ctrl-TAB for switching notebook pages
-        if ( msg->message == WM_KEYDOWN )
-        {
-            // don't process system keys here
-            if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) )
-            {
-                if ( (msg->wParam == VK_TAB) && wxIsCtrlDown() )
-                {
-                    // find the first notebook parent and change its page
-                    wxWindow *win = this;
-                    wxNotebook *nbook = NULL;
-                    while ( win && !nbook )
-                    {
-                        nbook = wxDynamicCast(win, wxNotebook);
-                        win = win->GetParent();
-                    }
-
-                    if ( nbook )
-                    {
-                        bool forward = !wxIsShiftDown();
-
-                        nbook->AdvanceSelection(forward);
-                    }
-                }
-            }
-        }
-#endif // 1/0
 
         // don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
         // message even when there is no cancel button and when the message is
@@ -2147,13 +2117,10 @@ void wxWindowMSW::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
 }
 
 void wxWindowMSW::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
-                              WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
+                                 WXHDC *hdc, WXHWND *hwnd)
 {
-#ifndef __WXMICROWIN__
-    *nCtlColor = CTLCOLOR_BTN;
     *hwnd = (WXHWND)lParam;
     *hdc = (WXHDC)wParam;
-#endif
 }
 
 void wxWindowMSW::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
@@ -2725,7 +2692,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
             break;
 
         // CTLCOLOR messages are sent by children to query the parent for their
-        // colors#ifndef __WXMICROWIN__
+        // colors
 #ifndef __WXMICROWIN__
         case WM_CTLCOLORMSGBOX:
         case WM_CTLCOLOREDIT:
@@ -2735,15 +2702,13 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
         case WM_CTLCOLORSCROLLBAR:
         case WM_CTLCOLORSTATIC:
             {
-                WXWORD nCtlColor;
                 WXHDC hdc;
                 WXHWND hwnd;
-                UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
+                UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
 
                 processed = HandleCtlColor(&rc.hBrush,
                                            (WXHDC)hdc,
                                            (WXHWND)hwnd,
-                                           nCtlColor,
                                            message,
                                            wParam,
                                            lParam);
@@ -3773,50 +3738,40 @@ bool wxWindowMSW::HandleDisplayChange()
     return GetEventHandler()->ProcessEvent(event);
 }
 
-bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
-                              WXHDC pDC,
-                              WXHWND pWnd,
-                              WXUINT nCtlColor,
-                              WXUINT message,
-                              WXWPARAM wParam,
-                              WXLPARAM lParam)
-{
 #ifndef __WXMICROWIN__
-    WXHBRUSH hBrush = 0;
 
-#ifdef __WXWINCE__
-    if (false)
-#else
-    if ( nCtlColor == CTLCOLOR_DLG )
-#endif
-    {
-        hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
-    }
+bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush,
+                                 WXHDC pDC,
+                                 WXHWND pWnd,
+                                 WXUINT message,
+                                 WXWPARAM wParam,
+                                 WXLPARAM lParam)
+{
 #if wxUSE_CONTROLS
+    wxControl *item = (wxControl *)FindItemByHWND(pWnd, true);
+    if ( item )
+        *brush = item->OnCtlColor(pDC, pWnd, 0, message, wParam, lParam);
     else
-    {
-        wxControl *item = (wxControl *)FindItemByHWND(pWnd, true);
-        if ( item )
-            hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
-    }
 #endif // wxUSE_CONTROLS
+        *brush = NULL;
 
-    if ( hBrush )
-        *brush = hBrush;
-
-    return hBrush != 0;
-#else // __WXMICROWIN__
-    return false;
-#endif
+    return *brush != NULL;
 }
 
+#endif // __WXMICROWIN__
+
 // Define for each class of dialog and control
-WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC WXUNUSED(hDC),
+WXHBRUSH wxWindowMSW::OnCtlColor(WXHDC hDC,
                                  WXHWND WXUNUSED(hWnd),
                                  WXUINT WXUNUSED(nCtlColor),
                                  WXUINT WXUNUSED(message),
                                  WXWPARAM WXUNUSED(wParam),
                                  WXLPARAM WXUNUSED(lParam))
+{
+    return MSWControlColor(hDC);
+}
+
+WXHBRUSH wxWindowMSW::MSWControlColor(WXHDC WXUNUSED(hDC))
 {
     return (WXHBRUSH)0;
 }
@@ -4070,43 +4025,52 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
 
 void wxWindowMSW::OnEraseBackground(wxEraseEvent& event)
 {
-    if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
+    switch ( GetBackgroundStyle() )
     {
-        // don't skip the event here, custom background means that the app is
-        // drawing it itself in its OnPaint()
-        return;
-    }
-
-    if ( !m_hasBgCol )
-    {
-        event.Skip();
-        return;
-    }
+        default:
+            wxFAIL_MSG( _T("unexpected background style") );
+            // fall through
 
-    // we have a fixed solid background colour, do use it
-    RECT rect;
-    ::GetClientRect(GetHwnd(), &rect);
+        case wxBG_STYLE_CUSTOM:
+            // don't skip the event here, custom background means that the app
+            // is drawing it itself in its OnPaint()
+            break;
 
-    wxColour backgroundColour(GetBackgroundColour());
-    COLORREF ref = PALETTERGB(backgroundColour.Red(),
-                              backgroundColour.Green(),
-                              backgroundColour.Blue());
-    HBRUSH hBrush = ::CreateSolidBrush(ref);
-    if ( !hBrush )
-        wxLogLastError(wxT("CreateSolidBrush"));
+        case wxBG_STYLE_SYSTEM:
+#if wxUSE_NOTEBOOK && wxUSE_UXTHEME
+            // automatically apply the tab control theme background to any
+            // child panels to have the same look as the native property sheet
+            // dialogs
+            {
+                for ( wxWindow *win = this; win; win = win->GetParent() )
+                {
+                    wxNotebook *nbook = wxDynamicCast(win, wxNotebook);
+                    if ( nbook )
+                    {
+                        nbook->DoEraseBackground(event);
+                        return;
+                    }
+                }
+            }
+#endif // wxUSE_NOTEBOOK
+            event.Skip();
+            break;
 
-    HDC hdc = (HDC)event.GetDC()->GetHDC();
+        case wxBG_STYLE_COLOUR:
+            // we have a fixed solid background colour, do use it
+            RECT rect;
+            ::GetClientRect(GetHwnd(), &rect);
 
-#ifndef __WXWINCE__
-    int mode = ::SetMapMode(hdc, MM_TEXT);
-#endif
+            HBRUSH hBrush = ::CreateSolidBrush(
+                                    wxColourToPalRGB(GetBackgroundColour()));
+            if ( !hBrush )
+                wxLogLastError(wxT("CreateSolidBrush"));
 
-    ::FillRect(hdc, &rect, hBrush);
-    ::DeleteObject(hBrush);
+            HDC hdc = GetHdcOf((*event.GetDC()));
 
-#ifndef __WXWINCE__
-    ::SetMapMode(hdc, mode);
-#endif
+            ::FillRect(hdc, &rect, hBrush);
+            ::DeleteObject(hBrush);
+    }
 }
 
 // ---------------------------------------------------------------------------