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