1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Toolbar.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
32 #include "Basemenu.hh"
35 // forward declaration
38 class Toolbarmenu
: public Basemenu
{
40 class Placementmenu
: public Basemenu
{
42 Placementmenu(const Placementmenu
&);
43 Placementmenu
& operator=(const Placementmenu
&);
47 virtual void itemSelected(int button
, unsigned int index
);
48 virtual void setValues(void);
51 Placementmenu(Toolbarmenu
*tm
);
52 virtual void reconfigure(void);
56 Placementmenu
*placementmenu
;
58 friend class Placementmenu
;
61 Toolbarmenu(const Toolbarmenu
&);
62 Toolbarmenu
& operator=(const Toolbarmenu
&);
65 virtual void itemSelected(int button
, unsigned int index
);
66 virtual void internal_hide(void);
67 virtual void setValues(void);
70 Toolbarmenu(Toolbar
*tb
);
73 inline Basemenu
*getPlacementmenu(void) { return placementmenu
; }
75 virtual void reconfigure(void);
79 class Toolbar
: public TimeoutHandler
{
81 bool on_top
, editing
, hidden
, do_auto_hide
;
82 unsigned int width_percent
;
84 std::string toolbarstr
;
88 unsigned long button_pixel
, pbutton_pixel
;
89 Pixmap base
, label
, wlabel
, clk
, button
, pbutton
;
90 Window window
, workspace_label
, window_label
, clock
, psbutton
, nsbutton
,
93 int x_hidden
, y_hidden
, hour
, minute
;
94 unsigned int window_label_w
, workspace_label_w
, clock_w
,
95 button_w
, bevel_w
, label_h
;
100 class HideHandler
: public TimeoutHandler
{
104 virtual void timeout(void);
109 Configuration
*config
;
110 BTimer
*clock_timer
, *hide_timer
;
111 Toolbarmenu
*toolbarmenu
;
114 std::string new_workspace_name
;
117 friend class HideHandler
;
118 friend class Toolbarmenu
;
119 friend class Toolbarmenu::Placementmenu
;
121 void drawArrow(Drawable surface
, bool left
) const;
122 void redrawPrevWorkspaceButton(bool pressed
= False
, bool redraw
= False
);
123 void redrawNextWorkspaceButton(bool pressed
= False
, bool redraw
= False
);
124 void redrawPrevWindowButton(bool preseed
= False
, bool redraw
= False
);
125 void redrawNextWindowButton(bool preseed
= False
, bool redraw
= False
);
127 void updateStrut(void);
130 void checkClock(bool redraw
= False
);
131 #else // HAVE_STRFTIME
132 void checkClock(bool redraw
= False
, bool date
= False
);
133 #endif // HAVE_STRFTIME
135 Toolbar(const Toolbar
&);
136 Toolbar
& operator=(const Toolbar
&);
139 Toolbar(BScreen
*scrn
);
140 virtual ~Toolbar(void);
142 inline Toolbarmenu
*getMenu(void) { return toolbarmenu
; }
144 inline bool isEditing(void) const { return editing
; }
145 inline bool isOnTop(void) const { return on_top
; }
146 inline bool isHidden(void) const { return hidden
; }
147 inline bool doAutoHide(void) const { return do_auto_hide
; }
148 inline unsigned int getWidthPercent(void) const { return width_percent
; }
149 inline int getPlacement(void) const { return placement
; }
151 void saveOnTop(bool);
152 void saveAutoHide(bool);
153 void saveWidthPercent(unsigned int);
154 void savePlacement(int);
159 void mapToolbar(void);
160 void unmapToolbar(void);
162 inline Window
getWindowID(void) const { return frame
.window
; }
164 inline const Rect
& getRect(void) const { return frame
.rect
; }
165 inline unsigned int getWidth(void) const { return frame
.rect
.width(); }
166 inline unsigned int getHeight(void) const { return frame
.rect
.height(); }
167 inline unsigned int getExposedHeight(void) const
168 { return (screen
->doHideToolbar() ? 0 :
169 ((do_auto_hide
) ? frame
.bevel_w
:
170 frame
.rect
.height())); }
171 inline int getX(void) const
172 { return ((hidden
) ? frame
.x_hidden
: frame
.rect
.x()); }
173 inline int getY(void) const
174 { return ((hidden
) ? frame
.y_hidden
: frame
.rect
.y()); }
176 void buttonPressEvent(const XButtonEvent
*be
);
177 void buttonReleaseEvent(const XButtonEvent
*re
);
178 void enterNotifyEvent(const XCrossingEvent
* /*unused*/);
179 void leaveNotifyEvent(const XCrossingEvent
* /*unused*/);
180 void exposeEvent(const XExposeEvent
*ee
);
181 void keyPressEvent(const XKeyEvent
*ke
);
184 void reconfigure(void);
185 void toggleAutoHide(void);
187 void redrawWindowLabel(bool redraw
= False
);
188 void redrawWorkspaceLabel(bool redraw
= False
);
190 virtual void timeout(void);
192 enum { TopLeft
= 1, BottomLeft
, TopCenter
,
193 BottomCenter
, TopRight
, BottomRight
};
197 #endif // __Toolbar_hh