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 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GtkLayout* gtkLayout, bool ownedRef = false)
77 	{
78 		this.gtkLayout = gtkLayout;
79 		super(cast(GtkContainer*)gtkLayout, ownedRef);
80 	}
81 
82 	// add the Scrollable capabilities
83 	mixin ScrollableT!(GtkLayout);
84 
85 
86 	/** */
87 	public static GType getType()
88 	{
89 		return gtk_layout_get_type();
90 	}
91 
92 	/**
93 	 * Creates a new #GtkLayout. Unless you have a specific adjustment
94 	 * you’d like the layout to use for scrolling, pass %NULL for
95 	 * @hadjustment and @vadjustment.
96 	 *
97 	 * Params:
98 	 *     hadjustment = horizontal scroll adjustment, or %NULL
99 	 *     vadjustment = vertical scroll adjustment, or %NULL
100 	 *
101 	 * Returns: a new #GtkLayout
102 	 *
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this(Adjustment hadjustment, Adjustment vadjustment)
106 	{
107 		auto p = gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
108 
109 		if(p is null)
110 		{
111 			throw new ConstructionException("null returned by new");
112 		}
113 
114 		this(cast(GtkLayout*) p);
115 	}
116 
117 	/**
118 	 * Retrieve the bin window of the layout used for drawing operations.
119 	 *
120 	 * Returns: a #GdkWindow
121 	 *
122 	 * Since: 2.14
123 	 */
124 	public Window getBinWindow()
125 	{
126 		auto p = gtk_layout_get_bin_window(gtkLayout);
127 
128 		if(p is null)
129 		{
130 			return null;
131 		}
132 
133 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
134 	}
135 
136 	/**
137 	 * This function should only be called after the layout has been
138 	 * placed in a #GtkScrolledWindow or otherwise configured for
139 	 * scrolling. It returns the #GtkAdjustment used for communication
140 	 * between the horizontal scrollbar and @layout.
141 	 *
142 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
143 	 *
144 	 * Deprecated: Use gtk_scrollable_get_hadjustment()
145 	 *
146 	 * Returns: horizontal scroll adjustment
147 	 */
148 	public Adjustment getHadjustment()
149 	{
150 		auto p = gtk_layout_get_hadjustment(gtkLayout);
151 
152 		if(p is null)
153 		{
154 			return null;
155 		}
156 
157 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
158 	}
159 
160 	/**
161 	 * Gets the size that has been set on the layout, and that determines
162 	 * the total extents of the layout’s scrollbar area. See
163 	 * gtk_layout_set_size ().
164 	 *
165 	 * Params:
166 	 *     width = location to store the width set on
167 	 *         @layout, or %NULL
168 	 *     height = location to store the height set on
169 	 *         @layout, or %NULL
170 	 */
171 	public void getSize(out uint width, out uint height)
172 	{
173 		gtk_layout_get_size(gtkLayout, &width, &height);
174 	}
175 
176 	/**
177 	 * This function should only be called after the layout has been
178 	 * placed in a #GtkScrolledWindow or otherwise configured for
179 	 * scrolling. It returns the #GtkAdjustment used for communication
180 	 * between the vertical scrollbar and @layout.
181 	 *
182 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
183 	 *
184 	 * Deprecated: Use gtk_scrollable_get_vadjustment()
185 	 *
186 	 * Returns: vertical scroll adjustment
187 	 */
188 	public Adjustment getVadjustment()
189 	{
190 		auto p = gtk_layout_get_vadjustment(gtkLayout);
191 
192 		if(p is null)
193 		{
194 			return null;
195 		}
196 
197 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
198 	}
199 
200 	/**
201 	 * Moves a current child of @layout to a new position.
202 	 *
203 	 * Params:
204 	 *     childWidget = a current child of @layout
205 	 *     x = X position to move to
206 	 *     y = Y position to move to
207 	 */
208 	public void move(Widget childWidget, int x, int y)
209 	{
210 		gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
211 	}
212 
213 	/**
214 	 * Adds @child_widget to @layout, at position (@x,@y).
215 	 * @layout becomes the new parent container of @child_widget.
216 	 *
217 	 * Params:
218 	 *     childWidget = child widget
219 	 *     x = X position of child widget
220 	 *     y = Y position of child widget
221 	 */
222 	public void put(Widget childWidget, int x, int y)
223 	{
224 		gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
225 	}
226 
227 	/**
228 	 * Sets the horizontal scroll adjustment for the layout.
229 	 *
230 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
231 	 *
232 	 * Deprecated: Use gtk_scrollable_set_hadjustment()
233 	 *
234 	 * Params:
235 	 *     adjustment = new scroll adjustment
236 	 */
237 	public void setHadjustment(Adjustment adjustment)
238 	{
239 		gtk_layout_set_hadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
240 	}
241 
242 	/**
243 	 * Sets the size of the scrollable area of the layout.
244 	 *
245 	 * Params:
246 	 *     width = width of entire scrollable area
247 	 *     height = height of entire scrollable area
248 	 */
249 	public void setSize(uint width, uint height)
250 	{
251 		gtk_layout_set_size(gtkLayout, width, height);
252 	}
253 
254 	/**
255 	 * Sets the vertical scroll adjustment for the layout.
256 	 *
257 	 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
258 	 *
259 	 * Deprecated: Use gtk_scrollable_set_vadjustment()
260 	 *
261 	 * Params:
262 	 *     adjustment = new scroll adjustment
263 	 */
264 	public void setVadjustment(Adjustment adjustment)
265 	{
266 		gtk_layout_set_vadjustment(gtkLayout, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
267 	}
268 }