1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
19 gdkregion
= gdk_region_new ();
22 Region::Region (double x
, double y
, double width
, double height
)
24 gdkregion
= gdk_region_new ();
25 Union (Rect (x
, y
, width
, height
));
28 Region::Region (Rect rect
)
30 gdkregion
= gdk_region_new ();
34 Region::Region (GdkRegion
*region
)
36 gdkregion
= gdk_region_copy (region
);
39 Region::Region (Region
*region
)
41 gdkregion
= gdk_region_copy (region
->gdkregion
);
46 gdk_region_destroy (gdkregion
);
53 return gdk_region_empty (gdkregion
);
57 Region::Union (Rect rect
)
59 GdkRectangle gdkrect
= rect
.ToGdkRectangle ();
60 gdk_region_union_with_rect (gdkregion
, &gdkrect
);
64 Region::Union (GdkRectangle
*rect
)
66 gdk_region_union_with_rect (gdkregion
, rect
);
70 Region::Union (Region
*region
)
72 gdk_region_union (gdkregion
, region
->gdkregion
);
76 Region::RectIn (Rect rect
)
78 GdkRectangle gdkrect
= rect
.ToGdkRectangle ();
79 return gdk_region_rect_in (gdkregion
, &gdkrect
);
83 Region::Intersect (Region
*region
)
85 gdk_region_intersect (gdkregion
, region
->gdkregion
);
89 Region::Intersect (Rect rect
)
91 Region tmp
= Region (rect
);
97 Region::Subtract (Region
*region
)
99 gdk_region_subtract (gdkregion
, region
->gdkregion
);
103 Region::Subtract (Rect rect
)
105 Region tmp
= Region (rect
);
110 Region::Offset (int dx
, int dy
)
112 gdk_region_offset (gdkregion
, dx
, dy
);
116 Region::GetRectangles (GdkRectangle
**rects
, int *count
)
118 gdk_region_get_rectangles (gdkregion
, rects
, count
);
121 // gdk_region_get_clipbox (gdkregion, *rects);
129 gdk_region_get_clipbox (gdkregion
, &clip
);
130 return Rect (clip
.x
, clip
.y
, clip
.width
, clip
.height
);
134 Region::Draw (cairo_t
*cr
)
139 gdk_region_get_rectangles (gdkregion
, &rects
, &i
);
141 for (count
= 0; count
< i
; count
++)
142 cairo_rectangle (cr
, rects
[count
].x
, rects
[count
].y
, rects
[count
].width
, rects
[count
].height
);