xtd 1.0.0
Loading...
Searching...
No Matches
main_menu.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "menu_item.hpp"
6#include "message.hpp"
7#include <xtd/collections/generic/list>
8#include <xtd/drawing/size>
9#include <memory>
10#include <vector>
11
13namespace xtd {
15 namespace forms {
17 class form;
19
42 public:
44
50 explicit main_menu(const std::vector<xtd::forms::menu_item_ref>& menu_items);
52
54 explicit main_menu(const std::initializer_list<xtd::forms::const_menu_item_ref>& menu_items);
56
58
108 [[nodiscard]] static auto create_standard_items(const xtd::event_handler& on_click) -> main_menu;
158 [[nodiscard]] static auto create_standard_items(const xtd::drawing::size& image_size, const xtd::event_handler& on_click) -> main_menu;
208 [[nodiscard]] static auto create_standard_items(const xtd::string& theme, const xtd::event_handler& on_click) -> main_menu;
259 [[nodiscard]] static auto create_standard_items(const xtd::string& theme, const xtd::drawing::size& size, const xtd::event_handler& on_click) -> main_menu;
261
263 template<typename on_click_type>
264 [[nodiscard]] static auto create_standard_items(on_click_type on_click) -> main_menu {return create_standard_items(xtd::event_handler(on_click));}
265 template<typename on_click_type>
266 [[nodiscard]] static auto create_standard_items(const xtd::drawing::size& size, on_click_type on_click) -> main_menu {return create_standard_items(size, xtd::event_handler(on_click));}
267 template<typename on_click_type>
268 [[nodiscard]] static auto create_standard_items(const xtd::string& theme, on_click_type on_click) -> main_menu {return create_standard_items(theme, xtd::event_handler(on_click));}
269 template<typename on_click_type>
270 [[nodiscard]] static auto create_standard_items(const xtd::string& theme, const xtd::drawing::size& size, on_click_type on_click) -> main_menu {return create_standard_items(theme, size, xtd::event_handler(on_click));}
272
273 protected:
275
277 [[nodiscard]] auto create_menu_handle() -> xtd::intptr override;
278 auto destroy_menu_handle(intptr handle) -> void override;
279 auto on_item_added(xtd::usize pos, menu_item_ref item) -> void override;
280 auto on_item_removed(xtd::usize pos, menu_item_ref item) -> void override;
282
283 private:
284 friend class form;
285 auto wm_click(message& message) -> void;
287 };
288 }
289}
290
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Represents the menu structure of a form.
Definition main_menu.hpp:41
friend class form
The form data allows you to specify the box of a form control.
Definition main_menu.hpp:284
static auto create_standard_items(const xtd::drawing::size &image_size, const xtd::event_handler &on_click) -> main_menu
A factory to create a main menu with specified image size and on click event handler.
static auto create_standard_items(const xtd::string &theme, const xtd::drawing::size &size, const xtd::event_handler &on_click) -> main_menu
A factory to create a main menu with specified theme, image size and on click event handler.
main_menu()
Initialize a new instance of main_menu class.
auto create_menu_handle() -> xtd::intptr override
Creates a new handle to the Menu.
static auto create_standard_items(const xtd::string &theme, const xtd::event_handler &on_click) -> main_menu
A factory to create a main menu with specified theme and on click event handler.
auto destroy_menu_handle(intptr handle) -> void override
Destroys the handle to the Menu.
main_menu(const std::vector< xtd::forms::menu_item_ref > &menu_items)
Initialize a new instance of main_menu class.
static auto create_standard_items(const xtd::event_handler &on_click) -> main_menu
A factory to create a main menu with specified on click event handler.
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.
generic_event_handler< const xtd::event_args & > event_handler
Represents the method that will handle an event that has no event data.
Definition event_handler.hpp:24
#define forms_export_
Define shared library export.
Definition forms_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
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_item 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
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:217
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:32
Implements a Windows message.
Definition message.hpp:33