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 = GtkMenuButton.html 27 * outPack = gtk 28 * outFile = MenuButton 29 * strct = GtkMenuButton 30 * realStrct= 31 * ctorStrct= 32 * clss = MenuButton 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_menu_button_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gio.MenuModel 47 * - gtk.Menu 48 * - gtk.Widget 49 * structWrap: 50 * - GMenuModel* -> MenuModel 51 * - GtkMenu* -> Menu 52 * - GtkWidget* -> Widget 53 * module aliases: 54 * local aliases: 55 * - getDirection -> getMenuDirection 56 * - setDirection -> setMenuDirection 57 * overrides: 58 */ 59 60 module gtk.MenuButton; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import gio.MenuModel; 69 private import gtk.Menu; 70 private import gtk.Widget; 71 72 73 private import gtk.ToggleButton; 74 75 /** 76 * The GtkMenuButton widget is used to display a menu when clicked on. 77 * This menu can be provided either as a GtkMenu, or an abstract GMenuModel. 78 * 79 * The GtkMenuButton widget can hold any valid child widget. That is, it 80 * can hold almost any other standard GtkWidget. The most commonly used 81 * child is the provided GtkArrow. 82 * 83 * The positioning of the menu is determined by the "direction" 84 * property of the menu button and the "halign" or "valign" 85 * properties of the menu. For example, when the direction is GTK_ARROW_DOWN 86 * and the horizontal alignment is GTK_ALIGN_START, the menu will be 87 * positioned below the button, with the starting edge (depending on the 88 * text direction) of the menu aligned with the starting edge of the button. 89 * If there is not enough space below the button, the menu is popped up above 90 * the button instead. If the alignment would move part of the menu offscreen, 91 * it is 'pushed in'. 92 * 93 * halign = start 94 * halign = center 95 * halign = end 96 * 97 * direction = down 98 * 99 * direction = up 100 * 101 * direction = left 102 * direction = right 103 * 104 * valign = start 105 * 106 * valign = center 107 * 108 * valign = end 109 */ 110 public class MenuButton : ToggleButton 111 { 112 113 /** the main Gtk struct */ 114 protected GtkMenuButton* gtkMenuButton; 115 116 117 /** Get the main Gtk struct */ 118 public GtkMenuButton* getMenuButtonStruct() 119 { 120 return gtkMenuButton; 121 } 122 123 124 /** the main Gtk struct as a void* */ 125 protected override void* getStruct() 126 { 127 return cast(void*)gtkMenuButton; 128 } 129 130 /** 131 * Sets our main struct and passes it to the parent class 132 */ 133 public this (GtkMenuButton* gtkMenuButton) 134 { 135 super(cast(GtkToggleButton*)gtkMenuButton); 136 this.gtkMenuButton = gtkMenuButton; 137 } 138 139 protected override void setStruct(GObject* obj) 140 { 141 super.setStruct(obj); 142 gtkMenuButton = cast(GtkMenuButton*)obj; 143 } 144 145 /** 146 */ 147 148 /** 149 * Creates a new GtkMenuButton widget with downwards-pointing 150 * arrow as the only child. You can replace the child widget 151 * with another GtkWidget should you wish to. 152 * Throws: ConstructionException GTK+ fails to create the object. 153 */ 154 public this () 155 { 156 // GtkWidget * gtk_menu_button_new (void); 157 auto p = gtk_menu_button_new(); 158 if(p is null) 159 { 160 throw new ConstructionException("null returned by gtk_menu_button_new()"); 161 } 162 this(cast(GtkMenuButton*) p); 163 } 164 165 /** 166 * Sets the GtkMenu that will be popped up when the button is clicked, 167 * or NULL to disable the button. If "menu-model" is set, 168 * it will be set to NULL. 169 * Params: 170 * popup = a GtkMenu. [allow-none] 171 * Since 3.6 172 */ 173 public void setPopup(Widget popup) 174 { 175 // void gtk_menu_button_set_popup (GtkMenuButton *menu_button, GtkWidget *popup); 176 gtk_menu_button_set_popup(gtkMenuButton, (popup is null) ? null : popup.getWidgetStruct()); 177 } 178 179 /** 180 * Returns the GtkMenu that pops out of the button. 181 * Returns: a GtkMenu or NULL. [transfer none] Since 3.6 182 */ 183 public Menu getPopup() 184 { 185 // GtkMenu * gtk_menu_button_get_popup (GtkMenuButton *menu_button); 186 auto p = gtk_menu_button_get_popup(gtkMenuButton); 187 188 if(p is null) 189 { 190 return null; 191 } 192 193 return ObjectG.getDObject!(Menu)(cast(GtkMenu*) p); 194 } 195 196 /** 197 * Sets the GMenuModel from which the "popup" property will be 198 * filled in, or NULL to disable the button. 199 * The GtkMenu will be created with gtk_menu_new_from_model(), so actions 200 * will be connected as documented there. 201 * If "popup" is already set, then its content will be lost 202 * and replaced by our newly created GtkMenu. 203 * Params: 204 * menuModel = a GMenuModel. [allow-none] 205 * Since 3.6 206 */ 207 public void setMenuModel(MenuModel menuModel) 208 { 209 // void gtk_menu_button_set_menu_model (GtkMenuButton *menu_button, GMenuModel *menu_model); 210 gtk_menu_button_set_menu_model(gtkMenuButton, (menuModel is null) ? null : menuModel.getMenuModelStruct()); 211 } 212 213 /** 214 * Returns the GMenuModel used to generate the menu. 215 * Returns: a GMenuModel or NULL. [transfer none] Since 3.6 216 */ 217 public MenuModel getMenuModel() 218 { 219 // GMenuModel * gtk_menu_button_get_menu_model (GtkMenuButton *menu_button); 220 auto p = gtk_menu_button_get_menu_model(gtkMenuButton); 221 222 if(p is null) 223 { 224 return null; 225 } 226 227 return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) p); 228 } 229 230 /** 231 * Sets the direction in which the menu will be popped up, as 232 * well as changing the arrow's direction. The child will not 233 * be changed to an arrow if it was customized. 234 * If the menu when popped out would have collided with screen edges, 235 * we will do our best to keep it inside the screen and fully visible. 236 * If you pass GTK_ARROW_NONE for a direction, the menu will behave 237 * as if you passed GTK_ARROW_DOWN (although you won't see any arrows). 238 * Params: 239 * direction = a GtkArrowType 240 * Since 3.6 241 */ 242 public void setMenuDirection(GtkArrowType direction) 243 { 244 // void gtk_menu_button_set_direction (GtkMenuButton *menu_button, GtkArrowType direction); 245 gtk_menu_button_set_direction(gtkMenuButton, direction); 246 } 247 248 /** 249 * Returns the direction the menu will be pointing at when popped up. 250 * Returns: a GtkArrowType value. Since 3.6 251 */ 252 public GtkArrowType getMenuDirection() 253 { 254 // GtkArrowType gtk_menu_button_get_direction (GtkMenuButton *menu_button); 255 return gtk_menu_button_get_direction(gtkMenuButton); 256 } 257 258 /** 259 * Sets the GtkWidget to use to line the menu with when popped up. Note that 260 * the align_widget must contain the GtkMenuButton itself. 261 * Setting it to NULL means that the popup menu will be aligned with the 262 * button itself. 263 * Params: 264 * alignWidget = a GtkWidget. [allow-none] 265 * Since 3.6 266 */ 267 public void setAlignWidget(Widget alignWidget) 268 { 269 // void gtk_menu_button_set_align_widget (GtkMenuButton *menu_button, GtkWidget *align_widget); 270 gtk_menu_button_set_align_widget(gtkMenuButton, (alignWidget is null) ? null : alignWidget.getWidgetStruct()); 271 } 272 273 /** 274 * Returns the parent GtkWidget to use to line up with menu. 275 * Returns: a GtkWidget value or NULL. [transfer none] Since 3.6 276 */ 277 public Widget getAlignWidget() 278 { 279 // GtkWidget * gtk_menu_button_get_align_widget (GtkMenuButton *menu_button); 280 auto p = gtk_menu_button_get_align_widget(gtkMenuButton); 281 282 if(p is null) 283 { 284 return null; 285 } 286 287 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 288 } 289 }