# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # A menu is a popup (or pull down) list of items, one of which may be selected before the menu goes away (clicking elsewhere dismisses the menu). # Menus may be used to construct either menu bars or popup menus. # A menu item has an integer ID associated with it which can be used to identify the selection, or to change the menu item in some way. A menu item with a special identifier {Wx::StandardID::ID_SEPARATOR} is a separator item and doesn't have an associated command but just makes a separator line appear in the menu. # Please note that {Wx::StandardID::ID_ABOUT} and {Wx::StandardID::ID_EXIT} are predefined by wxWidgets and have a special meaning since entries using these IDs will be taken out of the normal menus under macOS and will be inserted into the system menu (following the appropriate macOS interface guideline). # # Menu items may be either normal items, check items or radio items. Normal items don't have any special properties while the check items have a boolean flag associated to them and they show a checkmark in the menu when the flag is set. wxWidgets automatically toggles the flag value when the item is clicked and its value may be retrieved using either {Wx::Menu#is_checked} method of {Wx::Menu} or {Wx::MenuBar} itself or by using {Wx::Event::IsChecked} when you get the menu notification for the item in question. # The radio items are similar to the check items except that all the other items in the same radio group are unchecked when a radio item is checked. The radio group is formed by a contiguous range of radio items, i.e. it starts at the first item of this kind and ends with the first item of a different kind (or the end of the menu). Notice that because the radio groups are defined in terms of the item positions inserting or removing the items in the menu containing the radio items risks to not work correctly. # # == Allocation strategy # # All menus must be created on the heap because all menus attached to a menubar or to another menu will be deleted by their parent when it is deleted. The only exception to this rule are the popup menus (i.e. menus used with {Wx::Window#popup_menu}) as wxWidgets does not destroy them to allow reusing the same menu more than once. But the exception applies only to the menus themselves and not to any submenus of popup menus which are still destroyed by wxWidgets as usual and so must be heap-allocated. # As the frame menubar is deleted by the frame itself, it means that normally all menus used are deleted automatically. # # == Event handling # # Event handlers for the commands generated by the menu items can be connected directly to the menu object itself using {Wx::EvtHandler#bind}. If this menu is a submenu of another one, the events from its items can also be processed in the parent menu and so on, recursively. # If the menu is part of a menu bar, then events can also be handled in {Wx::MenuBar} object. # Finally, menu events can also be handled in the associated window, which is either the {Wx::Frame} associated with the menu bar this menu belongs to or the window for which {Wx::Window#popup_menu} was called for the popup menus. # See Dynamic Event Handling for how to bind event handlers to the various objects. # === # # Category: {Wx::Menus} # @see Wx::MenuBar # @see Wx::Window#popup_menu # @see Events and Event Handling # @see wxFileHistory (most recently used files menu) # # class Menu < EvtHandler # Returns the list of items in the menu. # {Wx::MenuItemList} is a pseudo-template list class containing {Wx::MenuItem} pointers, see {Wx::List}. # @return [Wx::MenuItemList] def get_menu_items; end alias_method :menu_items, :get_menu_items # @overload initialize() # Constructs a {Wx::Menu} object. # @return [Menu] # @overload initialize(title, style=0) # Constructs a {Wx::Menu} object with a title. # @param title [String] Title at the top of the menu (not always supported). # @param style [Integer] If set to {Wx::MENU_TEAROFF}, the menu will be detachable ({Wx::GTK} and {Wx::QT} only). # @return [Menu] def initialize(*args) end # @overload append(id, item=(''), helpString=(''), kind=Wx::ItemKind::ITEM_NORMAL) # Adds a menu item. # Example: # # m_pFileMenu->Append(ID_NEW_FILE, "&New file\tCTRL+N", "Creates a new XYZ document"); # or even better for stock menu items (see {Wx::MenuItem::MenuItem}): # # m_pFileMenu->Append(wxID_NEW, "", "Creates a new XYZ document"); # # This command can be used after the menu has been shown, as well as on initial creation of a menu or menubar. # @see Wx::Menu#append_separator # @see Wx::Menu#append_check_item # @see Wx::Menu#append_radio_item # @see Wx::Menu#append_sub_menu # @see Wx::Menu#insert # @see Wx::Menu#set_label # @see Wx::Menu#get_help_string # @see Wx::Menu#set_help_string # @see Wx::MenuItem # @param id [Integer] The menu command identifier. See Window IDs for more information about IDs (same considerations apply to both window and menu item IDs). # @param item [String] The string to appear on the menu item. See {Wx::MenuItem#set_item_label} for more details. # @param helpString [String] An optional help string associated with the item. By default, the handler for the {Wx::EVT_MENU_HIGHLIGHT} event displays this string in the status line. # @param kind [ItemKind] May be {Wx::ItemKind::ITEM_SEPARATOR}, {Wx::ItemKind::ITEM_NORMAL}, {Wx::ItemKind::ITEM_CHECK} or {Wx::ItemKind::ITEM_RADIO}. # @return [Wx::MenuItem] # @overload append(menuItem) # Adds a menu item object. # This is the most generic variant of {Wx::Menu#append} method because it may be used for both items (including separators) and submenus and because you can also specify various extra properties of a menu item this way, such as bitmaps and fonts. # # See the remarks for the other {Wx::Menu#append} overloads. # @see Wx::Menu#append_separator # @see Wx::Menu#append_check_item # @see Wx::Menu#append_radio_item # @see Wx::Menu#append_sub_menu # @see Wx::Menu#insert # @see Wx::Menu#set_label # @see Wx::Menu#get_help_string # @see Wx::Menu#set_help_string # @see Wx::MenuItem # @param menuItem [Wx::MenuItem] A menuitem object. It will be owned by the {Wx::Menu} object after this function is called, so do not delete it yourself. # @return [Wx::MenuItem] def append(*args) end # Adds a checkable item to the end of the menu. # # @see Wx::Menu#append # @see Wx::Menu#insert_check_item # @param id [Integer] # @param item [String] # @param help [String] # @return [Wx::MenuItem] def append_check_item(id, item, help=('')) end # Adds a radio item to the end of the menu. # All consequent radio items form a group and when an item in the group is checked, all the others are automatically unchecked. # Radio items are not supported under {Wx::Motif}. # @see Wx::Menu#append # @see Wx::Menu#insert_radio_item # @param id [Integer] # @param item [String] # @param help [String] # @return [Wx::MenuItem] def append_radio_item(id, item, help=('')) end # Adds a separator to the end of the menu. # # @see Wx::Menu#append # @see Wx::Menu#insert_separator # @return [Wx::MenuItem] def append_separator; end # Adds the given submenu to this menu. # text is the text shown in the menu for it and help is the help string shown in the status bar when the submenu item is selected. # @see Wx::Menu#insert # @see Wx::Menu#prepend # @param submenu [Wx::Menu] # @param text [String] # @param help [String] # @return [Wx::MenuItem] def append_sub_menu(submenu, text, help=('')) end # Inserts a break in a menu, causing the next appended item to appear in a new column. # This function only actually inserts a break in {Wx::MSW} and does nothing under the other platforms. # @return [void] def break_; end # Checks or unchecks the menu item. # # @see Wx::Menu#is_checked # @param id [Integer] The menu item identifier. # @param check [true,false] If true, the item will be checked, otherwise it will be unchecked. # @return [void] def check(id, check) end # @overload delete(id) # Deletes the menu item from the menu. # If the item is a submenu, it will not be deleted. Use {Wx::Menu#destroy} if you want to delete a submenu. # @see Wx::Menu#find_item # @see Wx::Menu#destroy # @see Wx::Menu#remove # @param id [Integer] Id of the menu item to be deleted. # @return [true,false] # @overload delete(item) # Deletes the menu item from the menu. # If the item is a submenu, it will not be deleted. Use {Wx::Menu#destroy} if you want to delete a submenu. # @see Wx::Menu#find_item # @see Wx::Menu#destroy # @see Wx::Menu#remove # @param item [Wx::MenuItem] Menu item to be deleted. # @return [true,false] def delete(*args) end # @overload destroy(id) # Deletes the menu item from the menu. # If the item is a submenu, it will be deleted. Use {Wx::Menu#remove} if you want to keep the submenu (for example, to reuse it later). # @see Wx::Menu#find_item # @see Wx::Menu#delete # @see Wx::Menu#remove # @param id [Integer] Id of the menu item to be deleted. # @return [true,false] # @overload destroy(item) # Deletes the menu item from the menu. # If the item is a submenu, it will be deleted. Use {Wx::Menu#remove} if you want to keep the submenu (for example, to reuse it later). # @see Wx::Menu#find_item # @see Wx::Menu#delete # @see Wx::Menu#remove # @param item [Wx::MenuItem] Menu item to be deleted. # @return [true,false] def destroy(*args) end # Enables or disables (greys out) a menu item. # # @see Wx::Menu#is_enabled # @param id [Integer] The menu item identifier. # @param enable [true,false] true to enable the menu item, false to disable it. # @return [void] def enable(id, enable) end # Finds the menu item object associated with the given menu item identifier and, optionally, the position of the item in the menu. # Unlike {Wx::Menu#find_item}, this function doesn't recurse but only looks at the direct children of this menu. # # Menu item object or NULL if not found. # @param id [Integer] The identifier of the menu item to find. # @param pos [size_t] If the pointer is not NULL, it is filled with the item's position if it was found or (size_t){Wx::NOT_FOUND} otherwise. # @return [Wx::MenuItem] def find_child_item(id, pos=nil) end # @overload find_item(itemString) # Finds the menu id for a menu item string. # Menu item identifier, or {Wx::NOT_FOUND} if none is found. # # Any special menu codes are stripped out of source and target strings before matching. # @param itemString [String] Menu item string to find. # @return [Integer] # @overload find_item(id, menu=nil) # Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to. # Menu item object or NULL if none is found. # @param id [Integer] Menu item identifier. # @param menu [Wx::Menu] If the pointer is not NULL, it will be filled with the item's parent menu (if the item was found) # @return [Wx::MenuItem] def find_item(*args) end # Returns the {Wx::MenuItem} given a position in the menu. # @param position [Integer] # @return [Wx::MenuItem] def find_item_by_position(position) end # Returns the help string associated with a menu item. # The help string, or the empty string if there is no help string or the item was not found. # @see Wx::Menu#set_help_string # @see Wx::Menu#append # @param id [Integer] The menu item identifier. # @return [String] def get_help_string(id) end alias_method :help_string, :get_help_string # Returns a menu item label. # The item label, or the empty string if the item was not found. # @see Wx::Menu#get_label_text # @see Wx::Menu#set_label # @param id [Integer] The menu item identifier. # @return [String] def get_label(id) end alias_method :label, :get_label # Returns a menu item label, without any of the original mnemonics and accelerators. # The item label, or the empty string if the item was not found. # @see Wx::Menu#get_label # @see Wx::Menu#set_label # @param id [Integer] The menu item identifier. # @return [String] def get_label_text(id) end alias_method :label_text, :get_label_text # Returns the number of items in the menu. # @return [Integer] def get_menu_item_count; end alias_method :menu_item_count, :get_menu_item_count # Returns the title of the menu. # # @see Wx::Menu#set_title # @return [Wx::String] def get_title; end alias_method :title, :get_title # @overload insert(pos, menuItem) # Inserts the given item before the position pos. # Inserting the item at position {Wx::Menu#get_menu_item_count} is the same as appending it. # @see Wx::Menu#append # @see Wx::Menu#prepend # @param pos [Integer] # @param menuItem [Wx::MenuItem] # @return [Wx::MenuItem] # @overload insert(pos, id, item=(''), helpString=(''), kind=Wx::ItemKind::ITEM_NORMAL) # Inserts the given item before the position pos. # Inserting the item at position {Wx::Menu#get_menu_item_count} is the same as appending it. # @see Wx::Menu#append # @see Wx::Menu#prepend # @param pos [Integer] # @param id [Integer] # @param item [String] # @param helpString [String] # @param kind [ItemKind] # @return [Wx::MenuItem] # @overload insert(pos, id, text, submenu, help=('')) # Inserts the given submenu before the position pos. # text is the text shown in the menu for it and help is the help string shown in the status bar when the submenu item is selected. # @see Wx::Menu#append_sub_menu # @see Wx::Menu#prepend # @param pos [Integer] # @param id [Integer] # @param text [String] # @param submenu [Wx::Menu] # @param help [String] # @return [Wx::MenuItem] def insert(*args) end # Inserts a checkable item at the given position. # # @see Wx::Menu#insert # @see Wx::Menu#append_check_item # @param pos [Integer] # @param id [Integer] # @param item [String] # @param helpString [String] # @return [Wx::MenuItem] def insert_check_item(pos, id, item, helpString=('')) end # Inserts a radio item at the given position. # # @see Wx::Menu#insert # @see Wx::Menu#append_radio_item # @param pos [Integer] # @param id [Integer] # @param item [String] # @param helpString [String] # @return [Wx::MenuItem] def insert_radio_item(pos, id, item, helpString=('')) end # Inserts a separator at the given position. # # @see Wx::Menu#insert # @see Wx::Menu#append_separator # @param pos [Integer] # @return [Wx::MenuItem] def insert_separator(pos) end # Determines whether a menu item is checked. # true if the menu item is checked, false otherwise. # @see Wx::Menu#check # @param id [Integer] The menu item identifier. # @return [true,false] def is_checked(id) end alias_method :checked?, :is_checked # Determines whether a menu item is enabled. # true if the menu item is enabled, false otherwise. # @see Wx::Menu#enable # @param id [Integer] The menu item identifier. # @return [true,false] def is_enabled(id) end alias_method :enabled?, :is_enabled # Allows handling native MSW menu command messages. # This is a low-level function which allows handling MSW WM_COMMAND messages generated when menu items are selected. It is particularly useful for the popup menus, as specific handling can then be defined in a {Wx::Menu}-derived class directly, instead of in the {Wx::Window}-derived owner class. # The base class version of this function generates {Wx::EVT_MENU} command events. # # true if the command was handled, false otherwise. # # Availability: only available for the {Wx::MSW} port. {Wx::msw} # @param param [WXUINT] The MSW command parameter. # @param id [WXWORD] The id of the command. # @return [true,false] def msw_command(param, id) end # @overload prepend(item) # Inserts the given item at position 0, i.e. before all the other existing items. # # @see Wx::Menu#append # @see Wx::Menu#insert # @param item [Wx::MenuItem] # @return [Wx::MenuItem] # @overload prepend(id, item=(''), helpString=(''), kind=Wx::ItemKind::ITEM_NORMAL) # Inserts the given item at position 0, i.e. before all the other existing items. # # @see Wx::Menu#append # @see Wx::Menu#insert # @param id [Integer] # @param item [String] # @param helpString [String] # @param kind [ItemKind] # @return [Wx::MenuItem] # @overload prepend(id, text, submenu, help=('')) # Inserts the given submenu at position 0. # # @see Wx::Menu#append_sub_menu # @see Wx::Menu#insert # @param id [Integer] # @param text [String] # @param submenu [Wx::Menu] # @param help [String] # @return [Wx::MenuItem] def prepend(*args) end # Inserts a checkable item at position 0. # # @see Wx::Menu#prepend # @see Wx::Menu#append_check_item # @param id [Integer] # @param item [String] # @param helpString [String] # @return [Wx::MenuItem] def prepend_check_item(id, item, helpString=('')) end # Inserts a radio item at position 0. # # @see Wx::Menu#prepend # @see Wx::Menu#append_radio_item # @param id [Integer] # @param item [String] # @param helpString [String] # @return [Wx::MenuItem] def prepend_radio_item(id, item, helpString=('')) end # Inserts a separator at position 0. # # @see Wx::Menu#prepend # @see Wx::Menu#append_separator # @return [Wx::MenuItem] def prepend_separator; end # @overload remove(id) # Removes the menu item from the menu but doesn't delete the associated C++ object. # This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus). # # A pointer to the item which was detached from the menu. # @param id [Integer] The identifier of the menu item to remove. # @return [Wx::MenuItem] # @overload remove(item) # Removes the menu item from the menu but doesn't delete the associated C++ object. # This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus). # # A pointer to the item which was detached from the menu. # @param item [Wx::MenuItem] The menu item to remove. # @return [Wx::MenuItem] def remove(*args) end # Sets an item's help string. # # @see Wx::Menu#get_help_string # @param id [Integer] The menu item identifier. # @param helpString [String] The help string to set. # @return [void] def set_help_string(id, helpString) end # Sets the label of a menu item. # # @see Wx::Menu#append # @see Wx::Menu#get_label # @param id [Integer] The menu item identifier. # @param label [String] The menu item label to set. # @return [void] def set_label(id, label) end # Sets the title of the menu. # Notice that you can only call this method directly for the popup menus, to change the title of a menu that is part of a menu bar you need to use {Wx::MenuBar#set_label_top}. # @see Wx::Menu#get_title # @param title [String] The title to set. # @return [void] def set_title(title) end alias_method :title=, :set_title # Update the state of all menu items, recursively, by generating {Wx::EVT_UPDATE_UI} events for them. # This is an internal wxWidgets function and shouldn't normally be called from outside of the library. If it is called, source argument should not be used, it is deprecated and exists only for backwards compatibility. # @param source [Wx::EvtHandler] # @return [void] def update_ui(source=nil) end # @param win [Wx::Window] # @return [void] def set_invoking_window(win) end alias_method :invoking_window=, :set_invoking_window # @return [Wx::Window] def get_invoking_window; end alias_method :invoking_window, :get_invoking_window # @return [Wx::Window] def get_window; end alias_method :window, :get_window # @return [Integer] def get_style; end alias_method :style, :get_style # @param parent [Wx::Menu] # @return [void] def set_parent(parent) end alias_method :parent=, :set_parent # @return [Wx::Menu] def get_parent; end alias_method :parent, :get_parent # @param menubar [Wx::MenuBar] # @return [void] def attach(menubar) end # @return [void] def detach; end # @return [true,false] def is_attached; end alias_method :attached?, :is_attached end # Menu end