From d50f331a99fb2736db30fd6ce085d8de67277546 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 3 Jul 2016 21:31:37 +0200 Subject: [PATCH] Fixed calculation of clipping box with negative size (wxGCDC). Graphics renderers accept negative clipping box size but for internal calculations done in wxDCImpl::DoSetClippingRegion() we need to have a box defined by (x,y) at top-left corner and having non-negative size so we need to recalculate parameters if necessary. --- src/common/dcgraph.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index a73e04d255..8f5f04b810 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -279,6 +279,20 @@ void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") ); + // Generally, renderers accept negative values of width/height + // but for internal calculations we need to have a box definition + // in the standard form, with (x,y) pointing to the top-left + // corner of the box and with non-negative width and height. + if ( w < 0 ) + { + w = -w; + x -= (w - 1); + } + if ( h < 0 ) + { + h = -h; + y -= (h - 1); + } m_graphicContext->Clip( x, y, w, h ); wxDCImpl::DoSetClippingRegion(x, y, w, h);