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.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user