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