]> Dogcows Code - chaz/openbox/blob - src/Toolbar.hh
5ec3029c148329604c3f90673edeaa740401dd68
[chaz/openbox] / src / Toolbar.hh
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)
5 //
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:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
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.
23
24 #ifndef __Toolbar_hh
25 #define __Toolbar_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29 }
30
31 #include "Screen.hh"
32 #include "Basemenu.hh"
33 #include "Timer.hh"
34
35 // forward declaration
36 class Toolbar;
37
38 class Toolbarmenu : public Basemenu {
39 private:
40 class Placementmenu : public Basemenu {
41 private:
42 Placementmenu(const Placementmenu&);
43 Placementmenu& operator=(const Placementmenu&);
44
45 protected:
46 virtual void itemSelected(int button, unsigned int index);
47
48 public:
49 Placementmenu(Toolbarmenu *tm);
50 };
51
52 Toolbar *toolbar;
53 Placementmenu *placementmenu;
54
55 friend class Placementmenu;
56 friend class Toolbar;
57
58 Toolbarmenu(const Toolbarmenu&);
59 Toolbarmenu& operator=(const Toolbarmenu&);
60
61 protected:
62 virtual void itemSelected(int button, unsigned int index);
63 virtual void internal_hide(void);
64
65 public:
66 Toolbarmenu(Toolbar *tb);
67 ~Toolbarmenu(void);
68
69 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
70
71 void reconfigure(void);
72 };
73
74
75 class Toolbar : public TimeoutHandler {
76 private:
77 bool on_top, editing, hidden, do_auto_hide;
78 Display *display;
79
80 struct ToolbarFrame {
81 unsigned long button_pixel, pbutton_pixel;
82 Pixmap base, label, wlabel, clk, button, pbutton;
83 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
84 pwbutton, nwbutton;
85
86 int x_hidden, y_hidden, hour, minute, grab_x, grab_y;
87 unsigned int window_label_w, workspace_label_w, clock_w,
88 button_w, bevel_w, label_h;
89
90 Rect rect;
91 } frame;
92
93 class HideHandler : public TimeoutHandler {
94 public:
95 Toolbar *toolbar;
96
97 virtual void timeout(void);
98 } hide_handler;
99
100 Blackbox *blackbox;
101 BScreen *screen;
102 BTimer *clock_timer, *hide_timer;
103 Toolbarmenu *toolbarmenu;
104 Strut strut;
105
106 std::string new_workspace_name;
107 size_t new_name_pos;
108
109 friend class HideHandler;
110 friend class Toolbarmenu;
111 friend class Toolbarmenu::Placementmenu;
112
113 void redrawPrevWorkspaceButton(bool pressed = False, bool redraw = False);
114 void redrawNextWorkspaceButton(bool pressed = False, bool redraw = False);
115 void redrawPrevWindowButton(bool preseed = False, bool redraw = False);
116 void redrawNextWindowButton(bool preseed = False, bool redraw = False);
117
118 void updateStrut(void);
119
120 #ifdef HAVE_STRFTIME
121 void checkClock(bool redraw = False);
122 #else // HAVE_STRFTIME
123 void checkClock(bool redraw = False, bool date = False);
124 #endif // HAVE_STRFTIME
125
126 Toolbar(const Toolbar&);
127 Toolbar& operator=(const Toolbar&);
128
129 public:
130 Toolbar(BScreen *scrn);
131 virtual ~Toolbar(void);
132
133 inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
134
135 inline bool isEditing(void) const { return editing; }
136 inline bool isOnTop(void) const { return on_top; }
137 inline bool isHidden(void) const { return hidden; }
138 inline bool doAutoHide(void) const { return do_auto_hide; }
139
140 inline Window getWindowID(void) const { return frame.window; }
141
142 inline const Rect& getRect(void) const { return frame.rect; }
143 inline unsigned int getWidth(void) const { return frame.rect.width(); }
144 inline unsigned int getHeight(void) const { return frame.rect.height(); }
145 inline unsigned int getExposedHeight(void) const
146 { return ((do_auto_hide) ? frame.bevel_w : frame.rect.height()); }
147 inline int getX(void) const
148 { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
149 inline int getY(void) const
150 { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
151
152 void buttonPressEvent(XButtonEvent *be);
153 void buttonReleaseEvent(XButtonEvent *re);
154 void enterNotifyEvent(XCrossingEvent * /*unused*/);
155 void leaveNotifyEvent(XCrossingEvent * /*unused*/);
156 void exposeEvent(XExposeEvent *ee);
157 void keyPressEvent(XKeyEvent *ke);
158
159 void edit(void);
160 void reconfigure(void);
161 void toggleAutoHide(void);
162
163 void redrawWindowLabel(bool redraw = False);
164 void redrawWorkspaceLabel(bool redraw = False);
165
166 virtual void timeout(void);
167
168 enum { TopLeft = 1, BottomLeft, TopCenter,
169 BottomCenter, TopRight, BottomRight };
170 };
171
172
173 #endif // __Toolbar_hh
This page took 0.043589 seconds and 3 git commands to generate.