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  = GtkPaned.html
27  * outPack = gtk
28  * outFile = Paned
29  * strct   = GtkPaned
30  * realStrct=
31  * ctorStrct=
32  * clss    = Paned
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- OrientableIF
40  * prefixes:
41  * 	- gtk_paned_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gdk.Window
48  * 	- gtk.Widget
49  * 	- gtk.OrientableIF
50  * 	- gtk.OrientableT
51  * structWrap:
52  * 	- GdkWindow* -> Window
53  * 	- GtkWidget* -> Widget
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gtk.Paned;
60 
61 public  import gtkc.gtktypes;
62 
63 private import gtkc.gtk;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 private import gdk.Window;
70 private import gtk.Widget;
71 private import gtk.OrientableIF;
72 private import gtk.OrientableT;
73 
74 
75 private import gtk.Container;
76 
77 /**
78  * GtkPaned has two panes, arranged either
79  * horizontally or vertically. The division between
80  * the two panes is adjustable by the user by dragging
81  * a handle.
82  *
83  * Child widgets are
84  * added to the panes of the widget with gtk_paned_pack1() and
85  * gtk_paned_pack2(). The division between the two children is set by default
86  * from the size requests of the children, but it can be adjusted by the
87  * user.
88  *
89  * A paned widget draws a separator between the two child widgets and a
90  * small handle that the user can drag to adjust the division. It does not
91  * draw any relief around the children or around the separator. (The space
92  * in which the separator is called the gutter.) Often, it is useful to put
93  * each child inside a GtkFrame with the shadow type set to GTK_SHADOW_IN
94  * so that the gutter appears as a ridge. No separator is drawn if one of
95  * the children is missing.
96  *
97  * Each child has two options that can be set, resize and shrink. If
98  * resize is true, then when the GtkPaned is resized, that child will
99  * expand or shrink along with the paned widget. If shrink is true, then
100  * that child can be made smaller than its requisition by the user.
101  * Setting shrink to FALSE allows the application to set a minimum size.
102  * If resize is false for both children, then this is treated as if
103  * resize is true for both children.
104  *
105  * The application can set the position of the slider as if it were set
106  * by the user, by calling gtk_paned_set_position().
107  *
108  * $(DDOC_COMMENT example)
109  */
110 public class Paned : Container, OrientableIF
111 {
112 	
113 	/** the main Gtk struct */
114 	protected GtkPaned* gtkPaned;
115 	
116 	
117 	/** Get the main Gtk struct */
118 	public GtkPaned* getPanedStruct()
119 	{
120 		return gtkPaned;
121 	}
122 	
123 	
124 	/** the main Gtk struct as a void* */
125 	protected override void* getStruct()
126 	{
127 		return cast(void*)gtkPaned;
128 	}
129 	
130 	/**
131 	 * Sets our main struct and passes it to the parent class
132 	 */
133 	public this (GtkPaned* gtkPaned)
134 	{
135 		super(cast(GtkContainer*)gtkPaned);
136 		this.gtkPaned = gtkPaned;
137 	}
138 	
139 	protected override void setStruct(GObject* obj)
140 	{
141 		super.setStruct(obj);
142 		gtkPaned = cast(GtkPaned*)obj;
143 	}
144 	
145 	// add the Orientable capabilities
146 	mixin OrientableT!(GtkPaned);
147 	
148 	/** */
149 	public void add(Widget child1, Widget child2)
150 	{
151 		add1(child1);
152 		add2(child2);
153 	}
154 	
155 	/**
156 	 */
157 	int[string] connectedSignals;
158 	
159 	bool delegate(Paned)[] onAcceptPositionListeners;
160 	/**
161 	 * The ::accept-position signal is a
162 	 * keybinding signal
163 	 * which gets emitted to accept the current position of the handle when
164 	 * moving it using key bindings.
165 	 * The default binding for this signal is Return or Space.
166 	 * Since 2.0
167 	 */
168 	void addOnAcceptPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
169 	{
170 		if ( !("accept-position" in connectedSignals) )
171 		{
172 			Signals.connectData(
173 			getStruct(),
174 			"accept-position",
175 			cast(GCallback)&callBackAcceptPosition,
176 			cast(void*)this,
177 			null,
178 			connectFlags);
179 			connectedSignals["accept-position"] = 1;
180 		}
181 		onAcceptPositionListeners ~= dlg;
182 	}
183 	extern(C) static gboolean callBackAcceptPosition(GtkPaned* widgetStruct, Paned _paned)
184 	{
185 		foreach ( bool delegate(Paned) dlg ; _paned.onAcceptPositionListeners )
186 		{
187 			if ( dlg(_paned) )
188 			{
189 				return 1;
190 			}
191 		}
192 		
193 		return 0;
194 	}
195 	
196 	bool delegate(Paned)[] onCancelPositionListeners;
197 	/**
198 	 * The ::cancel-position signal is a
199 	 * keybinding signal
200 	 * which gets emitted to cancel moving the position of the handle using key
201 	 * bindings. The position of the handle will be reset to the value prior to
202 	 * moving it.
203 	 * The default binding for this signal is Escape.
204 	 * Since 2.0
205 	 */
206 	void addOnCancelPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
207 	{
208 		if ( !("cancel-position" in connectedSignals) )
209 		{
210 			Signals.connectData(
211 			getStruct(),
212 			"cancel-position",
213 			cast(GCallback)&callBackCancelPosition,
214 			cast(void*)this,
215 			null,
216 			connectFlags);
217 			connectedSignals["cancel-position"] = 1;
218 		}
219 		onCancelPositionListeners ~= dlg;
220 	}
221 	extern(C) static gboolean callBackCancelPosition(GtkPaned* widgetStruct, Paned _paned)
222 	{
223 		foreach ( bool delegate(Paned) dlg ; _paned.onCancelPositionListeners )
224 		{
225 			if ( dlg(_paned) )
226 			{
227 				return 1;
228 			}
229 		}
230 		
231 		return 0;
232 	}
233 	
234 	bool delegate(gboolean, Paned)[] onCycleChildFocusListeners;
235 	/**
236 	 * The ::cycle-child-focus signal is a
237 	 * keybinding signal
238 	 * which gets emitted to cycle the focus between the children of the paned.
239 	 * The default binding is f6.
240 	 * Since 2.0
241 	 */
242 	void addOnCycleChildFocus(bool delegate(gboolean, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
243 	{
244 		if ( !("cycle-child-focus" in connectedSignals) )
245 		{
246 			Signals.connectData(
247 			getStruct(),
248 			"cycle-child-focus",
249 			cast(GCallback)&callBackCycleChildFocus,
250 			cast(void*)this,
251 			null,
252 			connectFlags);
253 			connectedSignals["cycle-child-focus"] = 1;
254 		}
255 		onCycleChildFocusListeners ~= dlg;
256 	}
257 	extern(C) static gboolean callBackCycleChildFocus(GtkPaned* widgetStruct, gboolean reversed, Paned _paned)
258 	{
259 		foreach ( bool delegate(gboolean, Paned) dlg ; _paned.onCycleChildFocusListeners )
260 		{
261 			if ( dlg(reversed, _paned) )
262 			{
263 				return 1;
264 			}
265 		}
266 		
267 		return 0;
268 	}
269 	
270 	bool delegate(gboolean, Paned)[] onCycleHandleFocusListeners;
271 	/**
272 	 * The ::cycle-handle-focus signal is a
273 	 * keybinding signal
274 	 * which gets emitted to cycle whether the paned should grab focus to allow
275 	 * the user to change position of the handle by using key bindings.
276 	 * The default binding for this signal is f8.
277 	 * Since 2.0
278 	 */
279 	void addOnCycleHandleFocus(bool delegate(gboolean, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
280 	{
281 		if ( !("cycle-handle-focus" in connectedSignals) )
282 		{
283 			Signals.connectData(
284 			getStruct(),
285 			"cycle-handle-focus",
286 			cast(GCallback)&callBackCycleHandleFocus,
287 			cast(void*)this,
288 			null,
289 			connectFlags);
290 			connectedSignals["cycle-handle-focus"] = 1;
291 		}
292 		onCycleHandleFocusListeners ~= dlg;
293 	}
294 	extern(C) static gboolean callBackCycleHandleFocus(GtkPaned* widgetStruct, gboolean reversed, Paned _paned)
295 	{
296 		foreach ( bool delegate(gboolean, Paned) dlg ; _paned.onCycleHandleFocusListeners )
297 		{
298 			if ( dlg(reversed, _paned) )
299 			{
300 				return 1;
301 			}
302 		}
303 		
304 		return 0;
305 	}
306 	
307 	bool delegate(GtkScrollType, Paned)[] onMoveHandleListeners;
308 	/**
309 	 * The ::move-handle signal is a
310 	 * keybinding signal
311 	 * which gets emitted to move the handle when the user is using key bindings
312 	 * to move it.
313 	 * Since 2.0
314 	 */
315 	void addOnMoveHandle(bool delegate(GtkScrollType, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
316 	{
317 		if ( !("move-handle" in connectedSignals) )
318 		{
319 			Signals.connectData(
320 			getStruct(),
321 			"move-handle",
322 			cast(GCallback)&callBackMoveHandle,
323 			cast(void*)this,
324 			null,
325 			connectFlags);
326 			connectedSignals["move-handle"] = 1;
327 		}
328 		onMoveHandleListeners ~= dlg;
329 	}
330 	extern(C) static gboolean callBackMoveHandle(GtkPaned* widgetStruct, GtkScrollType scrollType, Paned _paned)
331 	{
332 		foreach ( bool delegate(GtkScrollType, Paned) dlg ; _paned.onMoveHandleListeners )
333 		{
334 			if ( dlg(scrollType, _paned) )
335 			{
336 				return 1;
337 			}
338 		}
339 		
340 		return 0;
341 	}
342 	
343 	bool delegate(Paned)[] onToggleHandleFocusListeners;
344 	/**
345 	 * The ::toggle-handle-focus is a
346 	 * keybinding signal
347 	 * which gets emitted to accept the current position of the handle and then
348 	 * move focus to the next widget in the focus chain.
349 	 * The default binding is Tab.
350 	 * Since 2.0
351 	 */
352 	void addOnToggleHandleFocus(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
353 	{
354 		if ( !("toggle-handle-focus" in connectedSignals) )
355 		{
356 			Signals.connectData(
357 			getStruct(),
358 			"toggle-handle-focus",
359 			cast(GCallback)&callBackToggleHandleFocus,
360 			cast(void*)this,
361 			null,
362 			connectFlags);
363 			connectedSignals["toggle-handle-focus"] = 1;
364 		}
365 		onToggleHandleFocusListeners ~= dlg;
366 	}
367 	extern(C) static gboolean callBackToggleHandleFocus(GtkPaned* widgetStruct, Paned _paned)
368 	{
369 		foreach ( bool delegate(Paned) dlg ; _paned.onToggleHandleFocusListeners )
370 		{
371 			if ( dlg(_paned) )
372 			{
373 				return 1;
374 			}
375 		}
376 		
377 		return 0;
378 	}
379 	
380 	
381 	/**
382 	 * Creates a new GtkPaned widget.
383 	 * Params:
384 	 * orientation = the paned's orientation.
385 	 * Throws: ConstructionException GTK+ fails to create the object.
386 	 */
387 	public this (GtkOrientation orientation)
388 	{
389 		// GtkWidget * gtk_paned_new (GtkOrientation orientation);
390 		auto p = gtk_paned_new(orientation);
391 		if(p is null)
392 		{
393 			throw new ConstructionException("null returned by gtk_paned_new(orientation)");
394 		}
395 		this(cast(GtkPaned*) p);
396 	}
397 	
398 	/**
399 	 * Adds a child to the top or left pane with default parameters. This is
400 	 * equivalent to
401 	 * gtk_paned_pack1 (paned, child, FALSE, TRUE).
402 	 * Params:
403 	 * child = the child to add
404 	 */
405 	public void add1(Widget child)
406 	{
407 		// void gtk_paned_add1 (GtkPaned *paned,  GtkWidget *child);
408 		gtk_paned_add1(gtkPaned, (child is null) ? null : child.getWidgetStruct());
409 	}
410 	
411 	/**
412 	 * Adds a child to the bottom or right pane with default parameters. This
413 	 * is equivalent to
414 	 * gtk_paned_pack2 (paned, child, TRUE, TRUE).
415 	 * Params:
416 	 * child = the child to add
417 	 */
418 	public void add2(Widget child)
419 	{
420 		// void gtk_paned_add2 (GtkPaned *paned,  GtkWidget *child);
421 		gtk_paned_add2(gtkPaned, (child is null) ? null : child.getWidgetStruct());
422 	}
423 	
424 	/**
425 	 * Adds a child to the top or left pane.
426 	 * Params:
427 	 * child = the child to add
428 	 * resize = should this child expand when the paned widget is resized.
429 	 * shrink = can this child be made smaller than its requisition.
430 	 */
431 	public void pack1(Widget child, int resize, int shrink)
432 	{
433 		// void gtk_paned_pack1 (GtkPaned *paned,  GtkWidget *child,  gboolean resize,  gboolean shrink);
434 		gtk_paned_pack1(gtkPaned, (child is null) ? null : child.getWidgetStruct(), resize, shrink);
435 	}
436 	
437 	/**
438 	 * Adds a child to the bottom or right pane.
439 	 * Params:
440 	 * child = the child to add
441 	 * resize = should this child expand when the paned widget is resized.
442 	 * shrink = can this child be made smaller than its requisition.
443 	 */
444 	public void pack2(Widget child, int resize, int shrink)
445 	{
446 		// void gtk_paned_pack2 (GtkPaned *paned,  GtkWidget *child,  gboolean resize,  gboolean shrink);
447 		gtk_paned_pack2(gtkPaned, (child is null) ? null : child.getWidgetStruct(), resize, shrink);
448 	}
449 	
450 	/**
451 	 * Obtains the first child of the paned widget.
452 	 * Since 2.4
453 	 * Returns: first child, or NULL if it is not set. [transfer none]
454 	 */
455 	public Widget getChild1()
456 	{
457 		// GtkWidget * gtk_paned_get_child1 (GtkPaned *paned);
458 		auto p = gtk_paned_get_child1(gtkPaned);
459 		
460 		if(p is null)
461 		{
462 			return null;
463 		}
464 		
465 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
466 	}
467 	
468 	/**
469 	 * Obtains the second child of the paned widget.
470 	 * Since 2.4
471 	 * Returns: second child, or NULL if it is not set. [transfer none]
472 	 */
473 	public Widget getChild2()
474 	{
475 		// GtkWidget * gtk_paned_get_child2 (GtkPaned *paned);
476 		auto p = gtk_paned_get_child2(gtkPaned);
477 		
478 		if(p is null)
479 		{
480 			return null;
481 		}
482 		
483 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
484 	}
485 	
486 	/**
487 	 * Sets the position of the divider between the two panes.
488 	 * Params:
489 	 * position = pixel position of divider, a negative value means that the position
490 	 * is unset.
491 	 */
492 	public void setPosition(int position)
493 	{
494 		// void gtk_paned_set_position (GtkPaned *paned,  gint position);
495 		gtk_paned_set_position(gtkPaned, position);
496 	}
497 	
498 	/**
499 	 * Obtains the position of the divider between the two panes.
500 	 * Returns: position of the divider
501 	 */
502 	public int getPosition()
503 	{
504 		// gint gtk_paned_get_position (GtkPaned *paned);
505 		return gtk_paned_get_position(gtkPaned);
506 	}
507 	
508 	/**
509 	 * Returns the GdkWindow of the handle. This function is
510 	 * useful when handling button or motion events because it
511 	 * enables the callback to distinguish between the window
512 	 * of the paned, a child and the handle.
513 	 * Since 2.20
514 	 * Returns: the paned's handle window. [transfer none]
515 	 */
516 	public Window getHandleWindow()
517 	{
518 		// GdkWindow * gtk_paned_get_handle_window (GtkPaned *paned);
519 		auto p = gtk_paned_get_handle_window(gtkPaned);
520 		
521 		if(p is null)
522 		{
523 			return null;
524 		}
525 		
526 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
527 	}
528 }