diff options
author | fluxgen <fluxgen> | 2003-01-12 17:02:33 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-01-12 17:02:33 (GMT) |
commit | 5dabdacd6f60fee4877e86caf2875087de86bb38 (patch) | |
tree | c26a1bb561ed387d5295c3747038de7c8acfb17e /src/FbTk | |
parent | aff60c437cf1d9d6d78cfc12b3a1d733113ae1fa (diff) | |
download | fluxbox_lack-5dabdacd6f60fee4877e86caf2875087de86bb38.zip fluxbox_lack-5dabdacd6f60fee4877e86caf2875087de86bb38.tar.bz2 |
moved out MenuItem to MenuItem.hh
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Menu.hh | 62 |
1 files changed, 6 insertions, 56 deletions
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 0feab76..49c82d7 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Menu.hh,v 1.4 2003/01/10 00:46:54 fluxgen Exp $ | 25 | // $Id: Menu.hh,v 1.5 2003/01/12 17:02:33 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_MENU_HH | 27 | #ifndef FBTK_MENU_HH |
28 | #define FBTK_MENU_HH | 28 | #define FBTK_MENU_HH |
@@ -42,7 +42,6 @@ class MenuItem; | |||
42 | class MenuTheme; | 42 | class MenuTheme; |
43 | class ImageControl; | 43 | class ImageControl; |
44 | 44 | ||
45 | |||
46 | /// Base class for menus | 45 | /// Base class for menus |
47 | class Menu: public FbTk::EventHandler { | 46 | class Menu: public FbTk::EventHandler { |
48 | public: | 47 | public: |
@@ -67,6 +66,8 @@ public: | |||
67 | int insert(const char *label, int pos=-1); | 66 | int insert(const char *label, int pos=-1); |
68 | /// add submenu | 67 | /// add submenu |
69 | int insert(const char *label, Menu *submenu, int pos= -1); | 68 | int insert(const char *label, Menu *submenu, int pos= -1); |
69 | /// add menu item | ||
70 | int insert(MenuItem *item, int pos=-1); | ||
70 | /// remove an item | 71 | /// remove an item |
71 | int remove(unsigned int item); | 72 | int remove(unsigned int item); |
72 | /// remove all items | 73 | /// remove all items |
@@ -101,6 +102,7 @@ public: | |||
101 | void update(); | 102 | void update(); |
102 | void setItemSelected(unsigned int index, bool val); | 103 | void setItemSelected(unsigned int index, bool val); |
103 | void setItemEnabled(unsigned int index, bool val); | 104 | void setItemEnabled(unsigned int index, bool val); |
105 | inline void setMinimumSublevels(int m) { menu.minsub = m; } | ||
104 | virtual void drawSubmenu(unsigned int index); | 106 | virtual void drawSubmenu(unsigned int index); |
105 | /// show menu | 107 | /// show menu |
106 | virtual void show(); | 108 | virtual void show(); |
@@ -135,7 +137,7 @@ protected: | |||
135 | inline void setTitleVisibility(bool b) { title_vis = b; } | 137 | inline void setTitleVisibility(bool b) { title_vis = b; } |
136 | inline void setMovable(bool b) { movable = b; } | 138 | inline void setMovable(bool b) { movable = b; } |
137 | inline void setHideTree(bool h) { hide_tree = h; } | 139 | inline void setHideTree(bool h) { hide_tree = h; } |
138 | inline void setMinimumSublevels(int m) { menu.minsub = m; } | 140 | |
139 | 141 | ||
140 | virtual void itemSelected(int button, unsigned int index) { } | 142 | virtual void itemSelected(int button, unsigned int index) { } |
141 | virtual void drawItem(unsigned int index, bool highlight = false, | 143 | virtual void drawItem(unsigned int index, bool highlight = false, |
@@ -176,58 +178,6 @@ private: | |||
176 | 178 | ||
177 | }; | 179 | }; |
178 | 180 | ||
179 | /** | ||
180 | A menu item in Menu | ||
181 | */ | ||
182 | class MenuItem { | ||
183 | public: | ||
184 | MenuItem( | ||
185 | const char *label) | ||
186 | : m_label(label ? label : ""), | ||
187 | m_submenu(0), | ||
188 | m_enabled(true), | ||
189 | m_selected(false) | ||
190 | { } | ||
191 | /// create a menu item with a specific command to be executed on click | ||
192 | MenuItem(const char *label, RefCount<Command> &cmd): | ||
193 | m_label(label ? label : ""), | ||
194 | m_submenu(0), | ||
195 | m_command(cmd), | ||
196 | m_enabled(true), | ||
197 | m_selected(false) { | ||
198 | |||
199 | } | ||
200 | |||
201 | MenuItem(const char *label, Menu *submenu) | ||
202 | : m_label(label ? label : "") | ||
203 | , m_submenu(submenu) | ||
204 | , m_enabled(true) | ||
205 | , m_selected(false) | ||
206 | { } | ||
207 | |||
208 | void setSelected(bool selected) { m_selected = selected; } | ||
209 | void setEnabled(bool enabled) { m_enabled = enabled; } | ||
210 | Menu *submenu() { return m_submenu; } | ||
211 | /** | ||
212 | @name accessors | ||
213 | */ | ||
214 | //@{ | ||
215 | const std::string &label() const { return m_label; } | ||
216 | const Menu *submenu() const { return m_submenu; } | ||
217 | bool isEnabled() const { return m_enabled; } | ||
218 | bool isSelected() const { return m_selected; } | ||
219 | RefCount<Command> &command() { return m_command; } | ||
220 | const RefCount<Command> &command() const { return m_command; } | ||
221 | //@} | ||
222 | |||
223 | private: | ||
224 | std::string m_label; ///< label of this item | ||
225 | Menu *m_submenu; ///< a submenu, 0 if we don't have one | ||
226 | RefCount<Command> m_command; ///< command to be executed | ||
227 | bool m_enabled, m_selected; | ||
228 | |||
229 | friend class Menu; | ||
230 | }; | ||
231 | |||
232 | }; // end namespace FbTk | 181 | }; // end namespace FbTk |
182 | |||
233 | #endif // FBTK_MENU_HH | 183 | #endif // FBTK_MENU_HH |