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