wxRuby Documentation Home

Wx::MenuItem

A menu item represents an item in a menu. Note that you usually don’t have to deal with it directly as Menu methods usually construct an object of this class for you.

Also please note that the methods related to fonts and bitmaps are currently only implemented for Windows and GTK+.

Derived from

Object

See also

MenuBar, Menu

Methods

MenuItem.new(Menu parentMenu = nil,  Integer id = ID_SEPARATOR, 
             String text = "", 
              String helpString = "", 
             ItemKind kind = ITEM_NORMAL, 
             Menu subMenu = nil)

Constructs a MenuItem object.

Parameters

Destructor.

check(Boolean check = true)

Checks or unchecks the menu item.

Note that this only works when the item is already appended to a menu.

enable(Boolean enable = true)

Enables or disables the menu item.

Colour get_background_colour()

Returns the background colour associated with the menu item (Windows only).

Bitmap get_bitmap(Boolean checked = true)

Returns the checked or unchecked bitmap (Windows only).

Font get_font()

Returns the font associated with the menu item (Windows only).

String get_help()

Returns the help string associated with the menu item.

Integer get_id()

Returns the menu item identifier.

ItemKind get_kind()

Returns the item kind, one of ITEM_SEPARATOR, ITEM_NORMAL, ITEM_CHECK or ITEM_RADIO.

String get_label()

Returns the text associated with the menu item without any accelerator characters it might contain.

See also

get_text, get_label_from_text

String get_label_from_text(String text)

Strips all accelerator characters and mnemonics from the given text. For example,

MenuItem::GetLabelFromText("&Hello\tCtrl-H");

will return just "Hello".

See also

get_text, get_label

Integer get_margin_width()

Gets the width of the menu item checkmark bitmap (Windows only).

Menu get_menu()

Returns the menu this menu item is in, or NULL if this menu item is not attached.

String get_name()

Returns the text associated with the menu item.

NB: this function is deprecated, please use get_text or get_label instead.

String get_text()

Returns the text associated with the menu item, such as it was passed to the MenuItem constructor, i.e. with any accelerator characters it may contain.

See also

get_label, get_label_from_text

Menu get_sub_menu()

Returns the submenu associated with the menu item, or NULL if there isn’t one.

Colour get_text_colour()

Returns the text colour associated with the menu item (Windows only).

Boolean is_checkable()

Returns true if the item is checkable.

Boolean is_checked()

Returns true if the item is checked.

Boolean is_enabled()

Returns true if the item is enabled.

Boolean is_separator()

Returns true if the item is a separator.

Boolean is_sub_menu()

Returns true if the item is a submenu.

set_background_colour(Colour colour)

Sets the background colour associated with the menu item (Windows only).

set_bitmap(Bitmap bmp)

Sets the bitmap for the menu item (Windows and GTK+ only). It is equivalent to set_bitmaps, NullBitmap).

set_bitmaps(Bitmap checked,  Bitmap unchecked = NullBitmap)

Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap is also used as the single bitmap for uncheckable menu items.

set_font(Font font)

Sets the font associated with the menu item (Windows only).

set_help(String helpString)

Sets the help string.

set_margin_width(Integer width)

Sets the width of the menu item checkmark bitmap (Windows only).

set_menu(Menu menu)

Sets the parent menu which will contain this menu item.

set_sub_menu(Menu menu)

Sets the submenu of this menu item.

set_text(String text)

Sets the text associated with the menu item.

set_text_colour(Colour colour)

Sets the text colour associated with the menu item (Windows only).

[This page automatically generated from the Textile source at Wed Sep 09 02:21:17 +0100 2009]