alternative to assert
[gtkD.git] / src / gdk / Region.d
blobadefc94f64d68c4f923ee643544abb827a3dcdec
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile =
26 * outPack = gdk
27 * outFile = Region
28 * strct = GdkRegion
29 * realStrct=
30 * ctorStrct=
31 * clss = Region
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_region_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gdk.Region
45 * - gdk.Rectangle
46 * structWrap:
47 * - GdkRectangle* -> Rectangle
48 * - GdkRegion* -> Region
49 * local aliases:
52 module gdk.Region;
54 private import gdk.gdktypes;
56 private import lib.gdk;
58 private import gdk.Region;
59 private import gdk.Rectangle;
61 /**
62 * Description
63 * GDK provides the GdkPoint, GdkRectangle, GdkRegion and GdkSpan data types
64 * for representing pixels and sets of pixels on the screen.
65 * GdkPoint is a simple structure containing an x and y coordinate of a point.
66 * GdkRectangle is a structure holding the position and size of a rectangle.
67 * The intersection of two rectangles can be computed with
68 * gdk_rectangle_intersect(). To find the union of two rectangles use
69 * gdk_rectangle_union().
70 * GdkRegion is an opaque data type holding a set of arbitrary pixels, and is
71 * usually used for clipping graphical operations (see gdk_gc_set_clip_region()).
72 * GdkSpan is a structure holding a spanline. A spanline is a horizontal line that
73 * is one pixel wide. It is mainly used when rasterizing other graphics primitives.
74 * It can be intersected to regions by using gdk_region_spans_intersect_foreach().
76 public class Region
79 /** the main Gtk struct */
80 protected GdkRegion* gdkRegion;
83 public GdkRegion* getRegionStruct()
85 return gdkRegion;
89 /** the main Gtk struct as a void* */
90 protected void* getStruct()
92 return cast(void*)gdkRegion;
95 /**
96 * Sets our main struct and passes it to the parent class
98 public this (GdkRegion* gdkRegion)
100 this.gdkRegion = gdkRegion;
112 * Creates a new empty GdkRegion.
113 * Returns:
114 * a new empty GdkRegion
116 public this ()
118 // GdkRegion* gdk_region_new (void);
119 this(cast(GdkRegion*)gdk_region_new() );
123 * Creates a new GdkRegion using the polygon defined by a
124 * number of points.
125 * points:
126 * an array of GdkPoint structs
127 * npoints:
128 * the number of elements in the points array
129 * fill_rule:
130 * specifies which pixels are included in the region when the
131 * polygon overlaps itself.
132 * Returns:
133 * a new GdkRegion based on the given polygon
135 public static Region polygon(GdkPoint* points, int npoints, GdkFillRule fillRule)
137 // GdkRegion* gdk_region_polygon (GdkPoint *points, gint npoints, GdkFillRule fill_rule);
138 return new Region( gdk_region_polygon(points, npoints, fillRule) );
143 * Copies region, creating an identical new region.
144 * region:
145 * a GdkRegion
146 * Returns:
147 * a new region identical to region
149 public Region copy()
151 // GdkRegion* gdk_region_copy (GdkRegion *region);
152 return new Region( gdk_region_copy(gdkRegion) );
156 * Creates a new region containing the area rectangle.
157 * rectangle:
158 * a GdkRectangle
159 * Returns:
160 * a new region
162 public static Region rectangle(Rectangle rectangle)
164 // GdkRegion* gdk_region_rectangle (GdkRectangle *rectangle);
165 return new Region( gdk_region_rectangle((rectangle is null) ? null : rectangle.getRectangleStruct()) );
169 * Destroys a GdkRegion.
170 * region:
171 * a GdkRegion
173 public void destroy()
175 // void gdk_region_destroy (GdkRegion *region);
176 gdk_region_destroy(gdkRegion);
180 * Obtains the smallest rectangle which includes the entire GdkRegion.
181 * region:
182 * a GdkRegion
183 * rectangle:
184 * return location for the clipbox
186 public void getClipbox(Rectangle rectangle)
188 // void gdk_region_get_clipbox (GdkRegion *region, GdkRectangle *rectangle);
189 gdk_region_get_clipbox(gdkRegion, (rectangle is null) ? null : rectangle.getRectangleStruct());
193 * Obtains the area covered by the region as a list of rectangles.
194 * The array returned in rectangles must be freed with g_free().
195 * region:
196 * a GdkRegion
197 * rectangles:
198 * return location for an array of rectangles
199 * n_rectangles:
200 * length of returned array
202 public void getRectangles(GdkRectangle** rectangles, int* nRectangles)
204 // void gdk_region_get_rectangles (GdkRegion *region, GdkRectangle **rectangles, gint *n_rectangles);
205 gdk_region_get_rectangles(gdkRegion, rectangles, nRectangles);
209 * Finds out if the GdkRegion is empty.
210 * region:
211 * a GdkRegion
212 * Returns:
213 * TRUE if region is empty.
215 public int empty()
217 // gboolean gdk_region_empty (GdkRegion *region);
218 return gdk_region_empty(gdkRegion);
222 * Finds out if the two regions are the same.
223 * region1:
224 * a GdkRegion
225 * region2:
226 * a GdkRegion
227 * Returns:
228 * TRUE if region1 and region2 are equal.
230 public int equal(Region region2)
232 // gboolean gdk_region_equal (GdkRegion *region1, GdkRegion *region2);
233 return gdk_region_equal(gdkRegion, (region2 is null) ? null : region2.getRegionStruct());
237 * Finds out if a point is in a region.
238 * region:
239 * a GdkRegion
240 * x:
241 * the x coordinate of a point
242 * y:
243 * the y coordinate of a point
244 * Returns:
245 * TRUE if the point is in region.
247 public int pointIn(int x, int y)
249 // gboolean gdk_region_point_in (GdkRegion *region, int x, int y);
250 return gdk_region_point_in(gdkRegion, x, y);
254 * Tests whether a rectangle is within a region.
255 * region:
256 * a GdkRegion.
257 * rectangle:
258 * a GdkRectangle.
259 * Returns:
260 * GDK_OVERLAP_RECTANGLE_IN, GDK_OVERLAP_RECTANGLE_OUT, or
261 * GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside,
262 * outside, or partly inside the GdkRegion, respectively.
264 public GdkOverlapType rectIn(Rectangle rectangle)
266 // GdkOverlapType gdk_region_rect_in (GdkRegion *region, GdkRectangle *rectangle);
267 return gdk_region_rect_in(gdkRegion, (rectangle is null) ? null : rectangle.getRectangleStruct());
272 * Moves a region the specified distance.
273 * region:
274 * a GdkRegion
275 * dx:
276 * the distance to move the region horizontally
277 * dy:
278 * the distance to move the region vertically
280 public void offset(int dx, int dy)
282 // void gdk_region_offset (GdkRegion *region, gint dx, gint dy);
283 gdk_region_offset(gdkRegion, dx, dy);
287 * Resizes a region by the specified amount.
288 * Positive values shrink the region. Negative values expand it.
289 * region:
290 * a GdkRegion
291 * dx:
292 * the number of pixels to shrink the region horizontally
293 * dy:
294 * the number of pixels to shrink the region vertically
296 public void shrink(int dx, int dy)
298 // void gdk_region_shrink (GdkRegion *region, gint dx, gint dy);
299 gdk_region_shrink(gdkRegion, dx, dy);
303 * Sets the area of region to the union of the areas of region and
304 * rect. The resulting area is the set of pixels contained in
305 * either region or rect.
306 * region:
307 * a GdkRegion.
308 * rect:
309 * a GdkRectangle.
311 public void unionWithRect(Rectangle rect)
313 // void gdk_region_union_with_rect (GdkRegion *region, GdkRectangle *rect);
314 gdk_region_union_with_rect(gdkRegion, (rect is null) ? null : rect.getRectangleStruct());
318 * Sets the area of source1 to the intersection of the areas of source1
319 * and source2. The resulting area is the set of pixels contained in
320 * both source1 and source2.
321 * source1:
322 * a GdkRegion
323 * source2:
324 * another GdkRegion
326 public void intersect(Region source2)
328 // void gdk_region_intersect (GdkRegion *source1, GdkRegion *source2);
329 gdk_region_intersect(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
333 * Sets the area of source1 to the union of the areas of source1 and
334 * source2. The resulting area is the set of pixels contained in
335 * either source1 or source2.
336 * source1:
337 * a GdkRegion
338 * source2:
339 * a GdkRegion
341 public void unio(Region source2)
343 // void gdk_region_union (GdkRegion *source1, GdkRegion *source2);
344 gdk_region_union(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
348 * Subtracts the area of source2 from the area source1. The resulting
349 * area is the set of pixels contained in source1 but not in source2.
350 * source1:
351 * a GdkRegion
352 * source2:
353 * another GdkRegion
355 public void subtract(Region source2)
357 // void gdk_region_subtract (GdkRegion *source1, GdkRegion *source2);
358 gdk_region_subtract(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
362 * Sets the area of source1 to the exclusive-OR of the areas of source1
363 * and source2. The resulting area is the set of pixels contained in one
364 * or the other of the two sources but not in both.
365 * source1:
366 * a GdkRegion
367 * source2:
368 * another GdkRegion
370 public void xor(Region source2)
372 // void gdk_region_xor (GdkRegion *source1, GdkRegion *source2);
373 gdk_region_xor(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
379 * Calls a function on each span in the intersection of region and spans.
380 * region:
381 * a GdkRegion
382 * spans:
383 * an array of GdkSpans
384 * n_spans:
385 * the length of spans
386 * sorted:
387 * TRUE if spans is sorted wrt. the y coordinate
388 * function:
389 * function to call on each span in the intersection
390 * data:
391 * data to pass to function
393 public void spansIntersectForeach(GdkSpan* spans, int nSpans, int sorted, GdkSpanFunc funct, void* data)
395 // void gdk_region_spans_intersect_foreach (GdkRegion *region, GdkSpan *spans, int n_spans, gboolean sorted, GdkSpanFunc function, gpointer data);
396 gdk_region_spans_intersect_foreach(gdkRegion, spans, nSpans, sorted, funct, data);