xtd 0.2.0
context_menu.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "menu.hpp"
6#include "message.hpp"
7#include <xtd/drawing/point>
8#include <xtd/iclonable>
9
11namespace xtd {
13 namespace forms {
15 class control;
17
36 class forms_export_ context_menu : public menu, public iclonable {
37 public:
39
42 using menu_item_collection = std::vector<menu_item_ref>;
44
46
52 explicit context_menu(const menu_item_collection& menu_items);
54
56 explicit context_menu(const std::initializer_list<const_menu_item_ref>& menu_items);
57 context_menu(context_menu&&) = default;
58 context_menu(const context_menu&) = default;
59 context_menu& operator =(const context_menu&) = default;
62
64
73 protected:
75
81 xtd::uptr<xtd::object> clone() const override;
82
84 void destroy_menu_handle(intptr handle) override;
85 void on_item_added(size_t pos, menu_item_ref item) override;
86 void on_item_removed(size_t pos, menu_item_ref item) override;
88
89 private:
90 friend class control;
91 bool on_item_click(intptr menu_id);
92 };
93 }
94}
Represents a shortcut menu.
Definition context_menu.hpp:36
std::vector< menu_item_ref > menu_item_collection
Represents menu items collection.
Definition context_menu.hpp:42
intptr create_menu_handle() override
Creates a new handle to the Menu.
void show(const xtd::forms::control &control, const xtd::drawing::point &pos)
Displays the shortcut menu at the specified position.
xtd::uptr< xtd::object > clone() const override
Creates a new object that is a copy of the current instance.
void destroy_menu_handle(intptr handle) override
Destroys the handle to the Menu.
context_menu()
Initialize context_menu class.
context_menu(const menu_item_collection &menu_items)
Initialize a new instance of context_menu class.
Defines the base class for controls, which are components with visual representation.
Definition control.hpp:81
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition menu.hpp:37
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition iclonable.hpp:21
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
@ control
The left or right CTRL modifier key.
std::reference_wrapper< menu_item > menu_item_ref
Represents a menu item reference.
Definition menu_item_ref.hpp:23
Contains xtd::forms::menu menu.
Contains xtd::forms::message class.
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
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54