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