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 module gdk.DrawingContext; 26 27 private import cairo.Context; 28 private import cairo.Region; 29 private import gdk.Window; 30 private import gdk.c.functions; 31 public import gdk.c.types; 32 private import gobject.ObjectG; 33 public import gtkc.gdktypes; 34 35 36 /** 37 * #GdkDrawingContext is an object that represents the current drawing 38 * state of a #GdkWindow. 39 * 40 * It's possible to use a #GdkDrawingContext to draw on a #GdkWindow 41 * via rendering API like Cairo or OpenGL. 42 * 43 * A #GdkDrawingContext can only be created by calling gdk_window_begin_draw_frame() 44 * and will be valid until a call to gdk_window_end_draw_frame(). 45 * 46 * #GdkDrawingContext is available since GDK 3.22 47 */ 48 public class DrawingContext : ObjectG 49 { 50 /** the main Gtk struct */ 51 protected GdkDrawingContext* gdkDrawingContext; 52 53 /** Get the main Gtk struct */ 54 public GdkDrawingContext* getDrawingContextStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return gdkDrawingContext; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected override void* getStruct() 63 { 64 return cast(void*)gdkDrawingContext; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GdkDrawingContext* gdkDrawingContext, bool ownedRef = false) 71 { 72 this.gdkDrawingContext = gdkDrawingContext; 73 super(cast(GObject*)gdkDrawingContext, ownedRef); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return gdk_drawing_context_get_type(); 81 } 82 83 /** 84 * Retrieves a Cairo context to be used to draw on the #GdkWindow 85 * that created the #GdkDrawingContext. 86 * 87 * The returned context is guaranteed to be valid as long as the 88 * #GdkDrawingContext is valid, that is between a call to 89 * gdk_window_begin_draw_frame() and gdk_window_end_draw_frame(). 90 * 91 * Returns: a Cairo context to be used to draw 92 * the contents of the #GdkWindow. The context is owned by the 93 * #GdkDrawingContext and should not be destroyed 94 * 95 * Since: 3.22 96 */ 97 public Context getCairoContext() 98 { 99 auto p = gdk_drawing_context_get_cairo_context(gdkDrawingContext); 100 101 if(p is null) 102 { 103 return null; 104 } 105 106 return new Context(cast(cairo_t*) p); 107 } 108 109 /** 110 * Retrieves a copy of the clip region used when creating the @context. 111 * 112 * Returns: a Cairo region 113 * 114 * Since: 3.22 115 */ 116 public Region getClip() 117 { 118 auto p = gdk_drawing_context_get_clip(gdkDrawingContext); 119 120 if(p is null) 121 { 122 return null; 123 } 124 125 return new Region(cast(cairo_region_t*) p); 126 } 127 128 /** 129 * Retrieves the window that created the drawing @context. 130 * 131 * Returns: a #GdkWindow 132 * 133 * Since: 3.22 134 */ 135 public Window getWindow() 136 { 137 auto p = gdk_drawing_context_get_window(gdkDrawingContext); 138 139 if(p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 145 } 146 147 /** 148 * Checks whether the given #GdkDrawingContext is valid. 149 * 150 * Returns: %TRUE if the context is valid 151 * 152 * Since: 3.22 153 */ 154 public bool isValid() 155 { 156 return gdk_drawing_context_is_valid(gdkDrawingContext) != 0; 157 } 158 }