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
35 class forms_export_ menu : public component, public xtd::iequatable<menu> {
36 struct data;
37 public:
39
44
46
49 static constexpr int32 find_handle = 0;
51 static constexpr int32 find_shortcut = 1;
53
55 ~menu();
57
59
64 intptr handle() const noexcept;
65
68 virtual bool is_parent() const noexcept;
69
73 const menu_item& mdi_list_item() const noexcept;
74
78 const menu_item_collection& menu_items() const noexcept;
82 menu_item_collection& menu_items() noexcept;
87 menu& menu_items(const menu_item_collection& value);
89 menu& menu_items(const std::initializer_list<menu_item_ref>& value);
90 menu& menu_items(const std::vector<menu_item_ref>& value);
92
96 const xtd::ustring& name() const noexcept;
97
102 menu& name(const xtd::ustring& value);
103
106 std::any tag() const noexcept;
110 menu& tag(std::any value);
112
114
116 bool equals(const menu&) const noexcept override;
117
121 std::optional<std::reference_wrapper<context_menu>> get_context_menu() const noexcept;
122
126 std::optional<std::reference_wrapper<main_menu>> get_main_menu() const noexcept;
127
131 virtual void merge_menu(const menu& menu_src);
132
136 xtd::ustring to_string() const noexcept override;
138
139 protected:
140 friend menu_item;
141
143
151 explicit menu(const menu_item_collection& items);
153
155 explicit menu(const std::initializer_list<menu_item_ref>& items);
156 explicit menu(const std::vector<menu_item_ref>& items);
157 menu(menu&& rhs);
158 menu(const menu&) = default;
159 menu& operator =(const menu&) = default;
161
163
168 void clone_menu(const menu& menu_src);
169
172 virtual intptr create_menu_handle() = 0;
173
176 virtual void destroy_menu_handle(intptr handle);
177
178 virtual void on_item_added(size_t pos, menu_item_ref item);
179 virtual void on_item_removed(size_t pos, menu_item_ref item);
181
183 virtual void create_menu();
184 virtual void destroy_menu();
185 void recreate_menu();
186
187 std::shared_ptr<data> data_;
188 static std::map<intptr, std::reference_wrapper<menu>> handles_;
190 };
191 }
192}
Contains xtd::forms::layout::arranged_element_collection collection.
Provides the base implementation and enables object sharing between applications.
Definition component.h:23
Represents a shortcut menu.
Definition context_menu.h:34
Represents a collection of objects.
Definition arranged_element_collection.h:32
Represents the menu structure of a form.
Definition main_menu.h:39
Represents an individual item that is displayed within a main_menu or context_menu.
Definition menu_item.h:29
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h:35
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:18
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Contains xtd::forms::component class.
Contains xtd::forms::menu_item_ref alias.
#define forms_export_
Define shared library export.
Definition forms_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
intmax_t intptr
Represent a pointer or a handle.
Definition types.h:153
std::reference_wrapper< menu_item > menu_item_ref
Represents a menu item reference.
Definition menu_item_ref.h:21
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