aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toolbar.hh')
-rw-r--r--src/Toolbar.hh270
1 files changed, 158 insertions, 112 deletions
diff --git a/src/Toolbar.hh b/src/Toolbar.hh
index d6e19db..29756d5 100644
--- a/src/Toolbar.hh
+++ b/src/Toolbar.hh
@@ -1,3 +1,6 @@
1// Toolbar.hh for Fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
1// Toolbar.hh for Blackbox - an X11 Window manager 4// Toolbar.hh for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -19,145 +22,188 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22#ifndef _TOOLBAR_HH_ 25// $Id: Toolbar.hh,v 1.13 2002/11/15 12:04:27 fluxgen Exp $
23#define _TOOLBAR_HH_
24
25#include <X11/Xlib.h>
26
27
28 26
27#ifndef TOOLBAR_HH
28#define TOOLBAR_HH
29 29
30#include "Basemenu.hh" 30#include "Basemenu.hh"
31#include "LinkedList.hh"
32#include "Timer.hh" 31#include "Timer.hh"
33#include "IconBar.hh" 32#include "IconBar.hh"
34 33
35 34
36// forward declaration
37class Toolbar; 35class Toolbar;
38 36
39class Toolbarmenu : public Basemenu { 37/**
40private: 38 Menu for toolbar.
41 class Placementmenu : public Basemenu { 39 @see Toolbar
42 private: 40*/
43 Toolbarmenu *toolbarmenu; 41class Toolbarmenu:public Basemenu {
44 42public:
45 protected: 43 explicit Toolbarmenu(Toolbar *tb);
46 virtual void itemSelected(int, int); 44 ~Toolbarmenu();
47 45 #ifdef XINERAMA
48 public: 46 inline Basemenu *getHeadmenu() { return headmenu; }
49 Placementmenu(Toolbarmenu *); 47 #endif // XINERAMA
50 };
51
52 Toolbar *toolbar;
53 Placementmenu *placementmenu;
54 48
55 friend class Placementmenu; 49 inline Basemenu *getPlacementmenu() { return placementmenu; }
56 friend class Toolbar; 50 inline const Basemenu *getPlacementmenu() const { return placementmenu; }
57 51
52 void reconfigure();
58 53
59protected: 54protected:
60 virtual void itemSelected(int, int); 55 virtual void itemSelected(int button, unsigned int index);
61 virtual void internal_hide(void); 56 virtual void internal_hide();
62 57
63public: 58private:
64 Toolbarmenu(Toolbar *); 59 class Placementmenu : public Basemenu {
65 ~Toolbarmenu(void); 60 private:
66 61 Toolbarmenu *toolbarmenu;
67 inline Basemenu *getPlacementmenu(void) { return placementmenu; } 62
63 protected:
64 virtual void itemSelected(int button, unsigned int index);
65
66 public:
67 Placementmenu(Toolbarmenu *);
68 };
69
70#ifdef XINERAMA
71 class Headmenu : public Basemenu {
72 public:
73 Headmenu(Toolbarmenu *);
74 private:
75 Toolbarmenu *toolbarmenu;
76
77 protected:
78 virtual void itemSelected(int button, unsigned int index);
79 };
80 Headmenu *headmenu;
81 friend class Headmenu;
82#endif // XINERAMA
83
84
85 Toolbar *toolbar;
86 Placementmenu *placementmenu;
87
88 friend class Placementmenu;
89 friend class Toolbar;
68 90
69 void reconfigure(void);
70}; 91};
71 92
72 93/**
94 the toolbar.
95*/
73class Toolbar : public TimeoutHandler { 96class Toolbar : public TimeoutHandler {
74private: 97public:
75 Bool on_top, editing, hidden, do_auto_hide; 98 /**
76 Display *display; 99 Toolbar placement on the screen
77 100 */
78 struct frame { 101 enum Placement{ TOPLEFT = 1, BOTTOMLEFT, TOPCENTER,
79 unsigned long button_pixel, pbutton_pixel; 102 BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT };
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
93 virtual void timeout(void);
94 } hide_handler;
95
96 Fluxbox *fluxbox;
97 BImageControl *image_ctrl;
98 BScreen *screen;
99 BTimer *clock_timer, *hide_timer;
100 Toolbarmenu *toolbarmenu;
101 class IconBar *iconbar;
102
103 char *new_workspace_name, *new_name_pos;
104
105 friend class HideHandler;
106 friend class Toolbarmenu;
107 friend class Toolbarmenu::Placementmenu;
108 103
104 explicit Toolbar(BScreen *screen);
105 virtual ~Toolbar();
109 106
110public: 107 /// add icon to iconbar
111 Toolbar(BScreen *);
112 virtual ~Toolbar(void);
113 void addIcon(FluxboxWindow *w); 108 void addIcon(FluxboxWindow *w);
109 /// remove icon from iconbar
114 void delIcon(FluxboxWindow *w); 110 void delIcon(FluxboxWindow *w);
115 111
116 inline Toolbarmenu *getMenu(void) { return toolbarmenu; } 112 inline Toolbarmenu *getMenu() { return toolbarmenu; }
113 inline const Toolbarmenu *getMenu() const { return toolbarmenu; }
114
117 //inline Window getWindowLabel(void) { return frame.window_label; } 115 //inline Window getWindowLabel(void) { return frame.window_label; }
118 inline const Bool &isEditing(void) const { return editing; } 116
119 inline const Bool &isOnTop(void) const { return on_top; } 117 /// are we in workspacename editing?
120 inline const Bool &isHidden(void) const { return hidden; } 118 inline bool isEditing() const { return editing; }
121 inline const Bool &doAutoHide(void) const { return do_auto_hide; } 119 /// always on top?
122 120 inline bool isOnTop() const { return on_top; }
123 inline const Window &getWindowID(void) const { return frame.window; } 121 /// are we hidden?
124 122 inline bool isHidden() const { return hidden; }
125 inline const unsigned int &getWidth(void) const { return frame.width; } 123 /// do we auto hide the toolbar?
126 inline const unsigned int &getHeight(void) const { return frame.height; } 124 inline bool doAutoHide() const { return do_auto_hide; }
127 inline const unsigned int &getExposedHeight(void) const 125 /**
128 { return ((do_auto_hide) ? frame.bevel_w : frame.height); } 126 @return X window of the toolbar
129 inline const int &getX(void) const 127 */
130 { return ((hidden) ? frame.x_hidden : frame.x); } 128 inline Window getWindowID() const { return frame.window; }
131 inline const int &getY(void) const 129
132 { return ((hidden) ? frame.y_hidden : frame.y); } 130 inline unsigned int width() const { return frame.width; }
133 131 inline unsigned int height() const { return frame.height; }
134 void buttonPressEvent(XButtonEvent *); 132 inline unsigned int getExposedHeight() const { return ((do_auto_hide) ? frame.bevel_w : frame.height); }
135 void buttonReleaseEvent(XButtonEvent *); 133 inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); }
136 void enterNotifyEvent(XCrossingEvent *); 134 inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); }
137 void leaveNotifyEvent(XCrossingEvent *); 135 inline const IconBar *iconBar() const { return iconbar; }
138 void exposeEvent(XExposeEvent *); 136 /**
139 void keyPressEvent(XKeyEvent *); 137 @name eventhandlers
140 138 */
141 void redrawWindowLabel(Bool = False); 139 //@{
142 void redrawWorkspaceLabel(Bool = False); 140 void buttonPressEvent(XButtonEvent *be);
143 void redrawPrevWorkspaceButton(Bool = False, Bool = False); 141 void buttonReleaseEvent(XButtonEvent *be);
144 void redrawNextWorkspaceButton(Bool = False, Bool = False); 142 void enterNotifyEvent(XCrossingEvent *ce);
145 void redrawPrevWindowButton(Bool = False, Bool = False); 143 void leaveNotifyEvent(XCrossingEvent *ce);
146 void redrawNextWindowButton(Bool = False, Bool = False); 144 void exposeEvent(XExposeEvent *ee);
147 void edit(void); 145 void keyPressEvent(XKeyEvent *ke);
148 void reconfigure(void); 146 //@}
149 147
150#ifdef HAVE_STRFTIME 148 void redrawWindowLabel(bool redraw= false);
151 void checkClock(Bool = False); 149 void redrawWorkspaceLabel(bool redraw= false);
152#else // HAVE_STRFTIME 150 void redrawPrevWorkspaceButton(bool pressed = false, bool redraw = false);
153 void checkClock(Bool = False, Bool = False); 151 void redrawNextWorkspaceButton(bool pressed = false, bool redraw = false);
152 void redrawPrevWindowButton(bool pressed = false, bool redraw = false);
153 void redrawNextWindowButton(bool pressed = false, bool redraw = false);
154 /// enter edit mode on workspace label
155 void edit();
156 void reconfigure();
157
158#ifdef HAVE_STRFTIME
159 void checkClock(bool redraw = false);
160#else // HAVE_STRFTIME
161 void checkClock(bool redraw = false, bool date = false);
154#endif // HAVE_STRFTIME 162#endif // HAVE_STRFTIME
155 163
156 virtual void timeout(void); 164 virtual void timeout();
157 165
158 enum { TopLeft = 1, BottomLeft, TopCenter, 166
159 BottomCenter, TopRight, BottomRight }; 167private:
168 bool on_top; ///< always on top
169 bool editing; ///< edit workspace label mode
170 bool hidden; ///< hidden state
171 bool do_auto_hide; ///< do we auto hide
172 Display *display; ///< display connection
173
174 struct frame {
175 unsigned long button_pixel, pbutton_pixel;
176 Pixmap base, label, wlabel, clk, button, pbutton;
177 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
178 pwbutton, nwbutton;
179
180 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
181 unsigned int width, height, window_label_w, workspace_label_w, clock_w,
182 button_w, bevel_w, label_h;
183 } frame;
184
185 class HideHandler : public TimeoutHandler {
186 public:
187 Toolbar *toolbar;
188
189 virtual void timeout();
190 } hide_handler;
191
192 BScreen *screen;
193 BImageControl *image_ctrl;
194 BTimer clock_timer, hide_timer;
195 Toolbarmenu *toolbarmenu;
196 IconBar *iconbar;
197
198 std::string new_workspace_name; ///< temp variable in edit workspace name mode
199
200 friend class HideHandler;
201 friend class Toolbarmenu;
202 friend class Toolbarmenu::Placementmenu;
203 #ifdef XINERAMA
204 friend class Toolbarmenu::Headmenu;
205 #endif // XINERAMA
160}; 206};
161 207
162 208
163#endif // __Toolbar_hh 209#endif // TOOLBAR_HH