Represents the menu structure of a form.
| Windows | macOS | Gnome | |
|---|---|---|---|
| Light |
html menus_and_toolbars_main_menu_m.png html menus_and_toolbars_main_menu_g.png | ||
| Dark |
html menus_and_toolbars_main_menu_md.png html menus_and_toolbars_main_menu_gd.png |
Constructors | |
| main_menu () | |
| Initialize a new instance of main_menu class. More... | |
| main_menu (const std::vector< menu_item_ref > &menu_items) | |
| Initialize a new instance of main_menu class. More... | |
Methods | |
| static xtd::forms::main_menu | create_standard_items (const xtd::event_handler &on_click) |
| A factory to create a main menu with specified on click event handler. More... | |
| static xtd::forms::main_menu | create_standard_items (const xtd::drawing::size &image_size, const xtd::event_handler &on_click) |
| A factory to create a main menu with specified image size and on click event handler. More... | |
| static xtd::forms::main_menu | create_standard_items (const xtd::ustring &theme, const xtd::event_handler &on_click) |
| A factory to create a main menu with specified theme and on click event handler. More... | |
| static xtd::forms::main_menu | create_standard_items (const xtd::ustring &theme, const xtd::drawing::size &size, const xtd::event_handler &on_click) |
| A factory to create a main menu with specified theme, image size and on click event handler. More... | |
Protected methods | |
| intptr | create_menu_handle () override |
| Creates a new handle to the Menu. More... | |
| void | destroy_menu_handle (intptr handle) override |
| Destroys the handle to the Menu. More... | |
| void | on_item_added (size_t pos, menu_item_ref item) override |
| void | on_item_removed (size_t pos, menu_item_ref item) override |
Additional Inherited Members | |
Public Types inherited from xtd::forms::menu | |
| using | menu_item_collection = layout::arranged_element_collection< menu_item_ref > |
| Represents a collection of menu_item objects. More... | |
Static Public Attributes inherited from xtd::forms::menu | |
| static constexpr int32 | find_handle = 0 |
| Specifies that the find_menu_item(int32, intptr) method should search for a handle. More... | |
| static constexpr int32 | find_shortcut = 1 |
| Specifies that the find_menu_item(int32, intptr) method should search for a shortcut. More... | |
Public Member Functions inherited from xtd::forms::menu | |
| intptr | handle () const noexcept |
| Gets a value representing the window handle for the menu. More... | |
| virtual bool | is_parent () const noexcept |
| Gets a value indicating whether this menu contains any menu items. More... | |
| const menu_item & | mdi_list_item () const noexcept |
| Gets a value indicating the menu_item that is used to display a list of multiple document interface (MDI) child forms. More... | |
| const menu_item_collection & | menu_items () const noexcept |
| Gets a value indicating the collection of menu_item objects associated with the menu. More... | |
| menu_item_collection & | menu_items () noexcept |
| Gets a value indicating the collection of menu_item objects associated with the menu. More... | |
| menu & | menu_items (const menu_item_collection &value) |
| Sets a value indicating the collection of menu_item objects associated with the menu. More... | |
| const xtd::ustring & | name () const noexcept |
| Gets the name of the menu. More... | |
| menu & | name (const xtd::ustring &value) |
| Sets the name of the menu. More... | |
| std::any | tag () const noexcept |
| Gets user-defined data associated with the control. More... | |
| menu & | tag (std::any value) |
| Sets user-defined data associated with the control. More... | |
| bool | equals (const menu &) const noexcept override |
| std::optional< std::reference_wrapper< context_menu > > | get_context_menu () const noexcept |
| Gets the context_menu that contains this menu. More... | |
| std::optional< std::reference_wrapper< main_menu > > | get_main_menu () const noexcept |
| Gets the main_menu that contains this menu. More... | |
| virtual void | merge_menu (const menu &menu_src) |
| Merges the MenuItem objects of one menu with the current menu. More... | |
| xtd::ustring | to_string () const noexcept override |
| Returns a string that represents the menu control. More... | |
Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object. More... | |
| bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More... | |
| virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More... | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. More... | |
| template<typename object_t > | |
| std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Creates a shallow copy of the current object. More... | |
Public Member Functions inherited from xtd::iequatable< menu > | |
| virtual bool | equals (const menu &) const noexcept=0 |
| Indicates whether the current object is equal to another object of the same type. More... | |
Static Public Member Functions inherited from xtd::object | |
| static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. More... | |
| static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More... | |
Protected Attributes inherited from xtd::forms::menu | |
| friend | menu_item |
Protected Member Functions inherited from xtd::forms::menu | |
| menu () | |
| Initializes a new instance of the Menu class. More... | |
| menu (const menu_item_collection &items) | |
| Initializes a new instance of the Menu class. More... | |
| void | clone_menu (const menu &menu_src) |
| Copies the menu that is passed as a parameter to the current menu. More... | |
Protected Member Functions inherited from xtd::forms::component | |
| component () | |
| Initialises a new instance of the component class. More... | |
| virtual bool | can_raise_events () const noexcept |
| Gets a value indicating whether the component can raise an event. More... | |
| bool | design_mode () const noexcept |
| Gets a value that indicates whether the component is currently in design mode. More... | |
| xtd::forms::main_menu::main_menu | ( | ) |
Initialize a new instance of main_menu class.
|
explicit |
|
overrideprotectedvirtual |
Creates a new handle to the Menu.
Implements xtd::forms::menu.
|
static |
A factory to create a main menu with specified on click event handler.
| menu_items | an array xtd::forms::menu_item which will contain the created menu items. |
| on_click | an event handler to respond on lick event. |
| menu_index | sub_menu_index | menu_item | sub_menu_item |
|---|---|---|---|
| 0 | file | ||
| 0 | 0 | file | new |
| 0 | 1 | file | open |
| 0 | 2 | file | separator1 |
| 0 | 3 | file | save |
| 0 | 4 | file | save_as |
| 0 | 5 | file | separator2 |
| 0 | 6 | file | |
| 0 | 7 | file | print_preview |
| 0 | 8 | file | separator3 |
| 0 | 9 | file | exit |
| 1 | edit | ||
| 1 | 0 | edit | undo |
| 1 | 1 | edit | redo |
| 1 | 2 | edit | separator1 |
| 1 | 3 | edit | cut |
| 1 | 4 | edit | copy |
| 1 | 6 | edit | paste |
| 1 | 6 | edit | separator2 |
| 1 | 7 | edit | select_all |
| 2 | tools | ||
| 2 | 0 | tools | customize |
| 2 | 1 | tools | options |
| 3 | help | ||
| 3 | 0 | help | contents |
| 3 | 1 | help | index |
| 3 | 2 | help | search |
| 3 | 3 | help | separator1 |
| 3 | 4 | help | about |
|
static |
A factory to create a main menu with specified image size and on click event handler.
| menu_items | an array xtd::forms::menu_item which will contain the created menu items. |
| image_size | A xtd::drawing::size that represent the menu item image size. |
| on_click | an event handler to respond on lick event. |
| menu_index | sub_menu_index | menu_item | sub_menu_item |
|---|---|---|---|
| 0 | file | ||
| 0 | 0 | file | new |
| 0 | 1 | file | open |
| 0 | 2 | file | separator1 |
| 0 | 3 | file | save |
| 0 | 4 | file | save_as |
| 0 | 5 | file | separator2 |
| 0 | 6 | file | |
| 0 | 7 | file | print_preview |
| 0 | 8 | file | separator3 |
| 0 | 9 | file | exit |
| 1 | edit | ||
| 1 | 0 | edit | undo |
| 1 | 1 | edit | redo |
| 1 | 2 | edit | separator1 |
| 1 | 3 | edit | cut |
| 1 | 4 | edit | copy |
| 1 | 6 | edit | paste |
| 1 | 6 | edit | separator2 |
| 1 | 7 | edit | select_all |
| 2 | tools | ||
| 2 | 0 | tools | customize |
| 2 | 1 | tools | options |
| 3 | help | ||
| 3 | 0 | help | contents |
| 3 | 1 | help | index |
| 3 | 2 | help | search |
| 3 | 3 | help | separator1 |
| 3 | 4 | help | about |
|
static |
A factory to create a main menu with specified theme and on click event handler.
| menu_items | an array xtd::forms::menu_item which will contain the created menu items. |
| theme | The theme of menu item image. |
| on_click | an event handler to respond on lick event. |
| menu_index | sub_menu_index | menu_item | sub_menu_item |
|---|---|---|---|
| 0 | file | ||
| 0 | 0 | file | new |
| 0 | 1 | file | open |
| 0 | 2 | file | separator1 |
| 0 | 3 | file | save |
| 0 | 4 | file | save_as |
| 0 | 5 | file | separator2 |
| 0 | 6 | file | |
| 0 | 7 | file | print_preview |
| 0 | 8 | file | separator3 |
| 0 | 9 | file | exit |
| 1 | edit | ||
| 1 | 0 | edit | undo |
| 1 | 1 | edit | redo |
| 1 | 2 | edit | separator1 |
| 1 | 3 | edit | cut |
| 1 | 4 | edit | copy |
| 1 | 6 | edit | paste |
| 1 | 6 | edit | separator2 |
| 1 | 7 | edit | select_all |
| 2 | tools | ||
| 2 | 0 | tools | customize |
| 2 | 1 | tools | options |
| 3 | help | ||
| 3 | 0 | help | contents |
| 3 | 1 | help | index |
| 3 | 2 | help | search |
| 3 | 3 | help | separator1 |
| 3 | 4 | help | about |
|
static |
A factory to create a main menu with specified theme, image size and on click event handler.
| menu_items | an array xtd::forms::menu_item which will contain the created menu items. |
| theme | The theme of menu item image. |
| image_size | A xtd::drawing::size that represent the menu item image size. |
| on_click | an event handler to respond on lick event. |
| menu_index | sub_menu_index | menu_item | sub_menu_item |
|---|---|---|---|
| 0 | file | ||
| 0 | 0 | file | new |
| 0 | 1 | file | open |
| 0 | 2 | file | separator1 |
| 0 | 3 | file | save |
| 0 | 4 | file | save_as |
| 0 | 5 | file | separator2 |
| 0 | 6 | file | |
| 0 | 7 | file | print_preview |
| 0 | 8 | file | separator3 |
| 0 | 9 | file | exit |
| 1 | edit | ||
| 1 | 0 | edit | undo |
| 1 | 1 | edit | redo |
| 1 | 2 | edit | separator1 |
| 1 | 3 | edit | cut |
| 1 | 4 | edit | copy |
| 1 | 6 | edit | paste |
| 1 | 6 | edit | separator2 |
| 1 | 7 | edit | select_all |
| 2 | tools | ||
| 2 | 0 | tools | customize |
| 2 | 1 | tools | options |
| 3 | help | ||
| 3 | 0 | help | contents |
| 3 | 1 | help | index |
| 3 | 2 | help | search |
| 3 | 3 | help | separator1 |
| 3 | 4 | help | about |
|
overrideprotectedvirtual |
Destroys the handle to the Menu.
| handle | A handle to the menu. |
Reimplemented from xtd::forms::menu.