1 // Basemenu.hh for Blackbox - an X11 Window manager
2 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3 // Copyright (c) 2001 by Ben Jansens <xor@orodu.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.
32 #include "LinkedList.hh"
34 // forward declarations
42 LinkedList
<BasemenuItem
> *menuitems
;
45 BImageControl
*image_ctrl
;
47 Bool moving
, visible
, movable
, torn
, internal_menu
, title_vis
, shifted
,
50 int which_sub
, which_press
, which_sbl
, alignment
;
53 Pixmap frame_pixmap
, title_pixmap
, hilite_pixmap
, sel_pixmap
;
54 Window window
, frame
, title
;
57 int x
, y
, x_move
, y_move
, x_shift
, y_shift
, sublevels
, persub
, minsub
,
59 unsigned int width
, height
, title_h
, frame_h
, item_w
, item_h
, bevel_w
,
66 inline BasemenuItem
*find(int index
) { return menuitems
->find(index
); }
67 inline void setTitleVisibility(Bool b
) { title_vis
= b
; }
68 inline void setMovable(Bool b
) { movable
= b
; }
69 inline void setHideTree(Bool h
) { hide_tree
= h
; }
70 inline void setMinimumSublevels(int m
) { menu
.minsub
= m
; }
72 virtual void itemSelected(int, int) = 0;
73 virtual void drawItem(int, Bool
= False
, Bool
= False
,
74 int = -1, int = -1, unsigned int = 0, unsigned int = 0);
75 virtual void redrawTitle();
76 virtual void internal_hide(void);
80 Basemenu(ToolWindow
*);
81 virtual ~Basemenu(void);
83 inline const Bool
&isTorn(void) const { return torn
; }
84 inline const Bool
&isVisible(void) const { return visible
; }
86 // inline BScreen *getScreen(void) { return screen; }
88 inline const Window
&getWindowID(void) const { return menu
.window
; }
90 inline const char *getLabel(void) const { return menu
.label
; }
92 int insert(const char *, int = 0, const char * = (const char *) 0, int = -1);
93 int insert(const char **, int = -1, int = 0);
94 int insert(const char *, Basemenu
*, int = -1);
97 inline const int &getX(void) const { return menu
.x
; }
98 inline const int &getY(void) const { return menu
.y
; }
99 inline int getCount(void) { return menuitems
->count(); }
100 inline const int &getCurrentSubmenu(void) const { return which_sub
; }
102 inline const unsigned int &getWidth(void) const { return menu
.width
; }
103 inline const unsigned int &getHeight(void) const { return menu
.height
; }
104 inline const unsigned int &getTitleHeight(void) const { return menu
.title_h
; }
106 inline void setInternalMenu(void) { internal_menu
= True
; }
107 inline void setAlignment(int a
) { alignment
= a
; }
108 inline void setTorn(void) { torn
= True
; }
109 inline void removeParent(void)
110 { if (internal_menu
) parent
= (Basemenu
*) 0; }
112 Bool
hasSubmenu(int);
113 Bool
isItemSelected(int);
114 Bool
isItemEnabled(int);
116 void buttonPressEvent(XButtonEvent
*);
117 void buttonReleaseEvent(XButtonEvent
*);
118 void motionNotifyEvent(XMotionEvent
*);
119 void enterNotifyEvent(XCrossingEvent
*);
120 void leaveNotifyEvent(XCrossingEvent
*);
121 void exposeEvent(XExposeEvent
*);
122 void reconfigure(void);
123 void setLabel(const char *n
);
126 void setItemSelected(int, Bool
);
127 void setItemEnabled(int, Bool
);
129 virtual void drawSubmenu(int);
130 virtual void show(void);
131 virtual void hide(void);
133 enum { AlignDontCare
= 1, AlignTop
, AlignBottom
};
134 enum { Right
= 1, Left
};
135 enum { Empty
= 0, Square
, Triangle
, Diamond
};
136 enum { LeftJustify
= 1, RightJustify
, CenterJustify
};
138 inline const void setHighlight(int i
) { selected_item
= i
; }
145 const char **u
, *l
, *e
;
146 int f
, enabled
, selected
;
148 friend class Basemenu
;
155 BasemenuItem(const char *lp
, int fp
, const char *ep
= (const char *) 0) {
165 BasemenuItem(const char *lp
, Basemenu
*mp
) {
175 BasemenuItem(const char **up
, int fp
) {
184 inline const char *exec(void) const { return e
; }
185 inline const char *label(void) const { return l
; }
186 inline const char **ulabel(void) const { return u
; }
187 inline const int &function(void) const { return f
; }
188 inline Basemenu
*submenu(void) { return s
; }
190 inline const int &isEnabled(void) const { return enabled
; }
191 inline void setEnabled(int en
) { enabled
= en
; }
192 inline const int &isSelected(void) const { return selected
; }
193 inline void setSelected(int sel
) { selected
= sel
; }
197 #endif // __Basemenu_hh