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.Alignment;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gtk.Bin;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 public  import gtkc.gtktypes;
34 
35 
36 /**
37  * The #GtkAlignment widget controls the alignment and size of its child widget.
38  * It has four settings: xscale, yscale, xalign, and yalign.
39  * 
40  * The scale settings are used to specify how much the child widget should
41  * expand to fill the space allocated to the #GtkAlignment.
42  * The values can range from 0 (meaning the child doesn’t expand at all) to
43  * 1 (meaning the child expands to fill all of the available space).
44  * 
45  * The align settings are used to place the child widget within the available
46  * area. The values range from 0 (top or left) to 1 (bottom or right).
47  * Of course, if the scale settings are both set to 1, the alignment settings
48  * have no effect.
49  * 
50  * GtkAlignment has been deprecated in 3.14 and should not be used in
51  * newly-written code. The desired effect can be achieved by using the
52  * #GtkWidget:halign, #GtkWidget:valign and #GtkWidget:margin properties on the
53  * child widget.
54  */
55 public class Alignment : Bin
56 {
57 	/** the main Gtk struct */
58 	protected GtkAlignment* gtkAlignment;
59 
60 	/** Get the main Gtk struct */
61 	public GtkAlignment* getAlignmentStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return gtkAlignment;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)gtkAlignment;
72 	}
73 
74 	protected override void setStruct(GObject* obj)
75 	{
76 		gtkAlignment = cast(GtkAlignment*)obj;
77 		super.setStruct(obj);
78 	}
79 
80 	/**
81 	 * Sets our main struct and passes it to the parent class.
82 	 */
83 	public this (GtkAlignment* gtkAlignment, bool ownedRef = false)
84 	{
85 		this.gtkAlignment = gtkAlignment;
86 		super(cast(GtkBin*)gtkAlignment, ownedRef);
87 	}
88 
89 	/** */
90 	public static Alignment center(Widget widget)
91 	{
92 		Alignment a = new Alignment(0.5, 0.5, 0, 0);
93 		a.add(widget);
94 		return a;
95 	}
96 
97 	/** */
98 	public static Alignment north(Widget widget)
99 	{
100 		Alignment a = new Alignment(0.5, 0.0, 0, 0);
101 		a.add(widget);
102 		return a;
103 	}
104 
105 	/** */
106 	public static Alignment south(Widget widget)
107 	{
108 		Alignment a = new Alignment(0.5, 1.0, 0, 0);
109 		a.add(widget);
110 		return a;
111 	}
112 
113 	/** */
114 	public static Alignment east(Widget widget)
115 	{
116 		Alignment a = new Alignment(1.0, 0.5, 0, 0);
117 		a.add(widget);
118 		return a;
119 	}
120 
121 	/** */
122 	public static Alignment west(Widget widget)
123 	{
124 		Alignment a = new Alignment(0.0, 0.5, 0, 0);
125 		a.add(widget);
126 		return a;
127 	}
128 
129 	/** */
130 	public static Alignment northWest(Widget widget)
131 	{
132 		Alignment a = new Alignment(0.0, 0.0, 0, 0);
133 		a.add(widget);
134 		return a;
135 	}
136 
137 	/** */
138 	public static Alignment southWest(Widget widget)
139 	{
140 		Alignment a = new Alignment(0.0, 0.5, 0, 0);
141 		a.add(widget);
142 		return a;
143 	}
144 
145 	/** */
146 	public static Alignment northEast(Widget widget)
147 	{
148 		Alignment a = new Alignment(1.0, 0.0, 0, 0);
149 		a.add(widget);
150 		return a;
151 	}
152 
153 	/** */
154 	public static Alignment southEast(Widget widget)
155 	{
156 		Alignment a = new Alignment(1.0, 1.0, 0, 0);
157 		a.add(widget);
158 		return a;
159 	}
160 
161 	/**
162 	 */
163 
164 	/** */
165 	public static GType getType()
166 	{
167 		return gtk_alignment_get_type();
168 	}
169 
170 	/**
171 	 * Creates a new #GtkAlignment.
172 	 *
173 	 * Deprecated: Use #GtkWidget alignment and margin properties
174 	 *
175 	 * Params:
176 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
177 	 *         (right).
178 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
179 	 *         (bottom).
180 	 *     xscale = the amount that the child widget expands horizontally to fill up
181 	 *         unused space, from 0 to 1.
182 	 *         A value of 0 indicates that the child widget should never expand.
183 	 *         A value of 1 indicates that the child widget will expand to fill all of the
184 	 *         space allocated for the #GtkAlignment.
185 	 *     yscale = the amount that the child widget expands vertically to fill up
186 	 *         unused space, from 0 to 1. The values are similar to @xscale.
187 	 *
188 	 * Returns: the new #GtkAlignment
189 	 *
190 	 * Throws: ConstructionException GTK+ fails to create the object.
191 	 */
192 	public this(float xalign, float yalign, float xscale, float yscale)
193 	{
194 		auto p = gtk_alignment_new(xalign, yalign, xscale, yscale);
195 
196 		if(p is null)
197 		{
198 			throw new ConstructionException("null returned by new");
199 		}
200 
201 		this(cast(GtkAlignment*) p);
202 	}
203 
204 	/**
205 	 * Gets the padding on the different sides of the widget.
206 	 * See gtk_alignment_set_padding ().
207 	 *
208 	 * Deprecated: Use #GtkWidget alignment and margin properties
209 	 *
210 	 * Params:
211 	 *     paddingTop = location to store the padding for
212 	 *         the top of the widget, or %NULL
213 	 *     paddingBottom = location to store the padding
214 	 *         for the bottom of the widget, or %NULL
215 	 *     paddingLeft = location to store the padding
216 	 *         for the left of the widget, or %NULL
217 	 *     paddingRight = location to store the padding
218 	 *         for the right of the widget, or %NULL
219 	 *
220 	 * Since: 2.4
221 	 */
222 	public void getPadding(out uint paddingTop, out uint paddingBottom, out uint paddingLeft, out uint paddingRight)
223 	{
224 		gtk_alignment_get_padding(gtkAlignment, &paddingTop, &paddingBottom, &paddingLeft, &paddingRight);
225 	}
226 
227 	/**
228 	 * Sets the #GtkAlignment values.
229 	 *
230 	 * Deprecated: Use #GtkWidget alignment and margin properties
231 	 *
232 	 * Params:
233 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
234 	 *         (right).
235 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
236 	 *         (bottom).
237 	 *     xscale = the amount that the child widget expands horizontally to fill up
238 	 *         unused space, from 0 to 1.
239 	 *         A value of 0 indicates that the child widget should never expand.
240 	 *         A value of 1 indicates that the child widget will expand to fill all of the
241 	 *         space allocated for the #GtkAlignment.
242 	 *     yscale = the amount that the child widget expands vertically to fill up
243 	 *         unused space, from 0 to 1. The values are similar to @xscale.
244 	 */
245 	public void set(float xalign, float yalign, float xscale, float yscale)
246 	{
247 		gtk_alignment_set(gtkAlignment, xalign, yalign, xscale, yscale);
248 	}
249 
250 	/**
251 	 * Sets the padding on the different sides of the widget.
252 	 * The padding adds blank space to the sides of the widget. For instance,
253 	 * this can be used to indent the child widget towards the right by adding
254 	 * padding on the left.
255 	 *
256 	 * Deprecated: Use #GtkWidget alignment and margin properties
257 	 *
258 	 * Params:
259 	 *     paddingTop = the padding at the top of the widget
260 	 *     paddingBottom = the padding at the bottom of the widget
261 	 *     paddingLeft = the padding at the left of the widget
262 	 *     paddingRight = the padding at the right of the widget.
263 	 *
264 	 * Since: 2.4
265 	 */
266 	public void setPadding(uint paddingTop, uint paddingBottom, uint paddingLeft, uint paddingRight)
267 	{
268 		gtk_alignment_set_padding(gtkAlignment, paddingTop, paddingBottom, paddingLeft, paddingRight);
269 	}
270 }