xtd 1.0.0
Loading...
Searching...
No Matches
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
10namespace xtd {
12 namespace forms {
14 class control;
16
36 public:
38
41 using menu_item_collection = std::vector<xtd::forms::menu_item_ref>;
43
45
53
55 explicit context_menu(const std::initializer_list<xtd::forms::const_menu_item_ref>& menu_items);
56 context_menu(context_menu&&) = default;
57 context_menu(const context_menu&) = default;
58 context_menu& operator =(const context_menu&) = default;
61
63
69 auto show(const xtd::forms::control& control, const xtd::drawing::point& pos) -> void;
72 protected:
74
76 [[nodiscard]] auto create_menu_handle() -> xtd::intptr override;
77 auto destroy_menu_handle(intptr handle) -> void override;
78 auto on_item_added(xtd::usize pos, menu_item_ref item) -> void override;
79 auto on_item_removed(xtd::usize pos, menu_item_ref item) -> void override;
81
82 private:
83 friend class control;
84 [[nodiscard]] auto on_item_click(intptr menu_id) -> bool;
85 };
86 }
87}
std::vector< xtd::forms::menu_item_ref > menu_item_collection
Represents menu items collection.
Definition context_menu.hpp:41
auto create_menu_handle() -> xtd::intptr override
Creates a new handle to the Menu.
auto show(const xtd::forms::control &control, const xtd::drawing::point &pos) -> void
Displays the shortcut menu at the specified position.
context_menu()
Initialize context_menu class.
context_menu(const menu_item_collection &menu_items)
Initialize a new instance of context_menu class.
auto destroy_menu_handle(intptr handle) -> void override
Destroys the handle to the Menu.
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
auto menu_items() const noexcept -> const menu_item_collection &
Gets a value indicating the collection of menu_item objects associated with the menu.
auto handle() const noexcept -> xtd::intptr
Gets a value representing the window handle for the menu.
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
std::intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
xtd::ref< xtd::forms::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 texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54