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.Viewport;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Adjustment;
30 private import gtk.ScrollableIF;
31 private import gtk.ScrollableT;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkViewport` implements scrollability for widgets that lack their
39  * own scrolling capabilities.
40  * 
41  * Use `GtkViewport` to scroll child widgets such as `GtkGrid`,
42  * `GtkBox`, and so on.
43  * 
44  * The `GtkViewport` will start scrolling content only if allocated
45  * less than the child widget’s minimum size in a given orientation.
46  * 
47  * # CSS nodes
48  * 
49  * `GtkViewport` has a single CSS node with name `viewport`.
50  * 
51  * # Accessibility
52  * 
53  * `GtkViewport` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
54  */
55 public class Viewport : Widget, ScrollableIF
56 {
57 	/** the main Gtk struct */
58 	protected GtkViewport* gtkViewport;
59 
60 	/** Get the main Gtk struct */
61 	public GtkViewport* getViewportStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return gtkViewport;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)gtkViewport;
72 	}
73 
74 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (GtkViewport* gtkViewport, bool ownedRef = false)
78 	{
79 		this.gtkViewport = gtkViewport;
80 		super(cast(GtkWidget*)gtkViewport, ownedRef);
81 	}
82 
83 	// add the Scrollable capabilities
84 	mixin ScrollableT!(GtkViewport);
85 
86 
87 	/** */
88 	public static GType getType()
89 	{
90 		return gtk_viewport_get_type();
91 	}
92 
93 	/**
94 	 * Creates a new `GtkViewport`.
95 	 *
96 	 * The new viewport uses the given adjustments, or default
97 	 * adjustments if none are given.
98 	 *
99 	 * Params:
100 	 *     hadjustment = horizontal adjustment
101 	 *     vadjustment = vertical adjustment
102 	 *
103 	 * Returns: a new `GtkViewport`
104 	 *
105 	 * Throws: ConstructionException GTK+ fails to create the object.
106 	 */
107 	public this(Adjustment hadjustment, Adjustment vadjustment)
108 	{
109 		auto __p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
110 
111 		if(__p is null)
112 		{
113 			throw new ConstructionException("null returned by new");
114 		}
115 
116 		this(cast(GtkViewport*) __p);
117 	}
118 
119 	/**
120 	 * Gets the child widget of @viewport.
121 	 *
122 	 * Returns: the child widget of @viewport
123 	 */
124 	public Widget getChild()
125 	{
126 		auto __p = gtk_viewport_get_child(gtkViewport);
127 
128 		if(__p is null)
129 		{
130 			return null;
131 		}
132 
133 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
134 	}
135 
136 	/**
137 	 * Gets whether the viewport is scrolling to keep the focused
138 	 * child in view.
139 	 *
140 	 * Returns: %TRUE if the viewport keeps the focus child scrolled to view
141 	 */
142 	public bool getScrollToFocus()
143 	{
144 		return gtk_viewport_get_scroll_to_focus(gtkViewport) != 0;
145 	}
146 
147 	/**
148 	 * Sets the child widget of @viewport.
149 	 *
150 	 * Params:
151 	 *     child = the child widget
152 	 */
153 	public void setChild(Widget child)
154 	{
155 		gtk_viewport_set_child(gtkViewport, (child is null) ? null : child.getWidgetStruct());
156 	}
157 
158 	/**
159 	 * Sets whether the viewport should automatically scroll
160 	 * to keep the focused child in view.
161 	 *
162 	 * Params:
163 	 *     scrollToFocus = whether to keep the focus widget scrolled to view
164 	 */
165 	public void setScrollToFocus(bool scrollToFocus)
166 	{
167 		gtk_viewport_set_scroll_to_focus(gtkViewport, scrollToFocus);
168 	}
169 }