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 = GtkMenuItem.html
44 * - gtk_menu_item_activate
45 * - gtk_menu_item_new_with_label
46 * - gtk_menu_item_new_with_mnemonic
52 * - GtkWidget* -> Widget
63 import tango
.io
.Stdout
; // use the tango loging?
67 private import gtkc
.gtktypes
;
69 private import gtkc
.gtk
;
72 private import glib
.Str
;
73 private import gtk
.Widget
;
74 private import gtk
.AccelGroup
;
81 * The GtkMenuItem widget and the derived widgets are the only valid
82 * childs for menus. Their function is to correctly handle highlighting,
83 * alignment, events and submenus.
84 * As it derives from GtkBin it can hold any valid child widget, altough
85 * only a few are really useful.
87 private import gtk
.Item
;
88 public class MenuItem
: Item
91 /** the main Gtk struct */
92 protected GtkMenuItem
* gtkMenuItem
;
95 public GtkMenuItem
* getMenuItemStruct()
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gtkMenuItem
;
108 * Sets our main struct and passes it to the parent class
110 public this (GtkMenuItem
* gtkMenuItem
)
114 if ( gtkMenuItem
is null )
119 Stdout("struct gtkMenuItem is null on constructor").newline
;
123 printf("struct gtkMenuItem is null on constructor");
130 assert(gtkMenuItem
!is null, "struct gtkMenuItem is null on constructor");
132 super(cast(GtkItem
*)gtkMenuItem
);
133 this.gtkMenuItem
= gtkMenuItem
;
137 /** store the action code passed in by the applcation */
138 private char[] actionLabel
;
140 /** Gets the application set action code */
141 public char[] getActionName()
143 if ( actionLabel
is null )
151 * Creates a new menu item with a label and a listener and a action.
152 * used for backward compatibily with DUI.
154 this(char[] label
, void delegate(MenuItem
)dlg
, char[] action
)
157 this.actionLabel
= action
;
164 * Creates a new Item associated with a "activate" delegate and with a action code
165 * and optionally accelGroup
167 public this(void delegate(MenuItem
) dlg
, char[] label
, char[] action
,
169 AccelGroup accelGroup
=null,
171 GdkModifierType modifierType
=GdkModifierType
.CONTROL_MASK
,
172 GtkAccelFlags accelFlags
=GtkAccelFlags
.VISIBLE
175 this(label
, mnemonic
);
176 this.actionLabel
= action
;
178 if ( accelGroup
!is null && accelKey
!= '\0' )
180 addAccelerator("activate",accelGroup
,accelKey
,modifierType
,accelFlags
);
187 * Creates a new Item associated with a "activate" delegate
189 public this(void delegate(MenuItem
) dlg
, char[] label
, bool mnemonic
=true)
191 this(label
, mnemonic
);
196 * Creates a new GtkMenuItem whose child is a GtkLabel.
197 * If mnemonic is true the label
198 * will be created using gtk_label_new_with_mnemonic(), so underscores
199 * in label indicate the mnemonic for the menu item.
201 * the text for the label
203 * the newly created GtkMenuItem
205 public this (char[] label
, bool mnemonic
=true)
209 // GtkWidget* gtk_menu_item_new_with_mnemonic (const gchar *label);
210 this(cast(GtkMenuItem
*)gtk_menu_item_new_with_mnemonic(Str
.toStringz(label
)) );
214 // GtkWidget* gtk_menu_item_new_with_label (const gchar *label);
215 this(cast(GtkMenuItem
*)gtk_menu_item_new_with_label(Str
.toStringz(label
)) );
221 * Emits the "activate" signal on the given item
225 public void itemActivate()
227 // void gtk_menu_item_activate (GtkMenuItem *menu_item);
228 gtk_menu_item_activate(gtkMenuItem
);
235 // imports for the signal processing
236 private import gobject
.Signals
;
237 private import gtkc
.gdktypes
;
238 int[char[]] connectedSignals
;
240 void delegate(MenuItem
)[] onActivateListeners
;
241 void addOnActivate(void delegate(MenuItem
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
243 if ( !("activate" in connectedSignals
) )
248 cast(GCallback
)&callBackActivate
,
252 connectedSignals
["activate"] = 1;
254 onActivateListeners
~= dlg
;
256 extern(C
) static void callBackActivate(GtkMenuItem
* menuitemStruct
, MenuItem menuItem
)
258 bool consumed
= false;
260 foreach ( void delegate(MenuItem
) dlg
; menuItem
.onActivateListeners
)
268 void delegate(MenuItem
)[] onActivateItemListeners
;
269 void addOnActivateItem(void delegate(MenuItem
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
271 if ( !("activate-item" in connectedSignals
) )
276 cast(GCallback
)&callBackActivateItem
,
280 connectedSignals
["activate-item"] = 1;
282 onActivateItemListeners
~= dlg
;
284 extern(C
) static void callBackActivateItem(GtkMenuItem
* menuitemStruct
, MenuItem menuItem
)
286 bool consumed
= false;
288 foreach ( void delegate(MenuItem
) dlg
; menuItem
.onActivateItemListeners
)
296 void delegate(gint
, MenuItem
)[] onToggleSizeAllocateListeners
;
297 void addOnToggleSizeAllocate(void delegate(gint
, MenuItem
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
299 if ( !("toggle-size-allocate" in connectedSignals
) )
303 "toggle-size-allocate",
304 cast(GCallback
)&callBackToggleSizeAllocate
,
308 connectedSignals
["toggle-size-allocate"] = 1;
310 onToggleSizeAllocateListeners
~= dlg
;
312 extern(C
) static void callBackToggleSizeAllocate(GtkMenuItem
* menuitemStruct
, gint arg1
, MenuItem menuItem
)
314 bool consumed
= false;
316 foreach ( void delegate(gint
, MenuItem
) dlg
; menuItem
.onToggleSizeAllocateListeners
)
324 void delegate(gpointer
, MenuItem
)[] onToggleSizeRequestListeners
;
325 void addOnToggleSizeRequest(void delegate(gpointer
, MenuItem
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
327 if ( !("toggle-size-request" in connectedSignals
) )
331 "toggle-size-request",
332 cast(GCallback
)&callBackToggleSizeRequest
,
336 connectedSignals
["toggle-size-request"] = 1;
338 onToggleSizeRequestListeners
~= dlg
;
340 extern(C
) static void callBackToggleSizeRequest(GtkMenuItem
* menuitemStruct
, gpointer arg1
, MenuItem menuItem
)
342 bool consumed
= false;
344 foreach ( void delegate(gpointer
, MenuItem
) dlg
; menuItem
.onToggleSizeRequestListeners
)
355 * Creates a new GtkMenuItem.
357 * the newly created GtkMenuItem
361 // GtkWidget* gtk_menu_item_new (void);
362 this(cast(GtkMenuItem
*)gtk_menu_item_new() );
368 * Sets whether the menu item appears justified at the right
369 * side of a menu bar. This was traditionally done for "Help" menu
370 * items, but is now considered a bad idea. (If the widget
371 * layout is reversed for a right-to-left language like Hebrew
372 * or Arabic, right-justified-menu-items appear at the left.)
376 * if TRUE the menu item will appear at the
377 * far right if added to a menu bar.
379 public void setRightJustified(int rightJustified
)
381 // void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item, gboolean right_justified);
382 gtk_menu_item_set_right_justified(gtkMenuItem
, rightJustified
);
386 * Sets the widget submenu, or changes it.
388 * the menu item widget
392 public void setSubmenu(Widget submenu
)
394 // void gtk_menu_item_set_submenu (GtkMenuItem *menu_item, GtkWidget *submenu);
395 gtk_menu_item_set_submenu(gtkMenuItem
, (submenu
is null) ?
null : submenu
.getWidgetStruct());
399 * Set the accelerator path on menu_item, through which runtime changes of the
400 * menu item's accelerator caused by the user can be identified and saved to
401 * persistant storage (see gtk_accel_map_save() on this).
402 * To setup a default accelerator for this menu item, call
403 * gtk_accel_map_add_entry() with the same accel_path.
404 * See also gtk_accel_map_add_entry() on the specifics of accelerator paths,
405 * and gtk_menu_set_accel_path() for a more convenient variant of this function.
406 * This function is basically a convenience wrapper that handles calling
407 * gtk_widget_set_accel_path() with the appropriate accelerator group for
409 * Note that you do need to set an accelerator on the parent menu with
410 * gtk_menu_set_accel_group() for this to work.
412 * a valid GtkMenuItem
414 * accelerator path, corresponding to this menu item's
415 * functionality, or NULL to unset the current path.
417 public void setAccelPath(char[] accelPath
)
419 // void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item, const gchar *accel_path);
420 gtk_menu_item_set_accel_path(gtkMenuItem
, Str
.toStringz(accelPath
));
424 * Removes the widget's submenu.
426 * the menu item widget
428 public void removeSubmenu()
430 // void gtk_menu_item_remove_submenu (GtkMenuItem *menu_item);
431 gtk_menu_item_remove_submenu(gtkMenuItem
);
435 * Emits the "select" signal on the given item. Behaves exactly like
442 // void gtk_menu_item_select (GtkMenuItem *menu_item);
443 gtk_menu_item_select(gtkMenuItem
);
447 * Emits the "deselect" signal on the given item. Behaves exactly like
452 public void deselect()
454 // void gtk_menu_item_deselect (GtkMenuItem *menu_item);
455 gtk_menu_item_deselect(gtkMenuItem
);
460 * Emits the "toggle_size_request" signal on the given item.
464 * the requisition to use as signal data.
466 public void toggleSizeRequest(int* requisition
)
468 // void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item, gint *requisition);
469 gtk_menu_item_toggle_size_request(gtkMenuItem
, requisition
);
473 * Emits the "toggle_size_allocate" signal on the given item.
477 * the allocation to use as signal data.
479 public void toggleSizeAllocate(int allocation
)
481 // void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item, gint allocation);
482 gtk_menu_item_toggle_size_allocate(gtkMenuItem
, allocation
);
487 * Gets whether the menu item appears justified at the right
488 * side of the menu bar.
492 * TRUE if the menu item will appear at the
493 * far right if added to a menu bar.
495 public int getRightJustified()
497 // gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item);
498 return gtk_menu_item_get_right_justified(gtkMenuItem
);
502 * Gets the submenu underneath this menu item, if any. See
503 * gtk_menu_item_set_submenu().
507 * submenu for this menu item, or NULL if none.
508 * Style Property Details
509 * The "arrow-spacing" style property
510 * "arrow-spacing" gint : Read
511 * Space between label and arrow.
512 * Allowed values: >= 0
515 public Widget
getSubmenu()
517 // GtkWidget* gtk_menu_item_get_submenu (GtkMenuItem *menu_item);
518 return new Widget( gtk_menu_item_get_submenu(gtkMenuItem
) );