xtd 0.2.0
Loading...
Searching...
No Matches
menu_item.h
Go to the documentation of this file.
1
4#pragma once
5#include "menu.h"
6#include "menu_item_kind.h"
7#include "shortcut.h"
8#include <xtd/drawing/image>
9#include <xtd/event>
10#include <xtd/iclonable>
11
13namespace xtd {
15 namespace forms {
17 class main_menu;
18 class context_menu;
20
30 struct data;
31
32 public:
34
43 explicit menu_item(const xtd::ustring& text);
55 menu_item(const xtd::ustring& text, const xtd::drawing::image& image);
97 menu_item(const xtd::ustring& text, xtd::forms::menu_item_kind kind, bool checked);
113 menu_item(const xtd::ustring& text, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked);
142 menu_item(const xtd::ustring& text, xtd::event_handler on_click, const xtd::drawing::image& image);
190 menu_item(const xtd::ustring& text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind, bool checked);
208 menu_item(const xtd::ustring& text, xtd::event_handler on_click, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked);
219
221 template<typename delegate_type>
222 menu_item(const xtd::ustring& text, delegate_type on_click) : menu_item(text, xtd::event_handler(on_click)) {}
223 template<typename delegate_type>
224 menu_item(const xtd::ustring& text, delegate_type on_click, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), shortcut) {}
225 template<typename delegate_type>
226 menu_item(const xtd::ustring& text, delegate_type on_click, const xtd::drawing::image& image) : menu_item(text, xtd::event_handler(on_click), image) {}
227 template<typename delegate_type>
228 menu_item(const xtd::ustring& text, delegate_type on_click, const xtd::drawing::image& image, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), image, shortcut) {}
229 template<typename delegate_type>
230 menu_item(const xtd::ustring& text, delegate_type on_click, xtd::forms::menu_item_kind kind) : menu_item(text, xtd::event_handler(on_click), kind) {}
231 template<typename delegate_type>
232 menu_item(const xtd::ustring& text, delegate_type on_click, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), kind, shortcut) {}
233 template<typename delegate_type>
234 menu_item(const xtd::ustring& text, delegate_type on_click, xtd::forms::menu_item_kind kind, bool checked) : menu_item(text, xtd::event_handler(on_click), kind, checked) {}
235 template<typename delegate_type>
236 menu_item(const xtd::ustring& text, delegate_type on_click, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), kind, checked, shortcut) {}
237 template<typename delegate_type>
238 menu_item(const xtd::ustring& text, delegate_type on_click, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked) : menu_item(text, xtd::event_handler(on_click), image, kind, checked) {}
239 template<typename delegate_type>
240 menu_item(const xtd::ustring& text, delegate_type on_click, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), image, kind, checked, shortcut) {}
241 menu_item(const xtd::ustring& text, const std::initializer_list<const_menu_item_ref>& items);
243
250 menu_item(const xtd::ustring& text, const std::vector<menu_item_ref>& items);
251 menu_item(menu_item&&) = default;
252 menu_item(const menu_item&) = default;
253 menu_item& operator =(const menu_item&) = default;
255
257
261 intptr menu_id() const noexcept;
262
265 bool checked() const noexcept;
269 menu_item& checked(bool value);
270
273 bool enabled() const noexcept;
277 menu_item& enabled(bool value);
278
279 bool is_parent() const noexcept override;
280
283 xtd::forms::menu_item_kind kind() const noexcept;
288
291 xtd::forms::shortcut shortcut() const noexcept;
296
301 const xtd::ustring& text() const noexcept;
307 menu_item& text(const xtd::ustring& value);
309
311
315 void perform_click();
316
320 xtd::ustring to_string() const noexcept override;
322
324
331
332 protected:
333 friend main_menu;
334 friend context_menu;
335
337
343 std::unique_ptr<xtd::object> clone() const override;
344
345 intptr create_menu_handle() override;
346 void destroy_menu_handle(intptr handle) override;
347
351 virtual void on_click(const event_args& e);
352
353 void on_item_added(size_t pos, menu_item_ref item) override;
354 void on_item_removed(size_t pos, menu_item_ref item) override;
356
357 private:
358 std::shared_ptr<data> data_;
359 };
360 }
361}
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:49
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Represents an event.
Definition event.h:21
Represents a shortcut menu.
Definition context_menu.h:34
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
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, 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,...
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,...
menu_item(const xtd::ustring &text, 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,...
menu_item(const xtd::ustring &text, xtd::event_handler on_click)
Initializes a new instance of the class with a specified caption and event handler for the Click even...
intptr menu_id() const noexcept
Gets a value indicating the Windows identifier for this 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.
menu_item(const xtd::ustring &text, 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,...
menu_item()
Initializes a menu_item with a blank caption.
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,...
menu_item(const xtd::ustring &text, xtd::event_handler on_click, xtd::forms::shortcut shortcut)
Initializes a new instance of the class with a specified caption, event handler, and associated short...
menu_item(const xtd::ustring &text, 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,...
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,...
menu_item(const xtd::ustring &text, 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 it...
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(const xtd::ustring &text, 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::drawing::image &image)
Initializes a new instance of the class with a specified caption, and image 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,...
menu_item(const xtd::ustring &text, 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,...
menu_item(const xtd::ustring &text, 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,...
menu_item(const xtd::ustring &text, 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,...
menu_item(const xtd::ustring &text, const std::vector< menu_item_ref > &items)
Initializes a new instance of the class with a specified caption and an array of submenu items define...
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,...
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,...
menu_item(const xtd::ustring &text, 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,...
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::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 a...
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h:35
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.h:19
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.h:32
#define forms_export_
Define shared library export.
Definition forms_export.h:13
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
shortcut
Specifies shortcut keys that can be used by menu items.
Definition shortcut.h:21
menu_item_kind
Represent menu item kind used by xtd::forms::menu_item component.
Definition menu_item_kind.h:19
@ checked
The button has a checked or latched appearance. Use this appearance to show that a toggle button has ...
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
Contains xtd::forms::menu menu.
Contains xtd::forms::menu_item_kind enum class.
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
Contains xtd::forms::shortcut enum class.