diff options
Diffstat (limited to 'src/Toolbar.hh')
-rw-r--r-- | src/Toolbar.hh | 273 |
1 files changed, 161 insertions, 112 deletions
diff --git a/src/Toolbar.hh b/src/Toolbar.hh index d6e19db..7cc08b1 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,191 @@ | |||
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.11 2002/08/04 15:55:13 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 | ||
37 | class Toolbar; | 35 | class Toolbar; |
38 | 36 | ||
39 | class Toolbarmenu : public Basemenu { | 37 | /** |
40 | private: | 38 | Menu for toolbar. |
41 | class Placementmenu : public Basemenu { | 39 | @see Toolbar |
42 | private: | 40 | */ |
43 | Toolbarmenu *toolbarmenu; | 41 | class Toolbarmenu:public Basemenu { |
44 | 42 | public: | |
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 | ||
59 | protected: | 54 | protected: |
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 | ||
63 | public: | 58 | private: |
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 | #endif // XINERAMA | ||
81 | |||
82 | |||
83 | Toolbar *toolbar; | ||
84 | Placementmenu *placementmenu; | ||
85 | #ifdef XINERAMA | ||
86 | Headmenu *headmenu; | ||
87 | friend class Headmenu; | ||
88 | #endif // XINERAMA | ||
89 | |||
90 | friend class Placementmenu; | ||
91 | friend class Toolbar; | ||
68 | 92 | ||
69 | void reconfigure(void); | ||
70 | }; | 93 | }; |
71 | 94 | ||
72 | 95 | /** | |
96 | the toolbar. | ||
97 | */ | ||
73 | class Toolbar : public TimeoutHandler { | 98 | class Toolbar : public TimeoutHandler { |
74 | private: | 99 | public: |
75 | Bool on_top, editing, hidden, do_auto_hide; | 100 | /** |
76 | Display *display; | 101 | Toolbar placement on the screen |
77 | 102 | */ | |
78 | struct frame { | 103 | enum Placement{ TOPLEFT = 1, BOTTOMLEFT, TOPCENTER, |
79 | unsigned long button_pixel, pbutton_pixel; | 104 | 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 | 105 | ||
106 | explicit Toolbar(BScreen *screen); | ||
107 | virtual ~Toolbar(); | ||
109 | 108 | ||
110 | public: | 109 | /// add icon to iconbar |
111 | Toolbar(BScreen *); | ||
112 | virtual ~Toolbar(void); | ||
113 | void addIcon(FluxboxWindow *w); | 110 | void addIcon(FluxboxWindow *w); |
111 | /// remove icon from iconbar | ||
114 | void delIcon(FluxboxWindow *w); | 112 | void delIcon(FluxboxWindow *w); |
115 | 113 | ||
116 | inline Toolbarmenu *getMenu(void) { return toolbarmenu; } | 114 | inline Toolbarmenu *getMenu() { return toolbarmenu; } |
115 | inline const Toolbarmenu *getMenu() const { return toolbarmenu; } | ||
116 | |||
117 | //inline Window getWindowLabel(void) { return frame.window_label; } | 117 | //inline Window getWindowLabel(void) { return frame.window_label; } |
118 | inline const Bool &isEditing(void) const { return editing; } | 118 | |
119 | inline const Bool &isOnTop(void) const { return on_top; } | 119 | /// are we in workspacename editing? |
120 | inline const Bool &isHidden(void) const { return hidden; } | 120 | inline bool isEditing() const { return editing; } |
121 | inline const Bool &doAutoHide(void) const { return do_auto_hide; } | 121 | /// always on top? |
122 | 122 | inline bool isOnTop() const { return on_top; } | |
123 | inline const Window &getWindowID(void) const { return frame.window; } | 123 | /// are we hidden? |
124 | 124 | inline bool isHidden() const { return hidden; } | |
125 | inline const unsigned int &getWidth(void) const { return frame.width; } | 125 | /// do we auto hide the toolbar? |
126 | inline const unsigned int &getHeight(void) const { return frame.height; } | 126 | inline bool doAutoHide() const { return do_auto_hide; } |
127 | inline const unsigned int &getExposedHeight(void) const | 127 | /** |
128 | { return ((do_auto_hide) ? frame.bevel_w : frame.height); } | 128 | @return X window of the toolbar |
129 | inline const int &getX(void) const | 129 | */ |
130 | { return ((hidden) ? frame.x_hidden : frame.x); } | 130 | inline Window getWindowID() const { return frame.window; } |
131 | inline const int &getY(void) const | 131 | |
132 | { return ((hidden) ? frame.y_hidden : frame.y); } | 132 | inline unsigned int getWidth() const { return frame.width; } |
133 | 133 | inline unsigned int getHeight() const { return frame.height; } | |
134 | void buttonPressEvent(XButtonEvent *); | 134 | inline unsigned int getExposedHeight() const { return ((do_auto_hide) ? frame.bevel_w : frame.height); } |
135 | void buttonReleaseEvent(XButtonEvent *); | 135 | inline int getX() const { return ((hidden) ? frame.x_hidden : frame.x); } |
136 | void enterNotifyEvent(XCrossingEvent *); | 136 | inline int getY() const { return ((hidden) ? frame.y_hidden : frame.y); } |
137 | void leaveNotifyEvent(XCrossingEvent *); | 137 | inline IconBar *getIconBar() { return iconbar; } |
138 | void exposeEvent(XExposeEvent *); | 138 | /** |
139 | void keyPressEvent(XKeyEvent *); | 139 | @name eventhandlers |
140 | 140 | */ | |
141 | void redrawWindowLabel(Bool = False); | 141 | //@{ |
142 | void redrawWorkspaceLabel(Bool = False); | 142 | void buttonPressEvent(XButtonEvent *be); |
143 | void redrawPrevWorkspaceButton(Bool = False, Bool = False); | 143 | void buttonReleaseEvent(XButtonEvent *be); |
144 | void redrawNextWorkspaceButton(Bool = False, Bool = False); | 144 | void enterNotifyEvent(XCrossingEvent *ce); |
145 | void redrawPrevWindowButton(Bool = False, Bool = False); | 145 | void leaveNotifyEvent(XCrossingEvent *ce); |
146 | void redrawNextWindowButton(Bool = False, Bool = False); | 146 | void exposeEvent(XExposeEvent *ee); |
147 | void edit(void); | 147 | void keyPressEvent(XKeyEvent *ke); |
148 | void reconfigure(void); | 148 | //@} |
149 | 149 | ||
150 | #ifdef HAVE_STRFTIME | 150 | void redrawWindowLabel(bool redraw= false); |
151 | void checkClock(Bool = False); | 151 | void redrawWorkspaceLabel(bool redraw= false); |
152 | #else // HAVE_STRFTIME | 152 | void redrawPrevWorkspaceButton(bool pressed = false, bool redraw = false); |
153 | void checkClock(Bool = False, Bool = False); | 153 | void redrawNextWorkspaceButton(bool pressed = false, bool redraw = false); |
154 | void redrawPrevWindowButton(bool pressed = false, bool redraw = false); | ||
155 | void redrawNextWindowButton(bool pressed = false, bool redraw = false); | ||
156 | /// enter edit mode on workspace label | ||
157 | void edit(); | ||
158 | void reconfigure(); | ||
159 | |||
160 | #ifdef HAVE_STRFTIME | ||
161 | void checkClock(bool redraw = false); | ||
162 | #else // HAVE_STRFTIME | ||
163 | void checkClock(bool redraw = false, bool date = false); | ||
154 | #endif // HAVE_STRFTIME | 164 | #endif // HAVE_STRFTIME |
155 | 165 | ||
156 | virtual void timeout(void); | 166 | virtual void timeout(); |
157 | 167 | ||
158 | enum { TopLeft = 1, BottomLeft, TopCenter, | 168 | |
159 | BottomCenter, TopRight, BottomRight }; | 169 | private: |
170 | bool on_top; ///< always on top | ||
171 | bool editing; ///< edit workspace label mode | ||
172 | bool hidden; ///< hidden state | ||
173 | bool do_auto_hide; ///< do we auto hide | ||
174 | Display *display; ///< display connection | ||
175 | |||
176 | struct frame { | ||
177 | unsigned long button_pixel, pbutton_pixel; | ||
178 | Pixmap base, label, wlabel, clk, button, pbutton; | ||
179 | Window window, workspace_label, window_label, clock, psbutton, nsbutton, | ||
180 | pwbutton, nwbutton; | ||
181 | |||
182 | int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y; | ||
183 | unsigned int width, height, window_label_w, workspace_label_w, clock_w, | ||
184 | button_w, bevel_w, label_h; | ||
185 | } frame; | ||
186 | |||
187 | class HideHandler : public TimeoutHandler { | ||
188 | public: | ||
189 | Toolbar *toolbar; | ||
190 | |||
191 | virtual void timeout(void); | ||
192 | } hide_handler; | ||
193 | |||
194 | Fluxbox *fluxbox; ///< obsolete | ||
195 | BScreen *screen; ///< screen on wich this toolbar exist | ||
196 | BImageControl *image_ctrl; | ||
197 | BTimer clock_timer, *hide_timer; | ||
198 | Toolbarmenu *toolbarmenu; | ||
199 | IconBar *iconbar; | ||
200 | |||
201 | std::string new_workspace_name; ///< temp variable in edit mode | ||
202 | |||
203 | friend class HideHandler; | ||
204 | friend class Toolbarmenu; | ||
205 | friend class Toolbarmenu::Placementmenu; | ||
206 | #ifdef XINERAMA | ||
207 | friend class Toolbarmenu::Headmenu; | ||
208 | #endif // XINERAMA | ||
160 | }; | 209 | }; |
161 | 210 | ||
162 | 211 | ||
163 | #endif // __Toolbar_hh | 212 | #endif // TOOLBAR_HH |