From 875c095e870e407a41eab07cbc880ff40ad2aa35 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 27 Sep 2018 22:31:41 +0200 Subject: [PATCH] Normalize wxRegion rectangle if it has a negative size For compatibility with wxMSW and wxGTK rectangle defining wxRegion needs to be in the canonical form with (x,y) pointing to the top-left corner and width and height >= 0. --- src/osx/carbon/region.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/osx/carbon/region.cpp b/src/osx/carbon/region.cpp index a881b0996a..907b0f33fd 100644 --- a/src/osx/carbon/region.cpp +++ b/src/osx/carbon/region.cpp @@ -77,6 +77,21 @@ wxRegion::wxRegion(WXHRGN hRegion ) wxRegion::wxRegion(long x, long y, long w, long h) { + // Rectangle needs to be given in the canonical form, + // with (x,y) pointing to the top-left corner + // and with non-negative width and height + // (for compatibility with wxMSW anf wxGTK). + if ( w < 0 ) + { + w = -w; + x -= (w - 1); + } + if ( h < 0 ) + { + h = -h; + y -= (h - 1); + } + m_refData = new wxRegionRefData(x , y , w , h ); }