From b8abf338c8c83ea7f0dcf29b39dfd2223d16c462 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 9 Aug 2015 22:06:59 -0700 Subject: [PATCH] Make rectangle size the same as is drawn by raster-based wxDCs Outlined rectangles are one pixel larger with vector-based drawing, adjust them to get consistent behavior. Ellipses do not appear to need adjustment. See #17091 (cherry picked from commit 4623c5ad9c79e3c21fed575494212e62c0f3931f) --- src/common/dcgraph.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index c390eb4cec..1b09719609 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -876,10 +876,9 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) + if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0) { - // if we are offsetting the entire rectangle is moved 0.5, so the - // border line gets off by 1 + // outline is one pixel larger than what raster-based wxDC implementations draw w -= 1; h -= 1; } @@ -905,10 +904,9 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) + if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0) { - // if we are offsetting the entire rectangle is moved 0.5, so the - // border line gets off by 1 + // outline is one pixel larger than what raster-based wxDC implementations draw w -= 1; h -= 1; } @@ -925,13 +923,6 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); - if ( m_graphicContext->ShouldOffset() ) - { - // if we are offsetting the entire rectangle is moved 0.5, so the - // border line gets off by 1 - w -= 1; - h -= 1; - } m_graphicContext->DrawEllipse(x,y,w,h); }