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 
91 	public static GType getType()
92 	{
93 		return gtk_offscreen_window_get_type();
94 	}
95 
96 	/**
97 	 * Creates a toplevel container widget that is used to retrieve
98 	 * snapshots of widgets without showing them on the screen.
99 	 *
100 	 * Return: A pointer to a #GtkWidget
101 	 *
102 	 * Since: 2.20
103 	 *
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this()
107 	{
108 		auto p = gtk_offscreen_window_new();
109 		
110 		if(p is null)
111 		{
112 			throw new ConstructionException("null returned by new");
113 		}
114 		
115 		this(cast(GtkOffscreenWindow*) p);
116 	}
117 
118 	/**
119 	 * Retrieves a snapshot of the contained widget in the form of
120 	 * a #GdkPixbuf.  This is a new pixbuf with a reference count of 1,
121 	 * and the application should unreference it once it is no longer
122 	 * needed.
123 	 *
124 	 * Return: A #GdkPixbuf pointer, or %NULL.
125 	 *
126 	 * Since: 2.20
127 	 */
128 	public Pixbuf getPixbuf()
129 	{
130 		auto p = gtk_offscreen_window_get_pixbuf(gtkOffscreenWindow);
131 		
132 		if(p is null)
133 		{
134 			return null;
135 		}
136 		
137 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
138 	}
139 
140 	/**
141 	 * Retrieves a snapshot of the contained widget in the form of
142 	 * a #cairo_surface_t.  If you need to keep this around over window
143 	 * resizes then you should add a reference to it.
144 	 *
145 	 * Return: A #cairo_surface_t pointer to the offscreen
146 	 *     surface, or %NULL.
147 	 *
148 	 * Since: 2.20
149 	 */
150 	public Surface getSurface()
151 	{
152 		auto p = gtk_offscreen_window_get_surface(gtkOffscreenWindow);
153 		
154 		if(p is null)
155 		{
156 			return null;
157 		}
158 		
159 		return new Surface(cast(cairo_surface_t*) p);
160 	}
161 }