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: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- ScrollableIF
40  * prefixes:
41  * 	- gtk_layout_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_layout_get_hadjustment
46  * 	- gtk_layout_get_vadjustment
47  * 	- gtk_layout_set_hadjustment
48  * 	- gtk_layout_set_vadjustment
49  * omit signals:
50  * imports:
51  * 	- gdk.Window
52  * 	- gtk.Adjustment
53  * 	- gtk.Widget
54  * 	- gtk.ScrollableIF
55  * 	- gtk.ScrollableT
56  * structWrap:
57  * 	- GdkWindow* -> Window
58  * 	- GtkAdjustment* -> Adjustment
59  * 	- GtkWidget* -> Widget
60  * module aliases:
61  * local aliases:
62  * overrides:
63  */
64 
65 module gtk.Layout;
66 
67 public  import gtkc.gtktypes;
68 
69 private import gtkc.gtk;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 
74 private import gdk.Window;
75 private import gtk.Adjustment;
76 private import gtk.Widget;
77 private import gtk.ScrollableIF;
78 private import gtk.ScrollableT;
79 
80 
81 
82 private import gtk.Container;
83 
84 /**
85  * GtkLayout is similar to GtkDrawingArea in that it's a "blank slate"
86  * and doesn't do anything but paint a blank background by default. It's
87  * different in that it supports scrolling natively (you can add it to a
88  * GtkScrolledWindow), and it can contain child widgets, since it's a
89  * GtkContainer. However if you're just going to draw, a GtkDrawingArea
90  * is a better choice since it has lower overhead.
91  *
92  * When handling expose events on a GtkLayout, you must draw to
93  * GTK_LAYOUT (layout)->bin_window, rather than to
94  * GTK_WIDGET (layout)->window, as you would for a drawing
95  * area.
96  */
97 public class Layout : Container, ScrollableIF
98 {
99 	
100 	/** the main Gtk struct */
101 	protected GtkLayout* gtkLayout;
102 	
103 	
104 	public GtkLayout* getLayoutStruct()
105 	{
106 		return gtkLayout;
107 	}
108 	
109 	
110 	/** the main Gtk struct as a void* */
111 	protected override void* getStruct()
112 	{
113 		return cast(void*)gtkLayout;
114 	}
115 	
116 	/**
117 	 * Sets our main struct and passes it to the parent class
118 	 */
119 	public this (GtkLayout* gtkLayout)
120 	{
121 		super(cast(GtkContainer*)gtkLayout);
122 		this.gtkLayout = gtkLayout;
123 	}
124 	
125 	protected override void setStruct(GObject* obj)
126 	{
127 		super.setStruct(obj);
128 		gtkLayout = cast(GtkLayout*)obj;
129 	}
130 	
131 	// add the Scrollable capabilities
132 	mixin ScrollableT!(GtkLayout);
133 	
134 	/**
135 	 */
136 	
137 	/**
138 	 * Creates a new GtkLayout. Unless you have a specific adjustment
139 	 * you'd like the layout to use for scrolling, pass NULL for
140 	 * hadjustment and vadjustment.
141 	 * Params:
142 	 * hadjustment = horizontal scroll adjustment, or NULL. [allow-none]
143 	 * vadjustment = vertical scroll adjustment, or NULL. [allow-none]
144 	 * Throws: ConstructionException GTK+ fails to create the object.
145 	 */
146 	public this (Adjustment hadjustment, Adjustment vadjustment)
147 	{
148 		// GtkWidget * gtk_layout_new (GtkAdjustment *hadjustment,  GtkAdjustment *vadjustment);
149 		auto p = gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct());
150 		if(p is null)
151 		{
152 			throw new ConstructionException("null returned by gtk_layout_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct())");
153 		}
154 		this(cast(GtkLayout*) p);
155 	}
156 	
157 	/**
158 	 * Adds child_widget to layout, at position (x,y).
159 	 * layout becomes the new parent container of child_widget.
160 	 * Params:
161 	 * childWidget = child widget
162 	 * x = X position of child widget
163 	 * y = Y position of child widget
164 	 */
165 	public void put(Widget childWidget, int x, int y)
166 	{
167 		// void gtk_layout_put (GtkLayout *layout,  GtkWidget *child_widget,  gint x,  gint y);
168 		gtk_layout_put(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
169 	}
170 	
171 	/**
172 	 * Moves a current child of layout to a new position.
173 	 * Params:
174 	 * childWidget = a current child of layout
175 	 * x = X position to move to
176 	 * y = Y position to move to
177 	 */
178 	public void move(Widget childWidget, int x, int y)
179 	{
180 		// void gtk_layout_move (GtkLayout *layout,  GtkWidget *child_widget,  gint x,  gint y);
181 		gtk_layout_move(gtkLayout, (childWidget is null) ? null : childWidget.getWidgetStruct(), x, y);
182 	}
183 	
184 	/**
185 	 * Sets the size of the scrollable area of the layout.
186 	 * Params:
187 	 * width = width of entire scrollable area
188 	 * height = height of entire scrollable area
189 	 */
190 	public void setSize(uint width, uint height)
191 	{
192 		// void gtk_layout_set_size (GtkLayout *layout,  guint width,  guint height);
193 		gtk_layout_set_size(gtkLayout, width, height);
194 	}
195 	
196 	/**
197 	 * Gets the size that has been set on the layout, and that determines
198 	 * the total extents of the layout's scrollbar area. See
199 	 * gtk_layout_set_size().
200 	 * Params:
201 	 * width = location to store the width set on
202 	 * layout, or NULL. [out][allow-none]
203 	 * height = location to store the height set on
204 	 * layout, or NULL. [out][allow-none]
205 	 */
206 	public void getSize(out uint width, out uint height)
207 	{
208 		// void gtk_layout_get_size (GtkLayout *layout,  guint *width,  guint *height);
209 		gtk_layout_get_size(gtkLayout, &width, &height);
210 	}
211 	
212 	/**
213 	 * Retrieve the bin window of the layout used for drawing operations.
214 	 * Since 2.14
215 	 * Returns: a GdkWindow. [transfer none]
216 	 */
217 	public Window getBinWindow()
218 	{
219 		// GdkWindow * gtk_layout_get_bin_window (GtkLayout *layout);
220 		auto p = gtk_layout_get_bin_window(gtkLayout);
221 		
222 		if(p is null)
223 		{
224 			return null;
225 		}
226 		
227 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
228 	}
229 }