1
// Toolbar.hh for Fluxbox
2
// Copyright (c) 2002 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
4
// Toolbar.hh for Blackbox - an X11 Window manager
5
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
7
// Permission is hereby granted, free of charge, to any person obtaining a
8
// copy of this software and associated documentation files (the "Software"),
9
// to deal in the Software without restriction, including without limitation
10
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
// and/or sell copies of the Software, and to permit persons to whom the
12
// Software is furnished to do so, subject to the following conditions:
14
// The above copyright notice and this permission notice shall be included in
15
// all copies or substantial portions of the Software.
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
// DEALINGS IN THE SOFTWARE.
25
// $Id: Toolbar.hh 4062 2005-06-23 03:07:25Z fluxgen $
30
#include "ToolbarTheme.hh"
31
#include "LayerMenu.hh"
32
#include "ToolFactory.hh"
33
#include "ToolTheme.hh"
36
#include "FbTk/Timer.hh"
37
#include "FbTk/Resource.hh"
38
#include "FbTk/Observer.hh"
39
#include "FbTk/XLayer.hh"
40
#include "FbTk/XLayerItem.hh"
41
#include "FbTk/EventHandler.hh"
42
#include "FbTk/FbWindow.hh"
57
/// Handles iconbar, workspace name view and clock view
58
class Toolbar: public FbTk::EventHandler, public FbTk::Observer, public LayerObject {
61
/// Toolbar placement on the screen
63
// top and bottom placement
64
TOPLEFT = 1, BOTTOMLEFT, TOPCENTER,
65
BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT,
66
// left and right placement
67
LEFTCENTER, LEFTBOTTOM, LEFTTOP,
68
RIGHTCENTER, RIGHTBOTTOM, RIGHTTOP
71
/// Create a toolbar on the screen with specific width
72
Toolbar(BScreen &screen, FbTk::XLayer &layer, size_t width = 200);
78
void updateVisibleState();
82
void moveToLayer(int layernum);
84
void saveOnHead(int head);
90
void buttonPressEvent(XButtonEvent &be);
91
void buttonReleaseEvent(XButtonEvent &be);
92
void enterNotifyEvent(XCrossingEvent &ce);
93
void leaveNotifyEvent(XCrossingEvent &ce);
94
void exposeEvent(XExposeEvent &ee);
95
void handleEvent(XEvent &event);
98
/// enter edit mode on workspace label
101
void setPlacement(Placement where);
103
void update(FbTk::Subject *subj);
105
int layerNumber() const { return const_cast<FbTk::XLayerItem &>(m_layeritem).getLayerNum(); }
107
inline const FbTk::Menu &menu() const { return m_toolbarmenu; }
108
inline FbTk::Menu &menu() { return m_toolbarmenu; }
109
inline FbTk::Menu &placementMenu() { return m_placementmenu; }
110
inline const FbTk::Menu &placementMenu() const { return m_placementmenu; }
112
inline FbTk::Menu &layerMenu() { return m_layermenu; }
113
inline const FbTk::Menu &layerMenu() const { return m_layermenu; }
116
inline bool isHidden() const { return m_hidden; }
117
/// do we auto hide the toolbar?
118
inline bool doAutoHide() const { return *m_rc_auto_hide; }
119
/// @return X window of the toolbar
120
inline const FbTk::FbWindow &window() const { return frame.window; }
121
inline BScreen &screen() { return m_screen; }
122
inline const BScreen &screen() const { return m_screen; }
123
inline unsigned int width() const { return frame.window.width(); }
124
inline unsigned int height() const { return frame.window.height(); }
125
inline unsigned int exposedHeight() const { return doAutoHide() ? frame.bevel_w : frame.height; }
126
inline int x() const { return isHidden() ? frame.x_hidden : frame.x; }
127
inline int y() const { return isHidden() ? frame.y_hidden : frame.y; }
128
inline Placement placement() const { return *m_rc_placement; }
129
/// @return pointer to iconbar if it got one, else 0
130
inline const ToolbarTheme &theme() const { return m_theme; }
131
inline ToolbarTheme &theme() { return m_theme; }
132
bool isVertical() const;
134
inline int getOnHead() const { return *m_rc_on_head; }
136
inline unsigned char alpha() const { return *m_rc_alpha; }
138
void rearrangeItems();
141
void updateIconbarGraphics();
147
bool m_hidden; ///< hidden state
151
Frame(FbTk::EventHandler &evh, int screen_num);
154
FbTk::FbWindow window;
156
int x, y, x_hidden, y_hidden, grab_x, grab_y;
157
unsigned int width, height, bevel_w;
162
BScreen &m_screen; ///< screen connection
164
FbTk::Timer m_hide_timer; ///< timer to for auto hide toolbar
166
FbTk::XLayerItem m_layeritem; ///< layer item, must be declared before layermenu
167
LayerMenu m_layermenu;
168
FbMenu m_placementmenu, m_toolbarmenu;
172
ToolbarTheme m_theme;
175
typedef std::list<ToolbarItem *> ItemList;
176
ItemList m_item_list;
178
ToolFactory m_tool_factory;
180
Strut *m_strut; ///< created and destroyed by BScreen
183
FbTk::Resource<bool> m_rc_auto_hide, m_rc_maximize_over, m_rc_visible;
184
FbTk::Resource<int> m_rc_width_percent;
185
FbTk::Resource<int> m_rc_alpha;
186
FbTk::Resource<Fluxbox::Layer> m_rc_layernum;
187
FbTk::Resource<int> m_rc_on_head;
188
FbTk::Resource<Placement> m_rc_placement;
189
FbTk::Resource<int> m_rc_height;
190
FbTk::Resource<std::string> m_rc_tools;
191
std::auto_ptr<Shape> m_shape;
192
typedef std::list<std::string> StringList;
195
bool m_resize_lock; ///< to lock rearrangeItems or not