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.Layout;
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.Container;
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  * #GtkLayout is similar to #GtkDrawingArea in that it’s a “blank slate” and
42  * doesn’t do anything except paint a blank background by default. It’s
43  * different in that it supports scrolling natively due to implementing
44  * #GtkScrollable, and can contain child widgets since it’s a #GtkContainer.
45  * 
46  * If you just want to draw, a #GtkDrawingArea is a better choice since it has
47  * lower overhead. If you just need to position child widgets at specific
48  * points, then #GtkFixed provides that functionality on its own.
49  * 
50  * When handling expose events on a #GtkLayout, you must draw to the #GdkWindow
51  * returned by gtk_layout_get_bin_window(), rather than to the one returned by
52  * gtk_widget_get_window() as you would for a #GtkDrawingArea.
53  */
54 public class Layout : Container, ScrollableIF
55 {
56 	/** the main Gtk struct */
57 	protected GtkLayout* gtkLayout;
58 
59 	/** Get the main Gtk struct */
60 	public GtkLayout* getLayoutStruct(bool transferOwnership = false)
61 	{
62 		if (transferOwnership)
63 			ownedRef = false;
64 		return gtkLayout;
65 	}
66 
67 	/** the main Gtk struct as a void* */
68 	protected override void* getStruct()
69 	{
70 		return cast(void*)gtkLayout;
71 	}
72 
73 	protected override void setStruct(GObject* obj)
74 	{
75 		gtkLayout = cast(GtkLayout*)obj;
76 		super.setStruct(obj);
77 	}
78 
79 	/**
80 	 * Sets our main struct and passes it to the parent class.
81 	 */
82 	public this (GtkLayout* gtkLayout, bool ownedRef = false)
83 	{
84 		this.gtkLayout = gtkLayout;
85 		super(cast(GtkContainer*)gtkLayout, ownedRef);
86 	}
87 
88 	// add the Scrollable capabilities
89 	mixin ScrollableT!(GtkLayout);
90 
91 
92 	/** */
93 	public static GType getType()
94 	{
95 		return gtk_layout_get_type();
96 	}
97 
98 	/**
99 	 * Creates a new #GtkLayout. Unless you have a specific adjustment
100 	 * you’d like the layout to use for scrolling, pass %NULL for
101 	 * @hadjustment and @vadjustment.
102 	 *
103 	 * Params:
104 	 *     hadjustment = horizontal scroll adjustment, or %NULL
105 	 *     vadjustment = vertical scroll adjustment, or %NULL
106 	 *
107 	 * Returns: a new #GtkLayout
108 	 *
109 	 * Throws: ConstructionException GTK+ fails to create the object.
110 	 */
111 	public this(Adjustment hadjustment, Adjustment vadjustment)
112 	{
113 		auto p = gtk_layout_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(GtkLayout*) p);
121 	}
122 
123 	/**
124 	 * Retrieve the bin window of the layout used for drawing operations.
125 	 *
126 	 * Returns: a #GdkWindow
127 	 *
128 	 * Since: 2.14
129 	 */
130 	public Window getBinWindow()
131 	{
132 		auto p = gtk_layout_get_bin_window(gtkLayout);
133 
134 		if(p is null)
135 		{
136 			return null;
137 		}
138 
139 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
140 	}
141 
142 	/**
143 	 * This function should only be called after the layout has been
144 	 * placed in a #GtkScrolledWindow or otherwise configured for
145 	 * scrolling. It returns the #GtkAdjustment used for communication
146 	 * between the horizontal scrollbar and @layout.
147 	 *
148 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
149 	 *
150 	 * Deprecated: Use gtk_scrollable_get_hadjustment()
151 	 *
152 	 * Returns: horizontal scroll adjustment
153 	 */
154 	public Adjustment getHadjustment()
155 	{
156 		auto p = gtk_layout_get_hadjustment(gtkLayout);
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 size that has been set on the layout, and that determines
168 	 * the total extents of the layout’s scrollbar area. See
169 	 * gtk_layout_set_size ().
170 	 *
171 	 * Params:
172 	 *     width = location to store the width set on
173 	 *         @layout, or %NULL
174 	 *     height = location to store the height set on
175 	 *         @layout, or %NULL
176 	 */
177 	public void getSize(out uint width, out uint height)
178 	{
179 		gtk_layout_get_size(gtkLayout, &width, &height);
180 	}
181 
182 	/**
183 	 * This function should only be called after the layout has been
184 	 * placed in a #GtkScrolledWindow or otherwise configured for
185 	 * scrolling. It returns the #GtkAdjustment used for communication
186 	 * between the vertical scrollbar and @layout.
187 	 *
188 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
189 	 *
190 	 * Deprecated: Use gtk_scrollable_get_vadjustment()
191 	 *
192 	 * Returns: vertical scroll adjustment
193 	 */
194 	public Adjustment getVadjustment()
195 	{
196 		auto p = gtk_layout_get_vadjustment(gtkLayout);
197 
198 		if(p is null)
199 		{
200 			return null;
201 		}
202 
203 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
204 	}
205 
206 	/**
207 	 * Moves a current child of @layout to a new position.
208 	 *
209 	 * Params:
210 	 *     childWidget = a current child of @layout
211 	 *     x = X position to move to
212 	 *     y = Y position to move to
213 	 */
214 	public void move(Widget childWidget, int x, int y)
215 	{
216 		gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
217 	}
218 
219 	/**
220 	 * Adds @child_widget to @layout, at position (@x,@y).
221 	 * @layout becomes the new parent container of @child_widget.
222 	 *
223 	 * Params:
224 	 *     childWidget = child widget
225 	 *     x = X position of child widget
226 	 *     y = Y position of child widget
227 	 */
228 	public void put(Widget childWidget, int x, int y)
229 	{
230 		gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
231 	}
232 
233 	/**
234 	 * Sets the horizontal scroll adjustment for the layout.
235 	 *
236 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
237 	 *
238 	 * Deprecated: Use gtk_scrollable_set_hadjustment()
239 	 *
240 	 * Params:
241 	 *     adjustment = new scroll adjustment
242 	 */
243 	public void setHadjustment(Adjustment adjustment)
244 	{
245 		gtk_layout_set_hadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
246 	}
247 
248 	/**
249 	 * Sets the size of the scrollable area of the layout.
250 	 *
251 	 * Params:
252 	 *     width = width of entire scrollable area
253 	 *     height = height of entire scrollable area
254 	 */
255 	public void setSize(uint width, uint height)
256 	{
257 		gtk_layout_set_size(gtkLayout, width, height);
258 	}
259 
260 	/**
261 	 * Sets the vertical scroll adjustment for the layout.
262 	 *
263 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
264 	 *
265 	 * Deprecated: Use gtk_scrollable_set_vadjustment()
266 	 *
267 	 * Params:
268 	 *     adjustment = new scroll adjustment
269 	 */
270 	public void setVadjustment(Adjustment adjustment)
271 	{
272 		gtk_layout_set_vadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
273 	}
274 }