]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/notebook.cpp
Added licence line
[wxWidgets.git] / src / msw / notebook.cpp
index 13c06febc05a6001d1d52f6249ae358add205b18..eef37234b2465b4e709b8305d428ea96a1b789c0 100644 (file)
@@ -25,6 +25,7 @@
 // wxWidgets
 #ifndef WX_PRECOMP
   #include  "wx/string.h"
 // wxWidgets
 #ifndef WX_PRECOMP
   #include  "wx/string.h"
+  #include  "wx/dc.h"
 #endif  // WX_PRECOMP
 
 #include  "wx/log.h"
 #endif  // WX_PRECOMP
 
 #include  "wx/log.h"
@@ -888,32 +889,44 @@ void wxNotebook::UpdateBgBrush()
     }
 }
 
     }
 }
 
-void wxNotebook::DoEraseBackground(wxEraseEvent& event)
+WXHBRUSH wxNotebook::GetThemeBackgroundBrush(WXHDC hDC, wxWindow *win) const
 {
 {
-    // we can either draw the background ourselves or let DrawThemeBackground()
-    // do it, but as we already have the correct brush, let's do it ourselves
-    // (note that we use the same code in wxControl::MSWControlColor(), so if
-    // it breaks, it should at least break in consistent way)
     if ( m_hbrBackground )
     {
         // before drawing with the background brush, we need to position it
         // correctly
     if ( m_hbrBackground )
     {
         // before drawing with the background brush, we need to position it
         // correctly
-        wxWindow *win = (wxWindow *)event.GetEventObject();
-
         RECT rc;
         ::GetWindowRect(GetHwndOf(win), &rc);
 
         ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
 
         RECT rc;
         ::GetWindowRect(GetHwndOf(win), &rc);
 
         ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
 
-        HDC hdc = GetHdcOf(*event.GetDC());
-        if ( !::SetBrushOrgEx(hdc, -rc.left, -rc.top, NULL) )
+        if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
         {
             wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)"));
         }
         {
             wxLogLastError(_T("SetBrushOrgEx(notebook bg brush)"));
         }
+    }
 
 
+    return m_hbrBackground;
+}
+
+void wxNotebook::DoEraseBackground(wxEraseEvent& event)
+{
+    DoEraseBackground((wxWindow *)event.GetEventObject(),
+                      (WXHDC)GetHdcOf(*event.GetDC()));
+}
+
+void wxNotebook::DoEraseBackground(wxWindow *win, WXHDC hDC)
+{
+    // we can either draw the background ourselves or let DrawThemeBackground()
+    // do it, but as we already have the correct brush, let's do it ourselves
+    // (note that we use the same code in wxControl::MSWControlColor(), so if
+    // it breaks, it should at least break in consistent way)
+    WXHBRUSH hbr = GetThemeBackgroundBrush(hDC, win);
+    if ( hbr )
+    {
         RECT rectClient;
         ::GetClientRect(GetHwndOf(win), &rectClient);
         RECT rectClient;
         ::GetClientRect(GetHwndOf(win), &rectClient);
-        ::FillRect(hdc, &rectClient, (HBRUSH)m_hbrBackground);
+        ::FillRect((HDC)hDC, &rectClient, (HBRUSH)hbr);
     }
 }
 
     }
 }