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 	public static GType getType()
162 	{
163 		return gtk_alignment_get_type();
164 	}
165 
166 	/**
167 	 * Creates a new #GtkAlignment.
168 	 *
169 	 * Deprecated: Use #GtkWidget alignment and margin properties
170 	 *
171 	 * Params:
172 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
173 	 *         (right).
174 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
175 	 *         (bottom).
176 	 *     xscale = the amount that the child widget expands horizontally to fill up
177 	 *         unused space, from 0 to 1.
178 	 *         A value of 0 indicates that the child widget should never expand.
179 	 *         A value of 1 indicates that the child widget will expand to fill all of the
180 	 *         space allocated for the #GtkAlignment.
181 	 *     yscale = the amount that the child widget expands vertically to fill up
182 	 *         unused space, from 0 to 1. The values are similar to @xscale.
183 	 *
184 	 * Return: the new #GtkAlignment
185 	 *
186 	 * Throws: ConstructionException GTK+ fails to create the object.
187 	 */
188 	public this(float xalign, float yalign, float xscale, float yscale)
189 	{
190 		auto p = gtk_alignment_new(xalign, yalign, xscale, yscale);
191 		
192 		if(p is null)
193 		{
194 			throw new ConstructionException("null returned by new");
195 		}
196 		
197 		this(cast(GtkAlignment*) p);
198 	}
199 
200 	/**
201 	 * Gets the padding on the different sides of the widget.
202 	 * See gtk_alignment_set_padding ().
203 	 *
204 	 * Deprecated: Use #GtkWidget alignment and margin properties
205 	 *
206 	 * Params:
207 	 *     paddingTop = location to store the padding for
208 	 *         the top of the widget, or %NULL
209 	 *     paddingBottom = location to store the padding
210 	 *         for the bottom of the widget, or %NULL
211 	 *     paddingLeft = location to store the padding
212 	 *         for the left of the widget, or %NULL
213 	 *     paddingRight = location to store the padding
214 	 *         for the right of the widget, or %NULL
215 	 *
216 	 * Since: 2.4
217 	 */
218 	public void getPadding(out uint paddingTop, out uint paddingBottom, out uint paddingLeft, out uint paddingRight)
219 	{
220 		gtk_alignment_get_padding(gtkAlignment, &paddingTop, &paddingBottom, &paddingLeft, &paddingRight);
221 	}
222 
223 	/**
224 	 * Sets the #GtkAlignment values.
225 	 *
226 	 * Deprecated: Use #GtkWidget alignment and margin properties
227 	 *
228 	 * Params:
229 	 *     xalign = the horizontal alignment of the child widget, from 0 (left) to 1
230 	 *         (right).
231 	 *     yalign = the vertical alignment of the child widget, from 0 (top) to 1
232 	 *         (bottom).
233 	 *     xscale = the amount that the child widget expands horizontally to fill up
234 	 *         unused space, from 0 to 1.
235 	 *         A value of 0 indicates that the child widget should never expand.
236 	 *         A value of 1 indicates that the child widget will expand to fill all of the
237 	 *         space allocated for the #GtkAlignment.
238 	 *     yscale = the amount that the child widget expands vertically to fill up
239 	 *         unused space, from 0 to 1. The values are similar to @xscale.
240 	 */
241 	public void set(float xalign, float yalign, float xscale, float yscale)
242 	{
243 		gtk_alignment_set(gtkAlignment, xalign, yalign, xscale, yscale);
244 	}
245 
246 	/**
247 	 * Sets the padding on the different sides of the widget.
248 	 * The padding adds blank space to the sides of the widget. For instance,
249 	 * this can be used to indent the child widget towards the right by adding
250 	 * padding on the left.
251 	 *
252 	 * Deprecated: Use #GtkWidget alignment and margin properties
253 	 *
254 	 * Params:
255 	 *     paddingTop = the padding at the top of the widget
256 	 *     paddingBottom = the padding at the bottom of the widget
257 	 *     paddingLeft = the padding at the left of the widget
258 	 *     paddingRight = the padding at the right of the widget.
259 	 *
260 	 * Since: 2.4
261 	 */
262 	public void setPadding(uint paddingTop, uint paddingBottom, uint paddingLeft, uint paddingRight)
263 	{
264 		gtk_alignment_set_padding(gtkAlignment, paddingTop, paddingBottom, paddingLeft, paddingRight);
265 	}
266 }