]> Dogcows Code - chaz/openbox/blob - src/Toolbar.h
new root dir based on bb-cvs
[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 #include "Resource.h"
31 #include "Screen.h"
32 #include "Geometry.h"
33
34 // forward declaration
35 class Toolbar;
36
37 class Toolbarmenu : public Basemenu {
38 private:
39 class Placementmenu : public Basemenu {
40 private:
41 Toolbarmenu &toolbarmenu;
42
43 protected:
44 virtual void itemSelected(int, int);
45
46 public:
47 Placementmenu(Toolbarmenu &);
48 };
49
50 Toolbar &toolbar;
51 Placementmenu *placementmenu;
52
53 friend class Placementmenu;
54 friend class Toolbar;
55
56
57 protected:
58 virtual void itemSelected(int, int);
59 virtual void internal_hide();
60 virtual void setValues();
61
62 public:
63 Toolbarmenu(Toolbar &);
64 ~Toolbarmenu();
65
66 inline Basemenu *getPlacementmenu() { return placementmenu; }
67
68 void reconfigure();
69 };
70
71
72 class Toolbar : public TimeoutHandler {
73 private:
74 bool m_ontop, m_editing, m_hidden, m_autohide;
75 int m_width_percent, m_placement;
76 Display *display;
77
78 struct frame {
79 unsigned long button_pixel, pbutton_pixel;
80 Pixmap base, label, wlabel, clk, button, pbutton;
81 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
82 pwbutton, nwbutton;
83
84 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
85 unsigned int width, height, window_label_w, workspace_label_w, clock_w,
86 button_w, bevel_w, label_h;
87 } frame;
88
89 class HideHandler : public TimeoutHandler {
90 public:
91 Toolbar *toolbar;
92 virtual void timeout();
93 } hide_handler;
94
95 Openbox &openbox;
96 BScreen &screen;
97 Resource &config;
98 BImageControl *image_ctrl;
99 BTimer *clock_timer, *hide_timer;
100 Toolbarmenu *toolbarmenu;
101
102 char *new_workspace_name;
103 size_t new_name_pos;
104
105 friend class HideHandler;
106 friend class Toolbarmenu;
107 friend class Toolbarmenu::Placementmenu;
108
109
110 public:
111 Toolbar(BScreen &, Resource &);
112 virtual ~Toolbar();
113
114 inline Toolbarmenu *getMenu() { return toolbarmenu; }
115
116 inline const Window &getWindowID() const { return frame.window; }
117
118 //inline unsigned int getWidth() const { return frame.width; }
119 //inline unsigned int getHeight() const { return frame.height; }
120 unsigned int getExposedHeight() const;
121
122 //int getX() const;
123 //int getY() const;
124
125 Rect area() const;
126 //Size size() const { return area().size(); }
127 //Point origin() const { return area().origin(); }
128
129 void buttonPressEvent(XButtonEvent *);
130 void buttonReleaseEvent(XButtonEvent *);
131 void enterNotifyEvent(XCrossingEvent *);
132 void leaveNotifyEvent(XCrossingEvent *);
133 void exposeEvent(XExposeEvent *);
134 void keyPressEvent(XKeyEvent *);
135
136 void redrawWindowLabel(Bool = False);
137 void redrawWorkspaceLabel(Bool = False);
138 void redrawPrevWorkspaceButton(Bool = False, Bool = False);
139 void redrawNextWorkspaceButton(Bool = False, Bool = False);
140 void redrawPrevWindowButton(Bool = False, Bool = False);
141 void redrawNextWindowButton(Bool = False, Bool = False);
142 void edit();
143 void reconfigure();
144 void load();
145 void save();
146 void mapToolbar();
147 void unMapToolbar();
148 #ifdef HAVE_STRFTIME
149 void checkClock(Bool = False);
150 #else // HAVE_STRFTIME
151 void checkClock(Bool = False, Bool = False);
152 #endif // HAVE_STRFTIME
153
154 virtual void timeout();
155
156 inline bool onTop() const { return m_ontop; }
157 void setOnTop(bool);
158
159 inline bool autoHide() const { return m_autohide; }
160 void setAutoHide(bool);
161
162 inline int widthPercent() const { return m_width_percent; }
163 void setWidthPercent(int);
164
165 inline int placement() const { return m_placement; }
166 void setPlacement(int);
167
168 inline bool isEditing() const { return m_editing; }
169 inline bool isHidden() const { return m_hidden; }
170
171 enum { TopLeft = 1, BottomLeft, TopCenter,
172 BottomCenter, TopRight, BottomRight };
173 };
174
175
176 #endif // __Toolbar_hh
This page took 0.044121 seconds and 4 git commands to generate.