neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
action.hpp
Go to the documentation of this file.
1// action.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
26
27namespace neogfx
28{
29 class action : public reference_counted<i_action>
30 {
31 public:
33 public:
34 define_declared_event(Triggered, triggered)
35 define_declared_event(Hovered, hovered)
38 define_declared_event(Checked, checked)
39 define_declared_event(Unchecked, unchecked)
40 define_declared_event(Changed, changed)
41 public:
42 action();
43 action(string const& aText);
44 action(string const& aText, string const& aImageUri, dimension aDpiScaleFactor = 1.0, texture_sampling aSampling = texture_sampling::Scaled);
45 action(string const& aText, const i_texture& aImage);
46 action(string const& aText, const i_image& aImage);
48 action(i_action_container& aContainer, string const& aText);
49 action(i_action_container& aContainer, string const& aText, string const& aImageUri, dimension aDpiScaleFactor = 1.0, texture_sampling aSampling = texture_sampling::Scaled);
50 action(i_action_container& aContainer, string const& aText, const i_texture& aImage);
51 action(i_action_container& aContainer, string const& aText, const i_image& aImage);
52 public:
53 bool is_enabled() const override;
54 bool is_disabled() const override;
55 bool is_checkable() const override;
56 bool is_checked() const override;
57 bool is_unchecked() const override;
58 uuid const& group() const override;
59 bool is_separator() const override;
60 i_string const& text() const override;
61 i_string const& menu_text() const override;
62 i_string const& button_text() const override;
63 i_string const& tool_tip_text() const override;
64 i_string const& help_text() const override;
65 const i_texture& image() const override;
66 const i_texture& checked_image() const override;
67 const optional_key_sequence& shortcut() const override;
68 action& set_enabled(bool aEnabled) override;
69 action& set_checkable(bool aCheckable = true) override;
70 action& set_checked(bool aChecked) override;
71 action& set_group(uuid const& aGroup) override;
72 action& set_separator(bool aIsSeparator) override;
73 action& set_text(i_optional<i_string> const& aText = optional_text()) override;
74 action& set_menu_text(i_optional<i_string> const& aMenuText = optional_text()) override;
75 action& set_button_text(i_optional<i_string> const& aButtonText = optional_text()) override;
76 action& set_tool_tip_text(i_optional<i_string> const& aToolTipText = optional_text()) override;
77 action& set_help_text(i_optional<i_string> const& aHelpText = optional_text()) override;
78 action& set_image(const i_texture& aTexture) override;
79 action& set_checked_image(const i_texture& aTexture) override;
80 action& set_shortcut(const optional_key_sequence& aShortcut) override;
81 action& set_shortcut(i_string const& aShortcut) override;
82 public:
83 using i_action::set_text;
88 using i_action::set_image;
91 private:
92 bool iEnabled;
93 bool iCheckable;
94 bool iChecked;
95 uuid iGroup;
96 bool iSeparator;
97 optional_text iText;
98 optional_text iMenuText;
99 optional_text iButtonText;
100 optional_text iToolTipText;
101 optional_text iHelpText;
102 texture iImage;
103 texture iCheckedImage;
104 optional_key_sequence iShortcut;
105 };
106
107 namespace nrc
108 {
109 class action_ref
110 {
111 public:
112 action_ref(i_action_container& aContainer)
113 {
114 aContainer.add_action(make_ref<action>());
115 }
116 action_ref(i_action_container& aContainer, i_action& aAction)
117 {
118 aContainer.add_action(aAction);
119 }
120 };
121 }
122}
bool is_unchecked() const override
bool is_separator() const override
action & set_help_text(i_optional< i_string > const &aHelpText=optional_text()) override
i_string const & menu_text() const override
action & set_text(i_optional< i_string > const &aText=optional_text()) override
i_string const & tool_tip_text() const override
action & set_checked_image(const i_texture &aTexture) override
const i_texture & checked_image() const override
bool is_checked() const override
action & set_menu_text(i_optional< i_string > const &aMenuText=optional_text()) override
i_action abstract_type
Definition action.hpp:32
const optional_key_sequence & shortcut() const override
action & set_tool_tip_text(i_optional< i_string > const &aToolTipText=optional_text()) override
action & set_group(uuid const &aGroup) override
action & set_button_text(i_optional< i_string > const &aButtonText=optional_text()) override
action & set_separator(bool aIsSeparator) override
i_string const & text() const override
action & set_enabled(bool aEnabled) override
uuid const & group() const override
bool is_checkable() const override
define_declared_event(Triggered, triggered) define_declared_event(Hovered
action & set_image(const i_texture &aTexture) override
bool is_enabled() const override
i_string const & button_text() const override
action & set_checked(bool aChecked) override
bool is_disabled() const override
i_string const & help_text() const override
action & set_checkable(bool aCheckable=true) override
action & set_shortcut(const optional_key_sequence &aShortcut) override
virtual i_action & add_action(i_action &aAction)=0
default_geometry_value_type dimension
std::optional< key_sequence > optional_key_sequence
texture_sampling
Definition i_texture.hpp:42
#define define_declared_event(name, declName,...)
Definition event.hpp:195