]> Dogcows Code - chaz/openbox/blob - src/Toolbar.h
Initial revision
[chaz/openbox] / src / Toolbar.h
1 // Toolbar.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22
23 #ifndef __Toolbar_hh
24 #define __Toolbar_hh
25
26 #include <X11/Xlib.h>
27
28 #include "Basemenu.h"
29 #include "Timer.h"
30
31 // forward declaration
32 class Toolbar;
33
34 class Toolbarmenu : public Basemenu {
35 private:
36 class Placementmenu : public Basemenu {
37 private:
38 Toolbarmenu *toolbarmenu;
39
40 protected:
41 virtual void itemSelected(int, int);
42
43 public:
44 Placementmenu(Toolbarmenu *);
45 };
46
47 Toolbar *toolbar;
48 Placementmenu *placementmenu;
49
50 friend class Placementmenu;
51 friend class Toolbar;
52
53
54 protected:
55 virtual void itemSelected(int, int);
56 virtual void internal_hide(void);
57
58 public:
59 Toolbarmenu(Toolbar *);
60 ~Toolbarmenu(void);
61
62 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
63
64 void reconfigure(void);
65 };
66
67
68 class Toolbar : public TimeoutHandler {
69 private:
70 Bool on_top, editing, hidden, do_auto_hide;
71 Display *display;
72
73 struct frame {
74 unsigned long button_pixel, pbutton_pixel;
75 Pixmap base, label, wlabel, clk, button, pbutton;
76 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
77 pwbutton, nwbutton;
78
79 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
80 unsigned int width, height, window_label_w, workspace_label_w, clock_w,
81 button_w, bevel_w, label_h;
82 } frame;
83
84 class HideHandler : public TimeoutHandler {
85 public:
86 Toolbar *toolbar;
87
88 virtual void timeout(void);
89 } hide_handler;
90
91 Openbox *openbox;
92 BImageControl *image_ctrl;
93 BScreen *screen;
94 BTimer *clock_timer, *hide_timer;
95 Toolbarmenu *toolbarmenu;
96
97 char *new_workspace_name;
98 size_t new_name_pos;
99
100 friend class HideHandler;
101 friend class Toolbarmenu;
102 friend class Toolbarmenu::Placementmenu;
103
104
105 public:
106 Toolbar(BScreen *);
107 virtual ~Toolbar(void);
108
109 inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
110
111 inline const Bool &isEditing(void) const { return editing; }
112 inline const Bool &isOnTop(void) const { return on_top; }
113 inline const Bool &isHidden(void) const { return hidden; }
114 inline const Bool &doAutoHide(void) const { return do_auto_hide; }
115
116 inline const Window &getWindowID(void) const { return frame.window; }
117
118 inline const unsigned int &getWidth(void) const { return frame.width; }
119 inline const unsigned int &getHeight(void) const { return frame.height; }
120 inline const unsigned int &getExposedHeight(void) const
121 { return ((do_auto_hide) ? frame.bevel_w : frame.height); }
122 inline const int &getX(void) const
123 { return ((hidden) ? frame.x_hidden : frame.x); }
124 inline const int &getY(void) const
125 { return ((hidden) ? frame.y_hidden : frame.y); }
126
127 void buttonPressEvent(XButtonEvent *);
128 void buttonReleaseEvent(XButtonEvent *);
129 void enterNotifyEvent(XCrossingEvent *);
130 void leaveNotifyEvent(XCrossingEvent *);
131 void exposeEvent(XExposeEvent *);
132 void keyPressEvent(XKeyEvent *);
133
134 void redrawWindowLabel(Bool = False);
135 void redrawWorkspaceLabel(Bool = False);
136 void redrawPrevWorkspaceButton(Bool = False, Bool = False);
137 void redrawNextWorkspaceButton(Bool = False, Bool = False);
138 void redrawPrevWindowButton(Bool = False, Bool = False);
139 void redrawNextWindowButton(Bool = False, Bool = False);
140 void edit(void);
141 void reconfigure(void);
142
143 #ifdef HAVE_STRFTIME
144 void checkClock(Bool = False);
145 #else // HAVE_STRFTIME
146 void checkClock(Bool = False, Bool = False);
147 #endif // HAVE_STRFTIME
148
149 virtual void timeout(void);
150
151 enum { TopLeft = 1, BottomLeft, TopCenter,
152 BottomCenter, TopRight, BottomRight };
153 };
154
155
156 #endif // __Toolbar_hh
This page took 0.039422 seconds and 4 git commands to generate.