MenuSubItem.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_MENUSUBITEM_H
30#define PT_FORMS_MENUSUBITEM_H
31
32#include <Pt/Forms/Api.h>
33#include <Pt/Forms/MenuBase.h>
34#include <Pt/Forms/MenuItemBase.h>
35#include <Pt/Forms/Button.h>
36#include <Pt/Forms/Control.h>
37#include <Pt/Forms/FlowLayout.h>
38#include <Pt/SmartPtr.h>
39#include <vector>
40
41namespace Pt {
42namespace Forms {
43
44class Menu;
45class MenuBar;
46
56class PT_FORMS_API MenuSubItem : public MenuItemBase
57{
58 friend class Menu;
59
60 public:
64
65 public:
69
72 virtual ~MenuSubItem();
73
79 void setMenu(Menu* menu);
80
83 const Menu* menu() const
84 {
85 return _menu;
86 }
87
90 Menu* menu()
91 {
92 return _menu;
93 }
94
101 {
102 _parentMenu = p;
103 }
104
107 void cancel();
108
111 void closeMenu();
112
115 void openMenu();
116
119 bool isMenuOpen() const
120 {
121 return _isOpen;
122 }
123
124 protected:
125 virtual const std::vector<Key> onGetShortcuts();
126
127 virtual const std::vector<Pt::Char> onGetMnemonics();
128
129 virtual void onShortcut(const Key& key);
130
131 virtual void onMnemonic(Pt::Char m);
132
133 virtual void onPaint(PaintContext& context, const Pt::Gfx::RectF& updateRect);
134
135 private:
136 MenuBase* _parentMenu;
137 Menu* _menu;
138 bool _isOpen;
139};
140
141}}
142
143#endif
Key code and modifiers.
Definition Key.h:23
Represents a horizontal bar of top-level menus.
Definition MenuBar.h:78
Defines the coordination interface shared by menu containers.
Definition MenuBase.h:51
MenuItemBase()
Creates a menu item with empty content.
void cancel()
Cancels the nested menu interaction.
virtual void onPaint(PaintContext &context, const Pt::Gfx::RectF &updateRect)
Paints custom content in local coordinates.
void setParentMenu(MenuBase *p)
Sets the containing menu coordinator.
Definition MenuSubItem.h:100
Menu * menu()
Returns the nested menu, or 0 when none is assigned.
Definition MenuSubItem.h:90
virtual ~MenuSubItem()
Destroys the item.
void setMenu(Menu *menu)
Associates menu with this item.
virtual const std::vector< Key > onGetShortcuts()
Returns shortcuts registered by this control.
virtual void onShortcut(const Key &key)
Handles an activated form shortcut.
MenuItemBase Base
Defines the inherited menu item type.
Definition MenuSubItem.h:63
bool isMenuOpen() const
Returns true if the nested menu is open.
Definition MenuSubItem.h:119
virtual void onMnemonic(Pt::Char m)
Handles an activated form mnemonic.
virtual const std::vector< Pt::Char > onGetMnemonics()
Returns mnemonics registered by this control.
void closeMenu()
Closes the nested menu.
MenuSubItem()
Creates an item without a nested menu.
void openMenu()
Opens the nested menu.
const Menu * menu() const
Returns the nested menu, or 0 when none is assigned.
Definition MenuSubItem.h:83
Represents a popup menu containing commands and nested menus.
Definition Menu.h:71
Active painting session on a Forms paint surface.
Definition PaintContext.h:51
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33
Unicode character type.
Definition String.h:67