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 gdk.Window;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gtk.Adjustment;
31 private import gtk.Bin;
32 private import gtk.ScrollableIF;
33 private import gtk.ScrollableT;
34 private import gtk.Widget;
35 private import gtk.c.functions;
36 public  import gtk.c.types;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * The #GtkViewport widget acts as an adaptor class, implementing
42  * scrollability for child widgets that lack their own scrolling
43  * capabilities. Use GtkViewport to scroll child widgets such as
44  * #GtkGrid, #GtkBox, and so on.
45  * 
46  * If a widget has native scrolling abilities, such as #GtkTextView,
47  * #GtkTreeView or #GtkIconView, it can be added to a #GtkScrolledWindow
48  * with gtk_container_add(). If a widget does not, you must first add the
49  * widget to a #GtkViewport, then add the viewport to the scrolled window.
50  * gtk_container_add() does this automatically if a child that does not
51  * implement #GtkScrollable is added to a #GtkScrolledWindow, so you can
52  * ignore the presence of the viewport.
53  * 
54  * The GtkViewport will start scrolling content only if allocated less
55  * than the child widget’s minimum size in a given orientation.
56  * 
57  * # CSS nodes
58  * 
59  * GtkViewport has a single CSS node with name viewport.
60  */
61 public class Viewport : Bin, ScrollableIF
62 {
63 	/** the main Gtk struct */
64 	protected GtkViewport* gtkViewport;
65 
66 	/** Get the main Gtk struct */
67 	public GtkViewport* getViewportStruct(bool transferOwnership = false)
68 	{
69 		if (transferOwnership)
70 			ownedRef = false;
71 		return gtkViewport;
72 	}
73 
74 	/** the main Gtk struct as a void* */
75 	protected override void* getStruct()
76 	{
77 		return cast(void*)gtkViewport;
78 	}
79 
80 	protected override void setStruct(GObject* obj)
81 	{
82 		gtkViewport = cast(GtkViewport*)obj;
83 		super.setStruct(obj);
84 	}
85 
86 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GtkViewport* gtkViewport, bool ownedRef = false)
90 	{
91 		this.gtkViewport = gtkViewport;
92 		super(cast(GtkBin*)gtkViewport, ownedRef);
93 	}
94 
95 	// add the Scrollable capabilities
96 	mixin ScrollableT!(GtkViewport);
97 
98 
99 	/** */
100 	public static GType getType()
101 	{
102 		return gtk_viewport_get_type();
103 	}
104 
105 	/**
106 	 * Creates a new #GtkViewport with the given adjustments, or with default
107 	 * adjustments if none are given.
108 	 *
109 	 * Params:
110 	 *     hadjustment = horizontal adjustment
111 	 *     vadjustment = vertical adjustment
112 	 *
113 	 * Returns: a new #GtkViewport
114 	 *
115 	 * Throws: ConstructionException GTK+ fails to create the object.
116 	 */
117 	public this(Adjustment hadjustment, Adjustment vadjustment)
118 	{
119 		auto p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
120 
121 		if(p is null)
122 		{
123 			throw new ConstructionException("null returned by new");
124 		}
125 
126 		this(cast(GtkViewport*) p);
127 	}
128 
129 	/**
130 	 * Gets the bin window of the #GtkViewport.
131 	 *
132 	 * Returns: a #GdkWindow
133 	 *
134 	 * Since: 2.20
135 	 */
136 	public Window getBinWindow()
137 	{
138 		auto p = gtk_viewport_get_bin_window(gtkViewport);
139 
140 		if(p is null)
141 		{
142 			return null;
143 		}
144 
145 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
146 	}
147 
148 	/**
149 	 * Returns the horizontal adjustment of the viewport.
150 	 *
151 	 * Deprecated: Use gtk_scrollable_get_hadjustment()
152 	 *
153 	 * Returns: the horizontal adjustment of @viewport.
154 	 */
155 	public Adjustment getHadjustment()
156 	{
157 		auto p = gtk_viewport_get_hadjustment(gtkViewport);
158 
159 		if(p is null)
160 		{
161 			return null;
162 		}
163 
164 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
165 	}
166 
167 	/**
168 	 * Gets the shadow type of the #GtkViewport. See
169 	 * gtk_viewport_set_shadow_type().
170 	 *
171 	 * Returns: the shadow type
172 	 */
173 	public GtkShadowType getShadowType()
174 	{
175 		return gtk_viewport_get_shadow_type(gtkViewport);
176 	}
177 
178 	/**
179 	 * Returns the vertical adjustment of the viewport.
180 	 *
181 	 * Deprecated: Use gtk_scrollable_get_vadjustment()
182 	 *
183 	 * Returns: the vertical adjustment of @viewport.
184 	 */
185 	public Adjustment getVadjustment()
186 	{
187 		auto p = gtk_viewport_get_vadjustment(gtkViewport);
188 
189 		if(p is null)
190 		{
191 			return null;
192 		}
193 
194 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
195 	}
196 
197 	/**
198 	 * Gets the view window of the #GtkViewport.
199 	 *
200 	 * Returns: a #GdkWindow
201 	 *
202 	 * Since: 2.22
203 	 */
204 	public Window getViewWindow()
205 	{
206 		auto p = gtk_viewport_get_view_window(gtkViewport);
207 
208 		if(p is null)
209 		{
210 			return null;
211 		}
212 
213 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
214 	}
215 
216 	/**
217 	 * Sets the horizontal adjustment of the viewport.
218 	 *
219 	 * Deprecated: Use gtk_scrollable_set_hadjustment()
220 	 *
221 	 * Params:
222 	 *     adjustment = a #GtkAdjustment.
223 	 */
224 	public void setHadjustment(Adjustment adjustment)
225 	{
226 		gtk_viewport_set_hadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
227 	}
228 
229 	/**
230 	 * Sets the shadow type of the viewport.
231 	 *
232 	 * Params:
233 	 *     type = the new shadow type.
234 	 */
235 	public void setShadowType(GtkShadowType type)
236 	{
237 		gtk_viewport_set_shadow_type(gtkViewport, type);
238 	}
239 
240 	/**
241 	 * Sets the vertical adjustment of the viewport.
242 	 *
243 	 * Deprecated: Use gtk_scrollable_set_vadjustment()
244 	 *
245 	 * Params:
246 	 *     adjustment = a #GtkAdjustment.
247 	 */
248 	public void setVadjustment(Adjustment adjustment)
249 	{
250 		gtk_viewport_set_vadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
251 	}
252 }