From 8b07bd1e27e58245dc1c4c8a4d1d2afabf2bf768 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 3 Jul 2016 20:52:40 +0200 Subject: [PATCH] Fixed setting clipping box for wxDC (MSW). Because CreateRectRgn() Win API requires that (x1,y1) parameters represent the top-left corner of the clipping box so if a box with negative values of the width or height is passed to wxMSWDCImpl::DoSetClippingRegion() (what means that (x,y) doesn't represent top-left corner) we need to recalculate passed parameters to get the box with (x,y) at top-left corner. --- src/msw/dc.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index acf9cc1f22..9213388540 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -625,6 +625,19 @@ void wxMSWDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h // manually // // FIXME: possible +/-1 error here, to check! + // (x,y) has to represent the left-top corner of the region + // so if size values are negative we need to recalculate + // parameters of the region to get (x,y) at this corner. + if ( w < 0 ) + { + w = -w; + x -= (w - 1); + } + if ( h < 0 ) + { + h = -h; + y -= (h - 1); + } HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x + w),