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