aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/MenuItem.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/MenuItem.hh')
-rw-r--r--src/FbTk/MenuItem.hh22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh
index 20da8f7..b3b2f6b 100644
--- a/src/FbTk/MenuItem.hh
+++ b/src/FbTk/MenuItem.hh
@@ -42,6 +42,7 @@ class MenuItem {
42public: 42public:
43 MenuItem() 43 MenuItem()
44 : m_label(""), 44 : m_label(""),
45 m_menu(0),
45 m_submenu(0), 46 m_submenu(0),
46 m_enabled(true), 47 m_enabled(true),
47 m_selected(false), 48 m_selected(false),
@@ -50,14 +51,25 @@ public:
50 explicit MenuItem( 51 explicit MenuItem(
51 const char *label) 52 const char *label)
52 : m_label(label ? label : ""), 53 : m_label(label ? label : ""),
54 m_menu(0),
55 m_submenu(0),
56 m_enabled(true),
57 m_selected(false),
58 m_toggle_item(false)
59 { }
60
61 MenuItem(const char *label, Menu &host_menu)
62 : m_label(label ? label : ""),
63 m_menu(&host_menu),
53 m_submenu(0), 64 m_submenu(0),
54 m_enabled(true), 65 m_enabled(true),
55 m_selected(false), 66 m_selected(false),
56 m_toggle_item(false) 67 m_toggle_item(false)
57 { } 68 { }
58 /// create a menu item with a specific command to be executed on click 69 /// create a menu item with a specific command to be executed on click
59 MenuItem(const char *label, RefCount<Command> &cmd): 70 MenuItem(const char *label, RefCount<Command> &cmd, Menu *menu = 0):
60 m_label(label ? label : ""), 71 m_label(label ? label : ""),
72 m_menu(menu),
61 m_submenu(0), 73 m_submenu(0),
62 m_command(cmd), 74 m_command(cmd),
63 m_enabled(true), 75 m_enabled(true),
@@ -66,8 +78,9 @@ public:
66 78
67 } 79 }
68 80
69 MenuItem(const char *label, Menu *submenu) 81 MenuItem(const char *label, Menu *submenu, Menu *host_menu = 0)
70 : m_label(label ? label : "") 82 : m_label(label ? label : "")
83 , m_menu(host_menu)
71 , m_submenu(submenu) 84 , m_submenu(submenu)
72 , m_enabled(true) 85 , m_enabled(true)
73 , m_selected(false), 86 , m_selected(false),
@@ -110,9 +123,13 @@ public:
110 RefCount<Command> &command() { return m_command; } 123 RefCount<Command> &command() { return m_command; }
111 const RefCount<Command> &command() const { return m_command; } 124 const RefCount<Command> &command() const { return m_command; }
112 //@} 125 //@}
126
127 void setMenu(Menu &menu) { m_menu = &menu; }
128 Menu *menu() { return m_menu; }
113 129
114private: 130private:
115 std::string m_label; ///< label of this item 131 std::string m_label; ///< label of this item
132 Menu *m_menu; ///< the menu we live in
116 Menu *m_submenu; ///< a submenu, 0 if we don't have one 133 Menu *m_submenu; ///< a submenu, 0 if we don't have one
117 RefCount<Command> m_command; ///< command to be executed 134 RefCount<Command> m_command; ///< command to be executed
118 bool m_enabled, m_selected; 135 bool m_enabled, m_selected;
@@ -123,6 +140,7 @@ private:
123 std::string filename; 140 std::string filename;
124 }; 141 };
125 std::auto_ptr<Icon> m_icon; 142 std::auto_ptr<Icon> m_icon;
143
126}; 144};
127 145
128} // end namespace FbTk 146} // end namespace FbTk