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