/
MenuManager.h
85 lines (72 loc) · 2.46 KB
/
MenuManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <string>
#include "iuimanager.h"
#include "MenuElement.h"
/** greebo: The MenuManager takes care of adding and inserting the
* menuitems at the given paths.
*
* A valid menupath is for example: "main/file/exit" and consists of:
*
* <menubarID>/<menuItem>/.../<menuItem>
*
* The first part of the path is the name of the menubar you want to access.
* (the MenuManager can of course keep track of several menubars).
*
* Use the add() and insert() commands to create menuitems, the GtkWidget*
* pointers are delivered as return value.
*
*/
namespace ui {
class MenuManager :
public IMenuManager
{
// All known menubars
std::list<MenuElementPtr> _menuBars;
public:
// Constructor, initialises the menu from the registry
MenuManager();
wxMenuBar* getMenuBar(const std::string& name) override;
wxObject* get(const std::string& path) override;
void setVisibility(const std::string& path, bool visible) override;
/** greebo: Adds a new item as child under the given path.
*
* @insertPath: the path where to insert the item: "main/filters"
* @name: the name of the new item
* @type: the item type (usually menuFolder / menuItem)
* @caption: the display string of the menu item (incl. mnemonic)
* @icon: the icon filename (can be empty)
* @eventname: the event name (e.g. "ToggleShowSizeInfo")
*/
wxObject* add(const std::string& insertPath,
const std::string& name,
ui::eMenuItemType type,
const std::string& caption,
const std::string& icon,
const std::string& eventName) override;
/** greebo: Inserts a new menuItem as sibling _before_ the given insertPath.
*
* @insertPath: the path where to insert the item: "main/filters"
* @name: the name of the new menu item (no path, just the name)
* @caption: the display string including mnemonic
* @icon: the image file name relative to "bitmaps/", can be empty.
* @eventName: the event name this item is associated with (can be empty).
*/
wxObject* insert(const std::string& insertPath,
const std::string& name,
ui::eMenuItemType type,
const std::string& caption,
const std::string& icon,
const std::string& eventName) override;
/**
* Removes an entire menu subtree.
*/
void remove(const std::string& path) override;
/** greebo: Loads all the menu items from the registry, called upon initialisation.
*/
void loadFromRegistry();
/**
* Clears all references to GtkWidgets etc.
*/
void clear();
};
} // namespace ui