xtd 1.0.0
Loading...
Searching...
No Matches
menu.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "component.hpp"
8#include "menu_item_ref.hpp"
9#include <xtd/optional>
10#include <xtd/any>
11#include <xtd/iequatable>
12#include <map>
13
15namespace xtd {
17 namespace forms {
19 class context_menu;
20 class main_menu;
22
38 struct data;
39 public:
41
46
48
51 static constexpr xtd::int32 find_handle = 0;
53 static constexpr xtd::int32 find_shortcut = 1;
55
57 ~menu();
59
61
66 [[nodiscard]] auto handle() const noexcept -> xtd::intptr;
67
70 [[nodiscard]] virtual auto is_parent() const noexcept -> bool;
71
75 [[nodiscard]] auto mdi_list_item() const noexcept -> const xtd::forms::menu_item&;
76
80 [[nodiscard]] auto menu_items() const noexcept -> const menu_item_collection&;
84 [[nodiscard]] auto menu_items() noexcept -> menu_item_collection&;
89 auto menu_items(const menu_item_collection& value) -> menu&;
91 auto menu_items(const std::initializer_list<menu_item_ref>& value) -> menu&;
92 auto menu_items(const std::vector<menu_item_ref>& value) -> menu&;
94
98 [[nodiscard]] auto name() const noexcept -> const xtd::string&;
103 auto name(const xtd::string& value) -> menu&;
104
107 [[nodiscard]] auto tag() const noexcept -> const xtd::any_object&;
111 auto tag(const xtd::any_object& value) -> menu&;
113
115
120 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
124 [[nodiscard]] auto equals(const menu& other) const noexcept -> bool override;
125
128 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
129
133 [[nodiscard]] auto get_context_menu() const noexcept -> std::optional<xtd::ref<xtd::forms::context_menu>>;
134
138 [[nodiscard]] auto get_main_menu() const noexcept -> std::optional<xtd::ref<xtd::forms::main_menu>>;
139
143 virtual auto merge_menu(const menu& menu_src) -> void;
144
148 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
150
151 protected:
152 friend menu_item;
153
155
163 explicit menu(const menu_item_collection& items);
165
167 explicit menu(const std::initializer_list<menu_item_ref>& items);
168 explicit menu(const std::vector<menu_item_ref>& items);
169 menu(menu&& rhs);
170 menu(const menu&) = default;
171 menu& operator =(const menu&) = default;
173
175
180 auto clone_menu(const menu& menu_src) -> void;
181
184 [[nodiscard]] virtual auto create_menu_handle() -> xtd::intptr = 0;
185
188 virtual auto destroy_menu_handle(xtd::intptr handle) -> void;
189
190 virtual auto on_item_added(xtd::usize pos, xtd::forms::menu_item_ref item) -> void;
191 virtual auto on_item_removed(xtd::usize pos, xtd::forms::menu_item_ref item) -> void;
193
195 virtual auto create_menu() -> void;
196 virtual auto destroy_menu() -> void;
197 auto recreate_menu() -> void;
198
199 xtd::sptr<data> data_;
200 static std::map<intptr, xtd::ref<menu>> handles_;
202 };
203 }
204}
Contains xtd::forms::layout::arranged_element_collection collection.
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides the base implementation and enables object sharing between applications.
Definition component.hpp:26
Represents a shortcut menu.
Definition context_menu.hpp:35
Represents a collection of objects.
Definition arranged_element_collection.hpp:41
Represents the menu structure of a form.
Definition main_menu.hpp:41
auto to_string() const noexcept -> xtd::string override
Returns a string that represents the menu control.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
layout::arranged_element_collection< xtd::forms::menu_item_ref > menu_item_collection
Represents a collection of menu_item objects.
Definition menu.hpp:44
virtual auto destroy_menu_handle(xtd::intptr handle) -> void
Destroys the handle to the Menu.
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto clone_menu(const menu &menu_src) -> void
Copies the menu that is passed as a parameter to the current menu.
auto menu_items() const noexcept -> const menu_item_collection &
Gets a value indicating the collection of menu_item objects associated with the menu.
auto tag() const noexcept -> const xtd::any_object &
Gets user-defined data associated with the control.
menu()
Initializes a new instance of the Menu class.
auto name() const noexcept -> const xtd::string &
Gets the name of the menu.
auto get_main_menu() const noexcept -> std::optional< xtd::ref< xtd::forms::main_menu > >
Gets the main_menu that contains this menu.
static constexpr xtd::int32 find_shortcut
Specifies that the find_menu_item(int32, intptr) method should search for a shortcut.
Definition menu.hpp:53
auto handle() const noexcept -> xtd::intptr
Gets a value representing the window handle for the menu.
auto mdi_list_item() const noexcept -> const xtd::forms::menu_item &
Gets a value indicating the menu_item that is used to display a list of multiple document interface (...
static constexpr xtd::int32 find_handle
Specifies that the find_menu_item(int32, intptr) method should search for a handle.
Definition menu.hpp:51
virtual auto create_menu_handle() -> xtd::intptr=0
Creates a new handle to the Menu.
auto get_context_menu() const noexcept -> std::optional< xtd::ref< xtd::forms::context_menu > >
Gets the context_menu that contains this menu.
virtual auto merge_menu(const menu &menu_src) -> void
Merges the MenuItem objects of one menu with the current menu.
virtual auto is_parent() const noexcept -> bool
Gets a value indicating whether this menu contains any menu items.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Contains xtd::forms::component class.
Contains xtd::forms::menu_item_ref alias.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
xtd::reference_wrapper_object< type_t > ref
The xtd::ref object is a reference wrapper.
Definition ref.hpp:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
xtd::ref< xtd::forms::menu_item > menu_item_ref
Represents a menu item reference.
Definition menu_item_ref.hpp:23
Contains xtd::forms::menu_item_ref alias.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197