alternative to assert
[gtkD.git] / gtkD / src / gtk / MenuShell.d
blobaaafa99fcab84247bc9aec8dab71de61a35f0cc7
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkMenuShell.html
26 * outPack = gtk
27 * outFile = MenuShell
28 * strct = GtkMenuShell
29 * realStrct=
30 * ctorStrct=
31 * clss = MenuShell
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_menu_shell_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - gtk.Widget
46 * structWrap:
47 * - GtkWidget* -> Widget
48 * module aliases:
49 * local aliases:
52 module gtk.MenuShell;
54 version(noAssert)
56 version(Tango)
58 import tango.io.Stdout; // use the tango loging?
62 private import gtkc.gtktypes;
64 private import gtkc.gtk;
67 private import gtk.Widget;
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.
81 private import gtk.Container;
82 public class MenuShell : Container
85 /** the main Gtk struct */
86 protected GtkMenuShell* gtkMenuShell;
89 public GtkMenuShell* getMenuShellStruct()
91 return gtkMenuShell;
95 /** the main Gtk struct as a void* */
96 protected void* getStruct()
98 return cast(void*)gtkMenuShell;
102 * Sets our main struct and passes it to the parent class
104 public this (GtkMenuShell* gtkMenuShell)
106 version(noAssert)
108 if ( gtkMenuShell is null )
110 int zero = 0;
111 version(Tango)
113 Stdout("struct gtkMenuShell is null on constructor").newline;
115 else
117 printf("struct gtkMenuShell is null on constructor");
119 zero = zero / zero;
122 else
124 assert(gtkMenuShell !is null, "struct gtkMenuShell is null on constructor");
126 super(cast(GtkContainer*)gtkMenuShell);
127 this.gtkMenuShell = gtkMenuShell;
133 // imports for the signal processing
134 private import gobject.Signals;
135 private import gtkc.gdktypes;
136 int[char[]] connectedSignals;
138 void delegate(gboolean, MenuShell)[] onActivateCurrentListeners;
139 void addOnActivateCurrent(void delegate(gboolean, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
141 if ( !("activate-current" in connectedSignals) )
143 Signals.connectData(
144 getStruct(),
145 "activate-current",
146 cast(GCallback)&callBackActivateCurrent,
147 cast(void*)this,
148 null,
149 connectFlags);
150 connectedSignals["activate-current"] = 1;
152 onActivateCurrentListeners ~= dlg;
154 extern(C) static void callBackActivateCurrent(GtkMenuShell* menushellStruct, gboolean forceHide, MenuShell menuShell)
156 bool consumed = false;
158 foreach ( void delegate(gboolean, MenuShell) dlg ; menuShell.onActivateCurrentListeners )
160 dlg(forceHide, menuShell);
163 return consumed;
166 void delegate(MenuShell)[] onCancelListeners;
167 void addOnCancel(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
169 if ( !("cancel" in connectedSignals) )
171 Signals.connectData(
172 getStruct(),
173 "cancel",
174 cast(GCallback)&callBackCancel,
175 cast(void*)this,
176 null,
177 connectFlags);
178 connectedSignals["cancel"] = 1;
180 onCancelListeners ~= dlg;
182 extern(C) static void callBackCancel(GtkMenuShell* menushellStruct, MenuShell menuShell)
184 bool consumed = false;
186 foreach ( void delegate(MenuShell) dlg ; menuShell.onCancelListeners )
188 dlg(menuShell);
191 return consumed;
194 void delegate(GtkDirectionType, MenuShell)[] onCycleFocusListeners;
195 void addOnCycleFocus(void delegate(GtkDirectionType, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
197 if ( !("cycle-focus" in connectedSignals) )
199 Signals.connectData(
200 getStruct(),
201 "cycle-focus",
202 cast(GCallback)&callBackCycleFocus,
203 cast(void*)this,
204 null,
205 connectFlags);
206 connectedSignals["cycle-focus"] = 1;
208 onCycleFocusListeners ~= dlg;
210 extern(C) static void callBackCycleFocus(GtkMenuShell* menushellStruct, GtkDirectionType arg1, MenuShell menuShell)
212 bool consumed = false;
214 foreach ( void delegate(GtkDirectionType, MenuShell) dlg ; menuShell.onCycleFocusListeners )
216 dlg(arg1, menuShell);
219 return consumed;
222 void delegate(MenuShell)[] onDeactivateListeners;
223 void addOnDeactivate(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
225 if ( !("deactivate" in connectedSignals) )
227 Signals.connectData(
228 getStruct(),
229 "deactivate",
230 cast(GCallback)&callBackDeactivate,
231 cast(void*)this,
232 null,
233 connectFlags);
234 connectedSignals["deactivate"] = 1;
236 onDeactivateListeners ~= dlg;
238 extern(C) static void callBackDeactivate(GtkMenuShell* menushellStruct, MenuShell menuShell)
240 bool consumed = false;
242 foreach ( void delegate(MenuShell) dlg ; menuShell.onDeactivateListeners )
244 dlg(menuShell);
247 return consumed;
250 void delegate(GtkMenuDirectionType, MenuShell)[] onMoveCurrentListeners;
251 void addOnMoveCurrent(void delegate(GtkMenuDirectionType, MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
253 if ( !("move-current" in connectedSignals) )
255 Signals.connectData(
256 getStruct(),
257 "move-current",
258 cast(GCallback)&callBackMoveCurrent,
259 cast(void*)this,
260 null,
261 connectFlags);
262 connectedSignals["move-current"] = 1;
264 onMoveCurrentListeners ~= dlg;
266 extern(C) static void callBackMoveCurrent(GtkMenuShell* menushellStruct, GtkMenuDirectionType direction, MenuShell menuShell)
268 bool consumed = false;
270 foreach ( void delegate(GtkMenuDirectionType, MenuShell) dlg ; menuShell.onMoveCurrentListeners )
272 dlg(direction, menuShell);
275 return consumed;
278 void delegate(MenuShell)[] onSelectionDoneListeners;
279 void addOnSelectionDone(void delegate(MenuShell) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
281 if ( !("selection-done" in connectedSignals) )
283 Signals.connectData(
284 getStruct(),
285 "selection-done",
286 cast(GCallback)&callBackSelectionDone,
287 cast(void*)this,
288 null,
289 connectFlags);
290 connectedSignals["selection-done"] = 1;
292 onSelectionDoneListeners ~= dlg;
294 extern(C) static void callBackSelectionDone(GtkMenuShell* menushellStruct, MenuShell menuShell)
296 bool consumed = false;
298 foreach ( void delegate(MenuShell) dlg ; menuShell.onSelectionDoneListeners )
300 dlg(menuShell);
303 return consumed;
309 * Adds a new GtkMenuItem to the end of the menu shell's item list.
310 * menu_shell:
311 * a GtkMenuShell.
312 * child:
313 * The GtkMenuItem to add.
315 public void append(Widget child)
317 // void gtk_menu_shell_append (GtkMenuShell *menu_shell, GtkWidget *child);
318 gtk_menu_shell_append(gtkMenuShell, (child is null) ? null : child.getWidgetStruct());
322 * Adds a new GtkMenuItem to the beginning of the menu shell's item list.
323 * menu_shell:
324 * a GtkMenuShell.
325 * child:
326 * The GtkMenuItem to add.
328 public void prepend(Widget child)
330 // void gtk_menu_shell_prepend (GtkMenuShell *menu_shell, GtkWidget *child);
331 gtk_menu_shell_prepend(gtkMenuShell, (child is null) ? null : child.getWidgetStruct());
335 * Adds a new GtkMenuItem to the menu shell's item list at the position
336 * indicated by position.
337 * menu_shell:
338 * a GtkMenuShell.
339 * child:
340 * The GtkMenuItem to add.
341 * position:
342 * The position in the item list where child is added.
343 * Positions are numbered from 0 to n-1.
345 public void insert(Widget child, int position)
347 // void gtk_menu_shell_insert (GtkMenuShell *menu_shell, GtkWidget *child, gint position);
348 gtk_menu_shell_insert(gtkMenuShell, (child is null) ? null : child.getWidgetStruct(), position);
352 * Deactivates the menu shell. Typically this results in the menu shell
353 * being erased from the screen.
354 * menu_shell:
355 * a GtkMenuShell.
357 public void deactivate()
359 // void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell);
360 gtk_menu_shell_deactivate(gtkMenuShell);
364 * Selects the menu item from the menu shell.
365 * menu_shell:
366 * a GtkMenuShell.
367 * menu_item:
368 * The GtkMenuItem to select.
370 public void selectItem(Widget menuItem)
372 // void gtk_menu_shell_select_item (GtkMenuShell *menu_shell, GtkWidget *menu_item);
373 gtk_menu_shell_select_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct());
377 * Select the first visible or selectable child of the menu shell;
378 * don't select tearoff items unless the only item is a tearoff
379 * item.
380 * menu_shell:
381 * a GtkMenuShell
382 * search_sensitive:
383 * 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 * Since 2.2
390 public void selectFirst(int searchSensitive)
392 // void gtk_menu_shell_select_first (GtkMenuShell *menu_shell, gboolean search_sensitive);
393 gtk_menu_shell_select_first(gtkMenuShell, searchSensitive);
397 * Deselects the currently selected item from the menu shell, if any.
398 * menu_shell:
399 * a GtkMenuShell.
401 public void deselect()
403 // void gtk_menu_shell_deselect (GtkMenuShell *menu_shell);
404 gtk_menu_shell_deselect(gtkMenuShell);
408 * Activates the menu item within the menu shell.
409 * menu_shell:
410 * a GtkMenuShell.
411 * menu_item:
412 * The GtkMenuItem to activate.
413 * force_deactivate:
414 * If TRUE, force the deactivation of the menu shell
415 * after the menu item is activated.
417 public void activateItem(Widget menuItem, int forceDeactivate)
419 // void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, GtkWidget *menu_item, gboolean force_deactivate);
420 gtk_menu_shell_activate_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct(), forceDeactivate);
424 * Cancels the selection within the menu shell.
425 * menu_shell:
426 * a GtkMenuShell
427 * Since 2.4
429 public void cancel()
431 // void gtk_menu_shell_cancel (GtkMenuShell *menu_shell);
432 gtk_menu_shell_cancel(gtkMenuShell);
436 * If take_focus is TRUE (the default) the menu shell will take the keyboard
437 * focus so that it will receive all keyboard events which is needed to enable
438 * keyboard navigation in menus.
439 * Setting take_focus to FALSE is useful only for special applications
440 * like virtual keyboard implementations which should not take keyboard
441 * focus.
442 * The take_focus state of a menu or menu bar is automatically propagated
443 * to submenus whenever a submenu is popped up, so you don't have to worry
444 * about recursively setting it for your entire menu hierarchy. Only when
445 * programmatically picking a submenu and popping it up manually, the
446 * take_focus property of the submenu needs to be set explicitely.
447 * Note that setting it to FALSE has side-effects:
448 * If the focus is in some other app, it keeps the focus and keynav in
449 * the menu doesn't work. Consequently, keynav on the menu will only
450 * work if the focus is on some toplevel owned by the onscreen keyboard.
451 * To avoid confusing the user, menus with take_focus set to FALSE
452 * should not display mnemonics or accelerators, since it cannot be
453 * guaranteed that they will work.
454 * See also gdk_keyboard_grab()
455 * menu_shell:
456 * a GtkMenuShell
457 * take_focus:
458 * TRUE if the menu shell should take the keyboard focus on popup.
459 * Since 2.8
461 public void setTakeFocus(int takeFocus)
463 // void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell, gboolean take_focus);
464 gtk_menu_shell_set_take_focus(gtkMenuShell, takeFocus);
468 * Returns TRUE if the menu shell will take the keyboard focus on popup.
469 * menu_shell:
470 * a GtkMenuShell
471 * Returns:
472 * TRUE if the menu shell will take the keyboard focus on popup.
473 * Since 2.8
475 public int getTakeFocus()
477 // gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell);
478 return gtk_menu_shell_get_take_focus(gtkMenuShell);