1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Toolbar.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.
32 #include "Basemenu.hh"
35 // forward declaration
38 class Toolbarmenu : public Basemenu {
40 class Placementmenu : public Basemenu {
42 Placementmenu(const Placementmenu&);
43 Placementmenu& operator=(const Placementmenu&);
47 virtual void itemSelected(int button, unsigned int index);
48 virtual void setValues(void);
51 Placementmenu(Toolbarmenu *tm);
52 virtual void reconfigure(void);
56 Placementmenu *placementmenu;
58 friend class Placementmenu;
61 Toolbarmenu(const Toolbarmenu&);
62 Toolbarmenu& operator=(const Toolbarmenu&);
65 virtual void itemSelected(int button, unsigned int index);
66 virtual void internal_hide(void);
67 virtual void setValues(void);
70 Toolbarmenu(Toolbar *tb);
73 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
75 virtual void reconfigure(void);
79 class Toolbar : public TimeoutHandler {
81 bool on_top, editing, hidden, do_auto_hide;
82 unsigned int width_percent;
84 std::string toolbarstr;
88 unsigned long button_pixel, pbutton_pixel;
89 Pixmap base, label, wlabel, clk, button, pbutton;
90 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
93 int x_hidden, y_hidden, hour, minute, grab_x, grab_y;
94 unsigned int window_label_w, workspace_label_w, clock_w,
95 button_w, bevel_w, label_h;
100 class HideHandler : public TimeoutHandler {
104 virtual void timeout(void);
109 Configuration *config;
110 BTimer *clock_timer, *hide_timer;
111 Toolbarmenu *toolbarmenu;
114 std::string new_workspace_name;
117 friend class HideHandler;
118 friend class Toolbarmenu;
119 friend class Toolbarmenu::Placementmenu;
121 void redrawPrevWorkspaceButton(bool pressed = False, bool redraw = False);
122 void redrawNextWorkspaceButton(bool pressed = False, bool redraw = False);
123 void redrawPrevWindowButton(bool preseed = False, bool redraw = False);
124 void redrawNextWindowButton(bool preseed = False, bool redraw = False);
126 void updateStrut(void);
129 void checkClock(bool redraw = False);
130 #else // HAVE_STRFTIME
131 void checkClock(bool redraw = False, bool date = False);
132 #endif // HAVE_STRFTIME
134 Toolbar(const Toolbar&);
135 Toolbar& operator=(const Toolbar&);
138 Toolbar(BScreen *scrn);
139 virtual ~Toolbar(void);
141 inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
143 inline bool isEditing(void) const { return editing; }
144 inline bool isOnTop(void) const { return on_top; }
145 inline bool isHidden(void) const { return hidden; }
146 inline bool doAutoHide(void) const { return do_auto_hide; }
147 inline unsigned int getWidthPercent(void) const { return width_percent; }
148 inline int getPlacement(void) const { return placement; }
150 void saveOnTop(bool);
151 void saveAutoHide(bool);
152 void saveWidthPercent(unsigned int);
153 void savePlacement(int);
158 void mapToolbar(void);
159 void unmapToolbar(void);
161 inline Window getWindowID(void) const { return frame.window; }
163 inline const Rect& getRect(void) const { return frame.rect; }
164 inline unsigned int getWidth(void) const { return frame.rect.width(); }
165 inline unsigned int getHeight(void) const { return frame.rect.height(); }
166 inline unsigned int getExposedHeight(void) const
167 { return (screen->doHideToolbar() ? 0 :
168 ((do_auto_hide) ? frame.bevel_w :
169 frame.rect.height())); }
170 inline int getX(void) const
171 { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
172 inline int getY(void) const
173 { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
175 void buttonPressEvent(const XButtonEvent *be);
176 void buttonReleaseEvent(const XButtonEvent *re);
177 void enterNotifyEvent(const XCrossingEvent * /*unused*/);
178 void leaveNotifyEvent(const XCrossingEvent * /*unused*/);
179 void exposeEvent(const XExposeEvent *ee);
180 void keyPressEvent(const XKeyEvent *ke);
183 void reconfigure(void);
184 void toggleAutoHide(void);
186 void redrawWindowLabel(bool redraw = False);
187 void redrawWorkspaceLabel(bool redraw = False);
189 virtual void timeout(void);
191 enum { TopLeft = 1, BottomLeft, TopCenter,
192 BottomCenter, TopRight, BottomRight };
196 #endif // __Toolbar_hh