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  * Conversion parameters:
26  * inFile  = GtkViewport.html
27  * outPack = gtk
28  * outFile = Viewport
29  * strct   = GtkViewport
30  * realStrct=
31  * ctorStrct=
32  * clss    = Viewport
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_viewport_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gdk.Window
48  * 	- gtk.Adjustment
49  * structWrap:
50  * 	- GdkWindow* -> Window
51  * 	- GtkAdjustment* -> Adjustment
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.Viewport;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import gobject.Signals;
66 public  import gtkc.gdktypes;
67 
68 private import gdk.Window;
69 private import gtk.Adjustment;
70 
71 
72 
73 private import gtk.Bin;
74 
75 /**
76  * Description
77  * The GtkViewport widget acts as an adaptor class, implementing
78  * scrollability for child widgets that lack their own scrolling
79  * capabilities. Use GtkViewport to scroll child widgets such as
80  * GtkTable, GtkBox, and so on.
81  * If a widget has native scrolling abilities, such as GtkTextView,
82  * GtkTreeView or GtkIconview, it can be added to a GtkScrolledWindow
83  * with gtk_container_add(). If a widget does not, you must first add the
84  * widget to a GtkViewport, then add the viewport to the scrolled window.
85  * The convenience function gtk_scrolled_window_add_with_viewport() does
86  * exactly this, so you can ignore the presence of the viewport.
87  */
88 public class Viewport : Bin
89 {
90 	
91 	/** the main Gtk struct */
92 	protected GtkViewport* gtkViewport;
93 	
94 	
95 	public GtkViewport* getViewportStruct()
96 	{
97 		return gtkViewport;
98 	}
99 	
100 	
101 	/** the main Gtk struct as a void* */
102 	protected override void* getStruct()
103 	{
104 		return cast(void*)gtkViewport;
105 	}
106 	
107 	/**
108 	 * Sets our main struct and passes it to the parent class
109 	 */
110 	public this (GtkViewport* gtkViewport)
111 	{
112 		super(cast(GtkBin*)gtkViewport);
113 		this.gtkViewport = gtkViewport;
114 	}
115 	
116 	protected override void setStruct(GObject* obj)
117 	{
118 		super.setStruct(obj);
119 		gtkViewport = cast(GtkViewport*)obj;
120 	}
121 	
122 	/**
123 	 */
124 	int[string] connectedSignals;
125 	
126 	void delegate(Adjustment, Adjustment, Viewport)[] onSetScrollAdjustmentsListeners;
127 	/**
128 	 * Set the scroll adjustments for the viewport. Usually scrolled containers
129 	 * like GtkScrolledWindow will emit this signal to connect two instances
130 	 * of GtkScrollbar to the scroll directions of the GtkViewport.
131 	 * See Also
132 	 * GtkScrolledWindow, GtkAdjustment
133 	 */
134 	void addOnSetScrollAdjustments(void delegate(Adjustment, Adjustment, Viewport) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
135 	{
136 		if ( !("set-scroll-adjustments" in connectedSignals) )
137 		{
138 			Signals.connectData(
139 			getStruct(),
140 			"set-scroll-adjustments",
141 			cast(GCallback)&callBackSetScrollAdjustments,
142 			cast(void*)this,
143 			null,
144 			connectFlags);
145 			connectedSignals["set-scroll-adjustments"] = 1;
146 		}
147 		onSetScrollAdjustmentsListeners ~= dlg;
148 	}
149 	extern(C) static void callBackSetScrollAdjustments(GtkViewport* horizontalStruct, GtkAdjustment* vertical, GtkAdjustment* arg2, Viewport _viewport)
150 	{
151 		foreach ( void delegate(Adjustment, Adjustment, Viewport) dlg ; _viewport.onSetScrollAdjustmentsListeners )
152 		{
153 			dlg(ObjectG.getDObject!(Adjustment)(vertical), ObjectG.getDObject!(Adjustment)(arg2), _viewport);
154 		}
155 	}
156 	
157 	
158 	/**
159 	 * Creates a new GtkViewport with the given adjustments.
160 	 * Params:
161 	 * hadjustment = horizontal adjustment.
162 	 * vadjustment = vertical adjustment.
163 	 * Throws: ConstructionException GTK+ fails to create the object.
164 	 */
165 	public this (Adjustment hadjustment, Adjustment vadjustment)
166 	{
167 		// GtkWidget * gtk_viewport_new (GtkAdjustment *hadjustment,  GtkAdjustment *vadjustment);
168 		auto p = gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
169 		if(p is null)
170 		{
171 			throw new ConstructionException("null returned by gtk_viewport_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct())");
172 		}
173 		this(cast(GtkViewport*) p);
174 	}
175 	
176 	/**
177 	 * Returns the horizontal adjustment of the viewport.
178 	 * Returns: the horizontal adjustment of viewport. [transfer none]
179 	 */
180 	public Adjustment getHadjustment()
181 	{
182 		// GtkAdjustment * gtk_viewport_get_hadjustment (GtkViewport *viewport);
183 		auto p = gtk_viewport_get_hadjustment(gtkViewport);
184 		
185 		if(p is null)
186 		{
187 			return null;
188 		}
189 		
190 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
191 	}
192 	
193 	/**
194 	 * Returns the vertical adjustment of the viewport.
195 	 * Returns: the vertical adjustment of viewport. [transfer none]
196 	 */
197 	public Adjustment getVadjustment()
198 	{
199 		// GtkAdjustment * gtk_viewport_get_vadjustment (GtkViewport *viewport);
200 		auto p = gtk_viewport_get_vadjustment(gtkViewport);
201 		
202 		if(p is null)
203 		{
204 			return null;
205 		}
206 		
207 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
208 	}
209 	
210 	/**
211 	 * Sets the horizontal adjustment of the viewport.
212 	 * Params:
213 	 * adjustment = a GtkAdjustment. [allow-none]
214 	 */
215 	public void setHadjustment(Adjustment adjustment)
216 	{
217 		// void gtk_viewport_set_hadjustment (GtkViewport *viewport,  GtkAdjustment *adjustment);
218 		gtk_viewport_set_hadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
219 	}
220 	
221 	/**
222 	 * Sets the vertical adjustment of the viewport.
223 	 * Params:
224 	 * adjustment = a GtkAdjustment. [allow-none]
225 	 */
226 	public void setVadjustment(Adjustment adjustment)
227 	{
228 		// void gtk_viewport_set_vadjustment (GtkViewport *viewport,  GtkAdjustment *adjustment);
229 		gtk_viewport_set_vadjustment(gtkViewport, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
230 	}
231 	
232 	/**
233 	 * Sets the shadow type of the viewport.
234 	 * Params:
235 	 * type = the new shadow type.
236 	 */
237 	public void setShadowType(GtkShadowType type)
238 	{
239 		// void gtk_viewport_set_shadow_type (GtkViewport *viewport,  GtkShadowType type);
240 		gtk_viewport_set_shadow_type(gtkViewport, type);
241 	}
242 	
243 	/**
244 	 * Gets the shadow type of the GtkViewport. See
245 	 * gtk_viewport_set_shadow_type().
246 	 * Returns: the shadow type
247 	 */
248 	public GtkShadowType getShadowType()
249 	{
250 		// GtkShadowType gtk_viewport_get_shadow_type (GtkViewport *viewport);
251 		return gtk_viewport_get_shadow_type(gtkViewport);
252 	}
253 	
254 	/**
255 	 * Gets the bin window of the GtkViewport.
256 	 * Since 2.20
257 	 * Returns: a GdkWindow. [transfer none]
258 	 */
259 	public Window getBinWindow()
260 	{
261 		// GdkWindow * gtk_viewport_get_bin_window (GtkViewport *viewport);
262 		auto p = gtk_viewport_get_bin_window(gtkViewport);
263 		
264 		if(p is null)
265 		{
266 			return null;
267 		}
268 		
269 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
270 	}
271 	
272 	/**
273 	 * Gets the view window of the GtkViewport.
274 	 * Since 2.22
275 	 * Returns: a GdkWindow. [transfer none]
276 	 */
277 	public Window getViewWindow()
278 	{
279 		// GdkWindow * gtk_viewport_get_view_window (GtkViewport *viewport);
280 		auto p = gtk_viewport_get_view_window(gtkViewport);
281 		
282 		if(p is null)
283 		{
284 			return null;
285 		}
286 		
287 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
288 	}
289 }