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
&);
46 virtual void itemSelected(int button
, unsigned int index
);
49 Placementmenu(Toolbarmenu
*tm
);
53 Placementmenu
*placementmenu
;
55 friend class Placementmenu
;
58 Toolbarmenu(const Toolbarmenu
&);
59 Toolbarmenu
& operator=(const Toolbarmenu
&);
62 virtual void itemSelected(int button
, unsigned int index
);
63 virtual void internal_hide(void);
66 Toolbarmenu(Toolbar
*tb
);
69 inline Basemenu
*getPlacementmenu(void) { return placementmenu
; }
71 void reconfigure(void);
75 class Toolbar
: public TimeoutHandler
{
77 bool on_top
, editing
, hidden
, do_auto_hide
;
81 unsigned long button_pixel
, pbutton_pixel
;
82 Pixmap base
, label
, wlabel
, clk
, button
, pbutton
;
83 Window window
, workspace_label
, window_label
, clock
, psbutton
, nsbutton
,
86 int x_hidden
, y_hidden
, hour
, minute
, grab_x
, grab_y
;
87 unsigned int window_label_w
, workspace_label_w
, clock_w
,
88 button_w
, bevel_w
, label_h
;
93 class HideHandler
: public TimeoutHandler
{
97 virtual void timeout(void);
102 BTimer
*clock_timer
, *hide_timer
;
103 Toolbarmenu
*toolbarmenu
;
106 std::string new_workspace_name
;
109 friend class HideHandler
;
110 friend class Toolbarmenu
;
111 friend class Toolbarmenu::Placementmenu
;
113 void redrawPrevWorkspaceButton(bool pressed
= False
, bool redraw
= False
);
114 void redrawNextWorkspaceButton(bool pressed
= False
, bool redraw
= False
);
115 void redrawPrevWindowButton(bool preseed
= False
, bool redraw
= False
);
116 void redrawNextWindowButton(bool preseed
= False
, bool redraw
= False
);
118 void updateStrut(void);
121 void checkClock(bool redraw
= False
);
122 #else // HAVE_STRFTIME
123 void checkClock(bool redraw
= False
, bool date
= False
);
124 #endif // HAVE_STRFTIME
126 Toolbar(const Toolbar
&);
127 Toolbar
& operator=(const Toolbar
&);
130 Toolbar(BScreen
*scrn
);
131 virtual ~Toolbar(void);
133 inline Toolbarmenu
*getMenu(void) { return toolbarmenu
; }
135 inline bool isEditing(void) const { return editing
; }
136 inline bool isOnTop(void) const { return on_top
; }
137 inline bool isHidden(void) const { return hidden
; }
138 inline bool doAutoHide(void) const { return do_auto_hide
; }
140 inline Window
getWindowID(void) const { return frame
.window
; }
142 inline const Rect
& getRect(void) const { return frame
.rect
; }
143 inline unsigned int getWidth(void) const { return frame
.rect
.width(); }
144 inline unsigned int getHeight(void) const { return frame
.rect
.height(); }
145 inline unsigned int getExposedHeight(void) const
146 { return ((do_auto_hide
) ? frame
.bevel_w
: frame
.rect
.height()); }
147 inline int getX(void) const
148 { return ((hidden
) ? frame
.x_hidden
: frame
.rect
.x()); }
149 inline int getY(void) const
150 { return ((hidden
) ? frame
.y_hidden
: frame
.rect
.y()); }
152 void buttonPressEvent(XButtonEvent
*be
);
153 void buttonReleaseEvent(XButtonEvent
*re
);
154 void enterNotifyEvent(XCrossingEvent
* /*unused*/);
155 void leaveNotifyEvent(XCrossingEvent
* /*unused*/);
156 void exposeEvent(XExposeEvent
*ee
);
157 void keyPressEvent(XKeyEvent
*ke
);
160 void reconfigure(void);
161 void toggleAutoHide(void);
163 void redrawWindowLabel(bool redraw
= False
);
164 void redrawWorkspaceLabel(bool redraw
= False
);
166 virtual void timeout(void);
168 enum { TopLeft
= 1, BottomLeft
, TopCenter
,
169 BottomCenter
, TopRight
, BottomRight
};
173 #endif // __Toolbar_hh