The Power in your Hands
Search Site:
About
Features
Documentation
Download
Community
Main
Class Index
Namespaces
Modules
include
Pt
Forms
MenuBase.h
1
/* Copyright (C) 2015 Marc Boris Duerner
2
Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
8
9
As a special exception, you may use this file as part of a free
10
software library without restriction. Specifically, if other files
11
instantiate templates or use macros or inline functions from this
12
file, or you compile this file and link it with other files to
13
produce an executable, this file does not by itself cause the
14
resulting executable to be covered by the GNU General Public
15
License. This exception does not however invalidate any other
16
reasons why the executable file might be covered by the GNU Library
17
General Public License.
18
19
This library is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
Lesser General Public License for more details.
23
24
You should have received a copy of the GNU Lesser General Public
25
License along with this library; if not, write to the Free Software
26
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27
MA 02110-1301 USA
28
*/
29
#ifndef PT_FORMS_MENUBASE_H
30
#define PT_FORMS_MENUBASE_H
31
32
#include <Pt/Forms/Api.h>
33
#include <Pt/Forms/Widget.h>
34
35
namespace
Pt
{
36
namespace
Forms {
37
38
class
MenuSubItem;
39
class
MenuItemBase;
40
50
class
PT_FORMS_API
MenuBase
51
{
52
public
:
55
MenuBase
();
56
59
virtual
~MenuBase
();
60
63
void
cancel
()
64
{
65
onCancel();
66
}
67
70
Pt::Forms::Widget
*
findMenu
(
const
Pt::Gfx::PointF
& screenPos)
71
{
72
return
onFindMenu(screenPos);
73
}
74
77
void
closeMenu
(
MenuSubItem
& item)
78
{
79
onCloseMenu(item);
80
}
81
84
void
openMenu
(
MenuSubItem
& item)
85
{
86
onOpenMenu(item);
87
}
88
91
const
MenuItemBase
*
parentItem
()
const
92
{
93
return
_parentItem;
94
}
95
98
MenuItemBase
*
parentItem
()
99
{
100
return
_parentItem;
101
}
102
107
void
setParentItem
(
MenuItemBase
* item)
108
{
109
_parentItem = item;
110
}
111
114
void
addMenu
(
MenuSubItem
& item)
115
{
116
onAddMenu(item);
117
}
118
121
void
removeMenu
(
MenuSubItem
& item)
122
{
123
onRemoveMenu(item);
124
}
125
126
protected
:
127
128
virtual
void
onCloseMenu(
MenuSubItem
& item) = 0;
129
130
virtual
void
onOpenMenu(
MenuSubItem
& item) = 0;
131
132
virtual
void
onAddMenu(
MenuSubItem
& item) = 0;
133
134
virtual
void
onRemoveMenu(
MenuSubItem
& item) = 0;
135
136
virtual
void
onCancel() = 0;
137
138
virtual
Pt::Forms::Widget
* onFindMenu(
const
Pt::Gfx::PointF
& screenPos) = 0;
139
140
private
:
141
MenuItemBase
* _parentItem;
142
};
143
144
}}
145
146
#endif
Pt
Core module.
Definition:
Allocator.h:33
Pt::Forms::MenuBase::addMenu
void addMenu(MenuSubItem &item)
Registers item as a submenu entry.
Definition:
MenuBase.h:114
Pt::Forms::MenuBase::~MenuBase
virtual ~MenuBase()
Destroys the menu coordination interface.
Pt::Forms::MenuBase::openMenu
void openMenu(MenuSubItem &item)
Opens the submenu associated with item.
Definition:
MenuBase.h:84
Pt::Forms::MenuBase
Defines the coordination interface shared by menu containers.
Definition:
MenuBase.h:51
Pt::Forms::MenuBase::cancel
void cancel()
Cancels the active menu interaction.
Definition:
MenuBase.h:63
Pt::Forms::Widget
Common type of every visual Forms object.
Definition:
Widget.h:105
Pt::Gfx::Point
Point with floating-point X and Y coordinates.
Definition:
Point.h:47
Pt::Forms::MenuSubItem
Represents a menu item that opens a nested menu.
Definition:
MenuSubItem.h:57
Pt::Forms::MenuBase::parentItem
MenuItemBase * parentItem()
Returns the item associated with this nested menu, or 0 for a root menu.
Definition:
MenuBase.h:98
Pt::Forms::MenuBase::MenuBase
MenuBase()
Creates an unassociated menu coordination interface.
Pt::Forms::MenuBase::closeMenu
void closeMenu(MenuSubItem &item)
Closes the submenu associated with item.
Definition:
MenuBase.h:77
Pt::Forms::MenuBase::setParentItem
void setParentItem(MenuItemBase *item)
Associates this nested menu with item.
Definition:
MenuBase.h:107
Pt::Forms::MenuBase::parentItem
const MenuItemBase * parentItem() const
Returns the item associated with this nested menu, or 0 for a root menu.
Definition:
MenuBase.h:91
Pt::Forms::MenuBase::removeMenu
void removeMenu(MenuSubItem &item)
Unregisters item as a submenu entry.
Definition:
MenuBase.h:121
Pt::Forms::MenuItemBase
Represents the common content and activation behavior of a menu item.
Definition:
MenuItemBase.h:55
Pt::Forms::MenuBase::findMenu
Pt::Forms::Widget * findMenu(const Pt::Gfx::PointF &screenPos)
Returns the menu widget at screenPos, or 0 when none is found.
Definition:
MenuBase.h:70