xtd 0.2.0
main_menu.h
Go to the documentation of this file.
1 #pragma once
5 #include "menu_item.h"
6 #include "message.h"
7 #include <xtd/drawing/size>
8 #include <memory>
9 #include <vector>
10 
12 namespace xtd {
14  namespace forms {
16  class form;
18 
38  class forms_export_ main_menu : public menu {
39  public:
41 
44  main_menu();
47  explicit main_menu(const std::vector<menu_item_ref>& menu_items);
49 
51  explicit main_menu(const std::initializer_list<const_menu_item_ref>& menu_items);
53 
55 
105  static xtd::forms::main_menu create_standard_items(const xtd::event_handler& on_click);
155  static xtd::forms::main_menu create_standard_items(const xtd::drawing::size& image_size, const xtd::event_handler& on_click);
205  static xtd::forms::main_menu create_standard_items(const xtd::ustring& theme, const xtd::event_handler& on_click);
256  static xtd::forms::main_menu create_standard_items(const xtd::ustring& theme, const xtd::drawing::size& size, const xtd::event_handler& on_click);
258 
260  template<typename on_click_type>
261  static xtd::forms::main_menu create_standard_items(on_click_type on_click) {return create_standard_items(xtd::event_handler(on_click));}
262  template<typename on_click_type>
263  static xtd::forms::main_menu create_standard_items(const xtd::drawing::size& size, on_click_type on_click) {return create_standard_items(size, xtd::event_handler(on_click));}
264  template<typename on_click_type>
265  static xtd::forms::main_menu create_standard_items(const xtd::ustring& theme, on_click_type on_click) {return create_standard_items(theme, xtd::event_handler(on_click));}
266  template<typename on_click_type>
267  static xtd::forms::main_menu create_standard_items(const xtd::ustring& theme, const xtd::drawing::size& size, on_click_type on_click) {return create_standard_items(theme, size, xtd::event_handler(on_click));}
269 
270  protected:
272 
274  intptr create_menu_handle() override;
275  void destroy_menu_handle(intptr handle) override;
276  void on_item_added(size_t pos, menu_item_ref item) override;
277  void on_item_removed(size_t pos, menu_item_ref item) override;
279 
280  private:
281  friend class form;
282  void wm_click(message& message);
283  std::vector<std::unique_ptr<menu_item>> standard_menu_items_;
284  };
285  }
286 }
287 
intmax_t intptr
Represent a pointer or a handle.
Definition: types.h:151
generic_event_handler<> event_handler
Represents the method that will handle an event that has no event data.
Definition: event_handler.h:32
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::forms::message class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Represents a window or dialog box that makes up an application&#39;s user interface.
Definition: form.h:52
Implements a Windows message.
Definition: message.h:26
Represents the base functionality for all menus. Although tool_strip_drop_down and tool_strip_drop_do...
Definition: menu.h:35
xtd::forms::style_sheets::control form
The form data allows you to specify the box of a form control.
Definition: form.h:21
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
Represents the menu structure of a form.
Definition: main_menu.h:38
Defines a 3D themed border. The effect depends on the border color value.
std::reference_wrapper< menu_item > menu_item_ref
Represents a menu item reference.
Definition: menu_item_ref.h:21
size_t size
Represents a size of any object in bytes.
Definition: types.h:195