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 = GtkOffscreenWindow.html 27 * outPack = gtk 28 * outFile = OffscreenWindow 29 * strct = GtkOffscreenWindow 30 * realStrct= 31 * ctorStrct= 32 * clss = OffscreenWindow 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_offscreen_window_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - cairo.Surface 47 * - gdk.Pixbuf 48 * structWrap: 49 * - GdkPixbuf* -> Pixbuf 50 * - cairo_surface_t* -> Surface 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gtk.OffscreenWindow; 57 58 public import gtkc.gtktypes; 59 60 private import gtkc.gtk; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 65 private import cairo.Surface; 66 private import gdk.Pixbuf; 67 68 69 70 private import gtk.Window; 71 72 /** 73 * GtkOffscreenWindow is strictly intended to be used for obtaining 74 * snapshots of widgets that are not part of a normal widget hierarchy. 75 * Since GtkOffscreenWindow is a toplevel widget you cannot obtain 76 * snapshots of a full window with it since you cannot pack a toplevel 77 * widget in another toplevel. 78 * 79 * The idea is to take a widget and manually set the state of it, 80 * add it to a GtkOffscreenWindow and then retrieve the snapshot 81 * as a cairo_surface_t or GdkPixbuf. 82 * 83 * GtkOffscreenWindow derives from GtkWindow only as an implementation 84 * detail. Applications should not use any API specific to GtkWindow 85 * to operate on this object. It should be treated as a GtkBin that 86 * has no parent widget. 87 * 88 * When contained offscreen widgets are redrawn, GtkOffscreenWindow 89 * will emit a "damage-event" signal. 90 */ 91 public class OffscreenWindow : Window 92 { 93 94 /** the main Gtk struct */ 95 protected GtkOffscreenWindow* gtkOffscreenWindow; 96 97 98 public GtkOffscreenWindow* getOffscreenWindowStruct() 99 { 100 return gtkOffscreenWindow; 101 } 102 103 104 /** the main Gtk struct as a void* */ 105 protected override void* getStruct() 106 { 107 return cast(void*)gtkOffscreenWindow; 108 } 109 110 /** 111 * Sets our main struct and passes it to the parent class 112 */ 113 public this (GtkOffscreenWindow* gtkOffscreenWindow) 114 { 115 super(cast(GtkWindow*)gtkOffscreenWindow); 116 this.gtkOffscreenWindow = gtkOffscreenWindow; 117 } 118 119 protected override void setStruct(GObject* obj) 120 { 121 super.setStruct(obj); 122 gtkOffscreenWindow = cast(GtkOffscreenWindow*)obj; 123 } 124 125 /** 126 */ 127 128 /** 129 * Creates a toplevel container widget that is used to retrieve 130 * snapshots of widgets without showing them on the screen. 131 * Since 2.20 132 * Throws: ConstructionException GTK+ fails to create the object. 133 */ 134 public this () 135 { 136 // GtkWidget * gtk_offscreen_window_new (void); 137 auto p = gtk_offscreen_window_new(); 138 if(p is null) 139 { 140 throw new ConstructionException("null returned by gtk_offscreen_window_new()"); 141 } 142 this(cast(GtkOffscreenWindow*) p); 143 } 144 145 /** 146 * Retrieves a snapshot of the contained widget in the form of 147 * a cairo_surface_t. If you need to keep this around over window 148 * resizes then you should add a reference to it. 149 * Since 2.20 150 * Returns: A cairo_surface_t pointer to the offscreen surface, or NULL. [transfer none] 151 */ 152 public Surface getSurface() 153 { 154 // cairo_surface_t * gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen); 155 auto p = gtk_offscreen_window_get_surface(gtkOffscreenWindow); 156 157 if(p is null) 158 { 159 return null; 160 } 161 162 return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p); 163 } 164 165 /** 166 * Retrieves a snapshot of the contained widget in the form of 167 * a GdkPixbuf. This is a new pixbuf with a reference count of 1, 168 * and the application should unreference it once it is no longer 169 * needed. 170 * Since 2.20 171 * Returns: A GdkPixbuf pointer, or NULL. [transfer full] 172 */ 173 public Pixbuf getPixbuf() 174 { 175 // GdkPixbuf * gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen); 176 auto p = gtk_offscreen_window_get_pixbuf(gtkOffscreenWindow); 177 178 if(p is null) 179 { 180 return null; 181 } 182 183 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 184 } 185 }