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  * Conversion parameters:
26  * inFile  = GtkHandleBox.html
27  * outPack = gtk
28  * outFile = HandleBox
29  * strct   = GtkHandleBox
30  * realStrct=
31  * ctorStrct=
32  * clss    = HandleBox
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_handle_box_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.HandleBox;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 private import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 
65 
66 
67 private import gtk.Bin;
68 
69 /**
70  * Description
71  * The GtkHandleBox widget allows a portion of a window to be "torn
72  * off". It is a bin widget which displays its child and a handle that
73  * the user can drag to tear off a separate window (the float
74  * window) containing the child widget. A thin
75  * ghost is drawn in the original location of the
76  * handlebox. By dragging the separate window back to its original
77  * location, it can be reattached.
78  * When reattaching, the ghost and float window, must be aligned
79  * along one of the edges, the snap edge.
80  * This either can be specified by the application programmer
81  * explicitely, or GTK+ will pick a reasonable default based
82  * on the handle position.
83  * To make detaching and reattaching the handlebox as minimally confusing
84  * as possible to the user, it is important to set the snap edge so that
85  * the snap edge does not move when the handlebox is deattached. For
86  * instance, if the handlebox is packed at the bottom of a VBox, then
87  * when the handlebox is detached, the bottom edge of the handlebox's
88  * allocation will remain fixed as the height of the handlebox shrinks,
89  * so the snap edge should be set to GTK_POS_BOTTOM.
90  */
91 public class HandleBox : Bin
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GtkHandleBox* gtkHandleBox;
96 	
97 	
98 	public GtkHandleBox* getHandleBoxStruct()
99 	{
100 		return gtkHandleBox;
101 	}
102 	
103 	
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gtkHandleBox;
108 	}
109 	
110 	/**
111 	 * Sets our main struct and passes it to the parent class
112 	 */
113 	public this (GtkHandleBox* gtkHandleBox)
114 	{
115 		super(cast(GtkBin*)gtkHandleBox);
116 		this.gtkHandleBox = gtkHandleBox;
117 	}
118 	
119 	protected override void setStruct(GObject* obj)
120 	{
121 		super.setStruct(obj);
122 		gtkHandleBox = cast(GtkHandleBox*)obj;
123 	}
124 	
125 	/**
126 	 */
127 	int[string] connectedSignals;
128 	
129 	void delegate(GtkWidget*, HandleBox)[] onChildAttachedListeners;
130 	/**
131 	 * This signal is emitted when the contents of the
132 	 * handlebox are reattached to the main window.
133 	 */
134 	void addOnChildAttached(void delegate(GtkWidget*, HandleBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
135 	{
136 		if ( !("child-attached" in connectedSignals) )
137 		{
138 			Signals.connectData(
139 			getStruct(),
140 			"child-attached",
141 			cast(GCallback)&callBackChildAttached,
142 			cast(void*)this,
143 			null,
144 			connectFlags);
145 			connectedSignals["child-attached"] = 1;
146 		}
147 		onChildAttachedListeners ~= dlg;
148 	}
149 	extern(C) static void callBackChildAttached(GtkHandleBox* handleboxStruct, GtkWidget* widget, HandleBox _handleBox)
150 	{
151 		foreach ( void delegate(GtkWidget*, HandleBox) dlg ; _handleBox.onChildAttachedListeners )
152 		{
153 			dlg(widget, _handleBox);
154 		}
155 	}
156 	
157 	void delegate(GtkWidget*, HandleBox)[] onChildDetachedListeners;
158 	/**
159 	 * This signal is emitted when the contents of the
160 	 * handlebox are detached from the main window.
161 	 */
162 	void addOnChildDetached(void delegate(GtkWidget*, HandleBox) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
163 	{
164 		if ( !("child-detached" in connectedSignals) )
165 		{
166 			Signals.connectData(
167 			getStruct(),
168 			"child-detached",
169 			cast(GCallback)&callBackChildDetached,
170 			cast(void*)this,
171 			null,
172 			connectFlags);
173 			connectedSignals["child-detached"] = 1;
174 		}
175 		onChildDetachedListeners ~= dlg;
176 	}
177 	extern(C) static void callBackChildDetached(GtkHandleBox* handleboxStruct, GtkWidget* widget, HandleBox _handleBox)
178 	{
179 		foreach ( void delegate(GtkWidget*, HandleBox) dlg ; _handleBox.onChildDetachedListeners )
180 		{
181 			dlg(widget, _handleBox);
182 		}
183 	}
184 	
185 	
186 	/**
187 	 * Create a new handle box.
188 	 * Throws: ConstructionException GTK+ fails to create the object.
189 	 */
190 	public this ()
191 	{
192 		// GtkWidget * gtk_handle_box_new (void);
193 		auto p = gtk_handle_box_new();
194 		if(p is null)
195 		{
196 			throw new ConstructionException("null returned by gtk_handle_box_new()");
197 		}
198 		this(cast(GtkHandleBox*) p);
199 	}
200 	
201 	/**
202 	 * Sets the type of shadow to be drawn around the border
203 	 * of the handle box.
204 	 * Params:
205 	 * type = the shadow type.
206 	 */
207 	public void setShadowType(GtkShadowType type)
208 	{
209 		// void gtk_handle_box_set_shadow_type (GtkHandleBox *handle_box,  GtkShadowType type);
210 		gtk_handle_box_set_shadow_type(gtkHandleBox, type);
211 	}
212 	
213 	/**
214 	 * Sets the side of the handlebox where the handle is drawn.
215 	 * Params:
216 	 * position = the side of the handlebox where the handle should be drawn.
217 	 */
218 	public void setHandlePosition(GtkPositionType position)
219 	{
220 		// void gtk_handle_box_set_handle_position (GtkHandleBox *handle_box,  GtkPositionType position);
221 		gtk_handle_box_set_handle_position(gtkHandleBox, position);
222 	}
223 	
224 	/**
225 	 * Sets the snap edge of a handlebox. The snap edge is
226 	 * the edge of the detached child that must be aligned
227 	 * with the corresponding edge of the "ghost" left
228 	 * behind when the child was detached to reattach
229 	 * the torn-off window. Usually, the snap edge should
230 	 * be chosen so that it stays in the same place on
231 	 * the screen when the handlebox is torn off.
232 	 * If the snap edge is not set, then an appropriate value
233 	 * will be guessed from the handle position. If the
234 	 * handle position is GTK_POS_RIGHT or GTK_POS_LEFT,
235 	 * then the snap edge will be GTK_POS_TOP, otherwise
236 	 * it will be GTK_POS_LEFT.
237 	 * Params:
238 	 * edge = the snap edge, or -1 to unset the value; in which
239 	 * case GTK+ will try to guess an appropriate value
240 	 * in the future.
241 	 */
242 	public void setSnapEdge(GtkPositionType edge)
243 	{
244 		// void gtk_handle_box_set_snap_edge (GtkHandleBox *handle_box,  GtkPositionType edge);
245 		gtk_handle_box_set_snap_edge(gtkHandleBox, edge);
246 	}
247 	
248 	/**
249 	 * Gets the handle position of the handle box. See
250 	 * gtk_handle_box_set_handle_position().
251 	 * Returns: the current handle position.
252 	 */
253 	public GtkPositionType getHandlePosition()
254 	{
255 		// GtkPositionType gtk_handle_box_get_handle_position (GtkHandleBox *handle_box);
256 		return gtk_handle_box_get_handle_position(gtkHandleBox);
257 	}
258 	
259 	/**
260 	 * Gets the type of shadow drawn around the handle box. See
261 	 * gtk_handle_box_set_shadow_type().
262 	 * Returns: the type of shadow currently drawn around the handle box.
263 	 */
264 	public GtkShadowType getShadowType()
265 	{
266 		// GtkShadowType gtk_handle_box_get_shadow_type (GtkHandleBox *handle_box);
267 		return gtk_handle_box_get_shadow_type(gtkHandleBox);
268 	}
269 	
270 	/**
271 	 * Gets the edge used for determining reattachment of the handle box. See
272 	 * gtk_handle_box_set_snap_edge().
273 	 * Returns: the edge used for determining reattachment, or (GtkPositionType)-1 if this is determined (as per default) from the handle position.
274 	 */
275 	public GtkPositionType getSnapEdge()
276 	{
277 		// GtkPositionType gtk_handle_box_get_snap_edge (GtkHandleBox *handle_box);
278 		return gtk_handle_box_get_snap_edge(gtkHandleBox);
279 	}
280 	
281 	/**
282 	 * Whether the handlebox's child is currently detached.
283 	 * Since 2.14
284 	 * Returns: TRUE if the child is currently detached, otherwise FALSE
285 	 */
286 	public int getChildDetached()
287 	{
288 		// gboolean gtk_handle_box_get_child_detached (GtkHandleBox *handle_box);
289 		return gtk_handle_box_get_child_detached(gtkHandleBox);
290 	}
291 }