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 = GtkButtonBox.html 27 * outPack = gtk 28 * outFile = ButtonBox 29 * strct = GtkButtonBox 30 * realStrct= 31 * ctorStrct= 32 * clss = ButtonBox 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_button_box_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gtk.Button 47 * - gtk.HButtonBox 48 * - gtk.VButtonBox 49 * - gtk.Widget 50 * structWrap: 51 * - GtkWidget* -> Widget 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.ButtonBox; 58 59 public import gtkc.gtktypes; 60 61 private import gtkc.gtk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import gtk.Button; 66 private import gtk.HButtonBox; 67 private import gtk.VButtonBox; 68 private import gtk.Widget; 69 70 71 private import gtk.Box; 72 73 /** 74 * A button box should be used to provide a consistent layout of buttons 75 * throughout your application. The layout/spacing can be altered by the 76 * programmer, or if desired, by the user to alter the 'feel' of a 77 * program to a small degree. 78 * 79 * gtk_button_box_get_layout() and gtk_button_box_set_layout() retrieve and 80 * alter the method used to spread the buttons in a button box across the 81 * container, respectively. 82 * 83 * The main purpose of GtkButtonBox is to make sure the children have all the 84 * same size. GtkButtonBox gives all children the same size, but it does allow 85 * 'outliers' to keep their own larger size. To force all children to be 86 * strictly the same size without exceptions, you can set the 87 * "homogeneous" property to TRUE. 88 * 89 * To excempt individual children from homogeneous sizing regardless of their 90 * 'outlier' status, you can set the "non-homogeneous" child 91 * property. 92 */ 93 public class ButtonBox : Box 94 { 95 96 /** the main Gtk struct */ 97 protected GtkButtonBox* gtkButtonBox; 98 99 100 /** Get the main Gtk struct */ 101 public GtkButtonBox* getButtonBoxStruct() 102 { 103 return gtkButtonBox; 104 } 105 106 107 /** the main Gtk struct as a void* */ 108 protected override void* getStruct() 109 { 110 return cast(void*)gtkButtonBox; 111 } 112 113 /** 114 * Sets our main struct and passes it to the parent class 115 */ 116 public this (GtkButtonBox* gtkButtonBox) 117 { 118 super(cast(GtkBox*)gtkButtonBox); 119 this.gtkButtonBox = gtkButtonBox; 120 } 121 122 protected override void setStruct(GObject* obj) 123 { 124 super.setStruct(obj); 125 gtkButtonBox = cast(GtkButtonBox*)obj; 126 } 127 128 /** */ 129 static ButtonBox createActionBox( 130 void delegate(Button) onClicked, 131 StockID[] stocks, 132 string[] actions, 133 bool vertical=false 134 ) 135 { 136 ButtonBox bBox; 137 if ( vertical ) 138 { 139 bBox = VButtonBox.createActionBox(); 140 } 141 else 142 { 143 bBox = HButtonBox.createActionBox(); 144 } 145 146 Button button; 147 for( int i=0 ; i<stocks.length && i<actions.length ; i++) 148 { 149 button = new Button(stocks[i]); 150 bBox.packEnd(button, false, false, 7); 151 button.setActionName(actions[i]); 152 button.addOnClicked(onClicked); 153 } 154 return bBox; 155 } 156 157 /** */ 158 static ButtonBox createOkBox(void delegate(Button) onClicked) 159 { 160 static StockID[] stocks = [StockID.OK]; 161 string[] actions; 162 actions ~= "action.ok"; 163 return createActionBox(onClicked, stocks, actions); 164 } 165 166 /** */ 167 static ButtonBox createOkCancelBox(void delegate(Button) onClicked) 168 { 169 static StockID[] stocks = [StockID.OK, StockID.CANCEL]; 170 string[] actions; 171 actions ~= "action.ok"; 172 actions ~= "action.cancel"; 173 return createActionBox(onClicked, stocks, actions); 174 } 175 176 /** 177 */ 178 179 /** 180 * Creates a new GtkButtonBox. 181 * Params: 182 * orientation = the box' orientation. 183 * Throws: ConstructionException GTK+ fails to create the object. 184 */ 185 public this (GtkOrientation orientation) 186 { 187 // GtkWidget * gtk_button_box_new (GtkOrientation orientation); 188 auto p = gtk_button_box_new(orientation); 189 if(p is null) 190 { 191 throw new ConstructionException("null returned by gtk_button_box_new(orientation)"); 192 } 193 this(cast(GtkButtonBox*) p); 194 } 195 196 /** 197 * Retrieves the method being used to arrange the buttons in a button box. 198 * Returns: the method used to lay out buttons in widget. 199 */ 200 public GtkButtonBoxStyle getLayout() 201 { 202 // GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget); 203 return gtk_button_box_get_layout(gtkButtonBox); 204 } 205 206 /** 207 * Returns whether child should appear in a secondary group of children. 208 * Since 2.4 209 * Params: 210 * child = a child of widget 211 * Returns: whether child should appear in a secondary group of children. 212 */ 213 public int getChildSecondary(Widget child) 214 { 215 // gboolean gtk_button_box_get_child_secondary (GtkButtonBox *widget, GtkWidget *child); 216 return gtk_button_box_get_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()); 217 } 218 219 /** 220 * Returns whether the child is exempted from homogenous 221 * sizing. 222 * Params: 223 * child = a child of widget 224 * Returns: TRUE if the child is not subject to homogenous sizing Since 3.2 225 */ 226 public int getChildNonHomogeneous(Widget child) 227 { 228 // gboolean gtk_button_box_get_child_non_homogeneous (GtkButtonBox *widget, GtkWidget *child); 229 return gtk_button_box_get_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()); 230 } 231 232 /** 233 * Changes the way buttons are arranged in their container. 234 * Params: 235 * layoutStyle = the new layout style 236 */ 237 public void setLayout(GtkButtonBoxStyle layoutStyle) 238 { 239 // void gtk_button_box_set_layout (GtkButtonBox *widget, GtkButtonBoxStyle layout_style); 240 gtk_button_box_set_layout(gtkButtonBox, layoutStyle); 241 } 242 243 /** 244 * Sets whether child should appear in a secondary group of children. 245 * A typical use of a secondary child is the help button in a dialog. 246 * This group appears after the other children if the style 247 * is GTK_BUTTONBOX_START, GTK_BUTTONBOX_SPREAD or 248 * GTK_BUTTONBOX_EDGE, and before the other children if the style 249 * is GTK_BUTTONBOX_END. For horizontal button boxes, the definition 250 * of before/after depends on direction of the widget (see 251 * gtk_widget_set_direction()). If the style is GTK_BUTTONBOX_START 252 * or GTK_BUTTONBOX_END, then the secondary children are aligned at 253 * the other end of the button box from the main children. For the 254 * other styles, they appear immediately next to the main children. 255 * Params: 256 * child = a child of widget 257 * isSecondary = if TRUE, the child appears in a secondary group of the 258 * button box. 259 */ 260 public void setChildSecondary(Widget child, int isSecondary) 261 { 262 // void gtk_button_box_set_child_secondary (GtkButtonBox *widget, GtkWidget *child, gboolean is_secondary); 263 gtk_button_box_set_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), isSecondary); 264 } 265 266 /** 267 * Sets whether the child is exempted from homogeous sizing. 268 * Params: 269 * child = a child of widget 270 * nonHomogeneous = the new value 271 * Since 3.2 272 */ 273 public void setChildNonHomogeneous(Widget child, int nonHomogeneous) 274 { 275 // void gtk_button_box_set_child_non_homogeneous (GtkButtonBox *widget, GtkWidget *child, gboolean non_homogeneous); 276 gtk_button_box_set_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), nonHomogeneous); 277 } 278 }