neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
menu_item.hpp
Go to the documentation of this file.
1// menu_item.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>
24
25namespace neogfx
26{
27 class i_menu;
28
29 class menu_item : public i_menu_item
30 {
31 public:
33 define_declared_event(Deselected, deselected)
34 private:
35 typedef ref_ptr<i_action> action_pointer;
36 typedef std::shared_ptr<i_menu> menu_pointer;
37 typedef std::variant<std::monostate, action_pointer, menu_pointer> contents;
38 public:
41 menu_item(i_menu& aSubMenu);
42 menu_item(std::shared_ptr<i_menu> aSubMenu);
43 public:
44 menu_item_type type() const override;
45 uuid const& group() const override;
46 const i_action& action() const override;
47 i_action& action() override;
48 const i_menu& sub_menu() const override;
49 i_menu& sub_menu() override;
50 public:
51 const i_menu_item_widget& as_widget() const override;
53 void set_widget(i_menu_item_widget& aWidget) override;
54 void unset_widget() override;
55 public:
56 bool available() const override;
57 void select(bool aOpenAnySubMenu = true) override;
58 bool open_any_sub_menu() const override;
59 private:
60 contents iContents;
61 bool iOpenAnySubMenu;
62 i_menu_item_widget* iWidget;
63 };
64}
define_declared_event(Selected, selected) define_declared_event(Deselected
menu_item(std::shared_ptr< i_menu > aSubMenu)
i_menu_item_widget & as_widget() override
const i_action & action() const override
bool open_any_sub_menu() const override
void unset_widget() override
bool available() const override
uuid const & group() const override
i_action & action() override
i_menu & sub_menu() override
void select(bool aOpenAnySubMenu=true) override
menu_item_type type() const override
const i_menu & sub_menu() const override
menu_item(i_action &aAction)
const i_menu_item_widget & as_widget() const override
menu_item(i_ref_ptr< i_action > const &aAction)
menu_item(i_menu &aSubMenu)
void set_widget(i_menu_item_widget &aWidget) override
#define define_declared_event(name, declName,...)
Definition event.hpp:195