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