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