Fixed setting wxRegion with rectangle having negative size (MSW).

wxRegion uses CreateRectRgn() Win API which requires that its (x1,y1) parameters represent the top-left corner of the rectangle region so if a rectangle with negative values of the width or height is passed to wxRegion's ctor (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.
This commit is contained in:
Artur Wieczorek
2016-07-15 20:58:36 +02:00
parent 9ecea7dc74
commit b2760ff420

View File

@@ -94,22 +94,40 @@ wxRegion::wxRegion(WXHRGN hRegion)
M_REGION = (HRGN) hRegion;
}
static HRGN CreateRectRgnMSW(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
// (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);
}
return ::CreateRectRgn(x, y, x + w, y + h);
}
wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
m_refData = new wxRegionRefData;
M_REGION = ::CreateRectRgn(x, y, x + w, y + h);
M_REGION = CreateRectRgnMSW(x, y, w, h);
}
wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
{
m_refData = new wxRegionRefData;
M_REGION = ::CreateRectRgn(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
M_REGION = CreateRectRgnMSW(topLeft.x, topLeft.y, bottomRight.x-topLeft.x, bottomRight.y-topLeft.y);
}
wxRegion::wxRegion(const wxRect& rect)
{
m_refData = new wxRegionRefData;
M_REGION = ::CreateRectRgn(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
M_REGION = CreateRectRgnMSW(rect.x, rect.y, rect.width, rect.height);
}
wxRegion::wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle)