# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # A menu item represents an item in a menu. # Note that you usually don't have to deal with it directly as {Wx::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, Mac and GTK+. # === Events emitted by this class # # The following event-handler methods redirect the events to member method or handler blocks for {Wx::MenuEvent} events. # Event handler methods for events emitted by this class: # - {Wx::EvtHandler#evt_menu}(id, meth = nil, &block): Process a {Wx::EVT_MENU} command, which is generated by a menu item. This type of event is sent as {Wx::CommandEvent}. # - {Wx::EvtHandler#evt_menu_range}(id1, id2, meth = nil, &block): Process a {Wx::EVT_MENU} command, which is generated by a range of menu items. This type of event is sent as {Wx::CommandEvent}. # - {Wx::EvtHandler#evt_menu_open}(meth = nil, &block): A menu is about to be opened. On Windows, this is only sent once for each navigation of the menubar (up until all menus have closed). This type of event is sent as {Wx::MenuEvent}. # - {Wx::EvtHandler#evt_menu_close}(meth = nil, &block): A menu has been just closed. This type of event is sent as {Wx::MenuEvent}. # - {Wx::EvtHandler#evt_menu_highlight}(id, meth = nil, &block): The menu item with the specified id has been highlighted. If the id is {Wx::StandardID::ID_NONE}, highlighting has been removed from the previously highlighted menu item and there is no highlighted item any more. This is used by {Wx::Frame} to show help prompts in the status bar. This type of event is sent as {Wx::MenuEvent}. # - {Wx::EvtHandler#evt_menu_highlight_all}(meth = nil, &block): A menu item has been highlighted, i.e. the currently selected menu item has changed. This type of event is sent as {Wx::MenuEvent}. # # === # # Category: {Wx::Menus} # @see Wx::MenuBar # @see Wx::Menu # # class MenuItem < Object # Returns the background colour associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @return [Wx::Colour] def get_background_colour; end alias_method :background_colour, :get_background_colour # Returns the item bitmap. # This method exists only for compatibility, please use {Wx::MenuItem#get_bitmap_bundle} in the new code. # @return [Wx::Bitmap] def get_bitmap; end alias_method :bitmap, :get_bitmap # Returns the bitmap bundle containing the bitmap used for this item. # The returned bundle is invalid, i.e. empty, if no bitmap is associated with the item. # @see Wx::MenuItem#set_bitmap # @return [Wx::BitmapBundle] def get_bitmap_bundle; end alias_method :bitmap_bundle, :get_bitmap_bundle # Returns the bitmap used for disabled items. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @return [Wx::Bitmap] def get_disabled_bitmap; end alias_method :disabled_bitmap, :get_disabled_bitmap # Returns the font associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @return [Wx::Font] def get_font; end alias_method :font, :get_font # Returns the help string associated with the menu item. # @return [Wx::String] def get_help; end alias_method :help, :get_help # Returns the menu item identifier. # @return [Integer] def get_id; end alias_method :id, :get_id # Returns the text associated with the menu item including any accelerator characters that were passed to the constructor or {Wx::MenuItem#set_item_label}. # # @see Wx::MenuItem#get_item_label_text # @see Wx::MenuItem.get_label_text # @return [String] def get_item_label; end alias_method :item_label, :get_item_label # Returns the text associated with the menu item, without any accelerator characters. # # @see Wx::MenuItem#get_item_label # @see Wx::MenuItem.get_label_text # @return [String] def get_item_label_text; end alias_method :item_label_text, :get_item_label_text # Returns the item kind, one of {Wx::ItemKind::ITEM_SEPARATOR}, {Wx::ItemKind::ITEM_NORMAL}, {Wx::ItemKind::ITEM_CHECK} or {Wx::ItemKind::ITEM_RADIO}. # @return [ItemKind] def get_kind; end alias_method :kind, :get_kind # Gets the width of the menu item checkmark bitmap. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @return [Integer] def get_margin_width; end alias_method :margin_width, :get_margin_width # Returns the menu this menu item is in, or NULL if this menu item is not attached. # @return [Wx::Menu] def get_menu; end alias_method :menu, :get_menu # Returns the submenu associated with the menu item, or NULL if there isn't one. # @return [Wx::Menu] def get_sub_menu; end alias_method :sub_menu, :get_sub_menu # Returns the text colour associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @return [Wx::Colour] def get_text_colour; end alias_method :text_colour, :get_text_colour # Get our accelerator or NULL (caller must delete the pointer) # @return [Wx::AcceleratorEntry] def get_accel; end alias_method :accel, :get_accel # Returns true if the item is a check item. # Unlike {Wx::MenuItem#is_checkable} this doesn't return true for the radio buttons. # @return [true,false] def is_check; end alias_method :check?, :is_check # Returns true if the item is checkable. # Notice that the radio buttons are considered to be checkable as well, so this method returns true for them too. Use {Wx::MenuItem#is_check} if you want to test for the check items only. # @return [true,false] def is_checkable; end alias_method :checkable?, :is_checkable # Returns true if the item is checked. # @return [true,false] def is_checked; end alias_method :checked?, :is_checked # Returns true if the item is enabled. # @return [true,false] def is_enabled; end alias_method :enabled?, :is_enabled # Returns true if the item is a radio button. # @return [true,false] def is_radio; end alias_method :radio?, :is_radio # Returns true if the item is a separator. # @return [true,false] def is_separator; end alias_method :separator?, :is_separator # Returns true if the item is a submenu. # @return [true,false] def is_sub_menu; end alias_method :sub_menu?, :is_sub_menu # Sets the background colour associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param colour [Wx::Colour,String,Symbol] # @return [void] def set_background_colour(colour) end alias_method :background_colour=, :set_background_colour # @overload set_bitmap(bmp) # Sets the bitmap for the menu item. # Notice that GTK+ uses a global setting called gtk-menu-images to determine if the images should be shown in the menus at all. If it is off (which is the case in e.g. Gnome 2.28 by default), no images will be shown, consistently with the native behaviour. # @param bmp [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @return [void] # @overload set_bitmap(bmp, checked) # Sets the checked or unchecked bitmap for the menu item. # It is equivalent to {Wx::MenuItem#set_bitmaps(bmp,wxNullBitmap)} if checked is true or SetBitmaps({Wx::NULL_BITMAP}, bmp) otherwise. # Note that different bitmaps for checked and unchecked item states are not supported in most ports, while setting just a single bitmap using the overload above is supported in all of them. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param bmp [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @param checked [true,false] # @return [void] def set_bitmap(*args) end alias_method :bitmap=, :set_bitmap # Sets the checked/unchecked bitmaps for the menu item. # The first bitmap is also used as the single bitmap for uncheckable menu items. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param checked [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @param unchecked [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @return [void] def set_bitmaps(checked, unchecked=Wx::NULL_BITMAP) end alias_method :bitmaps=, :set_bitmaps # Sets the to be used for disabled menu items. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param disabled [Wx::BitmapBundle,Wx::Bitmap,Wx::Icon,Wx::Image] # @return [void] def set_disabled_bitmap(disabled) end alias_method :disabled_bitmap=, :set_disabled_bitmap # Sets the font associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param font [Wx::Font,Wx::FontInfo] # @return [void] def set_font(font) end alias_method :font=, :set_font # Sets the help string. # @param helpString [String] # @return [void] def set_help(helpString) end alias_method :help=, :set_help # Sets the label associated with the menu item. # Note that if the ID of this menu item corresponds to a stock ID, then it is not necessary to specify a label: wxWidgets will automatically use the stock item label associated with that ID. See the {Wx::constructor} for more info. # The label string for the normal menu items (not separators) may include the accelerator which can be used to activate the menu item from keyboard. An accelerator key can be specified using the ampersand & character. In order to embed an ampersand character in the menu item text, the ampersand must be doubled. # Optionally you can specify also an accelerator string appending a tab character \t followed by a valid key combination (e.g. CTRL+V). Its general syntax is any combination of "CTRL", "RAWCTRL", "ALT" and "SHIFT" strings (case doesn't matter) separated by either '-' or '+' characters and followed by the accelerator itself. Notice that CTRL corresponds to the "Ctrl" key on most platforms but not under macOS where it is mapped to "Cmd" key on Mac keyboard. Usually this is exactly what you want in portable code but if you really need to use the (rarely used for this purpose) "Ctrl" key even under Mac, you may use RAWCTRL to prevent this mapping. Under the other platforms RAWCTRL is the same as plain CTRL. # The accelerator may be any alphanumeric character, any function key (from F1 to F12), any numpad digit key using KP_ prefix (i.e. from KP_0 to KP_9) or one of the special strings listed below (again, case doesn't matter) corresponding to the specified key code: # - Del or Delete: WXK_DELETE- Back: WXK_BACK- Ins or Insert: WXK_INSERT- Enter or Return: WXK_RETURN- PgUp or PageUp: WXK_PAGEUP- PgDn or PageDown: WXK_PAGEDOWN- Left: WXK_LEFT- Right: WXK_RIGHT- Up: WXK_UP- Down: WXK_DOWN- Home: WXK_HOME- End: WXK_END- Space: WXK_SPACE- Tab: WXK_TAB- Esc or Escape: WXK_ESCAPE- Cancel: WXK_CANCEL- Clear: WXK_CLEAR- Menu: WXK_MENU- Pause: WXK_PAUSE- Capital: WXK_CAPITAL- Select: WXK_SELECT- Print: WXK_PRINT- Execute: WXK_EXECUTE- Snapshot: WXK_SNAPSHOT- Help: WXK_HELP- Add: WXK_ADD- Separator: WXK_SEPARATOR- Subtract: WXK_SUBTRACT- Decimal: WXK_DECIMAL- Divide: WXK_DIVIDE- Num_lock: WXK_NUMLOCK- Scroll_lock: WXK_SCROLL- KP_Space: WXK_NUMPAD_SPACE- KP_Tab: WXK_NUMPAD_TAB- KP_Enter: WXK_NUMPAD_ENTER- KP_Home: WXK_NUMPAD_HOME- KP_Left: WXK_NUMPAD_LEFT- KP_Up: WXK_NUMPAD_UP- KP_Right: WXK_NUMPAD_RIGHT- KP_Down: WXK_NUMPAD_DOWN- KP_PageUp: WXK_NUMPAD_PAGEUP- KP_PageDown: WXK_NUMPAD_PAGEDOWN- KP_Prior: WXK_NUMPAD_PAGEUP- KP_Next: WXK_NUMPAD_PAGEDOWN- KP_End: WXK_NUMPAD_END- KP_Begin: WXK_NUMPAD_BEGIN- KP_Insert: WXK_NUMPAD_INSERT- KP_Delete: WXK_NUMPAD_DELETE- KP_Equal: WXK_NUMPAD_EQUAL- KP_Multiply: WXK_NUMPAD_MULTIPLY- KP_Add: WXK_NUMPAD_ADD- KP_Separator: WXK_NUMPAD_SEPARATOR- KP_Subtract: WXK_NUMPAD_SUBTRACT- KP_Decimal: WXK_NUMPAD_DECIMAL- KP_Divide: WXK_NUMPAD_DIVIDE- Windows_Left: WXK_WINDOWS_LEFT- Windows_Right: WXK_WINDOWS_RIGHT- Windows_Menu: WXK_WINDOWS_MENU- Command: WXK_COMMAND # # Examples: # # m_pMyMenuItem->SetItemLabel("My &item\tCTRL+I"); # m_pMyMenuItem2->SetItemLabel("Clean && build\tF7"); # m_pMyMenuItem3->SetItemLabel("Simple item"); # m_pMyMenuItem4->SetItemLabel("Item with &accelerator"); # # In {Wx::GTK} using "SHIFT" with non-alphabetic characters currently doesn't work, even in combination with other modifiers, due to GTK+ limitation. E.g. Shift+Ctrl+A works but Shift+Ctrl+1 or Shift+/ do not, so avoid using accelerators of this form in portable code. # # In {Wx::GTk}, the left/right/up/down arrow keys do not work as accelerator keys for a menu item unless a modifier key is used. Additionally, the following keycodes are not supported as menu accelerator keys: # - WXK_COMMAND/WXK_CONTROL- WXK_SHIFT- WXK_ALT- WXK_SCROLL- WXK_CAPITAL- WXK_NUMLOCK- WXK_NUMPAD_TAB- WXK_TAB- WXK_WINDOWS_LEFT- WXK_WINDOWS_RIGHT- WXK_ADD- WXK_SEPARATOR- WXK_SUBTRACT- WXK_DECIMAL- WXK_DIVIDE- WXK_SNAPSHOT # @see Wx::MenuItem#get_item_label # @see Wx::MenuItem#get_item_label_text # @param label [String] # @return [void] def set_item_label(label) end alias_method :item_label=, :set_item_label # Sets the width of the menu item checkmark bitmap. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param width [Integer] # @return [void] def set_margin_width(width) end alias_method :margin_width=, :set_margin_width # Sets the parent menu which will contain this menu item. # @param menu [Wx::Menu] # @return [void] def set_menu(menu) end alias_method :menu=, :set_menu # Sets the submenu of this menu item. # @param menu [Wx::Menu] # @return [void] def set_sub_menu(menu) end alias_method :sub_menu=, :set_sub_menu # Sets the text colour associated with the menu item. # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param colour [Wx::Colour,String,Symbol] # @return [void] def set_text_colour(colour) end alias_method :text_colour=, :set_text_colour # Set the accel for this item - this may also be done indirectly with {Wx::MenuItem#set_text} # @param accel [Wx::AcceleratorEntry] # @return [void] def set_accel(accel) end alias_method :accel=, :set_accel # Add an extra accelerator for this menu item. # Additional accelerators are not shown in the item's label, but still will trigger the menu command when pressed. # They can be useful to let multiple keys be used as accelerators for the same command, e.g. WXK_ADD and WXK_NUMPAD_ADD. # Availability: only available for the {Wx::MSW}, {Wx::GTK} ports. {Wx::msw},{Wx::gtk} # @param accel [Wx::AcceleratorEntry] # @return [void] def add_extra_accel(accel) end # Clear the extra accelerators list. # This doesn't affect the main item accelerator (if any). # @return [void] def clear_extra_accels; end # Constructs a {Wx::MenuItem} object. # Menu items can be standard, or "stock menu items", or custom. For the standard menu items (such as commands to open a file, exit the program and so on, see Stock Items for the full list) it is enough to specify just the stock ID and leave text and helpString empty. Some platforms (currently {Wx::GTK} only, and see the remark in {Wx::MenuItem#set_bitmap} documentation) will also show standard bitmaps for stock menu items. # Leaving at least text empty for the stock menu items is actually strongly recommended as they will have appearance and keyboard interface (including standard accelerators) familiar to the user. # For the custom (non-stock) menu items, text must be specified and while helpString may be left empty, it's recommended to pass the item description (which is automatically shown by the library in the status bar when the menu item is selected) in this parameter. # Finally note that you can e.g. use a stock menu label without using its stock help string: # # // use all stock properties: # helpMenu->Append(wxID_ABOUT); # # // use the stock label and the stock accelerator but not the stock help string: # helpMenu->Append(wxID_ABOUT, "", "My custom help string"); # # // use all stock properties except for the bitmap: # wxMenuItem *mymenu = new wxMenuItem(helpMenu, wxID_ABOUT); # mymenu->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING)); # helpMenu->Append(mymenu); # # that is, stock properties are set independently one from the other. # @param parentMenu [Wx::Menu] Menu that the menu item belongs to. Can be NULL if the item is going to be added to the menu later. # @param id [Integer] Identifier for this menu item. May be {Wx::StandardID::ID_SEPARATOR}, in which case the given kind is ignored and taken to be {Wx::ItemKind::ITEM_SEPARATOR} instead. # @param text [String] Text for the menu item, as shown on the menu. See {Wx::MenuItem#set_item_label} for more info. # @param helpString [String] Optional help string that will be shown on the status bar. # @param kind [ItemKind] May be {Wx::ItemKind::ITEM_SEPARATOR}, {Wx::ItemKind::ITEM_NORMAL}, {Wx::ItemKind::ITEM_CHECK} or {Wx::ItemKind::ITEM_RADIO}. # @param subMenu [Wx::Menu] If non-NULL, indicates that the menu item is a submenu. # @return [MenuItem] def initialize(parentMenu=nil, id=Wx::ID_SEPARATOR, text=Wx::EMPTY_STRING, helpString=Wx::EMPTY_STRING, kind=Wx::ITEM_NORMAL, subMenu=nil) end # Checks or unchecks the menu item. # Note that this only works when the item is already appended to a menu. # @param check [true,false] # @return [void] def check(check=true) end # Enables or disables the menu item. # @param enable [true,false] # @return [void] def enable(enable=true) end # Strips all accelerator characters and mnemonics from the given text. # For example: # # wxMenuItem::GetLabelText("&Hello\tCtrl-h"); # # will return just "Hello". # @see Wx::MenuItem#get_item_label_text # @see Wx::MenuItem#get_item_label # @param text [String] # @return [String] def self.get_label_text(text) end end # MenuItem end