xtd - Reference Guide
0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <menu_item.h>
Represents an individual item that is displayed within a main_menu or context_menu.
Inherits xtd::forms::menu.
Public Member Functions | |
menu_item () | |
Initializes a menu_item with a blank caption. | |
menu_item (const xtd::ustring &text) | |
Initializes a new instance of the menu_item class with a specified caption for the menu item. | |
menu_item (const xtd::ustring &text, const std::vector< menu_item > &items) | |
Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image) | |
Initializes a new instance of the class with a specified caption, and image menu item. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind) | |
Initializes a new instance of the class with a specified caption, image menu item, and kind the menu item. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked) | |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and checked. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, checked, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::drawing::image &image, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, and image menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click) | |
Initializes a new instance of the class with a specified caption and event handler for the Click event of the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image) | |
Initializes a new instance of the class with a specified caption, event handler, and image menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind) | |
Initializes a new instance of the class with a specified caption, event handler, image menu item, and kind the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked) | |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and checked. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, checked, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, const xtd::drawing::image &image, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, and image menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, xtd::forms::menu_item_kind kind) | |
Initializes a new instance of the class with a specified caption, event handler, and kind the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, xtd::forms::menu_item_kind kind, bool checked) | |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item and checked. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item, checked, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, const xtd::event_handler &on_click, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, event handler, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, xtd::forms::menu_item_kind kind) | |
Initializes a new instance of the class with a specified caption, and kind the menu item. | |
menu_item (const xtd::ustring &text, xtd::forms::menu_item_kind kind, bool checked) | |
Initializes a new instance of the class with a specified caption, kind the menu item and checked. | |
menu_item (const xtd::ustring &text, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, kind the menu item, checked, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, kind the menu item, and associated shortcut key for the menu item. | |
menu_item (const xtd::ustring &text, xtd::forms::shortcut shortcut) | |
Initializes a new instance of the class with a specified caption, and associated shortcut key for the menu item. | |
bool | checked () const |
Gets a value indicating whether a check mark appears next to the text of the menu item. | |
menu_item & | checked (bool value) |
Sets a value indicating whether a check mark appears next to the text of the menu item. | |
bool | enabled () const |
Gets a value indicating whether the menu item is enabled. | |
menu_item & | enabled (bool value) |
Gets a value indicating whether the menu item is enabled. | |
xtd::forms::menu_item_kind | kind () const |
Gets a value that represents the kind of menu item. | |
menu_item & | kind (xtd::forms::menu_item_kind value) |
Gets a value that represents the kind of menu item. | |
int32_t | menu_id () const |
Gets a value indicating the Windows identifier for this menu item. | |
xtd::forms::shortcut | shortcut () const |
Gets a value indicating the shortcut key associated with the menu item. | |
menu_item & | shortcut (xtd::forms::shortcut value) |
Sets a value indicating the shortcut key associated with the menu item. | |
const xtd::ustring & | text () const |
Gets a value indicating the caption of the menu item. | |
menu_item & | text (const xtd::ustring &value) |
Sets a value indicating the caption of the menu item. | |
xtd::ustring | to_string () const noexcept override |
Returns a string that represents the menu control. | |
Public Member Functions inherited from xtd::forms::menu | |
std::optional< context_menu > | get_context_menu () const |
Gets the context_menu that contains this menu. | |
std::optional< main_menu > | get_main_menu () const |
Gets the main_menu that contains this menu. | |
intptr_t | handle () const |
Gets a value representing the window handle for the menu. | |
bool | is_parent () const |
Gets a value indicating whether this menu contains any menu items. | |
const menu_item & | mdi_list_item () const |
Gets a value indicating the menu_item that is used to display a list of multiple document interface (MDI) child forms. | |
menu_item_collection & | menu_items () |
Gets a value indicating the collection of menu_item objects associated with the menu. | |
const menu_item_collection & | menu_items () const |
Gets a value indicating the collection of menu_item objects associated with the menu. | |
menu & | menu_items (const menu_item_collection &value) |
Sets a value indicating the collection of menu_item objects associated with the menu. | |
virtual void | merge_menu (const menu &menu_src) |
Merges the MenuItem objects of one menu with the current menu. | |
const xtd::ustring & | name () const |
Gets the name of the menu. | |
menu & | name (const xtd::ustring &value) |
Sets the name of the menu. | |
std::any | tag () const |
Gets user-defined data associated with the control. | |
menu & | tag (std::any value) |
Sets user-defined data associated with the control. | |
xtd::ustring | to_string () const noexcept override |
Returns a string that represents the menu control. | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
template<typename object_t > | |
std::unique_ptr< object_t > | memberwise_clone () const |
Gets the type of the current instance. | |
virtual xtd::ustring | to_string () const noexcept |
Returns a std::string that represents the current object. | |
Protected Attributes | |
friend | context_menu |
friend | main_menu |
Protected Member Functions | |
intptr_t | create_menu_handle () override |
Creates a new handle to the Menu. | |
void | destroy_menu_handle (intptr_t handle) override |
Destroy the handle to the Menu. | |
virtual void | on_menu_item_updated (const event_args &e) |
Protected Member Functions inherited from xtd::forms::menu | |
menu () | |
Initializes a new instance of the Menu class. | |
menu (const menu_item_collection &items) | |
Initializes a new instance of the Menu class. | |
void | clone_menu (const menu &menu_src) |
Copies the menu that is passed as a parameter to the current menu. | |
virtual intptr_t | create_menu_handle ()=0 |
Creates a new handle to the Menu. | |
virtual void | destroy_menu_handle (intptr_t handle)=0 |
Destroy the handle to the Menu. | |
Protected Member Functions inherited from xtd::forms::component | |
component ()=default | |
Initialises a new instance of the component class. | |
virtual bool | can_raise_events () const |
Gets a value indicating whether the component can raise an event. | |
bool | design_mode () const |
Gets a value that indicates whether the component is currently in design mode. | |
Additional Inherited Members | |
Public Types inherited from xtd::forms::menu | |
using | menu_item_collection = layout::arranged_element_collection< menu_item > |
Represents a collection of menu_item objects. | |
Static Public Attributes inherited from xtd::forms::menu | |
static constexpr const int | find_handle |
Specifies that the find_menu_item(int32_t, intptr_t) method should search for a handle. | |
static constexpr const int | find_shortcut |
Specifies that the find_menu_item(int32_t, intptr_t) method should search for a shortcut. | |
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. | |
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
xtd::forms::menu_item::menu_item | ( | ) |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text | ) |
Initializes a new instance of the menu_item class with a specified caption for the menu item.
text | The caption for the menu item. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, and associated shortcut key for the menu item.
text | The caption for the menu item. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image | ||
) |
Initializes a new instance of the class with a specified caption, and image menu item.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, and image menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
xtd::forms::menu_item_kind | kind | ||
) |
Initializes a new instance of the class with a specified caption, and kind the menu item.
text | The caption for the menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
xtd::forms::menu_item_kind | kind, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, kind the menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind | ||
) |
Initializes a new instance of the class with a specified caption, image menu item, and kind the menu item.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
xtd::forms::menu_item_kind | kind, | ||
bool | checked | ||
) |
Initializes a new instance of the class with a specified caption, kind the menu item and checked.
text | The caption for the menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
xtd::forms::menu_item_kind | kind, | ||
bool | checked, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, kind the menu item, checked, and associated shortcut key for the menu item.
text | The caption for the menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked | ||
) |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and checked.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.
text | The caption for the menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click | ||
) |
Initializes a new instance of the class with a specified caption and event handler for the Click event of the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image | ||
) |
Initializes a new instance of the class with a specified caption, event handler, and image menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, and image menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
xtd::forms::menu_item_kind | kind | ||
) |
Initializes a new instance of the class with a specified caption, event handler, and kind the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
xtd::forms::menu_item_kind | kind, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind | ||
) |
Initializes a new instance of the class with a specified caption, event handler, image menu item, and kind the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked | ||
) |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item and checked.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, kind the menu item, checked, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked | ||
) |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and checked.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const xtd::event_handler & | on_click, | ||
const xtd::drawing::image & | image, | ||
xtd::forms::menu_item_kind | kind, | ||
bool | checked, | ||
xtd::forms::shortcut | shortcut | ||
) |
Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.
text | The caption for the menu item. |
on_click | The event_handler that handles the Click event for this menu item. |
image | A xtd::drawing::image menu item. |
kind | One of the xtd::forms::menu_item_kind value. |
checked | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
shortcut | One of the xtd::forms::shortcut values. |
xtd::forms::menu_item::menu_item | ( | const xtd::ustring & | text, |
const std::vector< menu_item > & | items | ||
) |
Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item.
text | The caption for the menu item. |
items | An array of menu_item objects that contains the submenu items for this menu item. |
|
inline |
Gets a value indicating whether a check mark appears next to the text of the menu item.
|
inline |
Sets a value indicating whether a check mark appears next to the text of the menu item.
value | true if there is a check mark next to the menu item; otherwise, false. The default is false. |
|
overrideprotectedvirtual |
Creates a new handle to the Menu.
Implements xtd::forms::menu.
|
overrideprotectedvirtual |
|
inline |
Gets a value indicating whether the menu item is enabled.
|
inline |
Gets a value indicating whether the menu item is enabled.
value | true if the menu item is enabled; otherwise, false. The default is true. |
|
inline |
Gets a value that represents the kind of menu item.
|
inline |
Gets a value that represents the kind of menu item.
value | One of the xtd::forms::menu_item_kind value. |
int32_t xtd::forms::menu_item::menu_id | ( | ) | const |
Gets a value indicating the Windows identifier for this menu item.
|
inline |
Gets a value indicating the shortcut key associated with the menu item.
|
inline |
Sets a value indicating the shortcut key associated with the menu item.
value | One of the xtd::forms::shortcut values. The default is xtd::forms::shortcut::none. |
|
inline |
Gets a value indicating the caption of the menu item.
|
inline |
Sets a value indicating the caption of the menu item.
value | The text caption of the menu item. |
|
overridevirtualnoexcept |
Returns a string that represents the menu control.
Reimplemented from xtd::forms::menu.