]>
Dogcows Code - chaz/openbox/blob - src/Basemenu.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Basemenu.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
43 typedef std::deque
<BasemenuItem
*> MenuItems
;
47 BImageControl
*image_ctrl
;
50 bool moving
, visible
, movable
, torn
, internal_menu
, title_vis
, shifted
,
53 int which_sub
, which_press
, which_sbl
, alignment
;
56 Pixmap frame_pixmap
, title_pixmap
, hilite_pixmap
;
57 Window window
, frame
, title
;
60 int x
, y
, x_move
, y_move
, x_shift
, y_shift
, sublevels
, persub
, minsub
;
61 unsigned int width
, height
, title_h
, frame_h
, item_w
, item_h
, bevel_w
,
65 Basemenu(const Basemenu
&);
66 Basemenu
& operator=(const Basemenu
&);
69 inline void setTitleVisibility(bool b
) { title_vis
= b
; }
70 inline void setMovable(bool b
) { movable
= b
; }
71 inline void setHideTree(bool h
) { hide_tree
= h
; }
72 inline void setMinimumSublevels(int m
) { menu
.minsub
= m
; }
74 virtual void itemSelected(int button
, unsigned int index
) = 0;
75 virtual void drawItem(int index
, bool highlight
= False
, bool clear
= False
,
76 int x
= -1, int y
= -1,
77 unsigned int w
= 0, unsigned int h
= 0);
78 virtual void redrawTitle(void);
79 virtual void internal_hide(void);
83 Basemenu(BScreen
*scrn
);
84 virtual ~Basemenu(void);
86 inline bool isTorn(void) const { return torn
; }
87 inline bool isVisible(void) const { return visible
; }
89 inline BScreen
*getScreen(void) { return screen
; }
91 inline Window
getWindowID(void) const { return menu
.window
; }
93 inline const char *getLabel(void) const { return menu
.label
.c_str(); }
95 int insert(BasemenuItem
*item
, int pos
);
96 int insert(const std::string
& label
, int function
= 0,
97 const std::string
& exec
= "", int pos
= -1);
98 int insert(const std::string
&label
, Basemenu
*submenu
, int pos
= -1);
99 int remove(int index
);
101 void changeItemLabel(unsigned int index
, const std::string
& label
);
103 inline int getX(void) const { return menu
.x
; }
104 inline int getY(void) const { return menu
.y
; }
105 inline unsigned int getCount(void) { return menuitems
.size(); }
106 inline int getCurrentSubmenu(void) const { return which_sub
; }
107 BasemenuItem
*find(int index
);
109 inline unsigned int getWidth(void) const { return menu
.width
; }
110 inline unsigned int getHeight(void) const { return menu
.height
; }
111 inline unsigned int getTitleHeight(void) const
112 { return menu
.title_h
; }
114 inline void setInternalMenu(void) { internal_menu
= True
; }
115 inline void setAlignment(int a
) { alignment
= a
; }
116 inline void setTorn(void) { torn
= True
; }
117 inline void removeParent(void)
118 { if (internal_menu
) parent
= (Basemenu
*) 0; }
120 bool hasSubmenu(int index
);
121 bool isItemSelected(int index
);
122 bool isItemEnabled(int index
);
124 void buttonPressEvent(XButtonEvent
*be
);
125 void buttonReleaseEvent(XButtonEvent
*be
);
126 void motionNotifyEvent(XMotionEvent
*me
);
127 void enterNotifyEvent(XCrossingEvent
*ce
);
128 void leaveNotifyEvent(XCrossingEvent
*ce
);
129 void exposeEvent(XExposeEvent
*ee
);
130 void reconfigure(void);
131 void setLabel(const std::string
& label
);
132 void move(int x
, int y
);
134 void setItemSelected(int index
, bool sel
);
135 void setItemEnabled(int index
, bool enable
);
137 virtual void drawSubmenu(int index
);
138 virtual void show(void);
139 virtual void hide(void);
141 enum { AlignDontCare
= 1, AlignTop
, AlignBottom
};
142 enum { Right
= 1, Left
};
143 enum { Empty
= 0, Square
, Triangle
, Diamond
};
151 int f
, enabled
, selected
;
153 friend class Basemenu
;
158 BasemenuItem(const std::string
& lp
, int fp
= 0, const std::string
& ep
= ""):
159 sub(0), l(lp
), e(ep
), f(fp
), enabled(1), selected(0) {}
161 BasemenuItem(const std::string
& lp
, Basemenu
*mp
): sub(mp
), l(lp
),
165 inline const char *exec(void) const { return e
.c_str(); }
166 inline const char *label(void) const { return l
.c_str(); }
167 inline int function(void) const { return f
; }
168 inline Basemenu
*submenu(void) { return sub
; }
170 inline void newLabel(const std::string
& label
) { l
= label
; }
172 inline int isEnabled(void) const { return enabled
; }
173 inline void setEnabled(int e
) { enabled
= e
; }
174 inline int isSelected(void) const { return selected
; }
175 inline void setSelected(int s
) { selected
= s
; }
179 #endif // __Basemenu_hh
This page took 0.041686 seconds and 4 git commands to generate.