diff options
Diffstat (limited to 'src/Toolbar.hh')
-rw-r--r-- | src/Toolbar.hh | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/src/Toolbar.hh b/src/Toolbar.hh new file mode 100644 index 0000000..d6e19db --- /dev/null +++ b/src/Toolbar.hh | |||
@@ -0,0 +1,163 @@ | |||
1 | // Toolbar.hh for Blackbox - an X11 Window manager | ||
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #ifndef _TOOLBAR_HH_ | ||
23 | #define _TOOLBAR_HH_ | ||
24 | |||
25 | #include <X11/Xlib.h> | ||
26 | |||
27 | |||
28 | |||
29 | |||
30 | #include "Basemenu.hh" | ||
31 | #include "LinkedList.hh" | ||
32 | #include "Timer.hh" | ||
33 | #include "IconBar.hh" | ||
34 | |||
35 | |||
36 | // forward declaration | ||
37 | class Toolbar; | ||
38 | |||
39 | class Toolbarmenu : public Basemenu { | ||
40 | private: | ||
41 | class Placementmenu : public Basemenu { | ||
42 | private: | ||
43 | Toolbarmenu *toolbarmenu; | ||
44 | |||
45 | protected: | ||
46 | virtual void itemSelected(int, int); | ||
47 | |||
48 | public: | ||
49 | Placementmenu(Toolbarmenu *); | ||
50 | }; | ||
51 | |||
52 | Toolbar *toolbar; | ||
53 | Placementmenu *placementmenu; | ||
54 | |||
55 | friend class Placementmenu; | ||
56 | friend class Toolbar; | ||
57 | |||
58 | |||
59 | protected: | ||
60 | virtual void itemSelected(int, int); | ||
61 | virtual void internal_hide(void); | ||
62 | |||
63 | public: | ||
64 | Toolbarmenu(Toolbar *); | ||
65 | ~Toolbarmenu(void); | ||
66 | |||
67 | inline Basemenu *getPlacementmenu(void) { return placementmenu; } | ||
68 | |||
69 | void reconfigure(void); | ||
70 | }; | ||
71 | |||
72 | |||
73 | class Toolbar : public TimeoutHandler { | ||
74 | private: | ||
75 | Bool on_top, editing, hidden, do_auto_hide; | ||
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 | |||
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 | |||
109 | |||
110 | public: | ||
111 | Toolbar(BScreen *); | ||
112 | virtual ~Toolbar(void); | ||
113 | void addIcon(FluxboxWindow *w); | ||
114 | void delIcon(FluxboxWindow *w); | ||
115 | |||
116 | inline Toolbarmenu *getMenu(void) { return toolbarmenu; } | ||
117 | //inline Window getWindowLabel(void) { return frame.window_label; } | ||
118 | inline const Bool &isEditing(void) const { return editing; } | ||
119 | inline const Bool &isOnTop(void) const { return on_top; } | ||
120 | inline const Bool &isHidden(void) const { return hidden; } | ||
121 | inline const Bool &doAutoHide(void) const { return do_auto_hide; } | ||
122 | |||
123 | inline const Window &getWindowID(void) const { return frame.window; } | ||
124 | |||
125 | inline const unsigned int &getWidth(void) const { return frame.width; } | ||
126 | inline const unsigned int &getHeight(void) const { return frame.height; } | ||
127 | inline const unsigned int &getExposedHeight(void) const | ||
128 | { return ((do_auto_hide) ? frame.bevel_w : frame.height); } | ||
129 | inline const int &getX(void) const | ||
130 | { return ((hidden) ? frame.x_hidden : frame.x); } | ||
131 | inline const int &getY(void) const | ||
132 | { return ((hidden) ? frame.y_hidden : frame.y); } | ||
133 | |||
134 | void buttonPressEvent(XButtonEvent *); | ||
135 | void buttonReleaseEvent(XButtonEvent *); | ||
136 | void enterNotifyEvent(XCrossingEvent *); | ||
137 | void leaveNotifyEvent(XCrossingEvent *); | ||
138 | void exposeEvent(XExposeEvent *); | ||
139 | void keyPressEvent(XKeyEvent *); | ||
140 | |||
141 | void redrawWindowLabel(Bool = False); | ||
142 | void redrawWorkspaceLabel(Bool = False); | ||
143 | void redrawPrevWorkspaceButton(Bool = False, Bool = False); | ||
144 | void redrawNextWorkspaceButton(Bool = False, Bool = False); | ||
145 | void redrawPrevWindowButton(Bool = False, Bool = False); | ||
146 | void redrawNextWindowButton(Bool = False, Bool = False); | ||
147 | void edit(void); | ||
148 | void reconfigure(void); | ||
149 | |||
150 | #ifdef HAVE_STRFTIME | ||
151 | void checkClock(Bool = False); | ||
152 | #else // HAVE_STRFTIME | ||
153 | void checkClock(Bool = False, Bool = False); | ||
154 | #endif // HAVE_STRFTIME | ||
155 | |||
156 | virtual void timeout(void); | ||
157 | |||
158 | enum { TopLeft = 1, BottomLeft, TopCenter, | ||
159 | BottomCenter, TopRight, BottomRight }; | ||
160 | }; | ||
161 | |||
162 | |||
163 | #endif // __Toolbar_hh | ||