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)
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:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
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.
32 // forward declaration
35 class Toolbarmenu : public Basemenu {
37 class Placementmenu : public Basemenu {
39 Toolbarmenu &toolbarmenu;
42 virtual void itemSelected(int, int);
45 Placementmenu(Toolbarmenu &);
49 Placementmenu *placementmenu;
51 friend class Placementmenu;
56 virtual void itemSelected(int, int);
57 virtual void internal_hide(void);
60 Toolbarmenu(Toolbar &);
63 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
65 void reconfigure(void);
69 class Toolbar : public TimeoutHandler {
71 Bool on_top, editing, hidden, do_auto_hide, do_hide;
75 unsigned long button_pixel, pbutton_pixel;
76 Pixmap base, label, wlabel, clk, button, pbutton;
77 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
80 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
81 unsigned int width, height, window_label_w, workspace_label_w, clock_w,
82 button_w, bevel_w, label_h;
85 class HideHandler : public TimeoutHandler {
89 virtual void timeout(void);
93 BImageControl *image_ctrl;
95 BTimer *clock_timer, *hide_timer;
96 Toolbarmenu *toolbarmenu;
98 char *new_workspace_name;
101 friend class HideHandler;
102 friend class Toolbarmenu;
103 friend class Toolbarmenu::Placementmenu;
108 virtual ~Toolbar(void);
110 inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
112 inline const Bool &isEditing(void) const { return editing; }
113 inline const Bool &isOnTop(void) const { return on_top; }
114 inline const Bool &isHidden(void) const { return hidden; }
115 inline const Bool &doAutoHide(void) const { return do_auto_hide; }
117 inline const Window &getWindowID(void) const { return frame.window; }
119 inline const unsigned int &getWidth(void) const { return frame.width; }
120 inline const unsigned int &getHeight(void) const { return frame.height; }
121 inline const unsigned int getExposedHeight(void) const {
122 if (do_hide) return 0;
123 else if (do_auto_hide) return frame.bevel_w;
124 else return frame.height;
127 inline const int &getX(void) const
128 { return ((hidden) ? frame.x_hidden : frame.x); }
129 // const int getY(void) const;
130 inline const int getY(void) const {
131 if (do_hide) return screen.size().h();
132 else if (hidden) return frame.y_hidden;
137 void buttonPressEvent(XButtonEvent *);
138 void buttonReleaseEvent(XButtonEvent *);
139 void enterNotifyEvent(XCrossingEvent *);
140 void leaveNotifyEvent(XCrossingEvent *);
141 void exposeEvent(XExposeEvent *);
142 void keyPressEvent(XKeyEvent *);
144 void redrawWindowLabel(Bool = False);
145 void redrawWorkspaceLabel(Bool = False);
146 void redrawPrevWorkspaceButton(Bool = False, Bool = False);
147 void redrawNextWorkspaceButton(Bool = False, Bool = False);
148 void redrawPrevWindowButton(Bool = False, Bool = False);
149 void redrawNextWindowButton(Bool = False, Bool = False);
151 void reconfigure(void);
152 void mapToolbar(void);
153 void unMapToolbar(void);
155 void checkClock(Bool = False);
156 #else // HAVE_STRFTIME
157 void checkClock(Bool = False, Bool = False);
158 #endif // HAVE_STRFTIME
160 virtual void timeout(void);
162 enum { TopLeft = 1, BottomLeft, TopCenter,
163 BottomCenter, TopRight, BottomRight };
167 #endif // __Toolbar_hh