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