Debian Codegraph @

include/ui/imenumanager.h

raw
1 #pragma once
2
3 #include "imodule.h"
4
5 class wxMenuBar;
6
7 namespace ui
8 {
9
10 namespace menu
11 {
12
13 /**
14 * greebo: The possible menu item types.
15 */
16 enum class ItemType
17 {
18 Nothing,
19 Root,
20 Bar,
21 Folder,
22 Item,
23 Separator,
24 };
25
26 // Interface of the menu items used by DarkRadiant's MenuManager
27 class IMenuElement
28 {
29 public:
30 virtual ~IMenuElement() {}
31
32 virtual ItemType getType() const = 0;
33
34 // The name of this element
35 virtual const std::string& getName() const = 0;
36
37 // Returns the event/statement that is associated to this item
38 virtual const std::string& getEvent() const = 0;
39
40 virtual void setAccelerator(const std::string& accelStr) = 0;
41
42 // Whether this item is a toggle-able item
43 virtual bool isToggle() const = 0;
44
45 virtual void setToggled(bool isToggled) = 0;
46 };
47
48 class IMenuManager :
49 public RegisterableModule
50 {
51 public:
52 /** Destructor
53 */
54 virtual ~IMenuManager() {}
55
56 /**
57 * Returns the constructed menu bar, ready for packing into a parent container.
58 */
59 virtual wxMenuBar* getMenuBar(const std::string& name) = 0;
60
61 /** greebo: Shows/hides the menuitem under the given path.
62 *
63 * @path: the path to the item (e.g. "main/view/cameraview")
64 * @visible: FALSE, if the widget should be hidden, TRUE otherwise
65 */
66 virtual void setVisibility(const std::string& path, bool visible) = 0;
67
68 /** greebo: Adds a new item as child under the given path.
69 *
70 * @insertPath: the path where to insert the item: "main/filters"
71 * @name: the name of the new item
72 * @type: the item type (usually menuFolder / menuItem)
73 * @caption: the display string of the menu item (incl. mnemonic)
74 * @icon: the icon filename (can be empty)
75 * @eventname: the event name (e.g. "ToggleShowSizeInfo")
76 */
77 virtual void add(const std::string& insertPath,
78 const std::string& name,
79 ItemType type,
80 const std::string& caption = "",
81 const std::string& icon = "",
82 const std::string& eventName = "") = 0;
83
84 /** greebo: Inserts a new menuItem as sibling _before_ the given insertPath.
85 *
86 * @insertPath: the path where to insert the item: "main/filters"
87 * @name: the name of the new menu item (no path, just the name)
88 * @caption: the display string including mnemonic
89 * @icon: the image file name relative to "bitmaps/", can be empty.
90 * @eventName: the event name this item is associated with (can be empty).
91 */
92 virtual void insert(const std::string& insertPath,
93 const std::string& name,
94 ItemType type,
95 const std::string& caption,
96 const std::string& icon,
97 const std::string& eventName) = 0;
98
99 // Returns true if the given path exists
100 virtual bool exists(const std::string& path) = 0;
101
102 /**
103 * Removes an entire path from the menus.
104 */
105 virtual void remove(const std::string& path) = 0;
106 };
107
108 } // namespace
109
110 } // namespace
111
112 constexpr const char* const MODULE_MENUMANAGER = "MenuManager";
113
114 inline ui::menu::IMenuManager& GlobalMenuManager()
115 {
116 static module::InstanceReference<ui::menu::IMenuManager> _reference(MODULE_MENUMANAGER);
117 return _reference;
118 }