xtd 0.2.0
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
37 class forms_export_ menu : public component, public xtd::iequatable<menu> {
38 struct data;
39 public:
41
46
48
51 static constexpr int32 find_handle = 0;
53 static constexpr int32 find_shortcut = 1;
55
57 ~menu();
59
61
66 intptr handle() const noexcept;
67
70 virtual bool is_parent() const noexcept;
71
75 const menu_item& mdi_list_item() const noexcept;
76
80 const menu_item_collection& menu_items() const noexcept;
84 menu_item_collection& menu_items() noexcept;
89 menu& menu_items(const menu_item_collection& value);
91 menu& menu_items(const std::initializer_list<menu_item_ref>& value);
92 menu& menu_items(const std::vector<menu_item_ref>& value);
94
98 const xtd::string& name() const noexcept;
99
104 menu& name(const xtd::string& value);
105
108 const xtd::any_object& tag() const noexcept;
112 menu& tag(const xtd::any_object& value);
114
116
121 bool equals(const xtd::object& obj) const noexcept override;
125 bool equals(const menu& other) const noexcept override;
126
129 xtd::size get_hash_code() const noexcept override;
130
134 std::optional<std::reference_wrapper<context_menu>> get_context_menu() const noexcept;
135
139 std::optional<std::reference_wrapper<main_menu>> get_main_menu() const noexcept;
140
144 virtual void merge_menu(const menu& menu_src);
145
149 xtd::string to_string() const noexcept override;
151
152 protected:
153 friend menu_item;
154
156
164 explicit menu(const menu_item_collection& items);
166
168 explicit menu(const std::initializer_list<menu_item_ref>& items);
169 explicit menu(const std::vector<menu_item_ref>& items);
170 menu(menu&& rhs);
171 menu(const menu&) = default;
172 menu& operator =(const menu&) = default;
174
176
181 void clone_menu(const menu& menu_src);
182
185 virtual intptr create_menu_handle() = 0;
186
189 virtual void destroy_menu_handle(intptr handle);
190
191 virtual void on_item_added(size_t pos, menu_item_ref item);
192 virtual void on_item_removed(size_t pos, menu_item_ref item);
194
196 virtual void create_menu();
197 virtual void destroy_menu();
198 void recreate_menu();
199
200 xtd::sptr<data> data_;
201 static std::map<intptr, std::reference_wrapper<menu>> handles_;
203 };
204 }
205}
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:25
Represents a shortcut menu.
Definition context_menu.hpp:36
Represents a collection of objects.
Definition arranged_element_collection.hpp:35
Represents the menu structure of a form.
Definition main_menu.hpp:41
Represents an individual item that is displayed within a main_menu or context_menu.
Definition menu_item.hpp:31
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.hpp:37
intptr handle() const noexcept
Gets a value representing the window handle for the menu.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Contains xtd::forms::component class.
Contains xtd::forms::menu_item_ref alias.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:175
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::reference_wrapper< 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 xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10