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  = GtkScrolledWindow.html
27  * outPack = gtk
28  * outFile = ScrolledWindow
29  * strct   = GtkScrolledWindow
30  * realStrct=
31  * ctorStrct=
32  * clss    = ScrolledWindow
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_scrolled_window_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_scrolled_window_new
46  * omit signals:
47  * imports:
48  * 	- gtk.Widget
49  * 	- gtk.Adjustment
50  * structWrap:
51  * 	- GtkAdjustment* -> Adjustment
52  * 	- GtkWidget* -> Widget
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.ScrolledWindow;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 
69 private import gtk.Widget;
70 private import gtk.Adjustment;
71 
72 
73 
74 private import gtk.Bin;
75 
76 /**
77  * Description
78  * GtkScrolledWindow is a GtkBin subclass: it's a container
79  * the accepts a single child widget. GtkScrolledWindow adds scrollbars
80  * to the child widget and optionally draws a beveled frame around the
81  * child widget.
82  * The scrolled window can work in two ways. Some widgets have native
83  * scrolling support; these widgets have "slots" for GtkAdjustment
84  * objects.
85  * [5]
86  * Widgets with native scroll support include GtkTreeView, GtkTextView,
87  * and GtkLayout.
88  * For widgets that lack native scrolling support, the GtkViewport
89  * widget acts as an adaptor class, implementing scrollability for child
90  * widgets that lack their own scrolling capabilities. Use GtkViewport
91  * to scroll child widgets such as GtkTable, GtkBox, and so on.
92  * If a widget has native scrolling abilities, it can be added to the
93  * GtkScrolledWindow with gtk_container_add(). If a widget does not, you
94  * must first add the widget to a GtkViewport, then add the GtkViewport
95  * to the scrolled window. The convenience function
96  * gtk_scrolled_window_add_with_viewport() does exactly this, so you can
97  * ignore the presence of the viewport.
98  * The position of the scrollbars is controlled by the scroll
99  * adjustments. See GtkAdjustment for the fields in an adjustment - for
100  * GtkScrollbar, used by GtkScrolledWindow, the "value" field
101  * represents the position of the scrollbar, which must be between the
102  * "lower" field and "upper - page_size." The "page_size" field
103  * represents the size of the visible scrollable area. The
104  * "step_increment" and "page_increment" fields are used when the user
105  * asks to step down (using the small stepper arrows) or page down (using
106  * for example the PageDown key).
107  * If a GtkScrolledWindow doesn't behave quite as you would like, or
108  * doesn't have exactly the right layout, it's very possible to set up
109  * your own scrolling with GtkScrollbar and for example a GtkTable.
110  */
111 public class ScrolledWindow : Bin
112 {
113 	
114 	/** the main Gtk struct */
115 	protected GtkScrolledWindow* gtkScrolledWindow;
116 	
117 	
118 	public GtkScrolledWindow* getScrolledWindowStruct()
119 	{
120 		return gtkScrolledWindow;
121 	}
122 	
123 	
124 	/** the main Gtk struct as a void* */
125 	protected override void* getStruct()
126 	{
127 		return cast(void*)gtkScrolledWindow;
128 	}
129 	
130 	/**
131 	 * Sets our main struct and passes it to the parent class
132 	 */
133 	public this (GtkScrolledWindow* gtkScrolledWindow)
134 	{
135 		super(cast(GtkBin*)gtkScrolledWindow);
136 		this.gtkScrolledWindow = gtkScrolledWindow;
137 	}
138 	
139 	protected override void setStruct(GObject* obj)
140 	{
141 		super.setStruct(obj);
142 		gtkScrolledWindow = cast(GtkScrolledWindow*)obj;
143 	}
144 	
145 	/** */
146 	public this()
147 	{
148 		this(null, null);
149 	}
150 	
151 	/** */
152 	public this(Widget widget)
153 	{
154 		this();
155 		addWithViewport(widget);
156 	}
157 	
158 	/**
159 	 * Creates a new scrolled window. The two arguments are the scrolled
160 	 * window's adjustments; these will be shared with the scrollbars and the
161 	 * child widget to keep the bars in sync with the child. Usually you want
162 	 * to pass NULL for the adjustments, which will cause the scrolled window
163 	 * to create them for you.
164 	 * Params:
165 	 *  hadjustment = Horizontal adjustment.
166 	 *  vadjustment = Vertical adjustment.
167 	 * Throws: ConstructionException GTK+ fails to create the object.
168 	 */
169 	public this (Adjustment hadjustment, Adjustment vadjustment)
170 	{
171 		// GtkWidget* gtk_scrolled_window_new (GtkAdjustment *hadjustment,  GtkAdjustment *vadjustment);
172 		auto p = gtk_scrolled_window_new(
173 		hadjustment is null ? null : hadjustment.getAdjustmentStruct(),
174 		vadjustment is null ? null : vadjustment.getAdjustmentStruct());
175 		
176 		if(p is null)
177 		{
178 			throw new ConstructionException("null returned by gtk_scrolled_window_new");
179 		}
180 		
181 		this(cast(GtkScrolledWindow*) p);
182 	}
183 	
184 	/**
185 	 * Creates a new Scrolled window and set the policy type
186 	 * Params:
187 	 *  hPolicy = the horizontal policy
188 	 *  vPolicy = the vertical policy
189 	 */
190 	this(PolicyType hPolicy, PolicyType vPolicy)
191 	{
192 		this();
193 		setPolicy(hPolicy, vPolicy);
194 	}
195 	
196 	/**
197 	 */
198 	int[string] connectedSignals;
199 	
200 	void delegate(GtkDirectionType, ScrolledWindow)[] onMoveFocusOutListeners;
201 	/**
202 	 */
203 	void addOnMoveFocusOut(void delegate(GtkDirectionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
204 	{
205 		if ( !("move-focus-out" in connectedSignals) )
206 		{
207 			Signals.connectData(
208 			getStruct(),
209 			"move-focus-out",
210 			cast(GCallback)&callBackMoveFocusOut,
211 			cast(void*)this,
212 			null,
213 			connectFlags);
214 			connectedSignals["move-focus-out"] = 1;
215 		}
216 		onMoveFocusOutListeners ~= dlg;
217 	}
218 	extern(C) static void callBackMoveFocusOut(GtkScrolledWindow* scrolledwindowStruct, GtkDirectionType arg1, ScrolledWindow _scrolledWindow)
219 	{
220 		foreach ( void delegate(GtkDirectionType, ScrolledWindow) dlg ; _scrolledWindow.onMoveFocusOutListeners )
221 		{
222 			dlg(arg1, _scrolledWindow);
223 		}
224 	}
225 	
226 	bool delegate(GtkScrollType, gboolean, ScrolledWindow)[] onScrollChildListeners;
227 	/**
228 	 * See Also
229 	 * GtkViewport, GtkAdjustment, GtkWidgetClass
230 	 * [5] The scrolled window installs GtkAdjustment objects in
231 	 * the child window's slots using the set_scroll_adjustments_signal,
232 	 * found in GtkWidgetClass. (Conceptually, these widgets implement a
233 	 * "Scrollable" interface; because GTK+ 1.2 lacked interface support in
234 	 * the object system, this interface is hackily implemented as a signal
235 	 * in GtkWidgetClass. The GTK+ 2.0 object system would allow a clean
236 	 * implementation, but it wasn't worth breaking the
237 	 * API.)
238 	 */
239 	void addOnScrollChild(bool delegate(GtkScrollType, gboolean, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
240 	{
241 		if ( !("scroll-child" in connectedSignals) )
242 		{
243 			Signals.connectData(
244 			getStruct(),
245 			"scroll-child",
246 			cast(GCallback)&callBackScrollChild,
247 			cast(void*)this,
248 			null,
249 			connectFlags);
250 			connectedSignals["scroll-child"] = 1;
251 		}
252 		onScrollChildListeners ~= dlg;
253 	}
254 	extern(C) static gboolean callBackScrollChild(GtkScrolledWindow* scrolledwindowStruct, GtkScrollType arg1, gboolean arg2, ScrolledWindow _scrolledWindow)
255 	{
256 		foreach ( bool delegate(GtkScrollType, gboolean, ScrolledWindow) dlg ; _scrolledWindow.onScrollChildListeners )
257 		{
258 			if ( dlg(arg1, arg2, _scrolledWindow) )
259 			{
260 				return 1;
261 			}
262 		}
263 		
264 		return 0;
265 	}
266 	
267 	
268 	/**
269 	 * Returns the horizontal scrollbar's adjustment, used to connect the
270 	 * horizontal scrollbar to the child widget's horizontal scroll
271 	 * functionality.
272 	 * Returns: the horizontal GtkAdjustment. [transfer none]
273 	 */
274 	public Adjustment getHadjustment()
275 	{
276 		// GtkAdjustment * gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window);
277 		auto p = gtk_scrolled_window_get_hadjustment(gtkScrolledWindow);
278 		
279 		if(p is null)
280 		{
281 			return null;
282 		}
283 		
284 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
285 	}
286 	
287 	/**
288 	 * Returns the vertical scrollbar's adjustment, used to connect the
289 	 * vertical scrollbar to the child widget's vertical scroll functionality.
290 	 * Returns: the vertical GtkAdjustment. [transfer none]
291 	 */
292 	public Adjustment getVadjustment()
293 	{
294 		// GtkAdjustment * gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window);
295 		auto p = gtk_scrolled_window_get_vadjustment(gtkScrolledWindow);
296 		
297 		if(p is null)
298 		{
299 			return null;
300 		}
301 		
302 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
303 	}
304 	
305 	/**
306 	 * Returns the horizontal scrollbar of scrolled_window.
307 	 * Since 2.8
308 	 * Returns: the horizontal scrollbar of the scrolled window, or NULL if it does not have one. [transfer none]
309 	 */
310 	public Widget getHscrollbar()
311 	{
312 		// GtkWidget * gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *scrolled_window);
313 		auto p = gtk_scrolled_window_get_hscrollbar(gtkScrolledWindow);
314 		
315 		if(p is null)
316 		{
317 			return null;
318 		}
319 		
320 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
321 	}
322 	
323 	/**
324 	 * Returns the vertical scrollbar of scrolled_window.
325 	 * Since 2.8
326 	 * Returns: the vertical scrollbar of the scrolled window, or NULL if it does not have one. [transfer none]
327 	 */
328 	public Widget getVscrollbar()
329 	{
330 		// GtkWidget * gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *scrolled_window);
331 		auto p = gtk_scrolled_window_get_vscrollbar(gtkScrolledWindow);
332 		
333 		if(p is null)
334 		{
335 			return null;
336 		}
337 		
338 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
339 	}
340 	
341 	/**
342 	 * Sets the scrollbar policy for the horizontal and vertical scrollbars.
343 	 * The policy determines when the scrollbar should appear; it is a value
344 	 * from the GtkPolicyType enumeration. If GTK_POLICY_ALWAYS, the
345 	 * scrollbar is always present; if GTK_POLICY_NEVER, the scrollbar is
346 	 * never present; if GTK_POLICY_AUTOMATIC, the scrollbar is present only
347 	 * if needed (that is, if the slider part of the bar would be smaller
348 	 * than the trough - the display is larger than the page size).
349 	 * Params:
350 	 * hscrollbarPolicy = policy for horizontal bar
351 	 * vscrollbarPolicy = policy for vertical bar
352 	 */
353 	public void setPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy)
354 	{
355 		// void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,  GtkPolicyType hscrollbar_policy,  GtkPolicyType vscrollbar_policy);
356 		gtk_scrolled_window_set_policy(gtkScrolledWindow, hscrollbarPolicy, vscrollbarPolicy);
357 	}
358 	
359 	/**
360 	 * Used to add children without native scrolling capabilities. This
361 	 * is simply a convenience function; it is equivalent to adding the
362 	 * unscrollable child to a viewport, then adding the viewport to the
363 	 * scrolled window. If a child has native scrolling, use
364 	 * gtk_container_add() instead of this function.
365 	 * The viewport scrolls the child by moving its GdkWindow, and takes
366 	 * the size of the child to be the size of its toplevel GdkWindow.
367 	 * This will be very wrong for most widgets that support native scrolling;
368 	 * for example, if you add a widget such as GtkTreeView with a viewport,
369 	 * the whole widget will scroll, including the column headings. Thus,
370 	 * widgets with native scrolling support should not be used with the
371 	 * GtkViewport proxy.
372 	 * A widget supports scrolling natively if the
373 	 * set_scroll_adjustments_signal field in GtkWidgetClass is non-zero,
374 	 * i.e. has been filled in with a valid signal identifier.
375 	 * Params:
376 	 * child = the widget you want to scroll
377 	 */
378 	public void addWithViewport(Widget child)
379 	{
380 		// void gtk_scrolled_window_add_with_viewport  (GtkScrolledWindow *scrolled_window,  GtkWidget *child);
381 		gtk_scrolled_window_add_with_viewport(gtkScrolledWindow, (child is null) ? null : child.getWidgetStruct());
382 	}
383 	
384 	/**
385 	 * Sets the placement of the contents with respect to the scrollbars
386 	 * for the scrolled window.
387 	 * The default is GTK_CORNER_TOP_LEFT, meaning the child is
388 	 * in the top left, with the scrollbars underneath and to the right.
389 	 * Other values in GtkCornerType are GTK_CORNER_TOP_RIGHT,
390 	 * GTK_CORNER_BOTTOM_LEFT, and GTK_CORNER_BOTTOM_RIGHT.
391 	 * See also gtk_scrolled_window_get_placement() and
392 	 * gtk_scrolled_window_unset_placement().
393 	 * Params:
394 	 * windowPlacement = position of the child window
395 	 */
396 	public void setPlacement(GtkCornerType windowPlacement)
397 	{
398 		// void gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window,  GtkCornerType window_placement);
399 		gtk_scrolled_window_set_placement(gtkScrolledWindow, windowPlacement);
400 	}
401 	
402 	/**
403 	 * Unsets the placement of the contents with respect to the scrollbars
404 	 * for the scrolled window. If no window placement is set for a scrolled
405 	 * window, it obeys the "gtk-scrolled-window-placement" XSETTING.
406 	 * See also gtk_scrolled_window_set_placement() and
407 	 * gtk_scrolled_window_get_placement().
408 	 * Since 2.10
409 	 */
410 	public void unsetPlacement()
411 	{
412 		// void gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window);
413 		gtk_scrolled_window_unset_placement(gtkScrolledWindow);
414 	}
415 	
416 	/**
417 	 * Changes the type of shadow drawn around the contents of
418 	 * scrolled_window.
419 	 * Params:
420 	 * type = kind of shadow to draw around scrolled window contents
421 	 */
422 	public void setShadowType(GtkShadowType type)
423 	{
424 		// void gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window,  GtkShadowType type);
425 		gtk_scrolled_window_set_shadow_type(gtkScrolledWindow, type);
426 	}
427 	
428 	/**
429 	 * Sets the GtkAdjustment for the horizontal scrollbar.
430 	 * Params:
431 	 * hadjustment = horizontal scroll adjustment
432 	 */
433 	public void setHadjustment(Adjustment hadjustment)
434 	{
435 		// void gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,  GtkAdjustment *hadjustment);
436 		gtk_scrolled_window_set_hadjustment(gtkScrolledWindow, (hadjustment is null) ? null : hadjustment.getAdjustmentStruct());
437 	}
438 	
439 	/**
440 	 * Sets the GtkAdjustment for the vertical scrollbar.
441 	 * Params:
442 	 * vadjustment = vertical scroll adjustment
443 	 */
444 	public void setVadjustment(Adjustment vadjustment)
445 	{
446 		// void gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,  GtkAdjustment *vadjustment);
447 		gtk_scrolled_window_set_vadjustment(gtkScrolledWindow, (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
448 	}
449 	
450 	/**
451 	 * Gets the placement of the contents with respect to the scrollbars
452 	 * for the scrolled window. See gtk_scrolled_window_set_placement().
453 	 * Returns: the current placement value. See also gtk_scrolled_window_set_placement() and gtk_scrolled_window_unset_placement().
454 	 */
455 	public GtkCornerType getPlacement()
456 	{
457 		// GtkCornerType gtk_scrolled_window_get_placement (GtkScrolledWindow *scrolled_window);
458 		return gtk_scrolled_window_get_placement(gtkScrolledWindow);
459 	}
460 	
461 	/**
462 	 * Retrieves the current policy values for the horizontal and vertical
463 	 * scrollbars. See gtk_scrolled_window_set_policy().
464 	 * Params:
465 	 * hscrollbarPolicy = location to store the policy
466 	 * for the horizontal scrollbar, or NULL. [out][allow-none]
467 	 * vscrollbarPolicy = location to store the policy
468 	 * for the vertical scrollbar, or NULL. [out][allow-none]
469 	 */
470 	public void getPolicy(out GtkPolicyType hscrollbarPolicy, out GtkPolicyType vscrollbarPolicy)
471 	{
472 		// void gtk_scrolled_window_get_policy (GtkScrolledWindow *scrolled_window,  GtkPolicyType *hscrollbar_policy,  GtkPolicyType *vscrollbar_policy);
473 		gtk_scrolled_window_get_policy(gtkScrolledWindow, &hscrollbarPolicy, &vscrollbarPolicy);
474 	}
475 	
476 	/**
477 	 * Gets the shadow type of the scrolled window. See
478 	 * gtk_scrolled_window_set_shadow_type().
479 	 * Returns: the current shadow type
480 	 */
481 	public GtkShadowType getShadowType()
482 	{
483 		// GtkShadowType gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window);
484 		return gtk_scrolled_window_get_shadow_type(gtkScrolledWindow);
485 	}
486 }