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