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
32 struct data;
33
34 public:
36
45 explicit menu_item(const xtd::string& text);
57 menu_item(const xtd::string& text, const xtd::drawing::image& image);
99 menu_item(const xtd::string& text, xtd::forms::menu_item_kind kind, bool checked);
115 menu_item(const xtd::string& text, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked);
144 menu_item(const xtd::string& text, xtd::event_handler on_click, const xtd::drawing::image& image);
192 menu_item(const xtd::string& text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind, bool checked);
210 menu_item(const xtd::string& text, xtd::event_handler on_click, const xtd::drawing::image& image, xtd::forms::menu_item_kind kind, bool checked);
221
223 template<typename delegate_type>
224 menu_item(const xtd::string& text, delegate_type on_click) : menu_item(text, xtd::event_handler(on_click)) {}
225 template<typename delegate_type>
226 menu_item(const xtd::string& text, delegate_type on_click, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), shortcut) {}
227 template<typename delegate_type>
228 menu_item(const xtd::string& text, delegate_type on_click, const xtd::drawing::image& image) : menu_item(text, xtd::event_handler(on_click), image) {}
229 template<typename delegate_type>
230 menu_item(const xtd::string& text, delegate_type on_click, const xtd::drawing::image& image, xtd::forms::shortcut shortcut) : menu_item(text, xtd::event_handler(on_click), image, shortcut) {}
231 template<typename delegate_type>
232 menu_item(const xtd::string& text, delegate_type on_click, xtd::forms::menu_item_kind kind) : menu_item(text, xtd::event_handler(on_click), kind) {}
233 template<typename delegate_type>
234 menu_item(const xtd::string& 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) {}
235 template<typename delegate_type>
236 menu_item(const xtd::string& text, delegate_type on_click, xtd::forms::menu_item_kind kind, bool checked) : menu_item(text, xtd::event_handler(on_click), kind, checked) {}
237 template<typename delegate_type>
238 menu_item(const xtd::string& 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) {}
239 template<typename delegate_type>
240 menu_item(const xtd::string& 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) {}
241 template<typename delegate_type>
242 menu_item(const xtd::string& 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) {}
243 menu_item(const xtd::string& text, const std::initializer_list<const_menu_item_ref>& items);
245
252 menu_item(const xtd::string& text, const std::vector<menu_item_ref>& items);
253 menu_item(menu_item&&) = default;
254 menu_item(const menu_item&) = default;
255 menu_item& operator =(const menu_item&) = default;
257
259
263 intptr menu_id() const noexcept;
264
267 bool checked() const noexcept;
271 menu_item& checked(bool value);
272
275 bool enabled() const noexcept;
279 menu_item& enabled(bool value);
280
281 bool is_parent() const noexcept override;
282
285 xtd::forms::menu_item_kind kind() const noexcept;
290
293 xtd::forms::shortcut shortcut() const noexcept;
298
303 const xtd::string& text() const noexcept;
309 menu_item& text(const xtd::string& value);
311
313
317 void perform_click();
318
322 xtd::string to_string() const noexcept override;
324
326
333
334 protected:
335 friend main_menu;
336 friend context_menu;
337
339
345 xtd::uptr<xtd::object> clone() const override;
346
347 intptr create_menu_handle() override;
348 void destroy_menu_handle(intptr handle) override;
349
353 virtual void on_click(const event_args& e);
354
355 void on_item_added(size_t pos, menu_item_ref item) override;
356 void on_item_removed(size_t pos, menu_item_ref item) override;
358
359 private:
360 xtd::sptr<data> data_;
361 };
362 }
363}
Represents text as a sequence of character units.
Definition basic_string.h:79
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:36
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
menu_item(const xtd::string &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::string &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::string &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::string &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::string &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::string &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::string &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::string &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(const xtd::string &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::string &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::string &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::string &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...
menu_item(const xtd::string &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()
Initializes a menu_item with a blank caption.
menu_item(const xtd::string &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::string &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::string &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::string &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::string &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::string &text)
Initializes a new instance of the menu_item class with a specified caption for the menu item.
menu_item(const xtd::string &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::string &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::string &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::string &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::string &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::string &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.
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.h:37
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.h:21
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
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
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
shortcut
Specifies shortcut keys that can be used by menu items.
Definition shortcut.h:24
menu_item_kind
Represent menu item kind used by xtd::forms::menu_item component.
Definition menu_item_kind.h:21
@ 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.