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  = GtkLayout.html
27  * outPack = gtk
28  * outFile = Layout
29  * strct   = GtkLayout
30  * realStrct=
31  * ctorStrct=
32  * clss    = Layout
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_layout_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gdk.Window
48  * 	- gtk.Adjustment
49  * 	- gtk.Widget
50  * structWrap:
51  * 	- GdkWindow* -> Window
52  * 	- GtkAdjustment* -> Adjustment
53  * 	- GtkWidget* -> Widget
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gtk.Layout;
60 
61 public  import gtkc.gtktypes;
62 
63 private import gtkc.gtk;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 
70 private import gdk.Window;
71 private import gtk.Adjustment;
72 private import gtk.Widget;
73 
74 
75 
76 private import gtk.Container;
77 
78 /**
79  * Description
80  * GtkLayout is similar to GtkDrawingArea in that it's a "blank slate"
81  * and doesn't do anything but paint a blank background by default. It's
82  * different in that it supports scrolling natively (you can add it to a
83  * GtkScrolledWindow), and it can contain child widgets, since it's a
84  * GtkContainer. However if you're just going to draw, a GtkDrawingArea
85  * is a better choice since it has lower overhead.
86  * When handling expose events on a GtkLayout, you must draw to
87  * GTK_LAYOUT (layout)->bin_window, rather than to
88  * GTK_WIDGET (layout)->window, as you would for a drawing
89  * area.
90  */
91 public class Layout : Container
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GtkLayout* gtkLayout;
96 	
97 	
98 	public GtkLayout* getLayoutStruct()
99 	{
100 		return gtkLayout;
101 	}
102 	
103 	
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gtkLayout;
108 	}
109 	
110 	/**
111 	 * Sets our main struct and passes it to the parent class
112 	 */
113 	public this (GtkLayout* gtkLayout)
114 	{
115 		super(cast(GtkContainer*)gtkLayout);
116 		this.gtkLayout = gtkLayout;
117 	}
118 	
119 	protected override void setStruct(GObject* obj)
120 	{
121 		super.setStruct(obj);
122 		gtkLayout = cast(GtkLayout*)obj;
123 	}
124 	
125 	/**
126 	 */
127 	int[string] connectedSignals;
128 	
129 	void delegate(Adjustment, Adjustment, Layout)[] onSetScrollAdjustmentsListeners;
130 	/**
131 	 * Set the scroll adjustments for the layout. Usually scrolled containers
132 	 * like GtkScrolledWindow will emit this signal to connect two instances
133 	 * of GtkScrollbar to the scroll directions of the GtkLayout.
134 	 * See Also
135 	 * GtkDrawingArea, GtkScrolledWindow
136 	 */
137 	void addOnSetScrollAdjustments(void delegate(Adjustment, Adjustment, Layout) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
138 	{
139 		if ( !("set-scroll-adjustments" in connectedSignals) )
140 		{
141 			Signals.connectData(
142 			getStruct(),
143 			"set-scroll-adjustments",
144 			cast(GCallback)&callBackSetScrollAdjustments,
145 			cast(void*)this,
146 			null,
147 			connectFlags);
148 			connectedSignals["set-scroll-adjustments"] = 1;
149 		}
150 		onSetScrollAdjustmentsListeners ~= dlg;
151 	}
152 	extern(C) static void callBackSetScrollAdjustments(GtkLayout* horizontalStruct, GtkAdjustment* vertical, GtkAdjustment* arg2, Layout _layout)
153 	{
154 		foreach ( void delegate(Adjustment, Adjustment, Layout) dlg ; _layout.onSetScrollAdjustmentsListeners )
155 		{
156 			dlg(ObjectG.getDObject!(Adjustment)(vertical), ObjectG.getDObject!(Adjustment)(arg2), _layout);
157 		}
158 	}
159 	
160 	
161 	/**
162 	 * Creates a new GtkLayout. Unless you have a specific adjustment
163 	 * you'd like the layout to use for scrolling, pass NULL for
164 	 * hadjustment and vadjustment.
165 	 * Params:
166 	 * hadjustment = horizontal scroll adjustment, or NULL. [allow-none]
167 	 * vadjustment = vertical scroll adjustment, or NULL. [allow-none]
168 	 * Throws: ConstructionException GTK+ fails to create the object.
169 	 */
170 	public this (Adjustment hadjustment, Adjustment vadjustment)
171 	{
172 		// GtkWidget * gtk_layout_new (GtkAdjustment *hadjustment,  GtkAdjustment *vadjustment);
173 		auto p = gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
174 		if(p is null)
175 		{
176 			throw new ConstructionException("null returned by gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct())");
177 		}
178 		this(cast(GtkLayout*) p);
179 	}
180 	
181 	/**
182 	 * Adds child_widget to layout, at position (x,y).
183 	 * layout becomes the new parent container of child_widget.
184 	 * Params:
185 	 * childWidget = child widget
186 	 * x = X position of child widget
187 	 * y = Y position of child widget
188 	 */
189 	public void put(Widget childWidget, int x, int y)
190 	{
191 		// void gtk_layout_put (GtkLayout *layout,  GtkWidget *child_widget,  gint x,  gint y);
192 		gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
193 	}
194 	
195 	/**
196 	 * Moves a current child of layout to a new position.
197 	 * Params:
198 	 * childWidget = a current child of layout
199 	 * x = X position to move to
200 	 * y = Y position to move to
201 	 */
202 	public void move(Widget childWidget, int x, int y)
203 	{
204 		// void gtk_layout_move (GtkLayout *layout,  GtkWidget *child_widget,  gint x,  gint y);
205 		gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
206 	}
207 	
208 	/**
209 	 * Sets the size of the scrollable area of the layout.
210 	 * Params:
211 	 * width = width of entire scrollable area
212 	 * height = height of entire scrollable area
213 	 */
214 	public void setSize(uint width, uint height)
215 	{
216 		// void gtk_layout_set_size (GtkLayout *layout,  guint width,  guint height);
217 		gtk_layout_set_size(gtkLayout, width, height);
218 	}
219 	
220 	/**
221 	 * Gets the size that has been set on the layout, and that determines
222 	 * the total extents of the layout's scrollbar area. See
223 	 * gtk_layout_set_size().
224 	 * Params:
225 	 * width = location to store the width set on
226 	 * layout, or NULL. [out][allow-none]
227 	 * height = location to store the height set on
228 	 * layout, or NULL. [out][allow-none]
229 	 */
230 	public void getSize(out uint width, out uint height)
231 	{
232 		// void gtk_layout_get_size (GtkLayout *layout,  guint *width,  guint *height);
233 		gtk_layout_get_size(gtkLayout, &width, &height);
234 	}
235 	
236 	/**
237 	 * Warning
238 	 * gtk_layout_freeze is deprecated and should not be used in newly-written code.
239 	 * This is a deprecated function, it doesn't do anything useful.
240 	 */
241 	public void freeze()
242 	{
243 		// void gtk_layout_freeze (GtkLayout *layout);
244 		gtk_layout_freeze(gtkLayout);
245 	}
246 	
247 	/**
248 	 * Warning
249 	 * gtk_layout_thaw is deprecated and should not be used in newly-written code.
250 	 * This is a deprecated function, it doesn't do anything useful.
251 	 */
252 	public void thaw()
253 	{
254 		// void gtk_layout_thaw (GtkLayout *layout);
255 		gtk_layout_thaw(gtkLayout);
256 	}
257 	
258 	/**
259 	 * This function should only be called after the layout has been
260 	 * placed in a GtkScrolledWindow or otherwise configured for
261 	 * scrolling. It returns the GtkAdjustment used for communication
262 	 * between the horizontal scrollbar and layout.
263 	 * See GtkScrolledWindow, GtkScrollbar, GtkAdjustment for details.
264 	 * Returns: horizontal scroll adjustment. [transfer none]
265 	 */
266 	public Adjustment getHadjustment()
267 	{
268 		// GtkAdjustment * gtk_layout_get_hadjustment (GtkLayout *layout);
269 		auto p = gtk_layout_get_hadjustment(gtkLayout);
270 		
271 		if(p is null)
272 		{
273 			return null;
274 		}
275 		
276 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
277 	}
278 	
279 	/**
280 	 * This function should only be called after the layout has been
281 	 * placed in a GtkScrolledWindow or otherwise configured for
282 	 * scrolling. It returns the GtkAdjustment used for communication
283 	 * between the vertical scrollbar and layout.
284 	 * See GtkScrolledWindow, GtkScrollbar, GtkAdjustment for details.
285 	 * Returns: vertical scroll adjustment. [transfer none]
286 	 */
287 	public Adjustment getVadjustment()
288 	{
289 		// GtkAdjustment * gtk_layout_get_vadjustment (GtkLayout *layout);
290 		auto p = gtk_layout_get_vadjustment(gtkLayout);
291 		
292 		if(p is null)
293 		{
294 			return null;
295 		}
296 		
297 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
298 	}
299 	
300 	/**
301 	 * Sets the horizontal scroll adjustment for the layout.
302 	 * See GtkScrolledWindow, GtkScrollbar, GtkAdjustment for details.
303 	 * Params:
304 	 * adjustment = new scroll adjustment. [allow-none]
305 	 */
306 	public void setHadjustment(Adjustment adjustment)
307 	{
308 		// void gtk_layout_set_hadjustment (GtkLayout *layout,  GtkAdjustment *adjustment);
309 		gtk_layout_set_hadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
310 	}
311 	
312 	/**
313 	 * Sets the vertical scroll adjustment for the layout.
314 	 * See GtkScrolledWindow, GtkScrollbar, GtkAdjustment for details.
315 	 * Params:
316 	 * adjustment = new scroll adjustment. [allow-none]
317 	 */
318 	public void setVadjustment(Adjustment adjustment)
319 	{
320 		// void gtk_layout_set_vadjustment (GtkLayout *layout,  GtkAdjustment *adjustment);
321 		gtk_layout_set_vadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
322 	}
323 	
324 	/**
325 	 * Retrieve the bin window of the layout used for drawing operations.
326 	 * Since 2.14
327 	 * Returns: a GdkWindow. [transfer none]
328 	 */
329 	public Window getBinWindow()
330 	{
331 		// GdkWindow * gtk_layout_get_bin_window (GtkLayout *layout);
332 		auto p = gtk_layout_get_bin_window(gtkLayout);
333 		
334 		if(p is null)
335 		{
336 			return null;
337 		}
338 		
339 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
340 	}
341 }