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.ButtonBox; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gtk.Box; 30 private import gtk.Button; 31 private import gtk.HButtonBox; 32 private import gtk.VButtonBox; 33 private import gtk.Widget; 34 private import gtkc.gtk; 35 public import gtkc.gtktypes; 36 37 38 public class ButtonBox : Box 39 { 40 /** the main Gtk struct */ 41 protected GtkButtonBox* gtkButtonBox; 42 43 /** Get the main Gtk struct */ 44 public GtkButtonBox* getButtonBoxStruct() 45 { 46 return gtkButtonBox; 47 } 48 49 /** the main Gtk struct as a void* */ 50 protected override void* getStruct() 51 { 52 return cast(void*)gtkButtonBox; 53 } 54 55 protected override void setStruct(GObject* obj) 56 { 57 gtkButtonBox = cast(GtkButtonBox*)obj; 58 super.setStruct(obj); 59 } 60 61 /** 62 * Sets our main struct and passes it to the parent class. 63 */ 64 public this (GtkButtonBox* gtkButtonBox, bool ownedRef = false) 65 { 66 this.gtkButtonBox = gtkButtonBox; 67 super(cast(GtkBox*)gtkButtonBox, ownedRef); 68 } 69 70 /** */ 71 static ButtonBox createActionBox( 72 void delegate(Button) onClicked, 73 StockID[] stocks, 74 string[] actions, 75 bool vertical=false 76 ) 77 { 78 ButtonBox bBox; 79 if ( vertical ) 80 { 81 bBox = VButtonBox.createActionBox(); 82 } 83 else 84 { 85 bBox = HButtonBox.createActionBox(); 86 } 87 88 Button button; 89 for( int i=0 ; i<stocks.length && i<actions.length ; i++) 90 { 91 button = new Button(stocks[i]); 92 bBox.packEnd(button, false, false, 7); 93 button.setActionName(actions[i]); 94 button.addOnClicked(onClicked); 95 } 96 return bBox; 97 } 98 99 /** */ 100 static ButtonBox createOkBox(void delegate(Button) onClicked) 101 { 102 static StockID[] stocks = [StockID.OK]; 103 string[] actions; 104 actions ~= "action.ok"; 105 return createActionBox(onClicked, stocks, actions); 106 } 107 108 /** */ 109 static ButtonBox createOkCancelBox(void delegate(Button) onClicked) 110 { 111 static StockID[] stocks = [StockID.OK, StockID.CANCEL]; 112 string[] actions; 113 actions ~= "action.ok"; 114 actions ~= "action.cancel"; 115 return createActionBox(onClicked, stocks, actions); 116 } 117 118 119 /** 120 */ 121 122 public static GType getType() 123 { 124 return gtk_button_box_get_type(); 125 } 126 127 /** 128 * Creates a new #GtkButtonBox. 129 * 130 * Params: 131 * orientation = the box' orientation. 132 * 133 * Return: a new #GtkButtonBox. 134 * 135 * Since: 3.0 136 * 137 * Throws: ConstructionException GTK+ fails to create the object. 138 */ 139 public this(GtkOrientation orientation) 140 { 141 auto p = gtk_button_box_new(orientation); 142 143 if(p is null) 144 { 145 throw new ConstructionException("null returned by new"); 146 } 147 148 this(cast(GtkButtonBox*) p); 149 } 150 151 /** 152 * Returns whether the child is exempted from homogenous 153 * sizing. 154 * 155 * Params: 156 * child = a child of @widget 157 * 158 * Return: %TRUE if the child is not subject to homogenous sizing 159 * 160 * Since: 3.2 161 */ 162 public bool getChildNonHomogeneous(Widget child) 163 { 164 return gtk_button_box_get_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()) != 0; 165 } 166 167 /** 168 * Returns whether @child should appear in a secondary group of children. 169 * 170 * Params: 171 * child = a child of @widget 172 * 173 * Return: whether @child should appear in a secondary group of children. 174 * 175 * Since: 2.4 176 */ 177 public bool getChildSecondary(Widget child) 178 { 179 return gtk_button_box_get_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct()) != 0; 180 } 181 182 /** 183 * Retrieves the method being used to arrange the buttons in a button box. 184 * 185 * Return: the method used to lay out buttons in @widget. 186 */ 187 public GtkButtonBoxStyle getLayout() 188 { 189 return gtk_button_box_get_layout(gtkButtonBox); 190 } 191 192 /** 193 * Sets whether the child is exempted from homogeous sizing. 194 * 195 * Params: 196 * child = a child of @widget 197 * nonHomogeneous = the new value 198 * 199 * Since: 3.2 200 */ 201 public void setChildNonHomogeneous(Widget child, bool nonHomogeneous) 202 { 203 gtk_button_box_set_child_non_homogeneous(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), nonHomogeneous); 204 } 205 206 /** 207 * Sets whether @child should appear in a secondary group of children. 208 * A typical use of a secondary child is the help button in a dialog. 209 * 210 * This group appears after the other children if the style 211 * is %GTK_BUTTONBOX_START, %GTK_BUTTONBOX_SPREAD or 212 * %GTK_BUTTONBOX_EDGE, and before the other children if the style 213 * is %GTK_BUTTONBOX_END. For horizontal button boxes, the definition 214 * of before/after depends on direction of the widget (see 215 * gtk_widget_set_direction()). If the style is %GTK_BUTTONBOX_START 216 * or %GTK_BUTTONBOX_END, then the secondary children are aligned at 217 * the other end of the button box from the main children. For the 218 * other styles, they appear immediately next to the main children. 219 * 220 * Params: 221 * child = a child of @widget 222 * isSecondary = if %TRUE, the @child appears in a secondary group of the 223 * button box. 224 */ 225 public void setChildSecondary(Widget child, bool isSecondary) 226 { 227 gtk_button_box_set_child_secondary(gtkButtonBox, (child is null) ? null : child.getWidgetStruct(), isSecondary); 228 } 229 230 /** 231 * Changes the way buttons are arranged in their container. 232 * 233 * Params: 234 * layoutStyle = the new layout style 235 */ 236 public void setLayout(GtkButtonBoxStyle layoutStyle) 237 { 238 gtk_button_box_set_layout(gtkButtonBox, layoutStyle); 239 } 240 }