]>
Dogcows Code - chaz/openbox/blob - src/Basemenu.h
1 // Basemenu.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
34 typedef std::vector
<BasemenuItem
*> menuitemList
;
38 menuitemList menuitems
;
41 BImageControl
*image_ctrl
;
44 Bool moving
, visible
, movable
, torn
, internal_menu
, title_vis
, shifted
,
47 int which_sub
, which_press
, which_sbl
, alignment
;
50 Pixmap frame_pixmap
, title_pixmap
, hilite_pixmap
, sel_pixmap
;
51 Window window
, frame
, title
;
54 int x
, y
, x_move
, y_move
, x_shift
, y_shift
, sublevels
, persub
, minsub
,
56 unsigned int width
, height
, title_h
, frame_h
, item_w
, item_h
, bevel_w
,
62 inline BasemenuItem
*find(int index
) { return menuitems
[index
]; }
63 inline void setTitleVisibility(Bool b
) { title_vis
= b
; }
64 inline void setMovable(Bool b
) { movable
= b
; }
65 inline void setHideTree(Bool h
) { hide_tree
= h
; }
66 inline void setMinimumSublevels(int m
) { menu
.minsub
= m
; }
68 virtual void itemSelected(int, int) = 0;
69 virtual void drawItem(int, Bool
= False
, Bool
= False
,
70 int = -1, int = -1, unsigned int = 0,
72 virtual void redrawTitle();
73 virtual void internal_hide(void);
78 virtual ~Basemenu(void);
80 inline const Bool
&isTorn(void) const { return torn
; }
81 inline const Bool
&isVisible(void) const { return visible
; }
83 inline BScreen
&getScreen(void) { return screen
; }
85 inline const Window
&getWindowID(void) const { return menu
.window
; }
87 inline const char *getLabel(void) const { return menu
.label
; }
89 int insert(const char *, int = 0, const char * = (const char *) 0, int = -1);
90 int insert(const char **, int = -1, int = 0);
91 int insert(const char *, Basemenu
*, int = -1);
94 inline int getX(void) const { return menu
.x
; }
95 inline int getY(void) const { return menu
.y
; }
96 inline unsigned int getCount(void) { return menuitems
.size(); }
97 inline int getCurrentSubmenu(void) const { return which_sub
; }
99 inline unsigned int getWidth(void) const { return menu
.width
; }
100 inline unsigned int getHeight(void) const { return menu
.height
; }
101 inline unsigned int getTitleHeight(void) const { return menu
.title_h
; }
103 inline void setInternalMenu(void) { internal_menu
= True
; }
104 inline void setAlignment(int a
) { alignment
= a
; }
105 inline void setTorn(void) { torn
= True
; }
106 inline void removeParent(void)
107 { if (internal_menu
) parent
= (Basemenu
*) 0; }
109 bool hasSubmenu(int);
110 bool isItemSelected(int);
111 bool isItemEnabled(int);
113 void buttonPressEvent(XButtonEvent
*);
114 void buttonReleaseEvent(XButtonEvent
*);
115 void motionNotifyEvent(XMotionEvent
*);
116 void enterNotifyEvent(XCrossingEvent
*);
117 void leaveNotifyEvent(XCrossingEvent
*);
118 void exposeEvent(XExposeEvent
*);
119 void reconfigure(void);
120 void setLabel(const char *n
);
123 void setItemSelected(int, bool);
124 void setItemEnabled(int, bool);
126 virtual void drawSubmenu(int);
127 virtual void show(void);
128 virtual void hide(void);
130 enum { AlignDontCare
= 1, AlignTop
, AlignBottom
};
131 enum { Right
= 1, Left
};
132 enum { Empty
= 0, Square
, Triangle
, Diamond
};
139 const char **u
, *l
, *e
;
140 int f
, enabled
, selected
;
142 friend class Basemenu
;
147 BasemenuItem(const char *lp
, int fp
, const char *ep
= (const char *) 0):
148 s(0), u(0), l(lp
), e(ep
), f(fp
), enabled(1), selected(0) {}
150 BasemenuItem(const char *lp
, Basemenu
*mp
): s(mp
), u(0), l(lp
), e(0), f(0),
151 enabled(1), selected(0) {}
153 BasemenuItem(const char **up
, int fp
): s(0), u(up
), l(0), e(0), f(fp
),
154 enabled(1), selected(0) {}
156 inline const char *exec(void) const { return e
; }
157 inline const char *label(void) const { return l
; }
158 inline const char **ulabel(void) const { return u
; }
159 inline const int &function(void) const { return f
; }
160 inline Basemenu
*submenu(void) { return s
; }
162 inline const int &isEnabled(void) const { return enabled
; }
163 inline void setEnabled(int e
) { enabled
= e
; }
164 inline const int &isSelected(void) const { return selected
; }
165 inline void setSelected(int s
) { selected
= s
; }
169 #endif // __Basemenu_hh
This page took 0.040916 seconds and 4 git commands to generate.