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 = gdk-Drawing-Primitives.html 27 * outPack = gdk 28 * outFile = Drawable 29 * strct = GdkDrawable 30 * realStrct= 31 * ctorStrct= 32 * clss = Drawable 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_drawable_ 41 * - gdk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gdk_drawable_ref 46 * - gdk_drawable_unref 47 * omit signals: 48 * imports: 49 * - glib.Str 50 * - gdk.Display 51 * - gdk.Screen 52 * - gdk.Visual 53 * - gdk.Colormap 54 * - gdk.Region 55 * - gdk.GC 56 * - gdk.Pixbuf 57 * - gdk.Color 58 * - gdk.Font 59 * - gdk.ImageGdk 60 * - pango.PgFont 61 * - pango.PgGlyphString 62 * - pango.PgMatrix 63 * - pango.PgLayout 64 * - pango.PgLayoutLine 65 * structWrap: 66 * - GdkColor* -> Color 67 * - GdkColormap* -> Colormap 68 * - GdkDisplay* -> Display 69 * - GdkDrawable* -> Drawable 70 * - GdkFont* -> Font 71 * - GdkGC* -> GC 72 * - GdkImage* -> ImageGdk 73 * - GdkPixbuf* -> Pixbuf 74 * - GdkRegion* -> Region 75 * - GdkScreen* -> Screen 76 * - GdkVisual* -> Visual 77 * - PangoFont* -> PgFont 78 * - PangoGlyphString* -> PgGlyphString 79 * - PangoLayout* -> PgLayout 80 * - PangoLayoutLine* -> PgLayoutLine 81 * - PangoMatrix* -> PgMatrix 82 * module aliases: 83 * local aliases: 84 * overrides: 85 * - getData 86 */ 87 88 module gdk.Drawable; 89 90 public import gtkc.gdktypes; 91 92 private import gtkc.gdk; 93 private import glib.ConstructionException; 94 private import gobject.ObjectG; 95 96 97 private import glib.Str; 98 private import gdk.Display; 99 private import gdk.Screen; 100 private import gdk.Visual; 101 private import gdk.Colormap; 102 private import gdk.Region; 103 private import gdk.GC; 104 private import gdk.Pixbuf; 105 private import gdk.Color; 106 private import gdk.Font; 107 private import gdk.ImageGdk; 108 private import pango.PgFont; 109 private import pango.PgGlyphString; 110 private import pango.PgMatrix; 111 private import pango.PgLayout; 112 private import pango.PgLayoutLine; 113 114 115 116 private import gobject.ObjectG; 117 118 /** 119 * Description 120 * These functions provide support for drawing points, lines, arcs and text 121 * onto what are called 'drawables'. Drawables, as the name suggests, are things 122 * which support drawing onto them, and are either GdkWindow or GdkPixmap 123 * objects. 124 * Many of the drawing operations take a GdkGC argument, which represents a 125 * graphics context. This GdkGC contains a number of drawing attributes such 126 * as foreground color, background color and line width, and is used to reduce 127 * the number of arguments needed for each drawing operation. See the 128 * Graphics Contexts section for 129 * more information. 130 * Some of the drawing operations take Pango data structures like PangoContext, 131 * PangoLayout or PangoLayoutLine as arguments. If you're using GTK+, the ususal 132 * way to obtain these structures is via gtk_widget_create_pango_context() or 133 * gtk_widget_create_pango_layout(). 134 */ 135 public class Drawable : ObjectG 136 { 137 138 /** the main Gtk struct */ 139 protected GdkDrawable* gdkDrawable; 140 141 142 public GdkDrawable* getDrawableStruct() 143 { 144 return gdkDrawable; 145 } 146 147 148 /** the main Gtk struct as a void* */ 149 protected override void* getStruct() 150 { 151 return cast(void*)gdkDrawable; 152 } 153 154 /** 155 * Sets our main struct and passes it to the parent class 156 */ 157 public this (GdkDrawable* gdkDrawable) 158 { 159 super(cast(GObject*)gdkDrawable); 160 this.gdkDrawable = gdkDrawable; 161 } 162 163 protected override void setStruct(GObject* obj) 164 { 165 super.setStruct(obj); 166 gdkDrawable = cast(GdkDrawable*)obj; 167 } 168 169 /** */ 170 public void drawPixbuf(Pixbuf pixbuf, int destX, int destY) 171 { 172 drawPixbuf(null, pixbuf, destX, destY); 173 } 174 175 /** */ 176 public void drawPixbuf(GC gc, Pixbuf pixbuf, int destX, int destY) 177 { 178 if ( pixbuf is null ) return; 179 gdk_draw_pixbuf(gdkDrawable, 180 (gc is null) ? null : gc.getGCStruct(), 181 pixbuf.getPixbufStruct(), 182 0, 0, destX, destY, 183 pixbuf.getWidth(), pixbuf.getHeight(), 184 GdkRgbDither.NORMAL, 185 0, 0); 186 } 187 188 /** 189 */ 190 191 /** 192 * Warning 193 * gdk_drawable_set_data is deprecated and should not be used in newly-written code. 194 * This function is equivalent to g_object_set_data(), 195 * the GObject variant should be used instead. 196 * Params: 197 * key = name to store the data under 198 * data = arbitrary data 199 * destroyFunc = function to free data, or NULL. [allow-none] 200 */ 201 public void setData(string key, void* data, GDestroyNotify destroyFunc) 202 { 203 // void gdk_drawable_set_data (GdkDrawable *drawable, const gchar *key, gpointer data, GDestroyNotify destroy_func); 204 gdk_drawable_set_data(gdkDrawable, Str.toStringz(key), data, destroyFunc); 205 } 206 207 /** 208 * Warning 209 * gdk_drawable_get_data is deprecated and should not be used in newly-written code. 210 * Equivalent to g_object_get_data(); the GObject variant should be 211 * used instead. 212 * Params: 213 * key = name the data was stored under 214 * Returns: the data stored at key 215 */ 216 public override void* getData(string key) 217 { 218 // gpointer gdk_drawable_get_data (GdkDrawable *drawable, const gchar *key); 219 return gdk_drawable_get_data(gdkDrawable, Str.toStringz(key)); 220 } 221 222 /** 223 * Warning 224 * gdk_drawable_get_display has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_window_get_display() instead 225 * Gets the GdkDisplay associated with a GdkDrawable. 226 * Since 2.2 227 * Returns: the GdkDisplay associated with drawable 228 */ 229 public Display getDisplay() 230 { 231 // GdkDisplay * gdk_drawable_get_display (GdkDrawable *drawable); 232 auto p = gdk_drawable_get_display(gdkDrawable); 233 234 if(p is null) 235 { 236 return null; 237 } 238 239 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 240 } 241 242 /** 243 * Warning 244 * gdk_drawable_get_screen has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_window_get_screen() instead 245 * Gets the GdkScreen associated with a GdkDrawable. 246 * Since 2.2 247 * Returns: the GdkScreen associated with drawable 248 */ 249 public Screen getScreen() 250 { 251 // GdkScreen * gdk_drawable_get_screen (GdkDrawable *drawable); 252 auto p = gdk_drawable_get_screen(gdkDrawable); 253 254 if(p is null) 255 { 256 return null; 257 } 258 259 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 260 } 261 262 /** 263 * Warning 264 * gdk_drawable_get_visual has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_window_get_visual() 265 * Gets the GdkVisual describing the pixel format of drawable. 266 * Returns: a GdkVisual 267 */ 268 public Visual getVisual() 269 { 270 // GdkVisual * gdk_drawable_get_visual (GdkDrawable *drawable); 271 auto p = gdk_drawable_get_visual(gdkDrawable); 272 273 if(p is null) 274 { 275 return null; 276 } 277 278 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 279 } 280 281 /** 282 * Sets the colormap associated with drawable. Normally this will 283 * happen automatically when the drawable is created; you only need to 284 * use this function if the drawable-creating function did not have a 285 * way to determine the colormap, and you then use drawable operations 286 * that require a colormap. The colormap for all drawables and 287 * graphics contexts you intend to use together should match. i.e. 288 * when using a GdkGC to draw to a drawable, or copying one drawable 289 * to another, the colormaps should match. 290 * Params: 291 * colormap = a GdkColormap 292 */ 293 public void setColormap(Colormap colormap) 294 { 295 // void gdk_drawable_set_colormap (GdkDrawable *drawable, GdkColormap *colormap); 296 gdk_drawable_set_colormap(gdkDrawable, (colormap is null) ? null : colormap.getColormapStruct()); 297 } 298 299 /** 300 * Gets the colormap for drawable, if one is set; returns 301 * NULL otherwise. 302 * Returns: the colormap, or NULL 303 */ 304 public Colormap getColormap() 305 { 306 // GdkColormap * gdk_drawable_get_colormap (GdkDrawable *drawable); 307 auto p = gdk_drawable_get_colormap(gdkDrawable); 308 309 if(p is null) 310 { 311 return null; 312 } 313 314 return ObjectG.getDObject!(Colormap)(cast(GdkColormap*) p); 315 } 316 317 /** 318 * Obtains the bit depth of the drawable, that is, the number of bits 319 * that make up a pixel in the drawable's visual. Examples are 8 bits 320 * per pixel, 24 bits per pixel, etc. 321 * Returns: number of bits per pixel 322 */ 323 public int getDepth() 324 { 325 // gint gdk_drawable_get_depth (GdkDrawable *drawable); 326 return gdk_drawable_get_depth(gdkDrawable); 327 } 328 329 /** 330 * Warning 331 * gdk_drawable_get_size has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_window_get_width() and gdk_window_get_height() for 332 * GdkWindows. Use gdk_pixmap_get_size() for GdkPixmaps. 333 * Fills *width and *height with the size of drawable. 334 * width or height can be NULL if you only want the other one. 335 * On the X11 platform, if drawable is a GdkWindow, the returned 336 * size is the size reported in the most-recently-processed configure 337 * event, rather than the current size on the X server. 338 * Params: 339 * width = location to store drawable's width, or NULL. [out][allow-none] 340 * height = location to store drawable's height, or NULL. [out][allow-none] 341 */ 342 public void getSize(out int width, out int height) 343 { 344 // void gdk_drawable_get_size (GdkDrawable *drawable, gint *width, gint *height); 345 gdk_drawable_get_size(gdkDrawable, &width, &height); 346 } 347 348 /** 349 * Computes the region of a drawable that potentially can be written 350 * to by drawing primitives. This region will not take into account 351 * the clip region for the GC, and may also not take into account 352 * other factors such as if the window is obscured by other windows, 353 * but no area outside of this region will be affected by drawing 354 * primitives. 355 * Returns: a GdkRegion. This must be freed with gdk_region_destroy() when you are done. 356 */ 357 public Region getClipRegion() 358 { 359 // GdkRegion * gdk_drawable_get_clip_region (GdkDrawable *drawable); 360 auto p = gdk_drawable_get_clip_region(gdkDrawable); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(Region)(cast(GdkRegion*) p); 368 } 369 370 /** 371 * Computes the region of a drawable that is potentially visible. 372 * This does not necessarily take into account if the window is 373 * obscured by other windows, but no area outside of this region 374 * is visible. 375 * Returns: a GdkRegion. This must be freed with gdk_region_destroy() when you are done. 376 */ 377 public Region getVisibleRegion() 378 { 379 // GdkRegion * gdk_drawable_get_visible_region (GdkDrawable *drawable); 380 auto p = gdk_drawable_get_visible_region(gdkDrawable); 381 382 if(p is null) 383 { 384 return null; 385 } 386 387 return ObjectG.getDObject!(Region)(cast(GdkRegion*) p); 388 } 389 390 /** 391 * Warning 392 * gdk_draw_point has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_rectangle() and cairo_fill() or 393 * cairo_move_to() and cairo_stroke() instead. 394 * Draws a point, using the foreground color and other attributes of 395 * the GdkGC. 396 * Params: 397 * gc = a GdkGC. 398 * x = the x coordinate of the point. 399 * y = the y coordinate of the point. 400 */ 401 public void drawPoint(GC gc, int x, int y) 402 { 403 // void gdk_draw_point (GdkDrawable *drawable, GdkGC *gc, gint x, gint y); 404 gdk_draw_point(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x, y); 405 } 406 407 /** 408 * Warning 409 * gdk_draw_points has been deprecated since version 2.22 and should not be used in newly-written code. Use n_points calls to cairo_rectangle() and 410 * cairo_fill() instead. 411 * Draws a number of points, using the foreground color and other 412 * attributes of the GdkGC. 413 * Params: 414 * gc = a GdkGC. 415 * points = an array of GdkPoint structures. 416 */ 417 public void drawPoints(GC gc, GdkPoint[] points) 418 { 419 // void gdk_draw_points (GdkDrawable *drawable, GdkGC *gc, const GdkPoint *points, gint n_points); 420 gdk_draw_points(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), points.ptr, cast(int) points.length); 421 } 422 423 /** 424 * Warning 425 * gdk_draw_line has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_line_to() and cairo_stroke() instead. 426 * Be aware that the default line width in Cairo is 2 pixels and that your 427 * coordinates need to describe the center of the line. To draw a single 428 * Params: 429 * gc = a GdkGC. 430 * x1_ = the x coordinate of the start point. 431 * y1_ = the y coordinate of the start point. 432 * x2_ = the x coordinate of the end point. 433 * y2_ = the y coordinate of the end point. 434 */ 435 public void drawLine(GC gc, int x1_, int y1_, int x2_, int y2_) 436 { 437 // void gdk_draw_line (GdkDrawable *drawable, GdkGC *gc, gint x1_, gint y1_, gint x2_, gint y2_); 438 gdk_draw_line(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x1_, y1_, x2_, y2_); 439 } 440 441 /** 442 * Warning 443 * gdk_draw_lines has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_line_to() and cairo_stroke() instead. See the 444 * documentation of gdk_draw_line() for notes on line drawing with Cairo. 445 * Draws a series of lines connecting the given points. 446 * The way in which joins between lines are draw is determined by the 447 * GdkCapStyle value in the GdkGC. This can be set with 448 * gdk_gc_set_line_attributes(). 449 * Params: 450 * gc = a GdkGC. 451 * points = an array of GdkPoint structures specifying the endpoints of the 452 */ 453 public void drawLines(GC gc, GdkPoint[] points) 454 { 455 // void gdk_draw_lines (GdkDrawable *drawable, GdkGC *gc, const GdkPoint *points, gint n_points); 456 gdk_draw_lines(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), points.ptr, cast(int) points.length); 457 } 458 459 /** 460 * Warning 461 * gdk_draw_pixbuf has been deprecated since version 2.22 and should not be used in newly-written code. Use gdk_cairo_set_source_pixbuf() and cairo_paint() or 462 * cairo_rectangle() and cairo_fill() instead. 463 * Renders a rectangular portion of a pixbuf to a drawable. The destination 464 * drawable must have a colormap. All windows have a colormap, however, pixmaps 465 * only have colormap by default if they were created with a non-NULL window 466 * argument. Otherwise a colormap must be set on them with 467 * gdk_drawable_set_colormap(). 468 * On older X servers, rendering pixbufs with an alpha channel involves round 469 * trips to the X server, and may be somewhat slow. 470 * If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf 471 * function is accelerated using mediaLib, which provides hardware 472 * acceleration on Intel, AMD, and Sparc chipsets. If desired, mediaLib 473 * support can be turned off by setting the GDK_DISABLE_MEDIALIB environment 474 * variable. 475 * Since 2.2 476 * Params: 477 * gc = a GdkGC, used for clipping, or NULL. [allow-none] 478 * pixbuf = a GdkPixbuf 479 * srcX = Source X coordinate within pixbuf. 480 * srcY = Source Y coordinates within pixbuf. 481 * destX = Destination X coordinate within drawable. 482 * destY = Destination Y coordinate within drawable. 483 * width = Width of region to render, in pixels, or -1 to use pixbuf width. 484 * height = Height of region to render, in pixels, or -1 to use pixbuf height. 485 * dither = Dithering mode for GdkRGB. 486 * xDither = X offset for dither. 487 * yDither = Y offset for dither. 488 */ 489 public void drawPixbuf(GC gc, Pixbuf pixbuf, int srcX, int srcY, int destX, int destY, int width, int height, GdkRgbDither dither, int xDither, int yDither) 490 { 491 // void gdk_draw_pixbuf (GdkDrawable *drawable, GdkGC *gc, const GdkPixbuf *pixbuf, gint src_x, gint src_y, gint dest_x, gint dest_y, gint width, gint height, GdkRgbDither dither, gint x_dither, gint y_dither); 492 gdk_draw_pixbuf(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), srcX, srcY, destX, destY, width, height, dither, xDither, yDither); 493 } 494 495 /** 496 * Warning 497 * gdk_draw_segments has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_move_to(), cairo_line_to() and cairo_stroke() 498 * instead. See the documentation of gdk_draw_line() for notes on line drawing 499 * with Cairo. 500 * Draws a number of unconnected lines. 501 * Params: 502 * gc = a GdkGC. 503 * segs = an array of GdkSegment structures specifying the start and 504 * end points of the lines to be drawn. 505 */ 506 public void drawSegments(GC gc, GdkSegment[] segs) 507 { 508 // void gdk_draw_segments (GdkDrawable *drawable, GdkGC *gc, const GdkSegment *segs, gint n_segs); 509 gdk_draw_segments(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), segs.ptr, cast(int) segs.length); 510 } 511 512 /** 513 * Warning 514 * gdk_draw_rectangle has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_rectangle() and cairo_fill() or cairo_stroke() 515 * instead. For stroking, the same caveats for converting code apply as for 516 * gdk_draw_line(). 517 * Draws a rectangular outline or filled rectangle, using the foreground color 518 * and other attributes of the GdkGC. 519 * A rectangle drawn filled is 1 pixel smaller in both dimensions than a 520 * rectangle outlined. Calling 521 * gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20) 522 * results in a filled rectangle 20 pixels wide and 20 pixels high. Calling 523 * gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) 524 * results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), 525 * and (20, 0), which makes it 21 pixels wide and 21 pixels high. 526 * Note 527 * Params: 528 * gc = a GdkGC. 529 * filled = TRUE if the rectangle should be filled. 530 * x = the x coordinate of the left edge of the rectangle. 531 * y = the y coordinate of the top edge of the rectangle. 532 * width = the width of the rectangle. 533 * height = the height of the rectangle. 534 */ 535 public void drawRectangle(GC gc, int filled, int x, int y, int width, int height) 536 { 537 // void gdk_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, gboolean filled, gint x, gint y, gint width, gint height); 538 gdk_draw_rectangle(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), filled, x, y, width, height); 539 } 540 541 /** 542 * Warning 543 * gdk_draw_arc has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_arc() and cairo_fill() or cairo_stroke() 544 * instead. Note that arcs just like any drawing operation in Cairo are 545 * antialiased unless you call cairo_set_antialias(). 546 * Draws an arc or a filled 'pie slice'. The arc is defined by the bounding 547 * rectangle of the entire ellipse, and the start and end angles of the part 548 * of the ellipse to be drawn. 549 * Params: 550 * gc = a GdkGC. 551 * filled = TRUE if the arc should be filled, producing a 'pie slice'. 552 * x = the x coordinate of the left edge of the bounding rectangle. 553 * y = the y coordinate of the top edge of the bounding rectangle. 554 * width = the width of the bounding rectangle. 555 * height = the height of the bounding rectangle. 556 * angle1 = the start angle of the arc, relative to the 3 o'clock position, 557 * counter-clockwise, in 1/64ths of a degree. 558 * angle2 = the end angle of the arc, relative to angle1, in 1/64ths 559 * of a degree. 560 */ 561 public void drawArc(GC gc, int filled, int x, int y, int width, int height, int angle1, int angle2) 562 { 563 // void gdk_draw_arc (GdkDrawable *drawable, GdkGC *gc, gboolean filled, gint x, gint y, gint width, gint height, gint angle1, gint angle2); 564 gdk_draw_arc(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), filled, x, y, width, height, angle1, angle2); 565 } 566 567 /** 568 * Warning 569 * gdk_draw_polygon has been deprecated since version 2.22 and should not be used in newly-written code. Use cairo_line_to() or cairo_append_path() and 570 * cairo_fill() or cairo_stroke() instead. 571 * Draws an outlined or filled polygon. 572 * Params: 573 * gc = a GdkGC. 574 * filled = TRUE if the polygon should be filled. The polygon is closed 575 * automatically, connecting the last point to the first point if 576 * necessary. 577 * points = an array of GdkPoint structures specifying the points making 578 * up the polygon. 579 */ 580 public void drawPolygon(GC gc, int filled, GdkPoint[] points) 581 { 582 // void gdk_draw_polygon (GdkDrawable *drawable, GdkGC *gc, gboolean filled, const GdkPoint *points, gint n_points); 583 gdk_draw_polygon(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), filled, points.ptr, cast(int) points.length); 584 } 585 586 /** 587 * Warning 588 * gdk_draw_trapezoids has been deprecated since version 2.22 and should not be used in newly-written code. Use Cairo path contruction functions and cairo_fill() 589 * instead. 590 * Draws a set of anti-aliased trapezoids. The trapezoids are 591 * combined using saturation addition, then drawn over the background 592 * as a set. This is low level functionality used internally to implement 593 * rotated underlines and backgrouds when rendering a PangoLayout and is 594 * likely not useful for applications. 595 * Since 2.6 596 * Params: 597 * gc = a GdkGC 598 * trapezoids = an array of GdkTrapezoid structures 599 */ 600 public void drawTrapezoids(GC gc, GdkTrapezoid[] trapezoids) 601 { 602 // void gdk_draw_trapezoids (GdkDrawable *drawable, GdkGC *gc, const GdkTrapezoid *trapezoids, gint n_trapezoids); 603 gdk_draw_trapezoids(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), trapezoids.ptr, cast(int) trapezoids.length); 604 } 605 606 /** 607 * Warning 608 * gdk_draw_glyphs has been deprecated since version 2.22 and should not be used in newly-written code. Use pango_cairo_show_glyphs() instead. 609 * This is a low-level function; 99% of text rendering should be done 610 * using gdk_draw_layout() instead. 611 * A glyph is a single image in a font. This function draws a sequence of 612 * glyphs. To obtain a sequence of glyphs you have to understand a 613 * lot about internationalized text handling, which you don't want to 614 * understand; thus, use gdk_draw_layout() instead of this function, 615 * gdk_draw_layout() handles the details. 616 * Params: 617 * gc = a GdkGC 618 * font = font to be used 619 * x = X coordinate of baseline origin 620 * y = Y coordinate of baseline origin 621 * glyphs = the glyph string to draw 622 */ 623 public void drawGlyphs(GC gc, PgFont font, int x, int y, PgGlyphString glyphs) 624 { 625 // void gdk_draw_glyphs (GdkDrawable *drawable, GdkGC *gc, PangoFont *font, gint x, gint y, PangoGlyphString *glyphs); 626 gdk_draw_glyphs(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), (font is null) ? null : font.getPgFontStruct(), x, y, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 627 } 628 629 /** 630 * Warning 631 * gdk_draw_glyphs_transformed has been deprecated since version 2.22 and should not be used in newly-written code. Use pango_cairo_show_glyphs() instead. 632 * Renders a PangoGlyphString onto a drawable, possibly 633 * transforming the layed-out coordinates through a transformation 634 * matrix. Note that the transformation matrix for font is not 635 * changed, so to produce correct rendering results, the font 636 * must have been loaded using a PangoContext with an identical 637 * transformation matrix to that passed in to this function. 638 * See also gdk_draw_glyphs(), gdk_draw_layout(). 639 * Since 2.6 640 * Params: 641 * gc = a GdkGC 642 * matrix = a PangoMatrix, or NULL to use an identity transformation. [allow-none] 643 * font = the font in which to draw the string 644 * x = the x position of the start of the string (in Pango 645 * units in user space coordinates) 646 * y = the y position of the baseline (in Pango units 647 * in user space coordinates) 648 * glyphs = the glyph string to draw 649 */ 650 public void drawGlyphsTransformed(GC gc, PgMatrix matrix, PgFont font, int x, int y, PgGlyphString glyphs) 651 { 652 // void gdk_draw_glyphs_transformed (GdkDrawable *drawable, GdkGC *gc, const PangoMatrix *matrix, PangoFont *font, gint x, gint y, PangoGlyphString *glyphs); 653 gdk_draw_glyphs_transformed(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), (matrix is null) ? null : matrix.getPgMatrixStruct(), (font is null) ? null : font.getPgFontStruct(), x, y, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 654 } 655 656 /** 657 * Warning 658 * gdk_draw_layout_line is deprecated and should not be used in newly-written code. 659 * Render a PangoLayoutLine onto an GDK drawable 660 * If the layout's PangoContext has a transformation matrix set, then 661 * x and y specify the position of the left edge of the baseline 662 * (left is in before-tranform user coordinates) in after-transform 663 * device coordinates. 664 * Params: 665 * gc = base graphics to use 666 * x = the x position of start of string (in pixels) 667 * y = the y position of baseline (in pixels) 668 * line = a PangoLayoutLine 669 */ 670 public void drawLayoutLine(GC gc, int x, int y, PgLayoutLine line) 671 { 672 // void gdk_draw_layout_line (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, PangoLayoutLine *line); 673 gdk_draw_layout_line(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x, y, (line is null) ? null : line.getPgLayoutLineStruct()); 674 } 675 676 /** 677 * Warning 678 * gdk_draw_layout_line_with_colors is deprecated and should not be used in newly-written code. 679 * Render a PangoLayoutLine onto a GdkDrawable, overriding the 680 * layout's normal colors with foreground and/or background. 681 * foreground and background need not be allocated. 682 * If the layout's PangoContext has a transformation matrix set, then 683 * x and y specify the position of the left edge of the baseline 684 * (left is in before-tranform user coordinates) in after-transform 685 * device coordinates. 686 * Params: 687 * gc = base graphics to use 688 * x = the x position of start of string (in pixels) 689 * y = the y position of baseline (in pixels) 690 * line = a PangoLayoutLine 691 * foreground = foreground override color, or NULL for none. [allow-none] 692 * background = background override color, or NULL for none. [allow-none] 693 */ 694 public void drawLayoutLineWithColors(GC gc, int x, int y, PgLayoutLine line, Color foreground, Color background) 695 { 696 // void gdk_draw_layout_line_with_colors (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, PangoLayoutLine *line, const GdkColor *foreground, const GdkColor *background); 697 gdk_draw_layout_line_with_colors(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x, y, (line is null) ? null : line.getPgLayoutLineStruct(), (foreground is null) ? null : foreground.getColorStruct(), (background is null) ? null : background.getColorStruct()); 698 } 699 700 /** 701 * Warning 702 * gdk_draw_layout is deprecated and should not be used in newly-written code. 703 * Render a PangoLayout onto a GDK drawable 704 * If the layout's PangoContext has a transformation matrix set, then 705 * x and y specify the position of the top left corner of the 706 * bounding box (in device space) of the transformed layout. 707 * If you're using GTK+, the usual way to obtain a PangoLayout 708 * is gtk_widget_create_pango_layout(). 709 * Params: 710 * gc = base graphics context to use 711 * x = the X position of the left of the layout (in pixels) 712 * y = the Y position of the top of the layout (in pixels) 713 * layout = a PangoLayout 714 */ 715 public void drawLayout(GC gc, int x, int y, PgLayout layout) 716 { 717 // void gdk_draw_layout (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, PangoLayout *layout); 718 gdk_draw_layout(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct()); 719 } 720 721 /** 722 * Warning 723 * gdk_draw_layout_with_colors is deprecated and should not be used in newly-written code. 724 * Render a PangoLayout onto a GdkDrawable, overriding the 725 * layout's normal colors with foreground and/or background. 726 * foreground and background need not be allocated. 727 * If the layout's PangoContext has a transformation matrix set, then 728 * x and y specify the position of the top left corner of the 729 * bounding box (in device space) of the transformed layout. 730 * If you're using GTK+, the ususal way to obtain a PangoLayout 731 * is gtk_widget_create_pango_layout(). 732 * Params: 733 * gc = base graphics context to use 734 * x = the X position of the left of the layout (in pixels) 735 * y = the Y position of the top of the layout (in pixels) 736 * layout = a PangoLayout 737 * foreground = foreground override color, or NULL for none. [allow-none] 738 * background = background override color, or NULL for none. [allow-none] 739 */ 740 public void drawLayoutWithColors(GC gc, int x, int y, PgLayout layout, Color foreground, Color background) 741 { 742 // void gdk_draw_layout_with_colors (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, PangoLayout *layout, const GdkColor *foreground, const GdkColor *background); 743 gdk_draw_layout_with_colors(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct(), (foreground is null) ? null : foreground.getColorStruct(), (background is null) ? null : background.getColorStruct()); 744 } 745 746 /** 747 * Warning 748 * gdk_draw_string has been deprecated since version 2.4 and should not be used in newly-written code. Use gdk_draw_layout() instead. 749 * Draws a string of characters in the given font or fontset. 750 * Params: 751 * font = a GdkFont. 752 * gc = a GdkGC. 753 * x = the x coordinate of the left edge of the text. 754 * y = the y coordinate of the baseline of the text. 755 * string = the string of characters to draw. 756 */ 757 public void drawString(Font font, GC gc, int x, int y, string string) 758 { 759 // void gdk_draw_string (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *string); 760 gdk_draw_string(gdkDrawable, (font is null) ? null : font.getFontStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, Str.toStringz(string)); 761 } 762 763 /** 764 * Warning 765 * gdk_draw_text has been deprecated since version 2.4 and should not be used in newly-written code. Use gdk_draw_layout() instead. 766 * Draws a number of characters in the given font or fontset. 767 * Params: 768 * font = a GdkFont. 769 * gc = a GdkGC. 770 * x = the x coordinate of the left edge of the text. 771 * y = the y coordinate of the baseline of the text. 772 * text = the characters to draw. 773 * textLength = the number of characters of text to draw. 774 */ 775 public void drawText(Font font, GC gc, int x, int y, string text, int textLength) 776 { 777 // void gdk_draw_text (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *text, gint text_length); 778 gdk_draw_text(gdkDrawable, (font is null) ? null : font.getFontStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, Str.toStringz(text), textLength); 779 } 780 781 /** 782 * Warning 783 * gdk_draw_text_wc has been deprecated since version 2.4 and should not be used in newly-written code. Use gdk_draw_layout() instead. 784 * Draws a number of wide characters using the given font of fontset. 785 * If the font is a 1-byte font, the string is converted into 1-byte 786 * characters (discarding the high bytes) before output. 787 * Params: 788 * font = a GdkFont. 789 * gc = a GdkGC. 790 * x = the x coordinate of the left edge of the text. 791 * y = the y coordinate of the baseline of the text. 792 * text = the wide characters to draw. 793 */ 794 public void drawTextWc(Font font, GC gc, int x, int y, GdkWChar[] text) 795 { 796 // void gdk_draw_text_wc (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const GdkWChar *text, gint text_length); 797 gdk_draw_text_wc(gdkDrawable, (font is null) ? null : font.getFontStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, text.ptr, cast(int) text.length); 798 } 799 800 /** 801 * Warning 802 * gdk_draw_drawable has been deprecated since version 2.22 and should not be used in newly-written code. Use gdk_cairo_set_source_pixmap(), cairo_rectangle() 803 * and cairo_fill() to draw pixmap on top of other drawables. Also keep 804 * in mind that the limitations on allowed sources do not apply to Cairo. 805 * Copies the width x height region of src at coordinates (xsrc, 806 * ysrc) to coordinates (xdest, ydest) in drawable. 807 * width and/or height may be given as -1, in which case the entire 808 * src drawable will be copied. 809 * Most fields in gc are not used for this operation, but notably the 810 * clip mask or clip region will be honored. 811 * The source and destination drawables must have the same visual and 812 * colormap, or errors will result. (On X11, failure to match 813 * visual/colormap results in a BadMatch error from the X server.) 814 * A common cause of this problem is an attempt to draw a bitmap to 815 * a color drawable. The way to draw a bitmap is to set the bitmap as 816 * the stipple on the GdkGC, set the fill mode to GDK_STIPPLED, and 817 * then draw the rectangle. 818 * Params: 819 * gc = a GdkGC sharing the drawable's visual and colormap 820 * src = the source GdkDrawable, which may be the same as drawable 821 * xsrc = X position in src of rectangle to draw 822 * ysrc = Y position in src of rectangle to draw 823 * xdest = X position in drawable where the rectangle should be drawn 824 * ydest = Y position in drawable where the rectangle should be drawn 825 * width = width of rectangle to draw, or -1 for entire src width 826 * height = height of rectangle to draw, or -1 for entire src height 827 */ 828 public void drawDrawable(GC gc, Drawable src, int xsrc, int ysrc, int xdest, int ydest, int width, int height) 829 { 830 // void gdk_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkDrawable *src, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height); 831 gdk_draw_drawable(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), (src is null) ? null : src.getDrawableStruct(), xsrc, ysrc, xdest, ydest, width, height); 832 } 833 834 /** 835 * Warning 836 * gdk_draw_image has been deprecated since version 2.22 and should not be used in newly-written code. Do not use GdkImage anymore, instead use Cairo image 837 * surfaces. 838 * Draws a GdkImage onto a drawable. 839 * The depth of the GdkImage must match the depth of the GdkDrawable. 840 * Params: 841 * gc = a GdkGC. 842 * image = the GdkImage to draw. 843 * xsrc = the left edge of the source rectangle within image. 844 * ysrc = the top of the source rectangle within image. 845 * xdest = the x coordinate of the destination within drawable. 846 * ydest = the y coordinate of the destination within drawable. 847 * width = the width of the area to be copied, or -1 to make the area 848 * extend to the right edge of image. 849 * height = the height of the area to be copied, or -1 to make the area 850 * extend to the bottom edge of image. 851 */ 852 public void drawImage(GC gc, ImageGdk image, int xsrc, int ysrc, int xdest, int ydest, int width, int height) 853 { 854 // void gdk_draw_image (GdkDrawable *drawable, GdkGC *gc, GdkImage *image, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height); 855 gdk_draw_image(gdkDrawable, (gc is null) ? null : gc.getGCStruct(), (image is null) ? null : image.getImageGdkStruct(), xsrc, ysrc, xdest, ydest, width, height); 856 } 857 858 /** 859 * Warning 860 * gdk_drawable_get_image has been deprecated since version 2.22 and should not be used in newly-written code. Use drawable as the source and draw to a Cairo image 861 * surface if you want to download contents to the client. 862 * A GdkImage stores client-side image data (pixels). In contrast, 863 * GdkPixmap and GdkWindow are server-side 864 * objects. gdk_drawable_get_image() obtains the pixels from a 865 * server-side drawable as a client-side GdkImage. The format of a 866 * GdkImage depends on the GdkVisual of the current display, which 867 * makes manipulating GdkImage extremely difficult; therefore, in 868 * most cases you should use gdk_pixbuf_get_from_drawable() instead of 869 * this lower-level function. A GdkPixbuf contains image data in a 870 * canonicalized RGB format, rather than a display-dependent format. 871 * Of course, there's a convenience vs. speed tradeoff here, so you'll 872 * want to think about what makes sense for your application. 873 * x, y, width, and height define the region of drawable to 874 * obtain as an image. 875 * You would usually copy image data to the client side if you intend 876 * to examine the values of individual pixels, for example to darken 877 * an image or add a red tint. It would be prohibitively slow to 878 * make a round-trip request to the windowing system for each pixel, 879 * so instead you get all of them at once, modify them, then copy 880 * them all back at once. 881 * If the X server or other windowing system backend is on the local 882 * machine, this function may use shared memory to avoid copying 883 * the image data. 884 * If the source drawable is a GdkWindow and partially offscreen 885 * or obscured, then the obscured portions of the returned image 886 * will contain undefined data. 887 * Params: 888 * x = x coordinate on drawable 889 * y = y coordinate on drawable 890 * width = width of region to get 891 * height = height or region to get 892 * Returns: a GdkImage containing the contents of drawable 893 */ 894 public ImageGdk getImage(int x, int y, int width, int height) 895 { 896 // GdkImage * gdk_drawable_get_image (GdkDrawable *drawable, gint x, gint y, gint width, gint height); 897 auto p = gdk_drawable_get_image(gdkDrawable, x, y, width, height); 898 899 if(p is null) 900 { 901 return null; 902 } 903 904 return ObjectG.getDObject!(ImageGdk)(cast(GdkImage*) p); 905 } 906 907 /** 908 * Warning 909 * gdk_drawable_copy_to_image has been deprecated since version 2.22 and should not be used in newly-written code. Use drawable as the source and draw to a Cairo image 910 * surface if you want to download contents to the client. 911 * Copies a portion of drawable into the client side image structure 912 * image. If image is NULL, creates a new image of size width x height 913 * and copies into that. See gdk_drawable_get_image() for further details. 914 * Since 2.4 915 * Params: 916 * image = a GdkDrawable, or NULL if a new image should be created. [allow-none] 917 * srcX = x coordinate on drawable 918 * srcY = y coordinate on drawable 919 * destX = x coordinate within image. Must be 0 if image is NULL 920 * destY = y coordinate within image. Must be 0 if image is NULL 921 * width = width of region to get 922 * height = height or region to get 923 * Returns: image, or a new a GdkImage containing the contents of drawable 924 */ 925 public ImageGdk copyToImage(ImageGdk image, int srcX, int srcY, int destX, int destY, int width, int height) 926 { 927 // GdkImage * gdk_drawable_copy_to_image (GdkDrawable *drawable, GdkImage *image, gint src_x, gint src_y, gint dest_x, gint dest_y, gint width, gint height); 928 auto p = gdk_drawable_copy_to_image(gdkDrawable, (image is null) ? null : image.getImageGdkStruct(), srcX, srcY, destX, destY, width, height); 929 930 if(p is null) 931 { 932 return null; 933 } 934 935 return ObjectG.getDObject!(ImageGdk)(cast(GdkImage*) p); 936 } 937 }