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 protected override void setStruct(GObject* obj) 68 { 69 gdkDrawingContext = cast(GdkDrawingContext*)obj; 70 super.setStruct(obj); 71 } 72 73 /** 74 * Sets our main struct and passes it to the parent class. 75 */ 76 public this (GdkDrawingContext* gdkDrawingContext, bool ownedRef = false) 77 { 78 this.gdkDrawingContext = gdkDrawingContext; 79 super(cast(GObject*)gdkDrawingContext, ownedRef); 80 } 81 82 83 /** */ 84 public static GType getType() 85 { 86 return gdk_drawing_context_get_type(); 87 } 88 89 /** 90 * Retrieves a Cairo context to be used to draw on the #GdkWindow 91 * that created the #GdkDrawingContext. 92 * 93 * The returned context is guaranteed to be valid as long as the 94 * #GdkDrawingContext is valid, that is between a call to 95 * gdk_window_begin_draw_frame() and gdk_window_end_draw_frame(). 96 * 97 * Returns: a Cairo context to be used to draw 98 * the contents of the #GdkWindow. The context is owned by the 99 * #GdkDrawingContext and should not be destroyed 100 * 101 * Since: 3.22 102 */ 103 public Context getCairoContext() 104 { 105 auto p = gdk_drawing_context_get_cairo_context(gdkDrawingContext); 106 107 if(p is null) 108 { 109 return null; 110 } 111 112 return new Context(cast(cairo_t*) p); 113 } 114 115 /** 116 * Retrieves a copy of the clip region used when creating the @context. 117 * 118 * Returns: a Cairo region 119 * 120 * Since: 3.22 121 */ 122 public Region getClip() 123 { 124 auto p = gdk_drawing_context_get_clip(gdkDrawingContext); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return new Region(cast(cairo_region_t*) p); 132 } 133 134 /** 135 * Retrieves the window that created the drawing @context. 136 * 137 * Returns: a #GdkWindow 138 * 139 * Since: 3.22 140 */ 141 public Window getWindow() 142 { 143 auto p = gdk_drawing_context_get_window(gdkDrawingContext); 144 145 if(p is null) 146 { 147 return null; 148 } 149 150 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 151 } 152 153 /** 154 * Checks whether the given #GdkDrawingContext is valid. 155 * 156 * Returns: %TRUE if the context is valid 157 * 158 * Since: 3.22 159 */ 160 public bool isValid() 161 { 162 return gdk_drawing_context_is_valid(gdkDrawingContext) != 0; 163 } 164 }