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.SizeGroup; 26 27 private import glib.ConstructionException; 28 private import glib.ListSG; 29 private import gobject.ObjectG; 30 private import gtk.BuildableIF; 31 private import gtk.BuildableT; 32 private import gtk.Widget; 33 private import gtkc.gtk; 34 public import gtkc.gtktypes; 35 36 37 /** 38 * #GtkSizeGroup provides a mechanism for grouping a number of widgets 39 * together so they all request the same amount of space. This is 40 * typically useful when you want a column of widgets to have the same 41 * size, but you can’t use a #GtkGrid widget. 42 * 43 * In detail, the size requested for each widget in a #GtkSizeGroup is 44 * the maximum of the sizes that would have been requested for each 45 * widget in the size group if they were not in the size group. The mode 46 * of the size group (see gtk_size_group_set_mode()) determines whether 47 * this applies to the horizontal size, the vertical size, or both sizes. 48 * 49 * Note that size groups only affect the amount of space requested, not 50 * the size that the widgets finally receive. If you want the widgets in 51 * a #GtkSizeGroup to actually be the same size, you need to pack them in 52 * such a way that they get the size they request and not more. For 53 * example, if you are packing your widgets into a table, you would not 54 * include the %GTK_FILL flag. 55 * 56 * #GtkSizeGroup objects are referenced by each widget in the size group, 57 * so once you have added all widgets to a #GtkSizeGroup, you can drop 58 * the initial reference to the size group with g_object_unref(). If the 59 * widgets in the size group are subsequently destroyed, then they will 60 * be removed from the size group and drop their references on the size 61 * group; when all widgets have been removed, the size group will be 62 * freed. 63 * 64 * Widgets can be part of multiple size groups; GTK+ will compute the 65 * horizontal size of a widget from the horizontal requisition of all 66 * widgets that can be reached from the widget by a chain of size groups 67 * of type %GTK_SIZE_GROUP_HORIZONTAL or %GTK_SIZE_GROUP_BOTH, and the 68 * vertical size from the vertical requisition of all widgets that can be 69 * reached from the widget by a chain of size groups of type 70 * %GTK_SIZE_GROUP_VERTICAL or %GTK_SIZE_GROUP_BOTH. 71 * 72 * Note that only non-contextual sizes of every widget are ever consulted 73 * by size groups (since size groups have no knowledge of what size a widget 74 * will be allocated in one dimension, it cannot derive how much height 75 * a widget will receive for a given width). When grouping widgets that 76 * trade height for width in mode %GTK_SIZE_GROUP_VERTICAL or %GTK_SIZE_GROUP_BOTH: 77 * the height for the minimum width will be the requested height for all 78 * widgets in the group. The same is of course true when horizontally grouping 79 * width for height widgets. 80 * 81 * Widgets that trade height-for-width should set a reasonably large minimum width 82 * by way of #GtkLabel:width-chars for instance. Widgets with static sizes as well 83 * as widgets that grow (such as ellipsizing text) need no such considerations. 84 * 85 * # GtkSizeGroup as GtkBuildable 86 * 87 * Size groups can be specified in a UI definition by placing an <object> 88 * element with `class="GtkSizeGroup"` somewhere in the UI definition. The 89 * widgets that belong to the size group are specified by a <widgets> element 90 * that may contain multiple <widget> elements, one for each member of the 91 * size group. The ”name” attribute gives the id of the widget. 92 * 93 * An example of a UI definition fragment with GtkSizeGroup: 94 * |[ 95 * <object class="GtkSizeGroup"> 96 * <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property> 97 * <widgets> 98 * <widget name="radio1"/> 99 * <widget name="radio2"/> 100 * </widgets> 101 * </object> 102 * ]| 103 */ 104 public class SizeGroup : ObjectG, BuildableIF 105 { 106 /** the main Gtk struct */ 107 protected GtkSizeGroup* gtkSizeGroup; 108 109 /** Get the main Gtk struct */ 110 public GtkSizeGroup* getSizeGroupStruct(bool transferOwnership = false) 111 { 112 if (transferOwnership) 113 ownedRef = false; 114 return gtkSizeGroup; 115 } 116 117 /** the main Gtk struct as a void* */ 118 protected override void* getStruct() 119 { 120 return cast(void*)gtkSizeGroup; 121 } 122 123 protected override void setStruct(GObject* obj) 124 { 125 gtkSizeGroup = cast(GtkSizeGroup*)obj; 126 super.setStruct(obj); 127 } 128 129 /** 130 * Sets our main struct and passes it to the parent class. 131 */ 132 public this (GtkSizeGroup* gtkSizeGroup, bool ownedRef = false) 133 { 134 this.gtkSizeGroup = gtkSizeGroup; 135 super(cast(GObject*)gtkSizeGroup, ownedRef); 136 } 137 138 // add the Buildable capabilities 139 mixin BuildableT!(GtkSizeGroup); 140 141 142 /** */ 143 public static GType getType() 144 { 145 return gtk_size_group_get_type(); 146 } 147 148 /** 149 * Create a new #GtkSizeGroup. 150 * 151 * Params: 152 * mode = the mode for the new size group. 153 * 154 * Returns: a newly created #GtkSizeGroup 155 * 156 * Throws: ConstructionException GTK+ fails to create the object. 157 */ 158 public this(GtkSizeGroupMode mode) 159 { 160 auto p = gtk_size_group_new(mode); 161 162 if(p is null) 163 { 164 throw new ConstructionException("null returned by new"); 165 } 166 167 this(cast(GtkSizeGroup*) p, true); 168 } 169 170 /** 171 * Adds a widget to a #GtkSizeGroup. In the future, the requisition 172 * of the widget will be determined as the maximum of its requisition 173 * and the requisition of the other widgets in the size group. 174 * Whether this applies horizontally, vertically, or in both directions 175 * depends on the mode of the size group. See gtk_size_group_set_mode(). 176 * 177 * When the widget is destroyed or no longer referenced elsewhere, it will 178 * be removed from the size group. 179 * 180 * Params: 181 * widget = the #GtkWidget to add 182 */ 183 public void addWidget(Widget widget) 184 { 185 gtk_size_group_add_widget(gtkSizeGroup, (widget is null) ? null : widget.getWidgetStruct()); 186 } 187 188 /** 189 * Returns if invisible widgets are ignored when calculating the size. 190 * 191 * Deprecated: Measuring the size of hidden widgets has not worked 192 * reliably for a long time. In most cases, they will report a size 193 * of 0 nowadays, and thus, their size will not affect the other 194 * size group members. In effect, size groups will always operate 195 * as if this property was %TRUE. Use a #GtkStack instead to hide 196 * widgets while still having their size taken into account. 197 * 198 * Returns: %TRUE if invisible widgets are ignored. 199 * 200 * Since: 2.8 201 */ 202 public bool getIgnoreHidden() 203 { 204 return gtk_size_group_get_ignore_hidden(gtkSizeGroup) != 0; 205 } 206 207 /** 208 * Gets the current mode of the size group. See gtk_size_group_set_mode(). 209 * 210 * Returns: the current mode of the size group. 211 */ 212 public GtkSizeGroupMode getMode() 213 { 214 return gtk_size_group_get_mode(gtkSizeGroup); 215 } 216 217 /** 218 * Returns the list of widgets associated with @size_group. 219 * 220 * Returns: a #GSList of 221 * widgets. The list is owned by GTK+ and should not be modified. 222 * 223 * Since: 2.10 224 */ 225 public ListSG getWidgets() 226 { 227 auto p = gtk_size_group_get_widgets(gtkSizeGroup); 228 229 if(p is null) 230 { 231 return null; 232 } 233 234 return new ListSG(cast(GSList*) p); 235 } 236 237 /** 238 * Removes a widget from a #GtkSizeGroup. 239 * 240 * Params: 241 * widget = the #GtkWidget to remove 242 */ 243 public void removeWidget(Widget widget) 244 { 245 gtk_size_group_remove_widget(gtkSizeGroup, (widget is null) ? null : widget.getWidgetStruct()); 246 } 247 248 /** 249 * Sets whether unmapped widgets should be ignored when 250 * calculating the size. 251 * 252 * Deprecated: Measuring the size of hidden widgets has not worked 253 * reliably for a long time. In most cases, they will report a size 254 * of 0 nowadays, and thus, their size will not affect the other 255 * size group members. In effect, size groups will always operate 256 * as if this property was %TRUE. Use a #GtkStack instead to hide 257 * widgets while still having their size taken into account. 258 * 259 * Params: 260 * ignoreHidden = whether unmapped widgets should be ignored 261 * when calculating the size 262 * 263 * Since: 2.8 264 */ 265 public void setIgnoreHidden(bool ignoreHidden) 266 { 267 gtk_size_group_set_ignore_hidden(gtkSizeGroup, ignoreHidden); 268 } 269 270 /** 271 * Sets the #GtkSizeGroupMode of the size group. The mode of the size 272 * group determines whether the widgets in the size group should 273 * all have the same horizontal requisition (%GTK_SIZE_GROUP_HORIZONTAL) 274 * all have the same vertical requisition (%GTK_SIZE_GROUP_VERTICAL), 275 * or should all have the same requisition in both directions 276 * (%GTK_SIZE_GROUP_BOTH). 277 * 278 * Params: 279 * mode = the mode to set for the size group. 280 */ 281 public void setMode(GtkSizeGroupMode mode) 282 { 283 gtk_size_group_set_mode(gtkSizeGroup, mode); 284 } 285 }