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:
47 * - GdkRectangle* -> Rectangle
48 * - GdkRegion* -> Region
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
;
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().
92 /** the main Gtk struct */
93 protected GdkRegion
* gdkRegion
;
96 public GdkRegion
* getRegionStruct()
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
)
115 if ( gdkRegion
is null )
120 Stdout("struct gdkRegion is null on constructor").newline
;
124 printf("struct gdkRegion is null on constructor");
131 assert(gdkRegion
!is null, "struct gdkRegion is null on constructor");
133 this.gdkRegion
= gdkRegion
;
145 * Creates a new empty GdkRegion.
147 * a new empty GdkRegion
151 // GdkRegion* gdk_region_new (void);
152 this(cast(GdkRegion
*)gdk_region_new() );
156 * Creates a new GdkRegion using the polygon defined by a
159 * an array of GdkPoint structs
161 * the number of elements in the points array
163 * specifies which pixels are included in the region when the
164 * polygon overlaps itself.
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.
180 * a new region identical to region
184 // GdkRegion* gdk_region_copy (GdkRegion *region);
185 return new Region( gdk_region_copy(gdkRegion
) );
189 * Creates a new region containing the area rectangle.
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.
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.
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().
231 * return location for an array of 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.
246 * TRUE if region is empty.
250 // gboolean gdk_region_empty (GdkRegion *region);
251 return gdk_region_empty(gdkRegion
);
255 * Finds out if the two regions are the same.
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.
274 * the x coordinate of a point
276 * the y coordinate of a point
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.
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.
309 * the distance to move the region horizontally
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.
325 * the number of pixels to shrink the region horizontally
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.
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.
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.
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.
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.
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.
416 * an array of GdkSpans
418 * the length of spans
420 * TRUE if spans is sorted wrt. the y coordinate
422 * function to call on each span in the intersection
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
);