fixed off by 1 bug in wxDC::GradientFillLinear() (patch 1788549)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-09-09 19:36:50 +00:00
parent ad91e1ade0
commit 5f77ee3b87
3 changed files with 36 additions and 4 deletions

View 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

View 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)

View 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);
}
}