neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
menu.hpp
Go to the documentation of this file.
1
// menu.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
>
23
#include <
neogfx/core/event.hpp
>
24
#include <
neogfx/app/action.hpp
>
25
#include <
neogfx/app/i_help.hpp
>
26
#include <
neogfx/gfx/texture.hpp
>
27
#include <
neogfx/gui/widget/i_menu.hpp
>
28
29
namespace
neogfx
30
{
31
class
menu
:
public
i_menu
32
{
33
public
:
34
define_declared_event
(MenuChanged, menu_changed)
35
define_declared_event
(ItemAdded,
item_added
,
item_index
)
36
define_declared_event
(ItemRemoved, item_removed,
item_index
)
37
define_declared_event
(ItemChanged,
item_changed
,
item_index
)
38
define_declared_event
(Opened, opened)
39
define_declared_event
(Closed, closed)
40
define_declared_event
(ItemSelected, item_selected,
i_menu_item
&)
41
define_declared_event
(SelectionCleared, selection_cleared)
42
define_declared_event
(OpenSubMenu, open_sub_menu,
i_menu
&)
43
private:
44
typedef
std
::unique_ptr<
i_menu_item
> item_pointer;
45
typedef
std
::
vector
<item_pointer>
item_list
;
46
public:
47
menu
(
i_menu
& aParent,
std
::
string
const& aTitle =
std
::
string
{},
menu_type
aType =
menu_type::Popup
);
48
menu
(std::string
const
& aTitle = std::string{},
menu_type
aType =
menu_type::Popup
);
49
~menu
();
50
public
:
51
const
i_widget
&
as_widget
()
const override
;
52
i_widget
&
as_widget
()
override
;
53
bool
has_parent
()
const override
;
54
i_menu
&
parent
()
override
;
55
void
set_parent
(
i_menu
& aParent)
override
;
56
menu_type
type
()
const override
;
57
uuid
const
&
group
()
const override
;
58
void
set_group
(
uuid
const
& aGroup)
override
;
59
i_string
const
&
title
()
const override
;
60
void
set_title
(
i_string
const
& aTitle)
override
;
61
const
i_texture
&
image
()
const override
;
62
void
set_image
(
i_string
const
& aUri)
override
;
63
void
set_image
(
const
i_image
& aImage)
override
;
64
void
set_image
(
const
i_texture
& aTexture)
override
;
65
uint32_t
count
()
const override
;
66
uint32_t
ideal_insert_index
(
uuid
const
& aGroup)
const override
;
67
const
i_menu_item
&
item_at
(
item_index
aItemIndex)
const override
;
68
i_menu_item
&
item_at
(
item_index
aItemIndex)
override
;
69
void
add_sub_menu
(
i_menu
& aSubMenu)
override
;
70
i_menu
&
add_sub_menu
(
i_string
const
& aSubMenuTitle,
uuid
const
& aGroup = {})
override
;
71
i_action
&
add_action
(
i_action
& aAction)
override
;
72
i_action
&
add_action
(
i_ref_ptr<i_action>
const
& aAction)
override
;
73
void
add_separator
(
uuid
const
& aGroup = {})
override
;
74
void
insert_sub_menu_at
(
item_index
aItemIndex,
i_menu
& aSubMenu)
override
;
75
i_menu
&
insert_sub_menu_at
(
item_index
aItemIndex,
i_string
const
& aSubMenuText,
uuid
const
& aGroup = {})
override
;
76
void
insert_action_at
(
item_index
aItemIndex,
i_action
& aAction)
override
;
77
void
insert_action_at
(
item_index
aItemIndex,
i_ref_ptr<i_action>
const
& aAction)
override
;
78
void
insert_separator_at
(
item_index
aItemIndex,
uuid
const
& aGroup = {})
override
;
79
void
remove_at
(
item_index
aItemIndex)
override
;
80
item_index
find_sub_menu
(
uuid
const
& aGroup)
const override
;
81
item_index
find
(
const
i_menu_item
& aItem)
const override
;
82
item_index
find
(
const
i_menu
& aSubMenu)
const override
;
83
bool
has_selected_item
()
const override
;
84
item_index
selected_item
()
const override
;
85
void
select_item_at
(
item_index
aItemIndex,
bool
aOpenAnySubMenu =
true
)
override
;
86
void
clear_selection
()
override
;
87
bool
has_available_items
()
const override
;
88
bool
item_available_at
(
item_index
aItemIndex)
const override
;
89
item_index
first_available_item
()
const override
;
90
item_index
previous_available_item
(
item_index
aCurrentIndex)
const override
;
91
item_index
next_available_item
(
item_index
aCurrentIndex)
const override
;
92
bool
is_open
()
const override
;
93
void
open
()
override
;
94
void
close
()
override
;
95
bool
is_modal
()
const override
;
96
void
set_modal
(
bool
aModal)
override
;
97
public
:
98
using
i_menu::ideal_insert_index
;
99
private
:
100
item_index
update_grouping_separators(
item_index
aItemIndex);
101
private
:
102
i_menu
* iParent;
103
menu_type
iType;
104
uuid
iGroup;
105
string
iTitle;
106
texture
iImage;
107
item_list
iItems;
108
action
iSeparator;
109
uint32_t iOpenCount;
110
std::optional<item_index> iSelection;
111
bool
iModal;
112
};
113
}
action.hpp
neogfx::action
Definition
action.hpp:30
neogfx::i_action
Definition
i_action.hpp:32
neogfx::i_image
Definition
i_image.hpp:35
neogfx::i_menu_item
Definition
i_menu_item.hpp:38
neogfx::i_menu
Definition
i_menu.hpp:36
neogfx::i_menu::ideal_insert_index
virtual uint32_t ideal_insert_index(uuid const &aGroup) const =0
neogfx::i_menu::item_index
uint32_t item_index
Definition
i_menu.hpp:40
neogfx::i_texture
Definition
i_texture.hpp:84
neogfx::i_widget
Definition
i_widget.hpp:50
neogfx::menu
Definition
menu.hpp:32
neogfx::menu::has_available_items
bool has_available_items() const override
neogfx::menu::item_at
const i_menu_item & item_at(item_index aItemIndex) const override
neogfx::menu::insert_sub_menu_at
i_menu & insert_sub_menu_at(item_index aItemIndex, i_string const &aSubMenuText, uuid const &aGroup={}) override
neogfx::menu::has_parent
bool has_parent() const override
neogfx::menu::insert_action_at
void insert_action_at(item_index aItemIndex, i_ref_ptr< i_action > const &aAction) override
neogfx::menu::image
const i_texture & image() const override
neogfx::menu::insert_separator_at
void insert_separator_at(item_index aItemIndex, uuid const &aGroup={}) override
neogfx::menu::group
uuid const & group() const override
neogfx::menu::menu
menu(std::string const &aTitle=std::string{}, menu_type aType=menu_type::Popup)
neogfx::menu::find
item_index find(const i_menu &aSubMenu) const override
neogfx::menu::insert_sub_menu_at
void insert_sub_menu_at(item_index aItemIndex, i_menu &aSubMenu) override
neogfx::menu::set_image
void set_image(i_string const &aUri) override
neogfx::menu::open
void open() override
neogfx::menu::item_available_at
bool item_available_at(item_index aItemIndex) const override
neogfx::menu::insert_action_at
void insert_action_at(item_index aItemIndex, i_action &aAction) override
neogfx::menu::as_widget
const i_widget & as_widget() const override
neogfx::menu::~menu
~menu()
neogfx::menu::is_open
bool is_open() const override
neogfx::menu::add_action
i_action & add_action(i_ref_ptr< i_action > const &aAction) override
neogfx::menu::clear_selection
void clear_selection() override
neogfx::menu::find
item_index find(const i_menu_item &aItem) const override
neogfx::menu::selected_item
item_index selected_item() const override
neogfx::menu::add_sub_menu
i_menu & add_sub_menu(i_string const &aSubMenuTitle, uuid const &aGroup={}) override
neogfx::menu::add_sub_menu
void add_sub_menu(i_menu &aSubMenu) override
neogfx::menu::add_separator
void add_separator(uuid const &aGroup={}) override
neogfx::menu::set_title
void set_title(i_string const &aTitle) override
neogfx::menu::parent
i_menu & parent() override
neogfx::menu::as_widget
i_widget & as_widget() override
neogfx::menu::item_list
item_index item_index closed selection_cleared define_declared_event(OpenSubMenu, open_sub_menu, i_menu &) private typedef std::vector< item_pointer > item_list
Definition
menu.hpp:42
neogfx::menu::find_sub_menu
item_index find_sub_menu(uuid const &aGroup) const override
neogfx::menu::set_image
void set_image(const i_image &aImage) override
neogfx::menu::select_item_at
void select_item_at(item_index aItemIndex, bool aOpenAnySubMenu=true) override
neogfx::menu::item_added
item_added
Definition
menu.hpp:35
neogfx::menu::ideal_insert_index
uint32_t ideal_insert_index(uuid const &aGroup) const override
neogfx::menu::set_group
void set_group(uuid const &aGroup) override
neogfx::menu::close
void close() override
neogfx::menu::next_available_item
item_index next_available_item(item_index aCurrentIndex) const override
neogfx::menu::type
menu_type type() const override
neogfx::menu::add_action
i_action & add_action(i_action &aAction) override
neogfx::menu::first_available_item
item_index first_available_item() const override
neogfx::menu::title
i_string const & title() const override
neogfx::menu::remove_at
void remove_at(item_index aItemIndex) override
neogfx::menu::set_image
void set_image(const i_texture &aTexture) override
neogfx::menu::item_at
i_menu_item & item_at(item_index aItemIndex) override
neogfx::menu::define_declared_event
define_declared_event(MenuChanged, menu_changed) define_declared_event(ItemAdded
neogfx::menu::set_parent
void set_parent(i_menu &aParent) override
neogfx::menu::item_changed
item_index item_changed
Definition
menu.hpp:37
neogfx::menu::is_modal
bool is_modal() const override
neogfx::menu::previous_available_item
item_index previous_available_item(item_index aCurrentIndex) const override
neogfx::menu::count
uint32_t count() const override
neogfx::menu::has_selected_item
bool has_selected_item() const override
neogfx::menu::set_modal
void set_modal(bool aModal) override
neogfx::texture
Definition
texture.hpp:35
neolib::i_ref_ptr
Definition
i_reference_counted.hpp:78
neolib::i_string
Definition
i_string.hpp:49
neolib::vector
Definition
vector.hpp:48
texture.hpp
i_help.hpp
i_menu.hpp
neogfx
Definition
action.hpp:28
neogfx::menu_type
menu_type
Definition
i_menu.hpp:30
neogfx::menu_type::Popup
@ Popup
std
Definition
plf_hive.h:79
event.hpp
neogfx.hpp
define_declared_event
#define define_declared_event(name, declName,...)
Definition
event.hpp:195
neolib::uuid
Definition
uuid.hpp:51
include
neogfx
gui
widget
menu.hpp
Generated by
1.9.8