diff options
Diffstat (limited to 'src/Basemenu.hh')
-rw-r--r-- | src/Basemenu.hh | 117 |
1 files changed, 55 insertions, 62 deletions
diff --git a/src/Basemenu.hh b/src/Basemenu.hh index 27aed54..14f7c67 100644 --- a/src/Basemenu.hh +++ b/src/Basemenu.hh | |||
@@ -1,3 +1,6 @@ | |||
1 | // Basemenu.hh for Fluxbox Window manager | ||
2 | // Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // | ||
1 | // Basemenu.hh for Blackbox - an X11 Window manager | 4 | // Basemenu.hh for Blackbox - an X11 Window manager |
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | 5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) |
3 | // | 6 | // |
@@ -19,10 +22,14 @@ | |||
19 | // 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 |
20 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
21 | 24 | ||
22 | #ifndef __Basemenu_hh | 25 | // $Id: Basemenu.hh,v 1.7 2002/02/17 19:00:04 fluxgen Exp $ |
23 | #define __Basemenu_hh | 26 | |
27 | #ifndef BASEMENU_HH | ||
28 | #define BASEMENU_HH | ||
24 | 29 | ||
25 | #include <X11/Xlib.h> | 30 | #include <X11/Xlib.h> |
31 | #include <vector> | ||
32 | #include <string> | ||
26 | 33 | ||
27 | // forward declarations | 34 | // forward declarations |
28 | class Basemenu; | 35 | class Basemenu; |
@@ -32,12 +39,10 @@ class Fluxbox; | |||
32 | class BImageControl; | 39 | class BImageControl; |
33 | class BScreen; | 40 | class BScreen; |
34 | 41 | ||
35 | #include "LinkedList.hh" | ||
36 | |||
37 | |||
38 | class Basemenu { | 42 | class Basemenu { |
39 | private: | 43 | private: |
40 | LinkedList<BasemenuItem> *menuitems; | 44 | typedef std::vector<BasemenuItem *> Menuitems; |
45 | Menuitems menuitems; | ||
41 | Fluxbox *fluxbox; | 46 | Fluxbox *fluxbox; |
42 | Basemenu *parent; | 47 | Basemenu *parent; |
43 | BImageControl *image_ctrl; | 48 | BImageControl *image_ctrl; |
@@ -61,7 +66,7 @@ private: | |||
61 | 66 | ||
62 | 67 | ||
63 | protected: | 68 | protected: |
64 | inline BasemenuItem *find(int index) { return menuitems->find(index); } | 69 | inline BasemenuItem *find(int index) { return menuitems[index]; } |
65 | inline void setTitleVisibility(Bool b) { title_vis = b; } | 70 | inline void setTitleVisibility(Bool b) { title_vis = b; } |
66 | inline void setMovable(Bool b) { movable = b; } | 71 | inline void setMovable(Bool b) { movable = b; } |
67 | inline void setHideTree(Bool h) { hide_tree = h; } | 72 | inline void setHideTree(Bool h) { hide_tree = h; } |
@@ -94,7 +99,7 @@ public: | |||
94 | 99 | ||
95 | inline const int &getX(void) const { return menu.x; } | 100 | inline const int &getX(void) const { return menu.x; } |
96 | inline const int &getY(void) const { return menu.y; } | 101 | inline const int &getY(void) const { return menu.y; } |
97 | inline int getCount(void) { return menuitems->count(); } | 102 | inline int getCount(void) { return menuitems.size(); } |
98 | inline const int &getCurrentSubmenu(void) const { return which_sub; } | 103 | inline const int &getCurrentSubmenu(void) const { return which_sub; } |
99 | 104 | ||
100 | inline const unsigned int &getWidth(void) const { return menu.width; } | 105 | inline const unsigned int &getWidth(void) const { return menu.width; } |
@@ -128,65 +133,53 @@ public: | |||
128 | virtual void show(void); | 133 | virtual void show(void); |
129 | virtual void hide(void); | 134 | virtual void hide(void); |
130 | 135 | ||
131 | enum { AlignDontCare = 1, AlignTop, AlignBottom }; | 136 | enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; |
132 | enum { Right = 1, Left }; | 137 | enum { RIGHT = 1, LEFT }; |
133 | enum { Empty = 0, Square, Triangle, Diamond }; | 138 | enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; |
134 | }; | ||
135 | 139 | ||
140 | }; | ||
136 | 141 | ||
137 | class BasemenuItem { | 142 | class BasemenuItem { |
138 | private: | 143 | public: |
139 | Basemenu *s; | 144 | BasemenuItem( |
140 | const char **u, *l, *e; | 145 | const char *label, |
141 | int f, enabled, selected; | 146 | int function, |
142 | 147 | const char *exec = (const char *) 0) | |
143 | friend class Basemenu; | 148 | : m_label(label ? label : "") |
144 | 149 | , m_exec(exec ? exec : "") | |
145 | 150 | , m_submenu(0) | |
146 | protected: | 151 | , m_function(function) |
152 | , m_enabled(true) | ||
153 | , m_selected(false) | ||
154 | { } | ||
155 | |||
156 | BasemenuItem(const char *label, Basemenu *submenu) | ||
157 | : m_label(label ? label : "") | ||
158 | , m_exec("") | ||
159 | , m_submenu(submenu) | ||
160 | , m_function(0) | ||
161 | , m_enabled(true) | ||
162 | , m_selected(false) | ||
163 | { } | ||
164 | |||
165 | inline const char *exec(void) const { return m_exec.c_str(); } | ||
166 | inline const char *label(void) const { return m_label.c_str(); } | ||
167 | inline int function(void) const { return m_function; } | ||
168 | inline Basemenu *submenu(void) { return m_submenu; } | ||
169 | |||
170 | inline bool isEnabled(void) const { return m_enabled; } | ||
171 | inline void setEnabled(bool enabled) { m_enabled = enabled; } | ||
172 | inline bool isSelected(void) const { return m_selected; } | ||
173 | inline void setSelected(bool selected) { m_selected = selected; } | ||
147 | 174 | ||
175 | private: | ||
176 | std::string m_label, m_exec; | ||
177 | Basemenu *m_submenu; | ||
178 | int m_function; | ||
179 | bool m_enabled, m_selected; | ||
148 | 180 | ||
149 | public: | 181 | friend class Basemenu; |
150 | BasemenuItem(const char *lp, int fp, const char *ep = (const char *) 0) { | ||
151 | l = lp; | ||
152 | e = ep; | ||
153 | s = 0; | ||
154 | f = fp; | ||
155 | u = 0; | ||
156 | enabled = 1; | ||
157 | selected = 0; | ||
158 | } | ||
159 | |||
160 | BasemenuItem(const char *lp, Basemenu *mp) { | ||
161 | l = lp; | ||
162 | s = mp; | ||
163 | e = 0; | ||
164 | f = 0; | ||
165 | u = 0; | ||
166 | enabled = 1; | ||
167 | selected = 0; | ||
168 | } | ||
169 | |||
170 | BasemenuItem(const char **up, int fp) { | ||
171 | u = up; | ||
172 | l = e = 0; | ||
173 | f = fp; | ||
174 | s = 0; | ||
175 | enabled = 1; | ||
176 | selected = 0; | ||
177 | } | ||
178 | |||
179 | inline const char *exec(void) const { return e; } | ||
180 | inline const char *label(void) const { return l; } | ||
181 | inline const char **ulabel(void) const { return u; } | ||
182 | inline const int &function(void) const { return f; } | ||
183 | inline Basemenu *submenu(void) { return s; } | ||
184 | |||
185 | inline const int &isEnabled(void) const { return enabled; } | ||
186 | inline void setEnabled(int e) { enabled = e; } | ||
187 | inline const int &isSelected(void) const { return selected; } | ||
188 | inline void setSelected(int s) { selected = s; } | ||
189 | }; | 182 | }; |
190 | 183 | ||
191 | 184 | ||
192 | #endif // __Basemenu_hh | 185 | #endif // _BASEMENU_HH_ |