From ad9ebd4b545f68841f01268c8842ea2fbceee7a6 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 16 Jul 2016 23:41:29 +0200 Subject: [PATCH] Fixed setting clipping box with negative size (wxDC, GTK). Rectangular clipping region with negative size is accepted by wxDC::SetClippingRegion() (for compatibility with wxGCDC and Cairo) but for internal calculations we need to have this box defined by (x,y) at top-left corner and having non-negative size so we need to recalculate box's parameters in wxWindowDCImpl::DoSetClippingRegion() if necessary. --- src/gtk/dcclient.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 1a3d60cc8e..507fd47769 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1871,6 +1871,20 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, w if (!m_gdkwindow) return; + // For internal calculations we need to have box definition + // in the canonical form, with (x,y) pointing to the top-left + // corner of the box and with non-negative width and height. + if ( width < 0 ) + { + width = -width; + x -= (width - 1); + } + if ( height < 0 ) + { + height = -height; + y -= (height - 1); + } + wxRect rect; rect.x = XLOG2DEV(x); rect.y = YLOG2DEV(y);