neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
menu_item_widget.hpp
Go to the documentation of this file.
1// menu_item_widget.hpp
2/*
3neogfx C++ App/Game Engine
4Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
27
28namespace neogfx
29{
30 class popup_menu;
31
33 {
35 public:
36 menu_item_widget(i_menu& aMenu, i_menu_item& aMenuItem);
37 menu_item_widget(i_widget& aParent, i_menu& aMenu, i_menu_item& aMenuItem);
38 menu_item_widget(i_layout& aLayout, i_menu& aMenu, i_menu_item& aMenuItem);
40 public:
41 i_menu& menu() const override;
42 i_menu_item& menu_item() const override;
43 public:
44 image_widget& item_icon() override; // todo: i_image_widget
45 text_widget& item_text() override; // todo: i_text_widget
46 public:
47 neogfx::size_policy size_policy() const override;
48 size minimum_size(optional_size const& aAvailableSpace = optional_size{}) const override;
49 public:
50 void paint_non_client(i_graphics_context& aGc) const override;
51 void paint(i_graphics_context& aGc) const override;
52 public:
53 color palette_color(color_role aColorRole) const override;
54 public:
55 bool can_capture() const override;
56 public:
57 void mouse_entered(const point& aPosition) override;
58 void mouse_left() override;
59 void mouse_button_pressed(mouse_button aButton, const point& aPosition, key_modifiers_e aKeyModifiers) override;
60 void mouse_button_released(mouse_button aButton, const point& aPosition) override;
61 bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override;
62 protected:
63 std::string mnemonic() const override;
64 void mnemonic_execute() override;
66 protected:
67 bool help_active() const override;
68 neogfx::help_type help_type() const override;
69 i_string const& help_text() const override;
70 public:
72 private:
73 void init();
74 virtual void select_item(bool aOpenAnySubMenu = false);
75 void close_menu();
76 private:
77 sink iSink;
78 dimension iGap = 9.0;
79 size iIconSize = size{ 16.0, 16.0 };
80 i_menu& iMenu;
81 i_menu_item& iMenuItem;
82 horizontal_layout iLayout;
83 image_widget iIcon;
84 text_widget iText;
85 horizontal_spacer iSpacer;
86 text_widget iShortcutText;
87 std::optional<std::unique_ptr<widget_timer>> iSubMenuOpener;
88 mutable std::optional<std::pair<color, texture>> iSubMenuArrow;
89 };
90}
image_widget & item_icon() override
color palette_color(color_role aColorRole) const override
bool help_active() const override
i_menu_item & menu_item() const override
void mouse_entered(const point &aPosition) override
text_widget & item_text() override
neogfx::size_policy size_policy() const override
void mouse_left() override
i_widget & mnemonic_widget() override
void mouse_button_pressed(mouse_button aButton, const point &aPosition, key_modifiers_e aKeyModifiers) override
i_menu & menu() const override
std::string mnemonic() const override
void paint(i_graphics_context &aGc) const override
void mouse_button_released(mouse_button aButton, const point &aPosition) override
i_string const & help_text() const override
bool key_pressed(scan_code_e aScanCode, key_code_e aKeyCode, key_modifiers_e aKeyModifiers) override
point sub_menu_position() const
neogfx::help_type help_type() const override
void mnemonic_execute() override
void paint_non_client(i_graphics_context &aGc) const override
size minimum_size(optional_size const &aAvailableSpace=optional_size{}) const override
bool can_capture() const override
default_geometry_value_type dimension
mouse_button
Definition i_mouse.hpp:31
help_type
Definition i_help.hpp:28
#define meta_object(...)
Definition i_object.hpp:28