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.
33 // forward declaration
36 class Toolbarmenu : public Basemenu {
38 class Placementmenu : public Basemenu {
40 Toolbarmenu &toolbarmenu;
43 virtual void itemSelected(int, int);
46 Placementmenu(Toolbarmenu &);
50 Placementmenu *placementmenu;
52 friend class Placementmenu;
57 virtual void itemSelected(int, int);
58 virtual void internal_hide();
61 Toolbarmenu(Toolbar &);
64 inline Basemenu *getPlacementmenu() { return placementmenu; }
70 class Toolbar : public TimeoutHandler {
72 bool m_ontop, m_editing, m_hidden, m_autohide;
73 int m_width_percent, m_placement;
77 unsigned long button_pixel, pbutton_pixel;
78 Pixmap base, label, wlabel, clk, button, pbutton;
79 Window window, workspace_label, window_label, clock, psbutton, nsbutton,
82 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
83 unsigned int width, height, window_label_w, workspace_label_w, clock_w,
84 button_w, bevel_w, label_h;
87 class HideHandler : public TimeoutHandler {
90 virtual void timeout();
95 BImageControl *image_ctrl;
97 BTimer *clock_timer, *hide_timer;
98 Toolbarmenu *toolbarmenu;
100 char *new_workspace_name;
103 friend class HideHandler;
104 friend class Toolbarmenu;
105 friend class Toolbarmenu::Placementmenu;
109 Toolbar(BScreen &, Resource &);
112 inline Toolbarmenu *getMenu() { return toolbarmenu; }
114 inline const Window &getWindowID() const { return frame.window; }
116 inline unsigned int getWidth() const { return frame.width; }
117 inline unsigned int getHeight() const { return frame.height; }
118 unsigned int getExposedHeight() const;
123 void buttonPressEvent(XButtonEvent *);
124 void buttonReleaseEvent(XButtonEvent *);
125 void enterNotifyEvent(XCrossingEvent *);
126 void leaveNotifyEvent(XCrossingEvent *);
127 void exposeEvent(XExposeEvent *);
128 void keyPressEvent(XKeyEvent *);
130 void redrawWindowLabel(Bool = False);
131 void redrawWorkspaceLabel(Bool = False);
132 void redrawPrevWorkspaceButton(Bool = False, Bool = False);
133 void redrawNextWorkspaceButton(Bool = False, Bool = False);
134 void redrawPrevWindowButton(Bool = False, Bool = False);
135 void redrawNextWindowButton(Bool = False, Bool = False);
143 void checkClock(Bool = False);
144 #else // HAVE_STRFTIME
145 void checkClock(Bool = False, Bool = False);
146 #endif // HAVE_STRFTIME
148 virtual void timeout();
150 inline bool onTop() const { return m_ontop; }
153 inline bool autoHide() const { return m_autohide; }
154 void setAutoHide(bool);
156 inline int widthPercent() const { return m_width_percent; }
157 void setWidthPercent(int);
159 inline int placement() const { return m_placement; }
160 void setPlacement(int);
162 inline bool isEditing() const { return m_editing; }
163 inline bool isHidden() const { return m_hidden; }
165 enum { TopLeft = 1, BottomLeft, TopCenter,
166 BottomCenter, TopRight, BottomRight };
170 #endif // __Toolbar_hh