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