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 = GtkMenuShell.html 27 * outPack = gtk 28 * outFile = MenuShell 29 * strct = GtkMenuShell 30 * realStrct= 31 * ctorStrct= 32 * clss = MenuShell 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_menu_shell_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - gtk.Widget 48 * structWrap: 49 * - GtkWidget* -> Widget 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gtk.MenuShell; 56 57 public import gtkc.gtktypes; 58 59 private import gtkc.gtk; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gobject.Signals; 64 public import gtkc.gdktypes; 65 66 private import gtk.Widget; 67 68 69 70 private import gtk.Container; 71 72 /** 73 * Description 74 * A GtkMenuShell is the abstract base class used to derive the 75 * GtkMenu and GtkMenuBar subclasses. 76 * A GtkMenuShell is a container of GtkMenuItem objects arranged in a 77 * list which can be navigated, selected, and activated by the user to perform 78 * application functions. A GtkMenuItem can have a submenu associated with it, 79 * allowing for nested hierarchical menus. 80 */ 81 public class MenuShell : Container 82 { 83 84 /** the main Gtk struct */ 85 protected GtkMenuShell* gtkMenuShell; 86 87 88 public GtkMenuShell* getMenuShellStruct() 89 { 90 return gtkMenuShell; 91 } 92 93 94 /** the main Gtk struct as a void* */ 95 protected override void* getStruct() 96 { 97 return cast(void*)gtkMenuShell; 98 } 99 100 /** 101 * Sets our main struct and passes it to the parent class 102 */ 103 public this (GtkMenuShell* gtkMenuShell) 104 { 105 super(cast(GtkContainer*)gtkMenuShell); 106 this.gtkMenuShell = gtkMenuShell; 107 } 108 109 protected override void setStruct(GObject* obj) 110 { 111 super.setStruct(obj); 112 gtkMenuShell = cast(GtkMenuShell*)obj; 113 } 114 115 /** 116 */ 117 int[string] connectedSignals; 118 119 void delegate(gboolean, MenuShell)[] onActivateCurrentListeners; 120 /** 121 * An action signal that activates the current menu item within the menu 122 * shell. 123 */ 124 void addOnActivateCurrent(void delegate(gboolean, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 125 { 126 if ( !("activate-current" in connectedSignals) ) 127 { 128 Signals.connectData( 129 getStruct(), 130 "activate-current", 131 cast(GCallback)&callBackActivateCurrent, 132 cast(void*)this, 133 null, 134 connectFlags); 135 connectedSignals["activate-current"] = 1; 136 } 137 onActivateCurrentListeners ~= dlg; 138 } 139 extern(C) static void callBackActivateCurrent(GtkMenuShell* menushellStruct, gboolean arg1, MenuShell _menuShell) 140 { 141 foreach ( void delegate(gboolean, MenuShell) dlg ; _menuShell.onActivateCurrentListeners ) 142 { 143 dlg(arg1, _menuShell); 144 } 145 } 146 147 void delegate(MenuShell)[] onCancelListeners; 148 /** 149 * An action signal which cancels the selection within the menu shell. 150 * Causes the GtkMenuShell::selection-done signal to be emitted. 151 */ 152 void addOnCancel(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 153 { 154 if ( !("cancel" in connectedSignals) ) 155 { 156 Signals.connectData( 157 getStruct(), 158 "cancel", 159 cast(GCallback)&callBackCancel, 160 cast(void*)this, 161 null, 162 connectFlags); 163 connectedSignals["cancel"] = 1; 164 } 165 onCancelListeners ~= dlg; 166 } 167 extern(C) static void callBackCancel(GtkMenuShell* menushellStruct, MenuShell _menuShell) 168 { 169 foreach ( void delegate(MenuShell) dlg ; _menuShell.onCancelListeners ) 170 { 171 dlg(_menuShell); 172 } 173 } 174 175 void delegate(GtkDirectionType, MenuShell)[] onCycleFocusListeners; 176 /** 177 */ 178 void addOnCycleFocus(void delegate(GtkDirectionType, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 179 { 180 if ( !("cycle-focus" in connectedSignals) ) 181 { 182 Signals.connectData( 183 getStruct(), 184 "cycle-focus", 185 cast(GCallback)&callBackCycleFocus, 186 cast(void*)this, 187 null, 188 connectFlags); 189 connectedSignals["cycle-focus"] = 1; 190 } 191 onCycleFocusListeners ~= dlg; 192 } 193 extern(C) static void callBackCycleFocus(GtkMenuShell* menushellStruct, GtkDirectionType arg1, MenuShell _menuShell) 194 { 195 foreach ( void delegate(GtkDirectionType, MenuShell) dlg ; _menuShell.onCycleFocusListeners ) 196 { 197 dlg(arg1, _menuShell); 198 } 199 } 200 201 void delegate(MenuShell)[] onDeactivateListeners; 202 /** 203 * This signal is emitted when a menu shell is deactivated. 204 */ 205 void addOnDeactivate(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 206 { 207 if ( !("deactivate" in connectedSignals) ) 208 { 209 Signals.connectData( 210 getStruct(), 211 "deactivate", 212 cast(GCallback)&callBackDeactivate, 213 cast(void*)this, 214 null, 215 connectFlags); 216 connectedSignals["deactivate"] = 1; 217 } 218 onDeactivateListeners ~= dlg; 219 } 220 extern(C) static void callBackDeactivate(GtkMenuShell* menushellStruct, MenuShell _menuShell) 221 { 222 foreach ( void delegate(MenuShell) dlg ; _menuShell.onDeactivateListeners ) 223 { 224 dlg(_menuShell); 225 } 226 } 227 228 void delegate(GtkMenuDirectionType, MenuShell)[] onMoveCurrentListeners; 229 /** 230 * An action signal which moves the current menu item in the direction 231 * specified by direction. 232 */ 233 void addOnMoveCurrent(void delegate(GtkMenuDirectionType, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 234 { 235 if ( !("move-current" in connectedSignals) ) 236 { 237 Signals.connectData( 238 getStruct(), 239 "move-current", 240 cast(GCallback)&callBackMoveCurrent, 241 cast(void*)this, 242 null, 243 connectFlags); 244 connectedSignals["move-current"] = 1; 245 } 246 onMoveCurrentListeners ~= dlg; 247 } 248 extern(C) static void callBackMoveCurrent(GtkMenuShell* menushellStruct, GtkMenuDirectionType arg1, MenuShell _menuShell) 249 { 250 foreach ( void delegate(GtkMenuDirectionType, MenuShell) dlg ; _menuShell.onMoveCurrentListeners ) 251 { 252 dlg(arg1, _menuShell); 253 } 254 } 255 256 bool delegate(gint, MenuShell)[] onMoveSelectedListeners; 257 /** 258 * The ::move-selected signal is emitted to move the selection to 259 * another item. 260 * TRUE to stop the signal emission, FALSE to continue 261 * Since 2.12 262 */ 263 void addOnMoveSelected(bool delegate(gint, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 264 { 265 if ( !("move-selected" in connectedSignals) ) 266 { 267 Signals.connectData( 268 getStruct(), 269 "move-selected", 270 cast(GCallback)&callBackMoveSelected, 271 cast(void*)this, 272 null, 273 connectFlags); 274 connectedSignals["move-selected"] = 1; 275 } 276 onMoveSelectedListeners ~= dlg; 277 } 278 extern(C) static gboolean callBackMoveSelected(GtkMenuShell* menuShellStruct, gint distance, MenuShell _menuShell) 279 { 280 foreach ( bool delegate(gint, MenuShell) dlg ; _menuShell.onMoveSelectedListeners ) 281 { 282 if ( dlg(distance, _menuShell) ) 283 { 284 return 1; 285 } 286 } 287 288 return 0; 289 } 290 291 void delegate(MenuShell)[] onSelectionDoneListeners; 292 /** 293 * This signal is emitted when a selection has been completed within a menu 294 * shell. 295 */ 296 void addOnSelectionDone(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 297 { 298 if ( !("selection-done" in connectedSignals) ) 299 { 300 Signals.connectData( 301 getStruct(), 302 "selection-done", 303 cast(GCallback)&callBackSelectionDone, 304 cast(void*)this, 305 null, 306 connectFlags); 307 connectedSignals["selection-done"] = 1; 308 } 309 onSelectionDoneListeners ~= dlg; 310 } 311 extern(C) static void callBackSelectionDone(GtkMenuShell* menushellStruct, MenuShell _menuShell) 312 { 313 foreach ( void delegate(MenuShell) dlg ; _menuShell.onSelectionDoneListeners ) 314 { 315 dlg(_menuShell); 316 } 317 } 318 319 320 /** 321 * Adds a new GtkMenuItem to the end of the menu shell's item list. 322 * Params: 323 * child = The GtkMenuItem to add. 324 */ 325 public void append(Widget child) 326 { 327 // void gtk_menu_shell_append (GtkMenuShell *menu_shell, GtkWidget *child); 328 gtk_menu_shell_append(gtkMenuShell, (child is null) ? null : child.getWidgetStruct()); 329 } 330 331 /** 332 * Adds a new GtkMenuItem to the beginning of the menu shell's item list. 333 * Params: 334 * child = The GtkMenuItem to add. 335 */ 336 public void prepend(Widget child) 337 { 338 // void gtk_menu_shell_prepend (GtkMenuShell *menu_shell, GtkWidget *child); 339 gtk_menu_shell_prepend(gtkMenuShell, (child is null) ? null : child.getWidgetStruct()); 340 } 341 342 /** 343 * Adds a new GtkMenuItem to the menu shell's item list at the position 344 * indicated by position. 345 * Params: 346 * child = The GtkMenuItem to add. 347 * position = The position in the item list where child is added. 348 * Positions are numbered from 0 to n-1. 349 */ 350 public void insert(Widget child, int position) 351 { 352 // void gtk_menu_shell_insert (GtkMenuShell *menu_shell, GtkWidget *child, gint position); 353 gtk_menu_shell_insert(gtkMenuShell, (child is null) ? null : child.getWidgetStruct(), position); 354 } 355 356 /** 357 * Deactivates the menu shell. Typically this results in the menu shell 358 * being erased from the screen. 359 */ 360 public void deactivate() 361 { 362 // void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell); 363 gtk_menu_shell_deactivate(gtkMenuShell); 364 } 365 366 /** 367 * Selects the menu item from the menu shell. 368 * Params: 369 * menuItem = The GtkMenuItem to select. 370 */ 371 public void selectItem(Widget menuItem) 372 { 373 // void gtk_menu_shell_select_item (GtkMenuShell *menu_shell, GtkWidget *menu_item); 374 gtk_menu_shell_select_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct()); 375 } 376 377 /** 378 * Select the first visible or selectable child of the menu shell; 379 * don't select tearoff items unless the only item is a tearoff 380 * item. 381 * Since 2.2 382 * Params: 383 * searchSensitive = if TRUE, search for the first selectable 384 * menu item, otherwise select nothing if 385 * the first item isn't sensitive. This 386 * should be FALSE if the menu is being 387 * popped up initially. 388 */ 389 public void selectFirst(int searchSensitive) 390 { 391 // void gtk_menu_shell_select_first (GtkMenuShell *menu_shell, gboolean search_sensitive); 392 gtk_menu_shell_select_first(gtkMenuShell, searchSensitive); 393 } 394 395 /** 396 * Deselects the currently selected item from the menu shell, if any. 397 */ 398 public void deselect() 399 { 400 // void gtk_menu_shell_deselect (GtkMenuShell *menu_shell); 401 gtk_menu_shell_deselect(gtkMenuShell); 402 } 403 404 /** 405 * Activates the menu item within the menu shell. 406 * Params: 407 * menuItem = The GtkMenuItem to activate. 408 * forceDeactivate = If TRUE, force the deactivation of the menu shell 409 * after the menu item is activated. 410 */ 411 public void activateItem(Widget menuItem, int forceDeactivate) 412 { 413 // void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, GtkWidget *menu_item, gboolean force_deactivate); 414 gtk_menu_shell_activate_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct(), forceDeactivate); 415 } 416 417 /** 418 * Cancels the selection within the menu shell. 419 * Since 2.4 420 */ 421 public void cancel() 422 { 423 // void gtk_menu_shell_cancel (GtkMenuShell *menu_shell); 424 gtk_menu_shell_cancel(gtkMenuShell); 425 } 426 427 /** 428 * If take_focus is TRUE (the default) the menu shell will take the keyboard 429 * focus so that it will receive all keyboard events which is needed to enable 430 * keyboard navigation in menus. 431 * Setting take_focus to FALSE is useful only for special applications 432 * like virtual keyboard implementations which should not take keyboard 433 * focus. 434 * The take_focus state of a menu or menu bar is automatically propagated 435 * to submenus whenever a submenu is popped up, so you don't have to worry 436 * about recursively setting it for your entire menu hierarchy. Only when 437 * programmatically picking a submenu and popping it up manually, the 438 * take_focus property of the submenu needs to be set explicitely. 439 * Since 2.8 440 * Params: 441 * takeFocus = TRUE if the menu shell should take the keyboard focus on popup. 442 */ 443 public void setTakeFocus(int takeFocus) 444 { 445 // void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell, gboolean take_focus); 446 gtk_menu_shell_set_take_focus(gtkMenuShell, takeFocus); 447 } 448 449 /** 450 * Returns TRUE if the menu shell will take the keyboard focus on popup. 451 * Since 2.8 452 * Returns: TRUE if the menu shell will take the keyboard focus on popup. 453 */ 454 public int getTakeFocus() 455 { 456 // gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell); 457 return gtk_menu_shell_get_take_focus(gtkMenuShell); 458 } 459 }