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.Paned;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.OrientableIF;
31 private import gtk.OrientableT;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 private import std.algorithm;
36 
37 
38 /**
39  * `GtkPaned` has two panes, arranged either horizontally or vertically.
40  * 
41  * ![An example GtkPaned](panes.png)
42  * 
43  * The division between the two panes is adjustable by the user
44  * by dragging a handle.
45  * 
46  * Child widgets are added to the panes of the widget with
47  * [method@Gtk.Paned.set_start_child] and [method@Gtk.Paned.set_end_child].
48  * The division between the two children is set by default from the size
49  * requests of the children, but it can be adjusted by the user.
50  * 
51  * A paned widget draws a separator between the two child widgets and a
52  * small handle that the user can drag to adjust the division. It does not
53  * draw any relief around the children or around the separator. (The space
54  * in which the separator is called the gutter.) Often, it is useful to put
55  * each child inside a [class@Gtk.Frame] so that the gutter appears as a
56  * ridge. No separator is drawn if one of the children is missing.
57  * 
58  * Each child has two options that can be set, @resize and @shrink. If
59  * @resize is true, then when the `GtkPaned` is resized, that child will
60  * expand or shrink along with the paned widget. If @shrink is true, then
61  * that child can be made smaller than its requisition by the user.
62  * Setting @shrink to %FALSE allows the application to set a minimum size.
63  * If @resize is false for both children, then this is treated as if
64  * @resize is true for both children.
65  * 
66  * The application can set the position of the slider as if it were set
67  * by the user, by calling [method@Gtk.Paned.set_position].
68  * 
69  * # CSS nodes
70  * 
71  * ```
72  * paned
73  * ├── <child>
74  * ├── separator[.wide]
75  * ╰── <child>
76  * ```
77  * 
78  * `GtkPaned` has a main CSS node with name paned, and a subnode for
79  * the separator with name separator. The subnode gets a .wide style
80  * class when the paned is supposed to be wide.
81  * 
82  * In horizontal orientation, the nodes are arranged based on the text
83  * direction, so in left-to-right mode, :first-child will select the
84  * leftmost child, while it will select the rightmost child in
85  * RTL layouts.
86  * 
87  * ## Creating a paned widget with minimum sizes.
88  * 
89  * ```c
90  * GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
91  * GtkWidget *frame1 = gtk_frame_new (NULL);
92  * GtkWidget *frame2 = gtk_frame_new (NULL);
93  * 
94  * gtk_widget_set_size_request (hpaned, 200, -1);
95  * 
96  * gtk_paned_set_start_child (GTK_PANED (hpaned), frame1);
97  * gtk_paned_set_start_child_resize (GTK_PANED (hpaned), TRUE);
98  * gtk_paned_set_start_child_shrink (GTK_PANED (hpaned), FALSE);
99  * gtk_widget_set_size_request (frame1, 50, -1);
100  * 
101  * gtk_paned_set_end_child (GTK_PANED (hpaned), frame2);
102  * gtk_paned_set_end_child_resize (GTK_PANED (hpaned), FALSE);
103  * gtk_paned_set_end_child_shrink (GTK_PANED (hpaned), FALSE);
104  * gtk_widget_set_size_request (frame2, 50, -1);
105  * ```
106  */
107 public class Paned : Widget, OrientableIF
108 {
109 	/** the main Gtk struct */
110 	protected GtkPaned* gtkPaned;
111 
112 	/** Get the main Gtk struct */
113 	public GtkPaned* getPanedStruct(bool transferOwnership = false)
114 	{
115 		if (transferOwnership)
116 			ownedRef = false;
117 		return gtkPaned;
118 	}
119 
120 	/** the main Gtk struct as a void* */
121 	protected override void* getStruct()
122 	{
123 		return cast(void*)gtkPaned;
124 	}
125 
126 	/**
127 	 * Sets our main struct and passes it to the parent class.
128 	 */
129 	public this (GtkPaned* gtkPaned, bool ownedRef = false)
130 	{
131 		this.gtkPaned = gtkPaned;
132 		super(cast(GtkWidget*)gtkPaned, ownedRef);
133 	}
134 
135 	// add the Orientable capabilities
136 	mixin OrientableT!(GtkPaned);
137 
138 
139 	/** */
140 	public static GType getType()
141 	{
142 		return gtk_paned_get_type();
143 	}
144 
145 	/**
146 	 * Creates a new `GtkPaned` widget.
147 	 *
148 	 * Params:
149 	 *     orientation = the paned’s orientation.
150 	 *
151 	 * Returns: a new `GtkPaned`.
152 	 *
153 	 * Throws: ConstructionException GTK+ fails to create the object.
154 	 */
155 	public this(GtkOrientation orientation)
156 	{
157 		auto __p = gtk_paned_new(orientation);
158 
159 		if(__p is null)
160 		{
161 			throw new ConstructionException("null returned by new");
162 		}
163 
164 		this(cast(GtkPaned*) __p);
165 	}
166 
167 	/**
168 	 * Retrieves the end child of the given `GtkPaned`.
169 	 *
170 	 * See also: `GtkPaned`:end-child
171 	 *
172 	 * Returns: the end child widget
173 	 */
174 	public Widget getEndChild()
175 	{
176 		auto __p = gtk_paned_get_end_child(gtkPaned);
177 
178 		if(__p is null)
179 		{
180 			return null;
181 		}
182 
183 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
184 	}
185 
186 	/**
187 	 * Obtains the position of the divider between the two panes.
188 	 *
189 	 * Returns: position of the divider
190 	 */
191 	public int getPosition()
192 	{
193 		return gtk_paned_get_position(gtkPaned);
194 	}
195 
196 	/**
197 	 * Returns whether the end child can be resized.
198 	 *
199 	 * Returns: %TRUE if the end child is resizable
200 	 */
201 	public bool getResizeEndChild()
202 	{
203 		return gtk_paned_get_resize_end_child(gtkPaned) != 0;
204 	}
205 
206 	/**
207 	 * Returns whether the start child can be resized.
208 	 *
209 	 * Returns: %TRUE if the start child is resizable
210 	 */
211 	public bool getResizeStartChild()
212 	{
213 		return gtk_paned_get_resize_start_child(gtkPaned) != 0;
214 	}
215 
216 	/**
217 	 * Returns whether the end child can be shrunk.
218 	 *
219 	 * Returns: %TRUE if the end child is shrinkable
220 	 */
221 	public bool getShrinkEndChild()
222 	{
223 		return gtk_paned_get_shrink_end_child(gtkPaned) != 0;
224 	}
225 
226 	/**
227 	 * Returns whether the start child can be shrunk.
228 	 *
229 	 * Returns: %TRUE if the start child is shrinkable
230 	 */
231 	public bool getShrinkStartChild()
232 	{
233 		return gtk_paned_get_shrink_start_child(gtkPaned) != 0;
234 	}
235 
236 	/**
237 	 * Retrieves the start child of the given `GtkPaned`.
238 	 *
239 	 * See also: `GtkPaned`:start-child
240 	 *
241 	 * Returns: the start child widget
242 	 */
243 	public Widget getStartChild()
244 	{
245 		auto __p = gtk_paned_get_start_child(gtkPaned);
246 
247 		if(__p is null)
248 		{
249 			return null;
250 		}
251 
252 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
253 	}
254 
255 	/**
256 	 * Gets whether the separator should be wide.
257 	 *
258 	 * Returns: %TRUE if the paned should have a wide handle
259 	 */
260 	public bool getWideHandle()
261 	{
262 		return gtk_paned_get_wide_handle(gtkPaned) != 0;
263 	}
264 
265 	/**
266 	 * Sets the end child of @paned to @child.
267 	 *
268 	 * Params:
269 	 *     child = the widget to add
270 	 */
271 	public void setEndChild(Widget child)
272 	{
273 		gtk_paned_set_end_child(gtkPaned, (child is null) ? null : child.getWidgetStruct());
274 	}
275 
276 	/**
277 	 * Sets the position of the divider between the two panes.
278 	 *
279 	 * Params:
280 	 *     position = pixel position of divider, a negative value means that the position
281 	 *         is unset.
282 	 */
283 	public void setPosition(int position)
284 	{
285 		gtk_paned_set_position(gtkPaned, position);
286 	}
287 
288 	/**
289 	 * Sets the `GtkPaned`:resize-end-child property
290 	 *
291 	 * Params:
292 	 *     resize = %TRUE to let the end child be resized
293 	 */
294 	public void setResizeEndChild(bool resize)
295 	{
296 		gtk_paned_set_resize_end_child(gtkPaned, resize);
297 	}
298 
299 	/**
300 	 * Sets the `GtkPaned`:resize-start-child property
301 	 *
302 	 * Params:
303 	 *     resize = %TRUE to let the start child be resized
304 	 */
305 	public void setResizeStartChild(bool resize)
306 	{
307 		gtk_paned_set_resize_start_child(gtkPaned, resize);
308 	}
309 
310 	/**
311 	 * Sets the `GtkPaned`:shrink-end-child property
312 	 *
313 	 * Params:
314 	 *     resize = %TRUE to let the end child be shrunk
315 	 */
316 	public void setShrinkEndChild(bool resize)
317 	{
318 		gtk_paned_set_shrink_end_child(gtkPaned, resize);
319 	}
320 
321 	/**
322 	 * Sets the `GtkPaned`:shrink-start-child property
323 	 *
324 	 * Params:
325 	 *     resize = %TRUE to let the start child be shrunk
326 	 */
327 	public void setShrinkStartChild(bool resize)
328 	{
329 		gtk_paned_set_shrink_start_child(gtkPaned, resize);
330 	}
331 
332 	/**
333 	 * Sets the start child of @paned to @child.
334 	 *
335 	 * Params:
336 	 *     child = the widget to add
337 	 */
338 	public void setStartChild(Widget child)
339 	{
340 		gtk_paned_set_start_child(gtkPaned, (child is null) ? null : child.getWidgetStruct());
341 	}
342 
343 	/**
344 	 * Sets whether the separator should be wide.
345 	 *
346 	 * Params:
347 	 *     wide = the new value for the [property@Gtk.Paned:wide-handle] property
348 	 */
349 	public void setWideHandle(bool wide)
350 	{
351 		gtk_paned_set_wide_handle(gtkPaned, wide);
352 	}
353 
354 	/**
355 	 * Emitted to accept the current position of the handle when
356 	 * moving it using key bindings.
357 	 *
358 	 * This is a [keybinding signal](class.SignalAction.html).
359 	 *
360 	 * The default binding for this signal is Return or Space.
361 	 */
362 	gulong addOnAcceptPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
363 	{
364 		return Signals.connect(this, "accept-position", dlg, connectFlags ^ ConnectFlags.SWAPPED);
365 	}
366 
367 	/**
368 	 * Emitted to cancel moving the position of the handle using key
369 	 * bindings.
370 	 *
371 	 * The position of the handle will be reset to the value prior to
372 	 * moving it.
373 	 *
374 	 * This is a [keybinding signal](class.SignalAction.html).
375 	 *
376 	 * The default binding for this signal is Escape.
377 	 */
378 	gulong addOnCancelPosition(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
379 	{
380 		return Signals.connect(this, "cancel-position", dlg, connectFlags ^ ConnectFlags.SWAPPED);
381 	}
382 
383 	/**
384 	 * Emitted to cycle the focus between the children of the paned.
385 	 *
386 	 * This is a [keybinding signal](class.SignalAction.html).
387 	 *
388 	 * The default binding is F6.
389 	 *
390 	 * Params:
391 	 *     reversed = whether cycling backward or forward
392 	 */
393 	gulong addOnCycleChildFocus(bool delegate(bool, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
394 	{
395 		return Signals.connect(this, "cycle-child-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED);
396 	}
397 
398 	/**
399 	 * Emitted to cycle whether the paned should grab focus to allow
400 	 * the user to change position of the handle by using key bindings.
401 	 *
402 	 * This is a [keybinding signal](class.SignalAction.html).
403 	 *
404 	 * The default binding for this signal is F8.
405 	 *
406 	 * Params:
407 	 *     reversed = whether cycling backward or forward
408 	 */
409 	gulong addOnCycleHandleFocus(bool delegate(bool, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
410 	{
411 		return Signals.connect(this, "cycle-handle-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED);
412 	}
413 
414 	/**
415 	 * Emitted to move the handle with key bindings.
416 	 *
417 	 * This is a [keybinding signal](class.SignalAction.html).
418 	 *
419 	 * Params:
420 	 *     scrollType = a #GtkScrollType
421 	 */
422 	gulong addOnMoveHandle(bool delegate(GtkScrollType, Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
423 	{
424 		return Signals.connect(this, "move-handle", dlg, connectFlags ^ ConnectFlags.SWAPPED);
425 	}
426 
427 	/**
428 	 * Emitted to accept the current position of the handle and then
429 	 * move focus to the next widget in the focus chain.
430 	 *
431 	 * This is a [keybinding signal](class.SignalAction.html).
432 	 *
433 	 * The default binding is Tab.
434 	 */
435 	gulong addOnToggleHandleFocus(bool delegate(Paned) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
436 	{
437 		return Signals.connect(this, "toggle-handle-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED);
438 	}
439 }