xtd 0.2.0
Loading...
Searching...
No Matches
menu.h
Go to the documentation of this file.
1
4#pragma once
6#include "component.h"
8#include "menu_item_ref.h"
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 std::any tag() const noexcept;
112 menu& tag(std::any value);
114
116
118 using object::equals;
119 bool equals(const menu&) const noexcept override;
120
124 std::optional<std::reference_wrapper<context_menu>> get_context_menu() const noexcept;
125
129 std::optional<std::reference_wrapper<main_menu>> get_main_menu() const noexcept;
130
134 virtual void merge_menu(const menu& menu_src);
135
139 xtd::string to_string() const noexcept override;
141
142 protected:
143 friend menu_item;
144
146
154 explicit menu(const menu_item_collection& items);
156
158 explicit menu(const std::initializer_list<menu_item_ref>& items);
159 explicit menu(const std::vector<menu_item_ref>& items);
160 menu(menu&& rhs);
161 menu(const menu&) = default;
162 menu& operator =(const menu&) = default;
164
166
171 void clone_menu(const menu& menu_src);
172
175 virtual intptr create_menu_handle() = 0;
176
179 virtual void destroy_menu_handle(intptr handle);
180
181 virtual void on_item_added(size_t pos, menu_item_ref item);
182 virtual void on_item_removed(size_t pos, menu_item_ref item);
184
186 virtual void create_menu();
187 virtual void destroy_menu();
188 void recreate_menu();
189
190 xtd::sptr<data> data_;
191 static std::map<intptr, std::reference_wrapper<menu>> handles_;
193 };
194 }
195}
Contains xtd::forms::layout::arranged_element_collection collection.
Provides the base implementation and enables object sharing between applications.
Definition component.h:25
Represents a shortcut menu.
Definition context_menu.h:36
Represents a collection of objects.
Definition arranged_element_collection.h:34
Represents the menu structure of a form.
Definition main_menu.h:41
Represents an individual item that is displayed within a main_menu or context_menu.
Definition menu_item.h:31
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h: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.h:22
Contains xtd::forms::component class.
Contains xtd::forms::menu_item_ref alias.
#define forms_export_
Define shared library export.
Definition forms_export.h:13
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.h:181
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
std::reference_wrapper< menu_item > menu_item_ref
Represents a menu item reference.
Definition menu_item_ref.h: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.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10