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