]>
Dogcows Code - chaz/openbox/blob - Basemenu.h
ba28404c608879181de43cf727aca72cc82ea664
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.
33 #include "LinkedList.h"
38 LinkedList
<BasemenuItem
> *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
->find(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 const int &getX(void) const { return menu
.x
; }
95 inline const int &getY(void) const { return menu
.y
; }
96 inline int getCount(void) { return menuitems
->count(); }
97 inline const int &getCurrentSubmenu(void) const { return which_sub
; }
99 inline const unsigned int &getWidth(void) const { return menu
.width
; }
100 inline const unsigned int &getHeight(void) const { return menu
.height
; }
101 inline const unsigned int &getTitleHeight(void) const
102 { return menu
.title_h
; }
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; }
110 Bool
hasSubmenu(int);
111 Bool
isItemSelected(int);
112 Bool
isItemEnabled(int);
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
);
124 void setItemSelected(int, Bool
);
125 void setItemEnabled(int, Bool
);
127 virtual void drawSubmenu(int);
128 virtual void show(void);
129 virtual void hide(void);
131 enum { AlignDontCare
= 1, AlignTop
, AlignBottom
};
132 enum { Right
= 1, Left
};
133 enum { Empty
= 0, Square
, Triangle
, Diamond
};
140 const char **u
, *l
, *e
;
141 int f
, enabled
, selected
;
143 friend class Basemenu
;
148 BasemenuItem(const char *lp
, int fp
, const char *ep
= (const char *) 0):
149 s(0), u(0), l(lp
), e(ep
), f(fp
), enabled(1), selected(0) {}
151 BasemenuItem(const char *lp
, Basemenu
*mp
): s(mp
), u(0), l(lp
), e(0), f(0),
152 enabled(1), selected(0) {}
154 BasemenuItem(const char **up
, int fp
): s(0), u(up
), l(0), e(0), f(fp
),
155 enabled(1), selected(0) {}
157 inline const char *exec(void) const { return e
; }
158 inline const char *label(void) const { return l
; }
159 inline const char **ulabel(void) const { return u
; }
160 inline const int &function(void) const { return f
; }
161 inline Basemenu
*submenu(void) { return s
; }
163 inline const int &isEnabled(void) const { return enabled
; }
164 inline void setEnabled(int e
) { enabled
= e
; }
165 inline const int &isSelected(void) const { return selected
; }
166 inline void setSelected(int s
) { selected
= s
; }
170 #endif // __Basemenu_hh
This page took 0.038798 seconds and 3 git commands to generate.