alternative to assert
[gtkD.git] / src / gtk / MenuShell.d
blob32150d62dca458f33fbddda9eb4b1087e8c6b685
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 * local aliases:
51 module gtk.MenuShell;
53 private import gtk.gtktypes;
55 private import lib.gtk;
57 private import gtk.Widget;
59 /**
60 * Description
61 * A GtkMenuShell is the abstract base class used to derive the
62 * GtkMenu and GtkMenuBar subclasses.
63 * A GtkMenuShell is a container of GtkMenuItem objects arranged in a
64 * list which can be navigated, selected, and activated by the user to perform
65 * application functions. A GtkMenuItem can have a submenu associated with it,
66 * allowing for nested hierarchical menus.
68 private import gtk.Container;
69 public class MenuShell : Container
72 /** the main Gtk struct */
73 protected GtkMenuShell* gtkMenuShell;
76 public GtkMenuShell* getMenuShellStruct()
78 return gtkMenuShell;
82 /** the main Gtk struct as a void* */
83 protected void* getStruct()
85 return cast(void*)gtkMenuShell;
88 /**
89 * Sets our main struct and passes it to the parent class
91 public this (GtkMenuShell* gtkMenuShell)
93 super(cast(GtkContainer*)gtkMenuShell);
94 this.gtkMenuShell = gtkMenuShell;
97 /**
100 // imports for the signal processing
101 private import gobject.Signals;
102 private import gdk.gdktypes;
103 int[char[]] connectedSignals;
105 void delegate(gboolean, MenuShell)[] onActivateCurrentListeners;
106 void addOnActivateCurrent(void delegate(gboolean, MenuShell) dlg)
108 if ( !("activate-current" in connectedSignals) )
110 Signals.connectData(
111 getStruct(),
112 "activate-current",
113 cast(GCallback)&callBackActivateCurrent,
114 this,
115 null,
116 cast(ConnectFlags)0);
117 connectedSignals["activate-current"] = 1;
119 onActivateCurrentListeners ~= dlg;
121 extern(C) static void callBackActivateCurrent(GtkMenuShell* menushellStruct, gboolean forceHide, MenuShell menuShell)
123 bit consumed = false;
125 foreach ( void delegate(gboolean, MenuShell) dlg ; menuShell.onActivateCurrentListeners )
127 dlg(forceHide, menuShell);
130 return consumed;
133 void delegate(MenuShell)[] onCancelListeners;
134 void addOnCancel(void delegate(MenuShell) dlg)
136 if ( !("cancel" in connectedSignals) )
138 Signals.connectData(
139 getStruct(),
140 "cancel",
141 cast(GCallback)&callBackCancel,
142 this,
143 null,
144 cast(ConnectFlags)0);
145 connectedSignals["cancel"] = 1;
147 onCancelListeners ~= dlg;
149 extern(C) static void callBackCancel(GtkMenuShell* menushellStruct, MenuShell menuShell)
151 bit consumed = false;
153 foreach ( void delegate(MenuShell) dlg ; menuShell.onCancelListeners )
155 dlg(menuShell);
158 return consumed;
161 void delegate(GtkDirectionType, MenuShell)[] onCycleFocusListeners;
162 void addOnCycleFocus(void delegate(GtkDirectionType, MenuShell) dlg)
164 if ( !("cycle-focus" in connectedSignals) )
166 Signals.connectData(
167 getStruct(),
168 "cycle-focus",
169 cast(GCallback)&callBackCycleFocus,
170 this,
171 null,
172 cast(ConnectFlags)0);
173 connectedSignals["cycle-focus"] = 1;
175 onCycleFocusListeners ~= dlg;
177 extern(C) static void callBackCycleFocus(GtkMenuShell* menushellStruct, GtkDirectionType arg1, MenuShell menuShell)
179 bit consumed = false;
181 foreach ( void delegate(GtkDirectionType, MenuShell) dlg ; menuShell.onCycleFocusListeners )
183 dlg(arg1, menuShell);
186 return consumed;
189 void delegate(MenuShell)[] onDeactivateListeners;
190 void addOnDeactivate(void delegate(MenuShell) dlg)
192 if ( !("deactivate" in connectedSignals) )
194 Signals.connectData(
195 getStruct(),
196 "deactivate",
197 cast(GCallback)&callBackDeactivate,
198 this,
199 null,
200 cast(ConnectFlags)0);
201 connectedSignals["deactivate"] = 1;
203 onDeactivateListeners ~= dlg;
205 extern(C) static void callBackDeactivate(GtkMenuShell* menushellStruct, MenuShell menuShell)
207 bit consumed = false;
209 foreach ( void delegate(MenuShell) dlg ; menuShell.onDeactivateListeners )
211 dlg(menuShell);
214 return consumed;
217 void delegate(GtkMenuDirectionType, MenuShell)[] onMoveCurrentListeners;
218 void addOnMoveCurrent(void delegate(GtkMenuDirectionType, MenuShell) dlg)
220 if ( !("move-current" in connectedSignals) )
222 Signals.connectData(
223 getStruct(),
224 "move-current",
225 cast(GCallback)&callBackMoveCurrent,
226 this,
227 null,
228 cast(ConnectFlags)0);
229 connectedSignals["move-current"] = 1;
231 onMoveCurrentListeners ~= dlg;
233 extern(C) static void callBackMoveCurrent(GtkMenuShell* menushellStruct, GtkMenuDirectionType direction, MenuShell menuShell)
235 bit consumed = false;
237 foreach ( void delegate(GtkMenuDirectionType, MenuShell) dlg ; menuShell.onMoveCurrentListeners )
239 dlg(direction, menuShell);
242 return consumed;
245 void delegate(MenuShell)[] onSelectionDoneListeners;
246 void addOnSelectionDone(void delegate(MenuShell) dlg)
248 if ( !("selection-done" in connectedSignals) )
250 Signals.connectData(
251 getStruct(),
252 "selection-done",
253 cast(GCallback)&callBackSelectionDone,
254 this,
255 null,
256 cast(ConnectFlags)0);
257 connectedSignals["selection-done"] = 1;
259 onSelectionDoneListeners ~= dlg;
261 extern(C) static void callBackSelectionDone(GtkMenuShell* menushellStruct, MenuShell menuShell)
263 bit consumed = false;
265 foreach ( void delegate(MenuShell) dlg ; menuShell.onSelectionDoneListeners )
267 dlg(menuShell);
270 return consumed;
276 * Adds a new GtkMenuItem to the end of the menu shell's item list.
277 * menu_shell:
278 * a GtkMenuShell.
279 * child:
280 * The GtkMenuItem to add.
282 public void append(Widget child)
284 // void gtk_menu_shell_append (GtkMenuShell *menu_shell, GtkWidget *child);
285 gtk_menu_shell_append(gtkMenuShell, (child is null) ? null : child.getWidgetStruct());
289 * Adds a new GtkMenuItem to the beginning of the menu shell's item list.
290 * menu_shell:
291 * a GtkMenuShell.
292 * child:
293 * The GtkMenuItem to add.
295 public void prepend(Widget child)
297 // void gtk_menu_shell_prepend (GtkMenuShell *menu_shell, GtkWidget *child);
298 gtk_menu_shell_prepend(gtkMenuShell, (child is null) ? null : child.getWidgetStruct());
302 * Adds a new GtkMenuItem to the menu shell's item list at the position
303 * indicated by position.
304 * menu_shell:
305 * a GtkMenuShell.
306 * child:
307 * The GtkMenuItem to add.
308 * position:
309 * The position in the item list where child is added.
310 * Positions are numbered from 0 to n-1.
312 public void insert(Widget child, int position)
314 // void gtk_menu_shell_insert (GtkMenuShell *menu_shell, GtkWidget *child, gint position);
315 gtk_menu_shell_insert(gtkMenuShell, (child is null) ? null : child.getWidgetStruct(), position);
319 * Deactivates the menu shell. Typically this results in the menu shell
320 * being erased from the screen.
321 * menu_shell:
322 * a GtkMenuShell.
324 public void deactivate()
326 // void gtk_menu_shell_deactivate (GtkMenuShell *menu_shell);
327 gtk_menu_shell_deactivate(gtkMenuShell);
331 * Selects the menu item from the menu shell.
332 * menu_shell:
333 * a GtkMenuShell.
334 * menu_item:
335 * The GtkMenuItem to select.
337 public void selectItem(Widget menuItem)
339 // void gtk_menu_shell_select_item (GtkMenuShell *menu_shell, GtkWidget *menu_item);
340 gtk_menu_shell_select_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct());
344 * Select the first visible or selectable child of the menu shell;
345 * don't select tearoff items unless the only item is a tearoff
346 * item.
347 * menu_shell:
348 * a GtkMenuShell
349 * search_sensitive:
350 * if TRUE, search for the first selectable
351 * menu item, otherwise select nothing if
352 * the first item isn't sensitive. This
353 * should be FALSE if the menu is being
354 * popped up initially.
355 * Since 2.2
357 public void selectFirst(int searchSensitive)
359 // void gtk_menu_shell_select_first (GtkMenuShell *menu_shell, gboolean search_sensitive);
360 gtk_menu_shell_select_first(gtkMenuShell, searchSensitive);
364 * Deselects the currently selected item from the menu shell, if any.
365 * menu_shell:
366 * a GtkMenuShell.
368 public void deselect()
370 // void gtk_menu_shell_deselect (GtkMenuShell *menu_shell);
371 gtk_menu_shell_deselect(gtkMenuShell);
375 * Activates the menu item within the menu shell.
376 * menu_shell:
377 * a GtkMenuShell.
378 * menu_item:
379 * The GtkMenuItem to activate.
380 * force_deactivate:
381 * If TRUE, force the deactivation of the menu shell
382 * after the menu item is activated.
384 public void activateItem(Widget menuItem, int forceDeactivate)
386 // void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell, GtkWidget *menu_item, gboolean force_deactivate);
387 gtk_menu_shell_activate_item(gtkMenuShell, (menuItem is null) ? null : menuItem.getWidgetStruct(), forceDeactivate);
391 * Cancels the selection within the menu shell.
392 * menu_shell:
393 * a GtkMenuShell
394 * Since 2.4
396 public void cancel()
398 // void gtk_menu_shell_cancel (GtkMenuShell *menu_shell);
399 gtk_menu_shell_cancel(gtkMenuShell);
403 * If take_focus is TRUE (the default) the menu shell will take the keyboard
404 * focus so that it will receive all keyboard events which is needed to enable
405 * keyboard navigation in menus.
406 * Setting take_focus to FALSE is useful only for special applications
407 * like virtual keyboard implementations which should not take keyboard
408 * focus.
409 * The take_focus state of a menu or menu bar is automatically propagated
410 * to submenus whenever a submenu is popped up, so you don't have to worry
411 * about recursively setting it for your entire menu hierarchy. Only when
412 * programmatically picking a submenu and popping it up manually, the
413 * take_focus property of the submenu needs to be set explicitely.
414 * Note that setting it to FALSE has side-effects:
415 * If the focus is in some other app, it keeps the focus and keynav in
416 * the menu doesn't work. Consequently, keynav on the menu will only
417 * work if the focus is on some toplevel owned by the onscreen keyboard.
418 * To avoid confusing the user, menus with take_focus set to FALSE
419 * should not display mnemonics or accelerators, since it cannot be
420 * guaranteed that they will work.
421 * See also gdk_keyboard_grab()
422 * menu_shell:
423 * a GtkMenuShell
424 * take_focus:
425 * TRUE if the menu shell should take the keyboard focus on popup.
426 * Since 2.8
428 public void setTakeFocus(int takeFocus)
430 // void gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell, gboolean take_focus);
431 gtk_menu_shell_set_take_focus(gtkMenuShell, takeFocus);
435 * Returns TRUE if the menu shell will take the keyboard focus on popup.
436 * menu_shell:
437 * a GtkMenuShell
438 * Returns:
439 * TRUE if the menu shell will take the keyboard focus on popup.
440 * Since 2.8
442 public int getTakeFocus()
444 // gboolean gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell);
445 return gtk_menu_shell_get_take_focus(gtkMenuShell);