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