Add gdk_region_rect_equal to compare a region with a rect

This commit is contained in:
Alexander Larsson 2009-05-26 20:48:10 +02:00
parent 8a689f2e15
commit 6c76f8f6ce
2 changed files with 28 additions and 0 deletions

View File

@ -1581,6 +1581,32 @@ gdk_region_equal (const GdkRegion *region1,
return TRUE;
}
/**
* gdk_region_rect_equal:
* @region: a #GdkRegion
* @rectangle: a #GdkRectangle
*
* Finds out if a regions is the same as a rectangle.
*
* Returns: %TRUE if @region and @rectangle are equal.
*
* Since: 2.18
*/
gboolean
gdk_region_rect_equal (const GdkRegion *region,
const GdkRectangle *rectangle)
{
g_return_val_if_fail (region != NULL, FALSE);
g_return_val_if_fail (rectangle != NULL, FALSE);
if (region->numRects != 1) return FALSE;
else if (region->extents.x1 != rectangle->x) return FALSE;
else if (region->extents.y1 != rectangle->y) return FALSE;
else if (region->extents.x2 != rectangle->x + rectangle->width) return FALSE;
else if (region->extents.y2 != rectangle->y + rectangle->height) return FALSE;
return TRUE;
}
/**
* gdk_region_point_in:
* @region: a #GdkRegion

View File

@ -77,6 +77,8 @@ void gdk_region_get_rectangles (const GdkRegion *region,
gboolean gdk_region_empty (const GdkRegion *region);
gboolean gdk_region_equal (const GdkRegion *region1,
const GdkRegion *region2);
gboolean gdk_region_rect_equal (const GdkRegion *region1,
const GdkRectangle *rectangle);
gboolean gdk_region_point_in (const GdkRegion *region,
int x,
int y);