]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed off by 1 bug in wxDC::GradientFillLinear() (patch 1788549)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 Sep 2007 19:36:50 +0000 (19:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 Sep 2007 19:36:50 +0000 (19:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
samples/drawing/drawing.cpp
src/common/dcbase.cpp

index 7a26570c9445802a2f9a5d4226b9aaf2348784f3..16ab468ffc33a858a38ef1dee0e2bddd9dfa964c 100644 (file)
@@ -255,6 +255,7 @@ wxGTK:
 - Generate wxEVT_COMMAND_LIST_END_LABEL_EDIT event even if label didn't change
 - Fix WX_GL_STEREO attribute handling (Tristan Mehamli)
 - Fix wxThread::SetPriority() when the thread is running (Christos Gourdoupis)
+- Fixed off by 1 bug in wxDC::GradientFillLinear() (Tim Kosse)
 
 
 2.8.4
index 497d68bf16f0b3cce539cbb175c1f757c0a0914a..021de6387b46d4fbcc5e33ebc20ef205509fe376 100644 (file)
@@ -1159,6 +1159,37 @@ void MyCanvas::DrawGradients(wxDC& dc)
     dc.DrawText(_T("Blue in bottom right corner"), r.x, r.y);
     r.Offset(0, TEXT_HEIGHT);
     dc.GradientFillConcentric(r, *wxBLUE, *wxWHITE, wxPoint(r.width, r.height));
+
+    // check that the area filled by the gradient is exactly the interior of
+    // the rectangle
+    r.x = 350;
+    r.y = 30;
+    dc.DrawText("The interior should be filled but", r.x, r.y);
+    r.y += 15;
+    dc.DrawText(" the red border should remain visible:", r.x, r.y);
+    r.y += 15;
+
+    r.width =
+    r.height = 50;
+    wxRect r2 = r;
+    r2.x += 60;
+    wxRect r3 = r;
+    r3.y += 60;
+    wxRect r4 = r2;
+    r4.y += 60;
+    dc.SetPen(wxPen(wxColour(255, 0, 0)));
+    dc.DrawRectangle(r);
+    r.Deflate(1);
+    dc.GradientFillLinear(r, wxColour(0,255,0), wxColour(0,0,0), wxNORTH);
+    dc.DrawRectangle(r2);
+    r2.Deflate(1);
+    dc.GradientFillLinear(r2, wxColour(0,0,0), wxColour(0,255,0), wxSOUTH);
+    dc.DrawRectangle(r3);
+    r3.Deflate(1);
+    dc.GradientFillLinear(r3, wxColour(0,255,0), wxColour(0,0,0), wxEAST);
+    dc.DrawRectangle(r4);
+    r4.Deflate(1);
+    dc.GradientFillLinear(r4, wxColour(0,0,0), wxColour(0,255,0), wxWEST);
 }
 
 void MyCanvas::DrawRegions(wxDC& dc)
index 67f907abca5cf755efba9db91d30fa17ca1a5c47..94eba63f8b451ae7fb91c618bf9c8ef0386bb7fe 100644 (file)
@@ -1302,7 +1302,7 @@ void wxImplDC::DoGradientFillLinear(const wxRect& rect,
             SetPen(wxPen(colour, 1, wxSOLID));
             SetBrush(wxBrush(colour));
             if(nDirection == wxEAST)
-                DoDrawRectangle(rect.GetRight()-x-xDelta, rect.GetTop(),
+                DoDrawRectangle(rect.GetRight()-x-xDelta+1, rect.GetTop(),
                         xDelta, rect.GetHeight());
             else //nDirection == wxWEST
                 DoDrawRectangle(rect.GetLeft()+x, rect.GetTop(),
@@ -1342,7 +1342,7 @@ void wxImplDC::DoGradientFillLinear(const wxRect& rect,
                 DoDrawRectangle(rect.GetLeft(), rect.GetTop()+y,
                         rect.GetWidth(), yDelta);
             else //nDirection == wxSOUTH
-                DoDrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta,
+                DoDrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta+1,
                         rect.GetWidth(), yDelta);
         }
     }
@@ -2432,7 +2432,7 @@ void wxDCBase::DoGradientFillLinear(const wxRect& rect,
             SetPen(wxPen(colour, 1, wxSOLID));
             SetBrush(wxBrush(colour));
             if(nDirection == wxEAST)
-                DrawRectangle(rect.GetRight()-x-xDelta, rect.GetTop(),
+                DrawRectangle(rect.GetRight()-x-xDelta+1, rect.GetTop(),
                         xDelta, rect.GetHeight());
             else //nDirection == wxWEST
                 DrawRectangle(rect.GetLeft()+x, rect.GetTop(),
@@ -2472,7 +2472,7 @@ void wxDCBase::DoGradientFillLinear(const wxRect& rect,
                 DrawRectangle(rect.GetLeft(), rect.GetTop()+y,
                         rect.GetWidth(), yDelta);
             else //nDirection == wxSOUTH
-                DrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta,
+                DrawRectangle(rect.GetLeft(), rect.GetBottom()-y-yDelta+1,
                         rect.GetWidth(), yDelta);
         }
     }