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(bool transferOwnership = false)
63 	{
64 		if (transferOwnership)
65 			ownedRef = false;
66 		return gtkOffscreenWindow;
67 	}
68 
69 	/** the main Gtk struct as a void* */
70 	protected override void* getStruct()
71 	{
72 		return cast(void*)gtkOffscreenWindow;
73 	}
74 
75 	protected override void setStruct(GObject* obj)
76 	{
77 		gtkOffscreenWindow = cast(GtkOffscreenWindow*)obj;
78 		super.setStruct(obj);
79 	}
80 
81 	/**
82 	 * Sets our main struct and passes it to the parent class.
83 	 */
84 	public this (GtkOffscreenWindow* gtkOffscreenWindow, bool ownedRef = false)
85 	{
86 		this.gtkOffscreenWindow = gtkOffscreenWindow;
87 		super(cast(GtkWindow*)gtkOffscreenWindow, ownedRef);
88 	}
89 
90 
91 	/** */
92 	public static GType getType()
93 	{
94 		return gtk_offscreen_window_get_type();
95 	}
96 
97 	/**
98 	 * Creates a toplevel container widget that is used to retrieve
99 	 * snapshots of widgets without showing them on the screen.
100 	 *
101 	 * Returns: A pointer to a #GtkWidget
102 	 *
103 	 * Since: 2.20
104 	 *
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this()
108 	{
109 		auto p = gtk_offscreen_window_new();
110 		
111 		if(p is null)
112 		{
113 			throw new ConstructionException("null returned by new");
114 		}
115 		
116 		this(cast(GtkOffscreenWindow*) p);
117 	}
118 
119 	/**
120 	 * Retrieves a snapshot of the contained widget in the form of
121 	 * a #GdkPixbuf.  This is a new pixbuf with a reference count of 1,
122 	 * and the application should unreference it once it is no longer
123 	 * needed.
124 	 *
125 	 * Returns: A #GdkPixbuf pointer, or %NULL.
126 	 *
127 	 * Since: 2.20
128 	 */
129 	public Pixbuf getPixbuf()
130 	{
131 		auto p = gtk_offscreen_window_get_pixbuf(gtkOffscreenWindow);
132 		
133 		if(p is null)
134 		{
135 			return null;
136 		}
137 		
138 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true);
139 	}
140 
141 	/**
142 	 * Retrieves a snapshot of the contained widget in the form of
143 	 * a #cairo_surface_t.  If you need to keep this around over window
144 	 * resizes then you should add a reference to it.
145 	 *
146 	 * Returns: A #cairo_surface_t pointer to the offscreen
147 	 *     surface, or %NULL.
148 	 *
149 	 * Since: 2.20
150 	 */
151 	public Surface getSurface()
152 	{
153 		auto p = gtk_offscreen_window_get_surface(gtkOffscreenWindow);
154 		
155 		if(p is null)
156 		{
157 			return null;
158 		}
159 		
160 		return new Surface(cast(cairo_surface_t*) p);
161 	}
162 }