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 	/**
81 	 * Sets our main struct and passes it to the parent class.
82 	 */
83 	public this (GtkViewport* gtkViewport, bool ownedRef = false)
84 	{
85 		this.gtkViewport = gtkViewport;
86 		super(cast(GtkBin*)gtkViewport, ownedRef);
87 	}
88 
89 	// add the Scrollable capabilities
90 	mixin ScrollableT!(GtkViewport);
91 
92 
93 	/** */
94 	public static GType getType()
95 	{
96 		return gtk_viewport_get_type();
97 	}
98 
99 	/**
100 	 * Creates a new #GtkViewport with the given adjustments, or with default
101 	 * adjustments if none are given.
102 	 *
103 	 * Params:
104 	 *     hadjustment = horizontal adjustment
105 	 *     vadjustment = vertical adjustment
106 	 *
107 	 * Returns: a new #GtkViewport
108 	 *
109 	 * Throws: ConstructionException GTK+ fails to create the object.
110 	 */
111 	public this(Adjustment hadjustment, Adjustment vadjustment)
112 	{
113 		auto p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
114 
115 		if(p is null)
116 		{
117 			throw new ConstructionException("null returned by new");
118 		}
119 
120 		this(cast(GtkViewport*) p);
121 	}
122 
123 	/**
124 	 * Gets the bin window of the #GtkViewport.
125 	 *
126 	 * Returns: a #GdkWindow
127 	 *
128 	 * Since: 2.20
129 	 */
130 	public Window getBinWindow()
131 	{
132 		auto p = gtk_viewport_get_bin_window(gtkViewport);
133 
134 		if(p is null)
135 		{
136 			return null;
137 		}
138 
139 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
140 	}
141 
142 	/**
143 	 * Returns the horizontal adjustment of the viewport.
144 	 *
145 	 * Deprecated: Use gtk_scrollable_get_hadjustment()
146 	 *
147 	 * Returns: the horizontal adjustment of @viewport.
148 	 */
149 	public Adjustment getHadjustment()
150 	{
151 		auto p = gtk_viewport_get_hadjustment(gtkViewport);
152 
153 		if(p is null)
154 		{
155 			return null;
156 		}
157 
158 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
159 	}
160 
161 	/**
162 	 * Gets the shadow type of the #GtkViewport. See
163 	 * gtk_viewport_set_shadow_type().
164 	 *
165 	 * Returns: the shadow type
166 	 */
167 	public GtkShadowType getShadowType()
168 	{
169 		return gtk_viewport_get_shadow_type(gtkViewport);
170 	}
171 
172 	/**
173 	 * Returns the vertical adjustment of the viewport.
174 	 *
175 	 * Deprecated: Use gtk_scrollable_get_vadjustment()
176 	 *
177 	 * Returns: the vertical adjustment of @viewport.
178 	 */
179 	public Adjustment getVadjustment()
180 	{
181 		auto p = gtk_viewport_get_vadjustment(gtkViewport);
182 
183 		if(p is null)
184 		{
185 			return null;
186 		}
187 
188 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
189 	}
190 
191 	/**
192 	 * Gets the view window of the #GtkViewport.
193 	 *
194 	 * Returns: a #GdkWindow
195 	 *
196 	 * Since: 2.22
197 	 */
198 	public Window getViewWindow()
199 	{
200 		auto p = gtk_viewport_get_view_window(gtkViewport);
201 
202 		if(p is null)
203 		{
204 			return null;
205 		}
206 
207 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
208 	}
209 
210 	/**
211 	 * Sets the horizontal adjustment of the viewport.
212 	 *
213 	 * Deprecated: Use gtk_scrollable_set_hadjustment()
214 	 *
215 	 * Params:
216 	 *     adjustment = a #GtkAdjustment.
217 	 */
218 	public void setHadjustment(Adjustment adjustment)
219 	{
220 		gtk_viewport_set_hadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
221 	}
222 
223 	/**
224 	 * Sets the shadow type of the viewport.
225 	 *
226 	 * Params:
227 	 *     type = the new shadow type.
228 	 */
229 	public void setShadowType(GtkShadowType type)
230 	{
231 		gtk_viewport_set_shadow_type(gtkViewport, type);
232 	}
233 
234 	/**
235 	 * Sets the vertical adjustment of the viewport.
236 	 *
237 	 * Deprecated: Use gtk_scrollable_set_vadjustment()
238 	 *
239 	 * Params:
240 	 *     adjustment = a #GtkAdjustment.
241 	 */
242 	public void setVadjustment(Adjustment adjustment)
243 	{
244 		gtk_viewport_set_vadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
245 	}
246 }