]> git.saurik.com Git - wxWidgets.git/commitdiff
No changes, just refactor wxMSW background brush methods.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Mar 2011 00:00:29 +0000 (00:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Mar 2011 00:00:29 +0000 (00:00 +0000)
Factor out MSWGetCustomBgBrush() from MSWGetBgBrushForChild(). This is useful
as in the vast majority of cases the parent window will want to use the same
background brush for all of its children so it doesn't really care about the
concrete child passed to MSWGetBgBrushForChild() and we can adjust the brush
to the child origin in the common code instead of asking each derived class
overriding MSWGetBgBrushForChild() to do this.

This doesn't change anything but will make the upcoming changes to wxPanel
background painting simpler.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index ac3a69cb5b5ff2bde7a29a4e661eb125445ab4b8..70993e4d617cb220fdc52e308b6b8caf2453bd2b 100644 (file)
@@ -142,9 +142,6 @@ public:
       return true;
   }
 
-  // return the themed brush for painting our children
-  virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child);
-
   // draw child background
   virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
 
@@ -174,6 +171,9 @@ protected:
   void AdjustPageSize(wxNotebookPage *page);
 
 #if wxUSE_UXTHEME
+  // return the themed brush for painting our children
+  virtual WXHBRUSH MSWGetCustomBgBrush() { return m_hbrBackground; }
+
   // gets the bitmap of notebook background and returns a brush from it
   WXHBRUSH QueryBgBitmap();
 
index 64b95f9cd521252fcd760dccd3159f81cb12a3b4..2a76c1e17593bc6737909ef5b02a3045ca47d58d 100644 (file)
@@ -388,6 +388,18 @@ public:
     virtual void MSWDestroyWindow();
 
 
+    // Functions dealing with painting the window background. The derived
+    // classes should normally only need to reimplement MSWGetBgBrush() if they
+    // need to use a non-solid brush for erasing their background. This
+    // function is called by MSWGetBgBrushForChild() which only exists for the
+    // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by
+    // MSWGetBgBrush() to actually find the right brush to use.
+
+    // The brush returned from here must remain valid at least until the next
+    // event loop iteration. Returning 0, as is done by default, indicates
+    // there is no custom background brush.
+    virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; }
+
     // this function should return the brush to paint the children controls
     // background or 0 if this window doesn't impose any particular background
     // on its children
index ea0df3addfd2b4e1d0fda98a131c2a01c9eec3c8..db3df7f5387404d1f4b0493b5d40716ad57d0f42 100644 (file)
@@ -1146,28 +1146,6 @@ void wxNotebook::UpdateBgBrush()
     }
 }
 
-WXHBRUSH wxNotebook::MSWGetBgBrushForChild(WXHDC hDC, wxWindow *child)
-{
-    if ( m_hbrBackground )
-    {
-        // before drawing with the background brush, we need to position it
-        // correctly
-        RECT rc;
-        ::GetWindowRect(GetHwndOf(child), &rc);
-
-        ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
-
-        if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
-        {
-            wxLogLastError(wxT("SetBrushOrgEx(notebook bg brush)"));
-        }
-
-        return m_hbrBackground;
-    }
-
-    return wxNotebookBase::MSWGetBgBrushForChild(hDC, child);
-}
-
 bool wxNotebook::MSWPrintChild(WXHDC hDC, wxWindow *child)
 {
     // solid background colour overrides themed background drawing
index a310475417b7de62d15bbcd49d0a80f2230287d8..d982f3ed224b5bd51255aefbfa193c8fb5cc9f2e 100644 (file)
@@ -4884,9 +4884,30 @@ bool wxWindowMSW::DoEraseBackground(WXHDC hDC)
 }
 
 WXHBRUSH
-wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC),
-                                   wxWindowMSW * WXUNUSED(child))
+wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)
 {
+    // Test for the custom background brush first.
+    WXHBRUSH hbrush = MSWGetCustomBgBrush();
+    if ( hbrush )
+    {
+        // We assume that this is either a stipple or hatched brush and not a
+        // solid one as otherwise it would have been enough to set the
+        // background colour and such brushes need to be positioned correctly
+        // in order to align when different windows are painted, so do it here.
+        RECT rc;
+        ::GetWindowRect(GetHwndOf(child), &rc);
+
+        ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
+
+        if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
+        {
+            wxLogLastError(wxT("SetBrushOrgEx(bg brush)"));
+        }
+
+        return hbrush;
+    }
+
+    // Otherwise see if we have a custom background colour.
     if ( m_hasBgCol )
     {
         wxBrush *