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