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