]> git.saurik.com Git - wxWidgets.git/commitdiff
Set brush origin for hatch brushes too.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 Aug 2009 17:25:33 +0000 (17:25 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 5 Aug 2009 17:25:33 +0000 (17:25 +0000)
They don't explicitly use a bitmap but MSDN still says that their origin
should be set to align brushes used on different windows.

Closes #11072.

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

src/msw/dc.cpp

index d25954bd326cde007f881e528f6ce8e472aead3a..46eebf25c5f2f249eee98cf0dedc766091476346 100644 (file)
@@ -1543,15 +1543,22 @@ void wxMSWDCImpl::SetBrush(const wxBrush& brush)
     if ( brush.IsOk() )
     {
         // we must make sure the brush is aligned with the logical coordinates
-        // before selecting it
+        // before selecting it or using the same brush for the background of
+        // different windows would result in discontinuities
+        wxSize sizeBrushBitmap = wxDefaultSize;
         wxBitmap *stipple = brush.GetStipple();
         if ( stipple && stipple->IsOk() )
+            sizeBrushBitmap = stipple->GetSize();
+        else if ( brush.IsHatch() )
+            sizeBrushBitmap = wxSize(8, 8);
+
+        if ( sizeBrushBitmap.IsFullySpecified() )
         {
             if ( !::SetBrushOrgEx
                     (
                         GetHdc(),
-                        m_deviceOriginX % stipple->GetWidth(),
-                        m_deviceOriginY % stipple->GetHeight(),
+                        m_deviceOriginX % sizeBrushBitmap.x,
+                        m_deviceOriginY % sizeBrushBitmap.y,
                         NULL                    // [out] previous brush origin
                     ) )
             {