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
35namespace Pt {
36namespace Forms {
37
38class MenuSubItem;
39class MenuItemBase;
40
50class PT_FORMS_API MenuBase
51{
52 public:
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
78 {
79 onCloseMenu(item);
80 }
81
85 {
86 onOpenMenu(item);
87 }
88
91 const MenuItemBase* parentItem() const
92 {
93 return _parentItem;
94 }
95
99 {
100 return _parentItem;
101 }
102
108 {
109 _parentItem = item;
110 }
111
115 {
116 onAddMenu(item);
117 }
118
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
void cancel()
Cancels the active menu interaction.
Definition MenuBase.h:63
void setParentItem(MenuItemBase *item)
Associates this nested menu with item.
Definition MenuBase.h:107
MenuItemBase * parentItem()
Returns the item associated with this nested menu, or 0 for a root menu.
Definition MenuBase.h:98
virtual ~MenuBase()
Destroys the menu coordination interface.
const MenuItemBase * parentItem() const
Returns the item associated with this nested menu, or 0 for a root menu.
Definition MenuBase.h:91
void closeMenu(MenuSubItem &item)
Closes the submenu associated with item.
Definition MenuBase.h:77
void addMenu(MenuSubItem &item)
Registers item as a submenu entry.
Definition MenuBase.h:114
void openMenu(MenuSubItem &item)
Opens the submenu associated with item.
Definition MenuBase.h:84
void removeMenu(MenuSubItem &item)
Unregisters item as a submenu entry.
Definition MenuBase.h:121
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
MenuBase()
Creates an unassociated menu coordination interface.
Represents the common content and activation behavior of a menu item.
Definition MenuItemBase.h:55
Represents a menu item that opens a nested menu.
Definition MenuSubItem.h:57
Common type of every visual Forms object.
Definition Widget.h:105
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33