]> Dogcows Code - chaz/openbox/blob - src/Toolbar.hh
Take menu file from rc file if it isn't specified on the command line.
[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 Toolbar *toolbar;
45
46 protected:
47 virtual void itemSelected(int button, unsigned int index);
48 virtual void setValues(void);
49
50 public:
51 Placementmenu(Toolbarmenu *tm);
52 virtual void reconfigure(void);
53 };
54
55 Toolbar *toolbar;
56 Placementmenu *placementmenu;
57
58 friend class Placementmenu;
59 friend class Toolbar;
60
61 Toolbarmenu(const Toolbarmenu&);
62 Toolbarmenu& operator=(const Toolbarmenu&);
63
64 protected:
65 virtual void itemSelected(int button, unsigned int index);
66 virtual void internal_hide(void);
67 virtual void setValues(void);
68
69 public:
70 Toolbarmenu(Toolbar *tb);
71 ~Toolbarmenu(void);
72
73 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
74
75 virtual void reconfigure(void);
76 };
77
78
79 class Toolbar : public TimeoutHandler {
80 private:
81 bool on_top, editing, hidden, do_auto_hide;
82 unsigned int width_percent;
83 int placement;
84 std::string toolbarstr;
85 Display *display;
86
87 struct ToolbarFrame {
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,
91 pwbutton, nwbutton;
92
93 int x_hidden, y_hidden, hour, minute;
94 unsigned int window_label_w, workspace_label_w, clock_w,
95 button_w, bevel_w, label_h;
96
97 Rect rect;
98 } frame;
99
100 class HideHandler : public TimeoutHandler {
101 public:
102 Toolbar *toolbar;
103
104 virtual void timeout(void);
105 } hide_handler;
106
107 Blackbox *blackbox;
108 BScreen *screen;
109 Configuration *config;
110 BTimer *clock_timer, *hide_timer;
111 Toolbarmenu *toolbarmenu;
112 Strut strut;
113
114 std::string new_workspace_name;
115 size_t new_name_pos;
116
117 friend class HideHandler;
118 friend class Toolbarmenu;
119 friend class Toolbarmenu::Placementmenu;
120
121 void drawArrow(Drawable surface, bool left) const;
122 void redrawPrevWorkspaceButton(bool pressed = False, bool redraw = False);
123 void redrawNextWorkspaceButton(bool pressed = False, bool redraw = False);
124 void redrawPrevWindowButton(bool preseed = False, bool redraw = False);
125 void redrawNextWindowButton(bool preseed = False, bool redraw = False);
126
127 void updateStrut(void);
128
129 #ifdef HAVE_STRFTIME
130 void checkClock(bool redraw = False);
131 #else // HAVE_STRFTIME
132 void checkClock(bool redraw = False, bool date = False);
133 #endif // HAVE_STRFTIME
134
135 Toolbar(const Toolbar&);
136 Toolbar& operator=(const Toolbar&);
137
138 public:
139 Toolbar(BScreen *scrn);
140 virtual ~Toolbar(void);
141
142 inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
143
144 inline bool isEditing(void) const { return editing; }
145 inline bool isOnTop(void) const { return on_top; }
146 inline bool isHidden(void) const { return hidden; }
147 inline bool doAutoHide(void) const { return do_auto_hide; }
148 inline unsigned int getWidthPercent(void) const { return width_percent; }
149 inline int getPlacement(void) const { return placement; }
150
151 void saveOnTop(bool);
152 void saveAutoHide(bool);
153 void saveWidthPercent(unsigned int);
154 void savePlacement(int);
155
156 void save_rc(void);
157 void load_rc(void);
158
159 void mapToolbar(void);
160 void unmapToolbar(void);
161
162 inline Window getWindowID(void) const { return frame.window; }
163
164 inline const Rect& getRect(void) const { return frame.rect; }
165 inline unsigned int getWidth(void) const { return frame.rect.width(); }
166 inline unsigned int getHeight(void) const { return frame.rect.height(); }
167 inline unsigned int getExposedHeight(void) const
168 { return (screen->doHideToolbar() ? 0 :
169 ((do_auto_hide) ? frame.bevel_w :
170 frame.rect.height())); }
171 inline int getX(void) const
172 { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
173 inline int getY(void) const
174 { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
175
176 void buttonPressEvent(const XButtonEvent *be);
177 void buttonReleaseEvent(const XButtonEvent *re);
178 void enterNotifyEvent(const XCrossingEvent * /*unused*/);
179 void leaveNotifyEvent(const XCrossingEvent * /*unused*/);
180 void exposeEvent(const XExposeEvent *ee);
181 void keyPressEvent(const XKeyEvent *ke);
182
183 void edit(void);
184 void reconfigure(void);
185 void toggleAutoHide(void);
186
187 void redrawWindowLabel(bool redraw = False);
188 void redrawWorkspaceLabel(bool redraw = False);
189
190 virtual void timeout(void);
191
192 enum { TopLeft = 1, BottomLeft, TopCenter,
193 BottomCenter, TopRight, BottomRight };
194 };
195
196
197 #endif // __Toolbar_hh
This page took 0.039954 seconds and 4 git commands to generate.