1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = cairo-Regions.html
27  * outPack = cairo
28  * outFile = Region
29  * strct   = cairo_region_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = Region
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- cairo_region_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * 	- cairo_region_t* -> Region
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module cairo.Region;
54 
55 public  import cairo.c.types;
56 
57 private import cairo.c.functions;
58 private import glib.ConstructionException;
59 
60 
61 
62 
63 /**
64  * Regions are a simple graphical data type representing an area of
65  * integer-aligned rectangles. They are often used on raster surfaces
66  * to track areas of interest, such as change or clip areas.
67  */
68 public class Region
69 {
70 	
71 	/** the main Gtk struct */
72 	protected cairo_region_t* cairo_region;
73 	
74 	
75 	/** Get the main Gtk struct */
76 	public cairo_region_t* getRegionStruct()
77 	{
78 		return cairo_region;
79 	}
80 	
81 	
82 	/** the main Gtk struct as a void* */
83 	protected void* getStruct()
84 	{
85 		return cast(void*)cairo_region;
86 	}
87 	
88 	/**
89 	 * Sets our main struct and passes it to the parent class
90 	 */
91 	public this (cairo_region_t* cairo_region)
92 	{
93 		this.cairo_region = cairo_region;
94 	}
95 	
96 	/**
97 	 */
98 	
99 	/**
100 	 * Allocates a new empty region object.
101 	 * Since 1.10
102 	 * Returns: A newly allocated cairo_region_t. Free with cairo_region_destroy(). This function always returns a valid pointer; if memory cannot be allocated, then a special error object is returned where all operations on the object do nothing. You can check for this with cairo_region_status().
103 	 */
104 	public static Region create()
105 	{
106 		// cairo_region_t * cairo_region_create (void);
107 		auto p = cairo_region_create();
108 		
109 		if(p is null)
110 		{
111 			return null;
112 		}
113 		
114 		return new Region(cast(cairo_region_t*) p);
115 	}
116 	
117 	/**
118 	 * Allocates a new region object containing rectangle.
119 	 * Since 1.10
120 	 * Params:
121 	 * rectangle = a cairo_rectangle_int_t
122 	 * Returns: A newly allocated cairo_region_t. Free with cairo_region_destroy(). This function always returns a valid pointer; if memory cannot be allocated, then a special error object is returned where all operations on the object do nothing. You can check for this with cairo_region_status().
123 	 */
124 	public static Region createRectangle(ref cairo_rectangle_int_t rectangle)
125 	{
126 		// cairo_region_t * cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle);
127 		auto p = cairo_region_create_rectangle(&rectangle);
128 		
129 		if(p is null)
130 		{
131 			return null;
132 		}
133 		
134 		return new Region(cast(cairo_region_t*) p);
135 	}
136 	
137 	/**
138 	 * Allocates a new region object containing the union of all given rects.
139 	 * Since 1.10
140 	 * Params:
141 	 * rects = an array of count rectangles
142 	 * Returns: A newly allocated cairo_region_t. Free with cairo_region_destroy(). This function always returns a valid pointer; if memory cannot be allocated, then a special error object is returned where all operations on the object do nothing. You can check for this with cairo_region_status().
143 	 */
144 	public static Region createRectangles(cairo_rectangle_int_t[] rects)
145 	{
146 		// cairo_region_t * cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,  int count);
147 		auto p = cairo_region_create_rectangles(rects.ptr, cast(int) rects.length);
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		return new Region(cast(cairo_region_t*) p);
155 	}
156 	
157 	/**
158 	 * Allocates a new region object copying the area from original.
159 	 * Since 1.10
160 	 * Returns: A newly allocated cairo_region_t. Free with cairo_region_destroy(). This function always returns a valid pointer; if memory cannot be allocated, then a special error object is returned where all operations on the object do nothing. You can check for this with cairo_region_status().
161 	 */
162 	public Region copy()
163 	{
164 		// cairo_region_t * cairo_region_copy (const cairo_region_t *original);
165 		auto p = cairo_region_copy(cairo_region);
166 		
167 		if(p is null)
168 		{
169 			return null;
170 		}
171 		
172 		return new Region(cast(cairo_region_t*) p);
173 	}
174 	
175 	/**
176 	 * Increases the reference count on region by one. This prevents
177 	 * region from being destroyed until a matching call to
178 	 * cairo_region_destroy() is made.
179 	 * Since 1.10
180 	 * Returns: the referenced cairo_region_t.
181 	 */
182 	public Region reference()
183 	{
184 		// cairo_region_t * cairo_region_reference (cairo_region_t *region);
185 		auto p = cairo_region_reference(cairo_region);
186 		
187 		if(p is null)
188 		{
189 			return null;
190 		}
191 		
192 		return new Region(cast(cairo_region_t*) p);
193 	}
194 	
195 	/**
196 	 * Destroys a cairo_region_t object created with
197 	 * cairo_region_create(), cairo_region_copy(), or
198 	 * or cairo_region_create_rectangle().
199 	 * Since 1.10
200 	 */
201 	public void destroy()
202 	{
203 		// void cairo_region_destroy (cairo_region_t *region);
204 		cairo_region_destroy(cairo_region);
205 	}
206 	
207 	/**
208 	 * Checks whether an error has previous occurred for this
209 	 * region object.
210 	 * Since 1.10
211 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
212 	 */
213 	public cairo_status_t status()
214 	{
215 		// cairo_status_t cairo_region_status (const cairo_region_t *region);
216 		return cairo_region_status(cairo_region);
217 	}
218 	
219 	/**
220 	 * Gets the bounding rectangle of region as a cairo_rectangle_int_t
221 	 * Since 1.10
222 	 * Params:
223 	 * extents = rectangle into which to store the extents
224 	 */
225 	public void getExtents(out cairo_rectangle_int_t extents)
226 	{
227 		// void cairo_region_get_extents (const cairo_region_t *region,  cairo_rectangle_int_t *extents);
228 		cairo_region_get_extents(cairo_region, &extents);
229 	}
230 	
231 	/**
232 	 * Returns the number of rectangles contained in region.
233 	 * Since 1.10
234 	 * Returns: The number of rectangles contained in region.
235 	 */
236 	public int numRectangles()
237 	{
238 		// int cairo_region_num_rectangles (const cairo_region_t *region);
239 		return cairo_region_num_rectangles(cairo_region);
240 	}
241 	
242 	/**
243 	 * Stores the nth rectangle from the region in rectangle.
244 	 * Since 1.10
245 	 * Params:
246 	 * nth = a number indicating which rectangle should be returned
247 	 * rectangle = return location for a cairo_rectangle_int_t
248 	 */
249 	public void getRectangle(int nth, out cairo_rectangle_int_t rectangle)
250 	{
251 		// void cairo_region_get_rectangle (const cairo_region_t *region,  int nth,  cairo_rectangle_int_t *rectangle);
252 		cairo_region_get_rectangle(cairo_region, nth, &rectangle);
253 	}
254 	
255 	/**
256 	 * Checks whether region is empty.
257 	 * Since 1.10
258 	 * Returns: TRUE if region is empty, FALSE if it isn't.
259 	 */
260 	public cairo_bool_t isEmpty()
261 	{
262 		// cairo_bool_t cairo_region_is_empty (const cairo_region_t *region);
263 		return cairo_region_is_empty(cairo_region);
264 	}
265 	
266 	/**
267 	 * Checks whether (x, y) is contained in region.
268 	 * Since 1.10
269 	 * Params:
270 	 * x = the x coordinate of a point
271 	 * y = the y coordinate of a point
272 	 * Returns: TRUE if (x, y) is contained in region, FALSE if it is not.
273 	 */
274 	public cairo_bool_t containsPoint(int x, int y)
275 	{
276 		// cairo_bool_t cairo_region_contains_point (const cairo_region_t *region,  int x,  int y);
277 		return cairo_region_contains_point(cairo_region, x, y);
278 	}
279 	
280 	/**
281 	 * Checks whether rectangle is inside, outside or partially contained
282 	 * in region
283 	 * Since 1.10
284 	 * Params:
285 	 * region = a cairo_region_t
286 	 * rectangle = a cairo_rectangle_int_t
287 	 * Returns: CAIRO_REGION_OVERLAP_IN if rectangle is entirely inside region, CAIRO_REGION_OVERLAP_OUT if rectangle is entirely outside region, or CAIRO_REGION_OVERLAP_PART if rectangle is partially inside and partially outside region.
288 	 */
289 	public cairo_region_overlap_t containsRectangle(ref cairo_rectangle_int_t rectangle)
290 	{
291 		// cairo_region_overlap_t cairo_region_contains_rectangle (const cairo_region_t *region,  const cairo_rectangle_int_t *rectangle);
292 		return cairo_region_contains_rectangle(cairo_region, &rectangle);
293 	}
294 	
295 	/**
296 	 * Compares whether region_a is equivalent to region_b. NULL as an argument
297 	 * is equal to itself, but not to any non-NULL region.
298 	 * Since 1.10
299 	 * Params:
300 	 * a = a cairo_region_t or NULL
301 	 * b = a cairo_region_t or NULL
302 	 * Returns: TRUE if both regions contained the same coverage, FALSE if it is not or any region is in an error status.
303 	 */
304 	public cairo_bool_t equal(Region b)
305 	{
306 		// cairo_bool_t cairo_region_equal (const cairo_region_t *a,  const cairo_region_t *b);
307 		return cairo_region_equal(cairo_region, (b is null) ? null : b.getRegionStruct());
308 	}
309 	
310 	/**
311 	 * Translates region by (dx, dy).
312 	 * Since 1.10
313 	 * Params:
314 	 * dx = Amount to translate in the x direction
315 	 * dy = Amount to translate in the y direction
316 	 */
317 	public void translate(int dx, int dy)
318 	{
319 		// void cairo_region_translate (cairo_region_t *region,  int dx,  int dy);
320 		cairo_region_translate(cairo_region, dx, dy);
321 	}
322 	
323 	/**
324 	 * Computes the intersection of dst with other and places the result in dst
325 	 * Since 1.10
326 	 * Params:
327 	 * other = another cairo_region_t
328 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
329 	 */
330 	public cairo_status_t intersect(Region other)
331 	{
332 		// cairo_status_t cairo_region_intersect (cairo_region_t *dst,  const cairo_region_t *other);
333 		return cairo_region_intersect(cairo_region, (other is null) ? null : other.getRegionStruct());
334 	}
335 	
336 	/**
337 	 * Computes the intersection of dst with rectangle and places the
338 	 * result in dst
339 	 * Since 1.10
340 	 * Params:
341 	 * rectangle = a cairo_rectangle_int_t
342 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
343 	 */
344 	public cairo_status_t intersectRectangle(ref cairo_rectangle_int_t rectangle)
345 	{
346 		// cairo_status_t cairo_region_intersect_rectangle (cairo_region_t *dst,  const cairo_rectangle_int_t *rectangle);
347 		return cairo_region_intersect_rectangle(cairo_region, &rectangle);
348 	}
349 	
350 	/**
351 	 * Subtracts other from dst and places the result in dst
352 	 * Since 1.10
353 	 * Params:
354 	 * other = another cairo_region_t
355 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
356 	 */
357 	public cairo_status_t subtract(Region other)
358 	{
359 		// cairo_status_t cairo_region_subtract (cairo_region_t *dst,  const cairo_region_t *other);
360 		return cairo_region_subtract(cairo_region, (other is null) ? null : other.getRegionStruct());
361 	}
362 	
363 	/**
364 	 * Subtracts rectangle from dst and places the result in dst
365 	 * Since 1.10
366 	 * Params:
367 	 * rectangle = a cairo_rectangle_int_t
368 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
369 	 */
370 	public cairo_status_t subtractRectangle(ref cairo_rectangle_int_t rectangle)
371 	{
372 		// cairo_status_t cairo_region_subtract_rectangle (cairo_region_t *dst,  const cairo_rectangle_int_t *rectangle);
373 		return cairo_region_subtract_rectangle(cairo_region, &rectangle);
374 	}
375 	
376 	/**
377 	 * Computes the union of dst with other and places the result in dst
378 	 * Since 1.10
379 	 * Params:
380 	 * other = another cairo_region_t
381 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
382 	 */
383 	public cairo_status_t unio(Region other)
384 	{
385 		// cairo_status_t cairo_region_union (cairo_region_t *dst,  const cairo_region_t *other);
386 		return cairo_region_union(cairo_region, (other is null) ? null : other.getRegionStruct());
387 	}
388 	
389 	/**
390 	 * Computes the union of dst with rectangle and places the result in dst.
391 	 * Since 1.10
392 	 * Params:
393 	 * rectangle = a cairo_rectangle_int_t
394 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
395 	 */
396 	public cairo_status_t unionRectangle(ref cairo_rectangle_int_t rectangle)
397 	{
398 		// cairo_status_t cairo_region_union_rectangle (cairo_region_t *dst,  const cairo_rectangle_int_t *rectangle);
399 		return cairo_region_union_rectangle(cairo_region, &rectangle);
400 	}
401 	
402 	/**
403 	 * Computes the exclusive difference of dst with other and places the
404 	 * result in dst. That is, dst will be set to contain all areas that
405 	 * are either in dst or in other, but not in both.
406 	 * Since 1.10
407 	 * Params:
408 	 * other = another cairo_region_t
409 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
410 	 */
411 	public cairo_status_t xor(Region other)
412 	{
413 		// cairo_status_t cairo_region_xor (cairo_region_t *dst,  const cairo_region_t *other);
414 		return cairo_region_xor(cairo_region, (other is null) ? null : other.getRegionStruct());
415 	}
416 	
417 	/**
418 	 * Computes the exclusive difference of dst with rectangle and places the
419 	 * result in dst. That is, dst will be set to contain all areas that are
420 	 * either in dst or in rectangle, but not in both.
421 	 * Since 1.10
422 	 * Params:
423 	 * rectangle = a cairo_rectangle_int_t
424 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY
425 	 */
426 	public cairo_status_t xorRectangle(ref cairo_rectangle_int_t rectangle)
427 	{
428 		// cairo_status_t cairo_region_xor_rectangle (cairo_region_t *dst,  const cairo_rectangle_int_t *rectangle);
429 		return cairo_region_xor_rectangle(cairo_region, &rectangle);
430 	}
431 }