aboutsummaryrefslogtreecommitdiff
path: root/src/Basemenu.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
committerfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
commit18830ac9add80cbd3bf7369307d7e35a519dca9b (patch)
tree4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/Basemenu.hh
parent1523b48bff07dead084af3064ad11c79a9b25df0 (diff)
downloadfluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip
fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2
Initial revision
Diffstat (limited to 'src/Basemenu.hh')
-rw-r--r--src/Basemenu.hh192
1 files changed, 192 insertions, 0 deletions
diff --git a/src/Basemenu.hh b/src/Basemenu.hh
new file mode 100644
index 0000000..27aed54
--- /dev/null
+++ b/src/Basemenu.hh
@@ -0,0 +1,192 @@
1// Basemenu.hh for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef __Basemenu_hh
23#define __Basemenu_hh
24
25#include <X11/Xlib.h>
26
27// forward declarations
28class Basemenu;
29class BasemenuItem;
30
31class Fluxbox;
32class BImageControl;
33class BScreen;
34
35#include "LinkedList.hh"
36
37
38class Basemenu {
39private:
40 LinkedList<BasemenuItem> *menuitems;
41 Fluxbox *fluxbox;
42 Basemenu *parent;
43 BImageControl *image_ctrl;
44 BScreen *screen;
45
46 Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
47 hide_tree;
48 Display *display;
49 int which_sub, which_press, which_sbl, alignment;
50
51 struct _menu {
52 Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
53 Window window, frame, title;
54
55 char *label;
56 int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
57 grab_x, grab_y;
58 unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
59 bevel_h;
60 } menu;
61
62
63protected:
64 inline BasemenuItem *find(int index) { return menuitems->find(index); }
65 inline void setTitleVisibility(Bool b) { title_vis = b; }
66 inline void setMovable(Bool b) { movable = b; }
67 inline void setHideTree(Bool h) { hide_tree = h; }
68 inline void setMinimumSublevels(int m) { menu.minsub = m; }
69
70 virtual void itemSelected(int, int) = 0;
71 virtual void drawItem(int, Bool = False, Bool = False,
72 int = -1, int = -1, unsigned int = 0, unsigned int = 0);
73 virtual void redrawTitle();
74 virtual void internal_hide(void);
75
76
77public:
78 Basemenu(BScreen *);
79 virtual ~Basemenu(void);
80
81 inline const Bool &isTorn(void) const { return torn; }
82 inline const Bool &isVisible(void) const { return visible; }
83
84 inline BScreen *getScreen(void) { return screen; }
85
86 inline const Window &getWindowID(void) const { return menu.window; }
87
88 inline const char *getLabel(void) const { return menu.label; }
89
90 int insert(const char *, int = 0, const char * = (const char *) 0, int = -1);
91 int insert(const char **, int = -1, int = 0);
92 int insert(const char *, Basemenu *, int = -1);
93 int remove(int);
94
95 inline const int &getX(void) const { return menu.x; }
96 inline const int &getY(void) const { return menu.y; }
97 inline int getCount(void) { return menuitems->count(); }
98 inline const int &getCurrentSubmenu(void) const { return which_sub; }
99
100 inline const unsigned int &getWidth(void) const { return menu.width; }
101 inline const unsigned int &getHeight(void) const { return menu.height; }
102 inline const unsigned int &getTitleHeight(void) const { return menu.title_h; }
103
104 inline void setInternalMenu(void) { internal_menu = True; }
105 inline void setAlignment(int a) { alignment = a; }
106 inline void setTorn(void) { torn = True; }
107 inline void removeParent(void)
108 { if (internal_menu) parent = (Basemenu *) 0; }
109
110 Bool hasSubmenu(int);
111 Bool isItemSelected(int);
112 Bool isItemEnabled(int);
113
114 void buttonPressEvent(XButtonEvent *);
115 void buttonReleaseEvent(XButtonEvent *);
116 void motionNotifyEvent(XMotionEvent *);
117 void enterNotifyEvent(XCrossingEvent *);
118 void leaveNotifyEvent(XCrossingEvent *);
119 void exposeEvent(XExposeEvent *);
120 void reconfigure(void);
121 void setLabel(const char *n);
122 void move(int, int);
123 void update(void);
124 void setItemSelected(int, Bool);
125 void setItemEnabled(int, Bool);
126
127 virtual void drawSubmenu(int);
128 virtual void show(void);
129 virtual void hide(void);
130
131 enum { AlignDontCare = 1, AlignTop, AlignBottom };
132 enum { Right = 1, Left };
133 enum { Empty = 0, Square, Triangle, Diamond };
134};
135
136
137class BasemenuItem {
138private:
139 Basemenu *s;
140 const char **u, *l, *e;
141 int f, enabled, selected;
142
143 friend class Basemenu;
144
145
146protected:
147
148
149public:
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};
190
191
192#endif // __Basemenu_hh