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 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (GtkAlignment* gtkAlignment, bool ownedRef = false)
78 	{
79 		this.gtkAlignment = gtkAlignment;
80 		super(cast(GtkBin*)gtkAlignment, ownedRef);
81 	}
82 
83 	/** */
84 	public static Alignment center(Widget widget)
85 	{
86 		Alignment a = new Alignment(0.5, 0.5, 0, 0);
87 		a.add(widget);
88 		return a;
89 	}
90 
91 	/** */
92 	public static Alignment north(Widget widget)
93 	{
94 		Alignment a = new Alignment(0.5, 0.0, 0, 0);
95 		a.add(widget);
96 		return a;
97 	}
98 
99 	/** */
100 	public static Alignment south(Widget widget)
101 	{
102 		Alignment a = new Alignment(0.5, 1.0, 0, 0);
103 		a.add(widget);
104 		return a;
105 	}
106 
107 	/** */
108 	public static Alignment east(Widget widget)
109 	{
110 		Alignment a = new Alignment(1.0, 0.5, 0, 0);
111 		a.add(widget);
112 		return a;
113 	}
114 
115 	/** */
116 	public static Alignment west(Widget widget)
117 	{
118 		Alignment a = new Alignment(0.0, 0.5, 0, 0);
119 		a.add(widget);
120 		return a;
121 	}
122 
123 	/** */
124 	public static Alignment northWest(Widget widget)
125 	{
126 		Alignment a = new Alignment(0.0, 0.0, 0, 0);
127 		a.add(widget);
128 		return a;
129 	}
130 
131 	/** */
132 	public static Alignment southWest(Widget widget)
133 	{
134 		Alignment a = new Alignment(0.0, 0.5, 0, 0);
135 		a.add(widget);
136 		return a;
137 	}
138 
139 	/** */
140 	public static Alignment northEast(Widget widget)
141 	{
142 		Alignment a = new Alignment(1.0, 0.0, 0, 0);
143 		a.add(widget);
144 		return a;
145 	}
146 
147 	/** */
148 	public static Alignment southEast(Widget widget)
149 	{
150 		Alignment a = new Alignment(1.0, 1.0, 0, 0);
151 		a.add(widget);
152 		return a;
153 	}
154 
155 	/**
156 	 */
157 
158 	/** */
159 	public static GType getType()
160 	{
161 		return gtk_alignment_get_type();
162 	}
163 
164 	/**
165 	 * Creates a new #GtkAlignment.
166 	 *
167 	 * Deprecated: Use #GtkWidget alignment and margin properties
168 	 *
169 	 * Params:
170 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
171 	 *         (right).
172 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
173 	 *         (bottom).
174 	 *     xscale = the amount that the child widget expands horizontally to fill up
175 	 *         unused space, from 0 to 1.
176 	 *         A value of 0 indicates that the child widget should never expand.
177 	 *         A value of 1 indicates that the child widget will expand to fill all of the
178 	 *         space allocated for the #GtkAlignment.
179 	 *     yscale = the amount that the child widget expands vertically to fill up
180 	 *         unused space, from 0 to 1. The values are similar to @xscale.
181 	 *
182 	 * Returns: the new #GtkAlignment
183 	 *
184 	 * Throws: ConstructionException GTK+ fails to create the object.
185 	 */
186 	public this(float xalign, float yalign, float xscale, float yscale)
187 	{
188 		auto p = gtk_alignment_new(xalign, yalign, xscale, yscale);
189 
190 		if(p is null)
191 		{
192 			throw new ConstructionException("null returned by new");
193 		}
194 
195 		this(cast(GtkAlignment*) p);
196 	}
197 
198 	/**
199 	 * Gets the padding on the different sides of the widget.
200 	 * See gtk_alignment_set_padding ().
201 	 *
202 	 * Deprecated: Use #GtkWidget alignment and margin properties
203 	 *
204 	 * Params:
205 	 *     paddingTop = location to store the padding for
206 	 *         the top of the widget, or %NULL
207 	 *     paddingBottom = location to store the padding
208 	 *         for the bottom of the widget, or %NULL
209 	 *     paddingLeft = location to store the padding
210 	 *         for the left of the widget, or %NULL
211 	 *     paddingRight = location to store the padding
212 	 *         for the right of the widget, or %NULL
213 	 *
214 	 * Since: 2.4
215 	 */
216 	public void getPadding(out uint paddingTop, out uint paddingBottom, out uint paddingLeft, out uint paddingRight)
217 	{
218 		gtk_alignment_get_padding(gtkAlignment, &paddingTop, &paddingBottom, &paddingLeft, &paddingRight);
219 	}
220 
221 	/**
222 	 * Sets the #GtkAlignment values.
223 	 *
224 	 * Deprecated: Use #GtkWidget alignment and margin properties
225 	 *
226 	 * Params:
227 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
228 	 *         (right).
229 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
230 	 *         (bottom).
231 	 *     xscale = the amount that the child widget expands horizontally to fill up
232 	 *         unused space, from 0 to 1.
233 	 *         A value of 0 indicates that the child widget should never expand.
234 	 *         A value of 1 indicates that the child widget will expand to fill all of the
235 	 *         space allocated for the #GtkAlignment.
236 	 *     yscale = the amount that the child widget expands vertically to fill up
237 	 *         unused space, from 0 to 1. The values are similar to @xscale.
238 	 */
239 	public void set(float xalign, float yalign, float xscale, float yscale)
240 	{
241 		gtk_alignment_set(gtkAlignment, xalign, yalign, xscale, yscale);
242 	}
243 
244 	/**
245 	 * Sets the padding on the different sides of the widget.
246 	 * The padding adds blank space to the sides of the widget. For instance,
247 	 * this can be used to indent the child widget towards the right by adding
248 	 * padding on the left.
249 	 *
250 	 * Deprecated: Use #GtkWidget alignment and margin properties
251 	 *
252 	 * Params:
253 	 *     paddingTop = the padding at the top of the widget
254 	 *     paddingBottom = the padding at the bottom of the widget
255 	 *     paddingLeft = the padding at the left of the widget
256 	 *     paddingRight = the padding at the right of the widget.
257 	 *
258 	 * Since: 2.4
259 	 */
260 	public void setPadding(uint paddingTop, uint paddingBottom, uint paddingLeft, uint paddingRight)
261 	{
262 		gtk_alignment_set_padding(gtkAlignment, paddingTop, paddingBottom, paddingLeft, paddingRight);
263 	}
264 }