alternative to assert
[gtkD.git] / gtkD / src / gdk / Region.d
blob3cc924b24cb23003204770e40337bb33fd515155
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
50 * local aliases:
53 module gdk.Region;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.gdktypes;
65 private import gtkc.gdk;
68 private import gdk.Region;
69 private import gdk.Rectangle;
74 /**
75 * Description
76 * GDK provides the GdkPoint, GdkRectangle, GdkRegion and GdkSpan data types
77 * for representing pixels and sets of pixels on the screen.
78 * GdkPoint is a simple structure containing an x and y coordinate of a point.
79 * GdkRectangle is a structure holding the position and size of a rectangle.
80 * The intersection of two rectangles can be computed with
81 * gdk_rectangle_intersect(). To find the union of two rectangles use
82 * gdk_rectangle_union().
83 * GdkRegion is an opaque data type holding a set of arbitrary pixels, and is
84 * usually used for clipping graphical operations (see gdk_gc_set_clip_region()).
85 * GdkSpan is a structure holding a spanline. A spanline is a horizontal line that
86 * is one pixel wide. It is mainly used when rasterizing other graphics primitives.
87 * It can be intersected to regions by using gdk_region_spans_intersect_foreach().
89 public class Region
92 /** the main Gtk struct */
93 protected GdkRegion* gdkRegion;
96 public GdkRegion* getRegionStruct()
98 return gdkRegion;
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)gdkRegion;
109 * Sets our main struct and passes it to the parent class
111 public this (GdkRegion* gdkRegion)
113 version(noAssert)
115 if ( gdkRegion is null )
117 int zero = 0;
118 version(Tango)
120 Stdout("struct gdkRegion is null on constructor").newline;
122 else
124 printf("struct gdkRegion is null on constructor");
126 zero = zero / zero;
129 else
131 assert(gdkRegion !is null, "struct gdkRegion is null on constructor");
133 this.gdkRegion = gdkRegion;
145 * Creates a new empty GdkRegion.
146 * Returns:
147 * a new empty GdkRegion
149 public this ()
151 // GdkRegion* gdk_region_new (void);
152 this(cast(GdkRegion*)gdk_region_new() );
156 * Creates a new GdkRegion using the polygon defined by a
157 * number of points.
158 * points:
159 * an array of GdkPoint structs
160 * npoints:
161 * the number of elements in the points array
162 * fill_rule:
163 * specifies which pixels are included in the region when the
164 * polygon overlaps itself.
165 * Returns:
166 * a new GdkRegion based on the given polygon
168 public static Region polygon(GdkPoint* points, int npoints, GdkFillRule fillRule)
170 // GdkRegion* gdk_region_polygon (GdkPoint *points, gint npoints, GdkFillRule fill_rule);
171 return new Region( gdk_region_polygon(points, npoints, fillRule) );
176 * Copies region, creating an identical new region.
177 * region:
178 * a GdkRegion
179 * Returns:
180 * a new region identical to region
182 public Region copy()
184 // GdkRegion* gdk_region_copy (GdkRegion *region);
185 return new Region( gdk_region_copy(gdkRegion) );
189 * Creates a new region containing the area rectangle.
190 * rectangle:
191 * a GdkRectangle
192 * Returns:
193 * a new region
195 public static Region rectangle(Rectangle rectangle)
197 // GdkRegion* gdk_region_rectangle (GdkRectangle *rectangle);
198 return new Region( gdk_region_rectangle((rectangle is null) ? null : rectangle.getRectangleStruct()) );
202 * Destroys a GdkRegion.
203 * region:
204 * a GdkRegion
206 public void destroy()
208 // void gdk_region_destroy (GdkRegion *region);
209 gdk_region_destroy(gdkRegion);
213 * Obtains the smallest rectangle which includes the entire GdkRegion.
214 * region:
215 * a GdkRegion
216 * rectangle:
217 * return location for the clipbox
219 public void getClipbox(Rectangle rectangle)
221 // void gdk_region_get_clipbox (GdkRegion *region, GdkRectangle *rectangle);
222 gdk_region_get_clipbox(gdkRegion, (rectangle is null) ? null : rectangle.getRectangleStruct());
226 * Obtains the area covered by the region as a list of rectangles.
227 * The array returned in rectangles must be freed with g_free().
228 * region:
229 * a GdkRegion
230 * rectangles:
231 * return location for an array of rectangles
232 * n_rectangles:
233 * length of returned array
235 public void getRectangles(GdkRectangle** rectangles, int* nRectangles)
237 // void gdk_region_get_rectangles (GdkRegion *region, GdkRectangle **rectangles, gint *n_rectangles);
238 gdk_region_get_rectangles(gdkRegion, rectangles, nRectangles);
242 * Finds out if the GdkRegion is empty.
243 * region:
244 * a GdkRegion
245 * Returns:
246 * TRUE if region is empty.
248 public int empty()
250 // gboolean gdk_region_empty (GdkRegion *region);
251 return gdk_region_empty(gdkRegion);
255 * Finds out if the two regions are the same.
256 * region1:
257 * a GdkRegion
258 * region2:
259 * a GdkRegion
260 * Returns:
261 * TRUE if region1 and region2 are equal.
263 public int equal(Region region2)
265 // gboolean gdk_region_equal (GdkRegion *region1, GdkRegion *region2);
266 return gdk_region_equal(gdkRegion, (region2 is null) ? null : region2.getRegionStruct());
270 * Finds out if a point is in a region.
271 * region:
272 * a GdkRegion
273 * x:
274 * the x coordinate of a point
275 * y:
276 * the y coordinate of a point
277 * Returns:
278 * TRUE if the point is in region.
280 public int pointIn(int x, int y)
282 // gboolean gdk_region_point_in (GdkRegion *region, int x, int y);
283 return gdk_region_point_in(gdkRegion, x, y);
287 * Tests whether a rectangle is within a region.
288 * region:
289 * a GdkRegion.
290 * rectangle:
291 * a GdkRectangle.
292 * Returns:
293 * GDK_OVERLAP_RECTANGLE_IN, GDK_OVERLAP_RECTANGLE_OUT, or
294 * GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside,
295 * outside, or partly inside the GdkRegion, respectively.
297 public GdkOverlapType rectIn(Rectangle rectangle)
299 // GdkOverlapType gdk_region_rect_in (GdkRegion *region, GdkRectangle *rectangle);
300 return gdk_region_rect_in(gdkRegion, (rectangle is null) ? null : rectangle.getRectangleStruct());
305 * Moves a region the specified distance.
306 * region:
307 * a GdkRegion
308 * dx:
309 * the distance to move the region horizontally
310 * dy:
311 * the distance to move the region vertically
313 public void offset(int dx, int dy)
315 // void gdk_region_offset (GdkRegion *region, gint dx, gint dy);
316 gdk_region_offset(gdkRegion, dx, dy);
320 * Resizes a region by the specified amount.
321 * Positive values shrink the region. Negative values expand it.
322 * region:
323 * a GdkRegion
324 * dx:
325 * the number of pixels to shrink the region horizontally
326 * dy:
327 * the number of pixels to shrink the region vertically
329 public void shrink(int dx, int dy)
331 // void gdk_region_shrink (GdkRegion *region, gint dx, gint dy);
332 gdk_region_shrink(gdkRegion, dx, dy);
336 * Sets the area of region to the union of the areas of region and
337 * rect. The resulting area is the set of pixels contained in
338 * either region or rect.
339 * region:
340 * a GdkRegion.
341 * rect:
342 * a GdkRectangle.
344 public void unionWithRect(Rectangle rect)
346 // void gdk_region_union_with_rect (GdkRegion *region, GdkRectangle *rect);
347 gdk_region_union_with_rect(gdkRegion, (rect is null) ? null : rect.getRectangleStruct());
351 * Sets the area of source1 to the intersection of the areas of source1
352 * and source2. The resulting area is the set of pixels contained in
353 * both source1 and source2.
354 * source1:
355 * a GdkRegion
356 * source2:
357 * another GdkRegion
359 public void intersect(Region source2)
361 // void gdk_region_intersect (GdkRegion *source1, GdkRegion *source2);
362 gdk_region_intersect(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
366 * Sets the area of source1 to the union of the areas of source1 and
367 * source2. The resulting area is the set of pixels contained in
368 * either source1 or source2.
369 * source1:
370 * a GdkRegion
371 * source2:
372 * a GdkRegion
374 public void unio(Region source2)
376 // void gdk_region_union (GdkRegion *source1, GdkRegion *source2);
377 gdk_region_union(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
381 * Subtracts the area of source2 from the area source1. The resulting
382 * area is the set of pixels contained in source1 but not in source2.
383 * source1:
384 * a GdkRegion
385 * source2:
386 * another GdkRegion
388 public void subtract(Region source2)
390 // void gdk_region_subtract (GdkRegion *source1, GdkRegion *source2);
391 gdk_region_subtract(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
395 * Sets the area of source1 to the exclusive-OR of the areas of source1
396 * and source2. The resulting area is the set of pixels contained in one
397 * or the other of the two sources but not in both.
398 * source1:
399 * a GdkRegion
400 * source2:
401 * another GdkRegion
403 public void xor(Region source2)
405 // void gdk_region_xor (GdkRegion *source1, GdkRegion *source2);
406 gdk_region_xor(gdkRegion, (source2 is null) ? null : source2.getRegionStruct());
412 * Calls a function on each span in the intersection of region and spans.
413 * region:
414 * a GdkRegion
415 * spans:
416 * an array of GdkSpans
417 * n_spans:
418 * the length of spans
419 * sorted:
420 * TRUE if spans is sorted wrt. the y coordinate
421 * function:
422 * function to call on each span in the intersection
423 * data:
424 * data to pass to function
426 public void spansIntersectForeach(GdkSpan* spans, int nSpans, int sorted, GdkSpanFunc funct, void* data)
428 // void gdk_region_spans_intersect_foreach (GdkRegion *region, GdkSpan *spans, int n_spans, gboolean sorted, GdkSpanFunc function, gpointer data);
429 gdk_region_spans_intersect_foreach(gdkRegion, spans, nSpans, sorted, funct, data);