aboutsummaryrefslogtreecommitdiff
path: root/src/Basemenu.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-01-12 18:19:45 (GMT)
committerfluxgen <fluxgen>2003-01-12 18:19:45 (GMT)
commit55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa (patch)
tree22389e0772fd84852ef994bbf5b597a67f3ab44a /src/Basemenu.hh
parent6c7f8c4d15333b22f3556447446d55b9325e28e7 (diff)
downloadfluxbox-55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa.zip
fluxbox-55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa.tar.bz2
replaced by FbTk Menu
Diffstat (limited to 'src/Basemenu.hh')
-rw-r--r--src/Basemenu.hh216
1 files changed, 0 insertions, 216 deletions
diff --git a/src/Basemenu.hh b/src/Basemenu.hh
deleted file mode 100644
index c68dad5..0000000
--- a/src/Basemenu.hh
+++ /dev/null
@@ -1,216 +0,0 @@
1// Basemenu.hh for Fluxbox Window manager
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
3//
4// Basemenu.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25// $Id: Basemenu.hh,v 1.23 2003/01/09 21:57:46 fluxgen Exp $
26
27#ifndef BASEMENU_HH
28#define BASEMENU_HH
29
30#include <X11/Xlib.h>
31#include <vector>
32#include <string>
33
34#include "FbWindow.hh"
35#include "EventHandler.hh"
36
37class BasemenuItem;
38class BScreen;
39
40namespace FbTk {
41class ImageControl;
42};
43
44/**
45 Base class for menus
46*/
47class Basemenu: public FbTk::EventHandler {
48public:
49 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
50 enum { RIGHT = 1, LEFT };
51
52 /**
53 Bullet type
54 */
55 enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
56
57 explicit Basemenu(BScreen *screen);
58 virtual ~Basemenu();
59
60 /**
61 @name manipulators
62 */
63 //@{
64 int insert(const char *label, int function= 0, const char *exec = 0, int pos = -1);
65 int insert(const char *label, Basemenu *submenu, int pos= -1);
66 int remove(unsigned int item);
67 inline void setInternalMenu() { internal_menu = true; }
68 inline void setAlignment(Alignment a) { m_alignment = a; }
69 inline void setTorn() { torn = true; }
70 inline void removeParent() { if (internal_menu) m_parent = 0; }
71 void raise();
72 void lower();
73 /**
74 @name event handlers
75 */
76 //@{
77 void buttonPressEvent(XButtonEvent &bp);
78 void buttonReleaseEvent(XButtonEvent &br);
79 void motionNotifyEvent(XMotionEvent &mn);
80 void enterNotifyEvent(XCrossingEvent &en);
81 void leaveNotifyEvent(XCrossingEvent &ce);
82 void exposeEvent(XExposeEvent &ee);
83 //@}
84
85 void reconfigure();
86 /// set label string
87 void setLabel(const char *labelstr);
88 /// move menu to x,y
89 void move(int x, int y);
90 void update();
91 void setItemSelected(unsigned int index, bool val);
92 void setItemEnabled(unsigned int index, bool val);
93 virtual void drawSubmenu(unsigned int index);
94 virtual void show();
95 virtual void hide();
96 /*@}*/
97
98 /**
99 @name accessors
100 */
101 //@{
102 bool isTorn() const { return torn; }
103 bool isVisible() const { return visible; }
104 const BScreen *screen() const { return m_screen; }
105 BScreen *screen() { return m_screen; }
106 Window windowID() const { return menu.window.window(); }
107 const std::string &label() const { return menu.label; }
108 int x() const { return menu.x; }
109 int y() const { return menu.y; }
110 unsigned int width() const { return menu.width; }
111 unsigned int height() const { return menu.height; }
112 unsigned int numberOfItems() const { return menuitems.size(); }
113 int currentSubmenu() const { return which_sub; }
114 unsigned int titleHeight() const { return menu.title_h; }
115 bool hasSubmenu(unsigned int index) const;
116 bool isItemSelected(unsigned int index) const;
117 bool isItemEnabled(unsigned int index) const;
118 //@}
119
120protected:
121
122 inline BasemenuItem *find(unsigned int index) const { return menuitems[index]; }
123 inline void setTitleVisibility(bool b) { title_vis = b; }
124 inline void setMovable(bool b) { movable = b; }
125 inline void setHideTree(bool h) { hide_tree = h; }
126 inline void setMinimumSublevels(int m) { menu.minsub = m; }
127
128 virtual void itemSelected(int button, unsigned int index) = 0;
129 virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false,
130 int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0);
131 virtual void redrawTitle();
132 virtual void internal_hide();
133 inline Basemenu *parent() { return m_parent; }
134 inline const Basemenu *parent() const { return m_parent; }
135
136private:
137
138 typedef std::vector<BasemenuItem *> Menuitems;
139 BScreen *m_screen;
140 Display *m_display;
141 Basemenu *m_parent;
142 FbTk::ImageControl *m_image_ctrl;
143 Menuitems menuitems;
144
145 bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
146 hide_tree;
147
148 int which_sub, which_press, which_sbl;
149 Alignment m_alignment;
150
151 struct _menu {
152 Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
153 FbTk::FbWindow window, frame, title;
154
155 std::string label;
156 int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
157 grab_x, grab_y;
158 unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
159 bevel_h;
160 } menu;
161
162};
163
164/**
165 A menu item in Basemenu
166*/
167class BasemenuItem {
168public:
169 BasemenuItem(
170 const char *label,
171 int function,
172 const char *exec = (const char *) 0)
173 : m_label(label ? label : "")
174 , m_exec(exec ? exec : "")
175 , m_submenu(0)
176 , m_function(function)
177 , m_enabled(true)
178 , m_selected(false)
179 { }
180
181 BasemenuItem(const char *label, Basemenu *submenu)
182 : m_label(label ? label : "")
183 , m_exec("")
184 , m_submenu(submenu)
185 , m_function(0)
186 , m_enabled(true)
187 , m_selected(false)
188 { }
189
190 void setSelected(bool selected) { m_selected = selected; }
191 void setEnabled(bool enabled) { m_enabled = enabled; }
192 Basemenu *submenu() { return m_submenu; }
193 /**
194 @name accessors
195 */
196 //@{
197 const std::string &exec() const { return m_exec; }
198 const std::string &label() const { return m_label; }
199 int function() const { return m_function; }
200 const Basemenu *submenu() const { return m_submenu; }
201 bool isEnabled() const { return m_enabled; }
202 bool isSelected() const { return m_selected; }
203 //@}
204
205private:
206 std::string m_label; ///< label of this item
207 std::string m_exec; ///< command string to execute
208 Basemenu *m_submenu; ///< a submenu, 0 if we don't have one
209 int m_function;
210 bool m_enabled, m_selected;
211
212 friend class Basemenu;
213};
214
215
216#endif // BASEMENU_HH