neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_menu.hpp
Go to the documentation of this file.
1
// i_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/app/i_action.hpp
>
24
#include <
neogfx/gui/widget/i_widget.hpp
>
25
#include <
neogfx/gui/widget/i_menu_item.hpp
>
26
27
namespace
neogfx
28
{
29
enum class
menu_type
: uint32_t
30
{
31
MenuBar
,
32
Popup
33
};
34
35
class
i_menu
:
public
i_action_container
36
{
37
public
:
38
struct
no_widget
: std::logic_error {
no_widget
() : std::logic_error{
"neogfx::i_menu::no_widget"
} {} };
39
public
:
40
typedef
uint32_t
item_index
;
41
public
:
42
declare_event
(menu_changed)
43
declare_event
(item_added,
item_index
)
44
declare_event
(item_removed,
item_index
)
45
declare_event
(item_changed,
item_index
)
46
declare_event
(opened)
47
declare_event
(closed)
48
declare_event
(item_selected,
i_menu_item
&)
49
declare_event
(selection_cleared)
50
declare_event
(open_sub_menu,
i_menu
&)
51
public:
52
typedef uint32_t
item_index
;
53
public:
54
struct
no_parent
:
std
::logic_error {
no_parent
() : std::logic_error(
"neogfx::i_menu::no_parent"
) {} };
55
struct
bad_item_index
: std::logic_error {
bad_item_index
() : std::logic_error(
"neogfx::i_menu::bad_item_index"
) {} };
56
struct
item_not_found
: std::logic_error {
item_not_found
() : std::logic_error(
"neogfx::i_menu::item_not_found"
) {} };
57
struct
no_selected_item
: std::logic_error {
no_selected_item
() : std::logic_error(
"neogfx::i_menu::no_selected_item"
) {} };
58
struct
cannot_select_item
: std::logic_error {
cannot_select_item
() : std::logic_error(
"neogfx::i_menu::cannot_select_item"
) {} };
59
struct
no_available_items
: std::logic_error {
no_available_items
() : std::logic_error(
"neogfx::i_menu::no_available_items"
) {} };
60
struct
already_closed
: std::logic_error {
already_closed
() : std::logic_error(
"neogfx::i_menu::already_closed"
) {} };
61
public
:
62
virtual
~i_menu
() =
default
;
63
public
:
64
virtual
const
i_widget
&
as_widget
()
const
= 0;
65
virtual
i_widget
&
as_widget
() = 0;
66
virtual
bool
has_parent
()
const
= 0;
67
virtual
i_menu
&
parent
() = 0;
68
virtual
void
set_parent
(
i_menu
& aParent) = 0;
69
virtual
menu_type
type
()
const
= 0;
70
virtual
uuid
const
&
group
()
const
= 0;
71
virtual
void
set_group
(
uuid
const
& aGroup) = 0;
72
virtual
i_string
const
&
title
()
const
= 0;
73
virtual
void
set_title
(
i_string
const
& aTitle) = 0;
74
virtual
const
i_texture
&
image
()
const
= 0;
75
virtual
void
set_image
(
i_string
const
& aUri) = 0;
76
virtual
void
set_image
(
i_image
const
& aImage) = 0;
77
virtual
void
set_image
(
i_texture
const
& aTexture) = 0;
78
virtual
uint32_t
count
()
const
= 0;
79
virtual
uint32_t
ideal_insert_index
(
uuid
const
& aGroup)
const
= 0;
80
virtual
const
i_menu_item
&
item_at
(
item_index
aItemIndex)
const
= 0;
81
virtual
i_menu_item
&
item_at
(
item_index
aItemIndex) = 0;
82
virtual
void
add_sub_menu
(
i_menu
& aSubMenu) = 0;
83
virtual
i_menu
&
add_sub_menu
(
i_string
const
& aSubMenuTitle,
uuid
const
& aGroup = {}) = 0;
84
virtual
void
add_separator
(
uuid
const
& aGroup = {}) = 0;
85
virtual
void
insert_sub_menu_at
(
item_index
aItemIndex,
i_menu
& aSubMenu) = 0;
86
virtual
i_menu
&
insert_sub_menu_at
(
item_index
aItemIndex,
i_string
const
& aSubMenuTitle,
uuid
const
& aGroup = {}) = 0;
87
virtual
void
insert_action_at
(
item_index
aItemIndex,
i_action
& aAction) = 0;
88
virtual
void
insert_action_at
(
item_index
aItemIndex,
i_ref_ptr<i_action>
const
& aAction) = 0;
89
virtual
void
insert_separator_at
(
item_index
aItemIndex,
uuid
const
& aGroup = {}) = 0;
90
virtual
void
remove_at
(
item_index
aItemIndex) = 0;
91
virtual
item_index
find_sub_menu
(
uuid
const
& aGroup)
const
= 0;
92
virtual
item_index
find
(
i_menu_item
const
& aItem)
const
= 0;
93
virtual
item_index
find
(
i_menu
const
& aSubMenu)
const
= 0;
94
virtual
bool
has_selected_item
()
const
= 0;
95
virtual
item_index
selected_item
()
const
= 0;
96
virtual
void
select_item_at
(
item_index
aItemIndex,
bool
aOpenAnySubMenu =
true
) = 0;
97
virtual
void
clear_selection
() = 0;
98
virtual
bool
has_available_items
()
const
= 0;
99
virtual
bool
item_available_at
(
item_index
aItemIndex)
const
= 0;
100
virtual
item_index
first_available_item
()
const
= 0;
101
virtual
item_index
previous_available_item
(
item_index
aCurrentIndex)
const
= 0;
102
virtual
item_index
next_available_item
(
item_index
aCurrentIndex)
const
= 0;
103
virtual
bool
is_open
()
const
= 0;
104
virtual
void
open
() = 0;
105
virtual
void
close
() = 0;
106
virtual
bool
is_modal
()
const
= 0;
107
virtual
void
set_modal
(
bool
aModal) = 0;
108
public
:
109
uint32_t
ideal_insert_index
(
i_action
const
& aAction)
const
110
{
111
return
ideal_insert_index
(aAction.
group
());
112
}
113
uint32_t
ideal_insert_index
(
i_menu
const
& aSubMenu)
const
114
{
115
return
ideal_insert_index
(aSubMenu.
group
());
116
}
117
};
118
}
neogfx::i_action_container
Definition
i_action.hpp:142
neogfx::i_action
Definition
i_action.hpp:32
neogfx::i_action::group
virtual uuid const & group() const =0
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::insert_action_at
virtual void insert_action_at(item_index aItemIndex, i_action &aAction)=0
neogfx::i_menu::insert_sub_menu_at
virtual i_menu & insert_sub_menu_at(item_index aItemIndex, i_string const &aSubMenuTitle, uuid const &aGroup={})=0
neogfx::i_menu::remove_at
virtual void remove_at(item_index aItemIndex)=0
neogfx::i_menu::add_sub_menu
virtual i_menu & add_sub_menu(i_string const &aSubMenuTitle, uuid const &aGroup={})=0
neogfx::i_menu::ideal_insert_index
uint32_t ideal_insert_index(i_menu const &aSubMenu) const
Definition
i_menu.hpp:113
neogfx::i_menu::set_group
virtual void set_group(uuid const &aGroup)=0
neogfx::i_menu::~i_menu
virtual ~i_menu()=default
neogfx::i_menu::as_widget
virtual i_widget & as_widget()=0
neogfx::i_menu::previous_available_item
virtual item_index previous_available_item(item_index aCurrentIndex) const =0
neogfx::i_menu::ideal_insert_index
uint32_t ideal_insert_index(i_action const &aAction) const
Definition
i_menu.hpp:109
neogfx::i_menu::type
virtual menu_type type() const =0
neogfx::i_menu::image
virtual const i_texture & image() const =0
neogfx::i_menu::insert_sub_menu_at
virtual void insert_sub_menu_at(item_index aItemIndex, i_menu &aSubMenu)=0
neogfx::i_menu::has_selected_item
virtual bool has_selected_item() const =0
neogfx::i_menu::is_open
virtual bool is_open() const =0
neogfx::i_menu::item_available_at
virtual bool item_available_at(item_index aItemIndex) const =0
neogfx::i_menu::set_image
virtual void set_image(i_image const &aImage)=0
neogfx::i_menu::select_item_at
virtual void select_item_at(item_index aItemIndex, bool aOpenAnySubMenu=true)=0
neogfx::i_menu::item_at
virtual const i_menu_item & item_at(item_index aItemIndex) const =0
neogfx::i_menu::parent
virtual i_menu & parent()=0
neogfx::i_menu::set_image
virtual void set_image(i_texture const &aTexture)=0
neogfx::i_menu::next_available_item
virtual item_index next_available_item(item_index aCurrentIndex) const =0
neogfx::i_menu::find
virtual item_index find(i_menu_item const &aItem) const =0
neogfx::i_menu::group
virtual uuid const & group() const =0
neogfx::i_menu::selected_item
virtual item_index selected_item() const =0
neogfx::i_menu::find
virtual item_index find(i_menu const &aSubMenu) const =0
neogfx::i_menu::is_modal
virtual bool is_modal() const =0
neogfx::i_menu::set_parent
virtual void set_parent(i_menu &aParent)=0
neogfx::i_menu::open
virtual void open()=0
neogfx::i_menu::title
virtual i_string const & title() const =0
neogfx::i_menu::as_widget
virtual const i_widget & as_widget() const =0
neogfx::i_menu::find_sub_menu
virtual item_index find_sub_menu(uuid const &aGroup) const =0
neogfx::i_menu::insert_action_at
virtual void insert_action_at(item_index aItemIndex, i_ref_ptr< i_action > const &aAction)=0
neogfx::i_menu::ideal_insert_index
virtual uint32_t ideal_insert_index(uuid const &aGroup) const =0
neogfx::i_menu::declare_event
declare_event(menu_changed) declare_event(item_added
neogfx::i_menu::has_available_items
virtual bool has_available_items() const =0
neogfx::i_menu::item_index
uint32_t item_index
Definition
i_menu.hpp:40
neogfx::i_menu::set_title
virtual void set_title(i_string const &aTitle)=0
neogfx::i_menu::clear_selection
virtual void clear_selection()=0
neogfx::i_menu::first_available_item
virtual item_index first_available_item() const =0
neogfx::i_menu::has_parent
virtual bool has_parent() const =0
neogfx::i_menu::close
virtual void close()=0
neogfx::i_menu::add_separator
virtual void add_separator(uuid const &aGroup={})=0
neogfx::i_menu::insert_separator_at
virtual void insert_separator_at(item_index aItemIndex, uuid const &aGroup={})=0
neogfx::i_menu::add_sub_menu
virtual void add_sub_menu(i_menu &aSubMenu)=0
neogfx::i_menu::set_modal
virtual void set_modal(bool aModal)=0
neogfx::i_menu::item_at
virtual i_menu_item & item_at(item_index aItemIndex)=0
neogfx::i_menu::count
virtual uint32_t count() const =0
neogfx::i_menu::set_image
virtual void set_image(i_string const &aUri)=0
neogfx::i_texture
Definition
i_texture.hpp:84
neogfx::i_widget
Definition
i_widget.hpp:50
neolib::i_ref_ptr
Definition
i_reference_counted.hpp:78
neolib::i_string
Definition
i_string.hpp:49
i_action.hpp
i_menu_item.hpp
i_widget.hpp
neogfx
Definition
action.hpp:28
neogfx::menu_type
menu_type
Definition
i_menu.hpp:30
neogfx::decoration_style::Popup
@ Popup
neogfx::object_type::MenuBar
@ MenuBar
std
Definition
plf_hive.h:79
neogfx.hpp
declare_event
#define declare_event(declName,...)
Definition
i_event.hpp:305
neogfx::i_menu::already_closed
Definition
i_menu.hpp:60
neogfx::i_menu::already_closed::already_closed
already_closed()
Definition
i_menu.hpp:60
neogfx::i_menu::bad_item_index
Definition
i_menu.hpp:55
neogfx::i_menu::bad_item_index::bad_item_index
bad_item_index()
Definition
i_menu.hpp:55
neogfx::i_menu::cannot_select_item
Definition
i_menu.hpp:58
neogfx::i_menu::cannot_select_item::cannot_select_item
cannot_select_item()
Definition
i_menu.hpp:58
neogfx::i_menu::item_not_found
Definition
i_menu.hpp:56
neogfx::i_menu::item_not_found::item_not_found
item_not_found()
Definition
i_menu.hpp:56
neogfx::i_menu::no_available_items
Definition
i_menu.hpp:59
neogfx::i_menu::no_available_items::no_available_items
no_available_items()
Definition
i_menu.hpp:59
neogfx::i_menu::no_parent
Definition
i_menu.hpp:54
neogfx::i_menu::no_parent::no_parent
no_parent()
Definition
i_menu.hpp:54
neogfx::i_menu::no_selected_item
Definition
i_menu.hpp:57
neogfx::i_menu::no_selected_item::no_selected_item
no_selected_item()
Definition
i_menu.hpp:57
neogfx::i_menu::no_widget
Definition
i_menu.hpp:38
neogfx::i_menu::no_widget::no_widget
no_widget()
Definition
i_menu.hpp:38
neolib::uuid
Definition
uuid.hpp:51
include
neogfx
gui
widget
i_menu.hpp
Generated by
1.9.8