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 gtkc.cairotypes; 56 57 private import gtkc.cairo; 58 private import glib.ConstructionException; 59 60 61 62 63 64 65 /** 66 * Description 67 * Regions are a simple graphical data type representing an area of 68 * integer-aligned rectangles. They are often used on raster surfaces 69 * to track areas of interest, such as change or clip areas. 70 */ 71 public class Region 72 { 73 74 /** the main Gtk struct */ 75 protected cairo_region_t* cairo_region; 76 77 78 public cairo_region_t* getRegionStruct() 79 { 80 return cairo_region; 81 } 82 83 84 /** the main Gtk struct as a void* */ 85 protected void* getStruct() 86 { 87 return cast(void*)cairo_region; 88 } 89 90 /** 91 * Sets our main struct and passes it to the parent class 92 */ 93 public this (cairo_region_t* cairo_region) 94 { 95 this.cairo_region = cairo_region; 96 } 97 98 /** 99 */ 100 101 /** 102 * Allocates a new empty region object. 103 * Since 1.10 104 * 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(). 105 */ 106 public static Region create() 107 { 108 // cairo_region_t * cairo_region_create (void); 109 auto p = cairo_region_create(); 110 111 if(p is null) 112 { 113 return null; 114 } 115 116 return new Region(cast(cairo_region_t*) p); 117 } 118 119 /** 120 * Allocates a new region object containing rectangle. 121 * Since 1.10 122 * Params: 123 * rectangle = a cairo_rectangle_int_t 124 * 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(). 125 */ 126 public static Region createRectangle(ref cairo_rectangle_int_t rectangle) 127 { 128 // cairo_region_t * cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle); 129 auto p = cairo_region_create_rectangle(&rectangle); 130 131 if(p is null) 132 { 133 return null; 134 } 135 136 return new Region(cast(cairo_region_t*) p); 137 } 138 139 /** 140 * Allocates a new region object containing the union of all given rects. 141 * Since 1.10 142 * Params: 143 * rects = an array of count rectangles 144 * 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(). 145 */ 146 public static Region createRectangles(cairo_rectangle_int_t[] rects) 147 { 148 // cairo_region_t * cairo_region_create_rectangles (const cairo_rectangle_int_t *rects, int count); 149 auto p = cairo_region_create_rectangles(rects.ptr, cast(int) rects.length); 150 151 if(p is null) 152 { 153 return null; 154 } 155 156 return new Region(cast(cairo_region_t*) p); 157 } 158 159 /** 160 * Allocates a new region object copying the area from original. 161 * Since 1.10 162 * 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(). 163 */ 164 public Region copy() 165 { 166 // cairo_region_t * cairo_region_copy (const cairo_region_t *original); 167 auto p = cairo_region_copy(cairo_region); 168 169 if(p is null) 170 { 171 return null; 172 } 173 174 return new Region(cast(cairo_region_t*) p); 175 } 176 177 /** 178 * Increases the reference count on region by one. This prevents 179 * region from being destroyed until a matching call to 180 * cairo_region_destroy() is made. 181 * Since 1.10 182 * Returns: the referenced cairo_region_t. 183 */ 184 public Region reference() 185 { 186 // cairo_region_t * cairo_region_reference (cairo_region_t *region); 187 auto p = cairo_region_reference(cairo_region); 188 189 if(p is null) 190 { 191 return null; 192 } 193 194 return new Region(cast(cairo_region_t*) p); 195 } 196 197 /** 198 * Destroys a cairo_region_t object created with 199 * cairo_region_create(), cairo_region_copy(), or 200 * or cairo_region_create_rectangle(). 201 * Since 1.10 202 */ 203 public void destroy() 204 { 205 // void cairo_region_destroy (cairo_region_t *region); 206 cairo_region_destroy(cairo_region); 207 } 208 209 /** 210 * Checks whether an error has previous occured for this 211 * region object. 212 * Since 1.10 213 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 214 */ 215 public cairo_status_t status() 216 { 217 // cairo_status_t cairo_region_status (const cairo_region_t *region); 218 return cairo_region_status(cairo_region); 219 } 220 221 /** 222 * Gets the bounding rectangle of region as a cairo_rectangle_int_t 223 * Since 1.10 224 * Params: 225 * extents = rectangle into which to store the extents 226 */ 227 public void getExtents(out cairo_rectangle_int_t extents) 228 { 229 // void cairo_region_get_extents (const cairo_region_t *region, cairo_rectangle_int_t *extents); 230 cairo_region_get_extents(cairo_region, &extents); 231 } 232 233 /** 234 * Returns the number of rectangles contained in region. 235 * Since 1.10 236 * Returns: The number of rectangles contained in region. 237 */ 238 public int numRectangles() 239 { 240 // int cairo_region_num_rectangles (const cairo_region_t *region); 241 return cairo_region_num_rectangles(cairo_region); 242 } 243 244 /** 245 * Stores the nth rectangle from the region in rectangle. 246 * Since 1.10 247 * Params: 248 * nth = a number indicating which rectangle should be returned 249 * rectangle = return location for a cairo_rectangle_int_t 250 */ 251 public void getRectangle(int nth, out cairo_rectangle_int_t rectangle) 252 { 253 // void cairo_region_get_rectangle (const cairo_region_t *region, int nth, cairo_rectangle_int_t *rectangle); 254 cairo_region_get_rectangle(cairo_region, nth, &rectangle); 255 } 256 257 /** 258 * Checks whether region is empty. 259 * Since 1.10 260 * Returns: TRUE if region is empty, FALSE if it isn't. 261 */ 262 public cairo_bool_t isEmpty() 263 { 264 // cairo_bool_t cairo_region_is_empty (const cairo_region_t *region); 265 return cairo_region_is_empty(cairo_region); 266 } 267 268 /** 269 * Checks whether (x, y) is contained in region. 270 * Since 1.10 271 * Params: 272 * x = the x coordinate of a point 273 * y = the y coordinate of a point 274 * Returns: TRUE if (x, y) is contained in region, FALSE if it is not. 275 */ 276 public cairo_bool_t containsPoint(int x, int y) 277 { 278 // cairo_bool_t cairo_region_contains_point (const cairo_region_t *region, int x, int y); 279 return cairo_region_contains_point(cairo_region, x, y); 280 } 281 282 /** 283 * Checks whether rectangle is inside, outside or partially contained 284 * in region 285 * Since 1.10 286 * Params: 287 * region = a cairo_region_t 288 * rectangle = a cairo_rectangle_int_t 289 * 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. 290 */ 291 public cairo_region_overlap_t containsRectangle(ref cairo_rectangle_int_t rectangle) 292 { 293 // cairo_region_overlap_t cairo_region_contains_rectangle (const cairo_region_t *region, const cairo_rectangle_int_t *rectangle); 294 return cairo_region_contains_rectangle(cairo_region, &rectangle); 295 } 296 297 /** 298 * Compares whether region_a is equivalent to region_b. NULL as an argument 299 * is equal to itself, but not to any non-NULL region. 300 * Since 1.10 301 * Params: 302 * a = a cairo_region_t or NULL 303 * b = a cairo_region_t or NULL 304 * Returns: TRUE if both regions contained the same coverage, FALSE if it is not or any region is in an error status. 305 */ 306 public cairo_bool_t equal(Region b) 307 { 308 // cairo_bool_t cairo_region_equal (const cairo_region_t *a, const cairo_region_t *b); 309 return cairo_region_equal(cairo_region, (b is null) ? null : b.getRegionStruct()); 310 } 311 312 /** 313 * Translates region by (dx, dy). 314 * Since 1.10 315 * Params: 316 * dx = Amount to translate in the x direction 317 * dy = Amount to translate in the y direction 318 */ 319 public void translate(int dx, int dy) 320 { 321 // void cairo_region_translate (cairo_region_t *region, int dx, int dy); 322 cairo_region_translate(cairo_region, dx, dy); 323 } 324 325 /** 326 * Computes the intersection of dst with other and places the result in dst 327 * Since 1.10 328 * Params: 329 * other = another cairo_region_t 330 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 331 */ 332 public cairo_status_t intersect(Region other) 333 { 334 // cairo_status_t cairo_region_intersect (cairo_region_t *dst, const cairo_region_t *other); 335 return cairo_region_intersect(cairo_region, (other is null) ? null : other.getRegionStruct()); 336 } 337 338 /** 339 * Computes the intersection of dst with rectangle and places the 340 * result in dst 341 * Since 1.10 342 * Params: 343 * rectangle = a cairo_rectangle_int_t 344 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 345 */ 346 public cairo_status_t intersectRectangle(ref cairo_rectangle_int_t rectangle) 347 { 348 // cairo_status_t cairo_region_intersect_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle); 349 return cairo_region_intersect_rectangle(cairo_region, &rectangle); 350 } 351 352 /** 353 * Subtracts other from dst and places the result in dst 354 * Since 1.10 355 * Params: 356 * other = another cairo_region_t 357 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 358 */ 359 public cairo_status_t subtract(Region other) 360 { 361 // cairo_status_t cairo_region_subtract (cairo_region_t *dst, const cairo_region_t *other); 362 return cairo_region_subtract(cairo_region, (other is null) ? null : other.getRegionStruct()); 363 } 364 365 /** 366 * Subtracts rectangle from dst and places the result in dst 367 * Since 1.10 368 * Params: 369 * rectangle = a cairo_rectangle_int_t 370 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 371 */ 372 public cairo_status_t subtractRectangle(ref cairo_rectangle_int_t rectangle) 373 { 374 // cairo_status_t cairo_region_subtract_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle); 375 return cairo_region_subtract_rectangle(cairo_region, &rectangle); 376 } 377 378 /** 379 * Computes the union of dst with other and places the result in dst 380 * Since 1.10 381 * Params: 382 * other = another cairo_region_t 383 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 384 */ 385 public cairo_status_t unio(Region other) 386 { 387 // cairo_status_t cairo_region_union (cairo_region_t *dst, const cairo_region_t *other); 388 return cairo_region_union(cairo_region, (other is null) ? null : other.getRegionStruct()); 389 } 390 391 /** 392 * Computes the union of dst with rectangle and places the result in dst. 393 * Since 1.10 394 * Params: 395 * rectangle = a cairo_rectangle_int_t 396 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 397 */ 398 public cairo_status_t unionRectangle(ref cairo_rectangle_int_t rectangle) 399 { 400 // cairo_status_t cairo_region_union_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle); 401 return cairo_region_union_rectangle(cairo_region, &rectangle); 402 } 403 404 /** 405 * Computes the exclusive difference of dst with other and places the 406 * result in dst. That is, dst will be set to contain all areas that 407 * are either in dst or in other, but not in both. 408 * Since 1.10 409 * Params: 410 * other = another cairo_region_t 411 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 412 */ 413 public cairo_status_t xor(Region other) 414 { 415 // cairo_status_t cairo_region_xor (cairo_region_t *dst, const cairo_region_t *other); 416 return cairo_region_xor(cairo_region, (other is null) ? null : other.getRegionStruct()); 417 } 418 419 /** 420 * Computes the exclusive difference of dst with rectangle and places the 421 * result in dst. That is, dst will be set to contain all areas that are 422 * either in dst or in rectangle, but not in both. 423 * Since 1.10 424 * Params: 425 * rectangle = a cairo_rectangle_int_t 426 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY 427 */ 428 public cairo_status_t xorRectangle(ref cairo_rectangle_int_t rectangle) 429 { 430 // cairo_status_t cairo_region_xor_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle); 431 return cairo_region_xor_rectangle(cairo_region, &rectangle); 432 } 433 }