From 79ffd029fa5e969f9f4bea3b9a4f3be2fc5b5092 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 16 Jul 2016 23:24:38 +0200 Subject: [PATCH] Allow creating wxRegion from rectangle with negative size (GTK). GdkRectangle used to represent a rectangle region should have (x,y) parameters pointing to the top-left corner of the box with non-negative width and height so if a rectangle with negative values of the width or height is passed to wxRegion::InitRect() (what means that (x,y) doesn't represent top-left corner) we need to recalculate passed parameters to get rectangle with (x,y) at the top-left corner. --- src/gtk/region.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gtk/region.cpp b/src/gtk/region.cpp index 054acd8e80..5284ba25c5 100644 --- a/src/gtk/region.cpp +++ b/src/gtk/region.cpp @@ -79,6 +79,20 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject); void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { + // Rectangle needs to be defined in the canonical 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); + } + GdkRectangle rect; rect.x = x; rect.y = y;