]> git.saurik.com Git - wxWidgets.git/commitdiff
Account for scrolling when setting the background brush origin in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Feb 2013 16:14:03 +0000 (16:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Feb 2013 16:14:03 +0000 (16:14 +0000)
We must use physical coordinates for the brush origin to account for the
coordinates offset in scrolled windows, so add MSWAdjustBrushOrg() and call it
from MSWGetBgBrushForChild().

Closes #14917.

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

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

index b465d05814e35d226364759208f0b42c7cb1a6b3..564f78f2d74aea725c39e19af7a6a61083f788de 100644 (file)
@@ -410,6 +410,17 @@ public:
     // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by
     // MSWGetBgBrush() to actually find the right brush to use.
 
+    // Adjust the origin for the brush returned by MSWGetBgBrushForChild().
+    //
+    // This needs to be overridden for scrolled windows to ensure that the
+    // scrolling of their associated DC is taken into account.
+    //
+    // Both parameters must be non-NULL.
+    virtual void MSWAdjustBrushOrg(int* WXUNUSED(xOrg),
+                                   int* WXUNUSED(yOrg)) const
+    {
+    }
+
     // 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.
index adc7e5a1fcb233c72b18f6160c50aba99ae8e096..73d93aaf613eb39a5ed00693c992d8748017aeff 100644 (file)
@@ -399,13 +399,19 @@ public:
 #endif
     }
 
+#ifdef __WXMSW__
     // we need to return a special WM_GETDLGCODE value to process just the
     // arrows but let the other navigation characters through
-#ifdef __WXMSW__
     virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
     {
         return FilterMSWWindowProc(nMsg, T::MSWWindowProc(nMsg, wParam, lParam));
     }
+
+    // Take into account the scroll origin.
+    virtual void MSWAdjustBrushOrg(int* xOrg, int* yOrg) const
+    {
+        CalcUnscrolledPosition(*xOrg, *yOrg, xOrg, yOrg);
+    }
 #endif // __WXMSW__
 
     WX_FORWARD_TO_SCROLL_HELPER()
index 4b07cbdf1d901bcabc5988c1ea0a5c488ad60d96..041edce030cf5d17a448f141987f5d354d31e5e3 100644 (file)
@@ -4959,7 +4959,11 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)
 
         ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
 
-        if ( !::SetBrushOrgEx((HDC)hDC, -rc.left, -rc.top, NULL) )
+        int x = rc.left,
+            y = rc.top;
+        MSWAdjustBrushOrg(&x, &y);
+
+        if ( !::SetBrushOrgEx((HDC)hDC, -x, -y, NULL) )
         {
             wxLogLastError(wxT("SetBrushOrgEx(bg brush)"));
         }