summaryrefslogtreecommitdiff
path: root/src/Basemenu.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-04-08 22:37:49 (GMT)
committerfluxgen <fluxgen>2002-04-08 22:37:49 (GMT)
commit45364e82b303bc05df73019b13e840b36f44bd34 (patch)
treecae2a8cf028b573b9f10340f18eec146627222fc /src/Basemenu.hh
parent02253281ee96b0b68a3369d4a02bd90a216c9c58 (diff)
downloadfluxbox_lack-45364e82b303bc05df73019b13e840b36f44bd34.zip
fluxbox_lack-45364e82b303bc05df73019b13e840b36f44bd34.tar.bz2
clean up
Diffstat (limited to 'src/Basemenu.hh')
-rw-r--r--src/Basemenu.hh120
1 files changed, 56 insertions, 64 deletions
diff --git a/src/Basemenu.hh b/src/Basemenu.hh
index f91e14f..616ca38 100644
--- a/src/Basemenu.hh
+++ b/src/Basemenu.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: Basemenu.hh,v 1.11 2002/04/03 23:08:19 fluxgen Exp $ 25// $Id: Basemenu.hh,v 1.12 2002/04/08 22:37:49 fluxgen Exp $
26 26
27#ifndef BASEMENU_HH 27#ifndef BASEMENU_HH
28#define BASEMENU_HH 28#define BASEMENU_HH
@@ -31,90 +31,82 @@
31#include <vector> 31#include <vector>
32#include <string> 32#include <string>
33 33
34// forward declarations
35class Basemenu; 34class Basemenu;
36class BasemenuItem; 35class BasemenuItem;
37
38class Fluxbox; 36class Fluxbox;
39class BImageControl; 37class BImageControl;
40class BScreen; 38class BScreen;
41 39
42class Basemenu { 40class Basemenu {
43public: 41public:
44 explicit Basemenu(BScreen *); 42 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
45 virtual ~Basemenu(void); 43 enum { RIGHT = 1, LEFT };
46 44 enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
47 inline const Bool &isTorn(void) const { return torn; } 45
48 inline const Bool &isVisible(void) const { return visible; } 46 explicit Basemenu(BScreen *screen);
49 47 virtual ~Basemenu();
50 inline BScreen *getScreen(void) const { return screen; }
51
52 inline const Window &getWindowID(void) const { return menu.window; }
53
54 inline const char *getLabel(void) const { return menu.label; }
55
56 int insert(const char *, int = 0, const char * = 0, int = -1);
57 48
58 int insert(const char *, Basemenu *, int = -1); 49 //manipulators
50 int insert(const char *label, int function= 0, const char *exec = 0, int pos = -1);
51 int insert(const char *label, Basemenu *submenu, int pos= -1);
59 int remove(unsigned int item); 52 int remove(unsigned int item);
60 53 inline void setInternalMenu() { internal_menu = true; }
61 inline const int &getX(void) const { return menu.x; } 54 inline void setAlignment(Alignment a) { m_alignment = a; }
62 inline const int &getY(void) const { return menu.y; } 55 inline void setTorn() { torn = true; }
63 inline int getCount(void) { return menuitems.size(); } 56 inline void removeParent() { if (internal_menu) m_parent = 0; }
64 inline const int &getCurrentSubmenu(void) const { return which_sub; }
65
66 inline const unsigned int &getWidth(void) const { return menu.width; }
67 inline const unsigned int &getHeight(void) const { return menu.height; }
68 inline const unsigned int &getTitleHeight(void) const { return menu.title_h; }
69
70 inline void setInternalMenu(void) { internal_menu = True; }
71 inline void setAlignment(int a) { alignment = a; }
72 inline void setTorn(void) { torn = True; }
73 inline void removeParent(void) { if (internal_menu) parent = (Basemenu *) 0; }
74
75 bool hasSubmenu(unsigned int index);
76 bool isItemSelected(unsigned int index);
77 bool isItemEnabled(unsigned int index);
78
79 void buttonPressEvent(XButtonEvent *); 57 void buttonPressEvent(XButtonEvent *);
80 void buttonReleaseEvent(XButtonEvent *); 58 void buttonReleaseEvent(XButtonEvent *);
81 void motionNotifyEvent(XMotionEvent *); 59 void motionNotifyEvent(XMotionEvent *);
82 void enterNotifyEvent(XCrossingEvent *); 60 void enterNotifyEvent(XCrossingEvent *);
83 void leaveNotifyEvent(XCrossingEvent *); 61 void leaveNotifyEvent(XCrossingEvent *);
84 void exposeEvent(XExposeEvent *); 62 void exposeEvent(XExposeEvent *);
85 void reconfigure(void); 63 void reconfigure();
86 void setLabel(const char *n); 64 void setLabel(const char *n);
87 void move(int, int); 65 void move(int x, int y);
88 void update(void); 66 void update();
89 void setItemSelected(unsigned int index, bool val); 67 void setItemSelected(unsigned int index, bool val);
90 void setItemEnabled(unsigned int, bool val); 68 void setItemEnabled(unsigned int index, bool val);
91
92 virtual void drawSubmenu(unsigned int index); 69 virtual void drawSubmenu(unsigned int index);
93 virtual void show(void); 70 virtual void show();
94 virtual void hide(void); 71 virtual void hide();
95 72
96 enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; 73 //accessors
97 enum { RIGHT = 1, LEFT }; 74 inline bool isTorn() const { return torn; }
98 enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; 75 inline bool isVisible() const { return visible; }
76 inline BScreen *screen() const { return m_screen; }
77 inline const Window windowID() const { return menu.window; }
78 inline const std::string &label() const { return menu.label; }
79 inline int x() const { return menu.x; }
80 inline int y() const { return menu.y; }
81 inline unsigned int width() const { return menu.width; }
82 inline unsigned int height() const { return menu.height; }
83 inline unsigned int numberOfItems() const { return menuitems.size(); }
84 inline int currentSubmenu() const { return which_sub; }
85 inline unsigned int titleHeight() const { return menu.title_h; }
86 bool hasSubmenu(unsigned int index) const;
87 bool isItemSelected(unsigned int index) const;
88 bool isItemEnabled(unsigned int index) const;
99 89
100private: 90private:
101 typedef std::vector<BasemenuItem *> Menuitems; 91 typedef std::vector<BasemenuItem *> Menuitems;
92 Fluxbox *m_fluxbox;
93 BScreen *m_screen;
94 Display *m_display;
95 Basemenu *m_parent;
96 BImageControl *m_image_ctrl;
102 Menuitems menuitems; 97 Menuitems menuitems;
103 Fluxbox *fluxbox; 98
104 Basemenu *parent; 99 bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
105 BImageControl *image_ctrl;
106 BScreen *screen;
107
108 Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
109 hide_tree; 100 hide_tree;
110 Display *display; 101
111 int which_sub, which_press, which_sbl, alignment; 102 int which_sub, which_press, which_sbl;
103 Alignment m_alignment;
112 104
113 struct _menu { 105 struct _menu {
114 Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; 106 Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
115 Window window, frame, title; 107 Window window, frame, title;
116 108
117 char *label; 109 std::string label;
118 int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, 110 int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
119 grab_x, grab_y; 111 grab_x, grab_y;
120 unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, 112 unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
@@ -123,7 +115,7 @@ private:
123 115
124 116
125protected: 117protected:
126 inline BasemenuItem *find(unsigned int index) { return menuitems[index]; } 118 inline BasemenuItem *find(unsigned int index) const { return menuitems[index]; }
127 inline void setTitleVisibility(bool b) { title_vis = b; } 119 inline void setTitleVisibility(bool b) { title_vis = b; }
128 inline void setMovable(bool b) { movable = b; } 120 inline void setMovable(bool b) { movable = b; }
129 inline void setHideTree(bool h) { hide_tree = h; } 121 inline void setHideTree(bool h) { hide_tree = h; }
@@ -133,7 +125,7 @@ protected:
133 virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false, 125 virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false,
134 int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); 126 int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0);
135 virtual void redrawTitle(); 127 virtual void redrawTitle();
136 virtual void internal_hide(void); 128 virtual void internal_hide();
137}; 129};
138 130
139class BasemenuItem { 131class BasemenuItem {
@@ -159,14 +151,14 @@ public:
159 , m_selected(false) 151 , m_selected(false)
160 { } 152 { }
161 153
162 inline const char *exec(void) const { return m_exec.c_str(); } 154 inline const std::string &exec() const { return m_exec; }
163 inline const char *label(void) const { return m_label.c_str(); } 155 inline const std::string &label() const { return m_label; }
164 inline int function(void) const { return m_function; } 156 inline int function() const { return m_function; }
165 inline Basemenu *submenu(void) { return m_submenu; } 157 inline Basemenu *submenu() const { return m_submenu; }
166 158
167 inline bool isEnabled(void) const { return m_enabled; } 159 inline bool isEnabled() const { return m_enabled; }
168 inline void setEnabled(bool enabled) { m_enabled = enabled; } 160 inline void setEnabled(bool enabled) { m_enabled = enabled; }
169 inline bool isSelected(void) const { return m_selected; } 161 inline bool isSelected() const { return m_selected; }
170 inline void setSelected(bool selected) { m_selected = selected; } 162 inline void setSelected(bool selected) { m_selected = selected; }
171 163
172private: 164private: