aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toolbar.hh')
-rw-r--r--src/Toolbar.hh275
1 files changed, 154 insertions, 121 deletions
diff --git a/src/Toolbar.hh b/src/Toolbar.hh
index d6e19db..3e9878c 100644
--- a/src/Toolbar.hh
+++ b/src/Toolbar.hh
@@ -1,3 +1,6 @@
1// Toolbar.hh for Fluxbox
2// Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3//
1// Toolbar.hh for Blackbox - an X11 Window manager 4// Toolbar.hh for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -19,145 +22,175 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22#ifndef _TOOLBAR_HH_ 25// $Id: Toolbar.hh,v 1.44 2003/08/19 21:28:57 fluxgen Exp $
23#define _TOOLBAR_HH_
24
25#include <X11/Xlib.h>
26
27
28 26
27#ifndef TOOLBAR_HH
28#define TOOLBAR_HH
29 29
30#include "Basemenu.hh"
31#include "LinkedList.hh"
32#include "Timer.hh" 30#include "Timer.hh"
33#include "IconBar.hh" 31#include "ToolbarTheme.hh"
34 32#include "ToolTheme.hh"
35 33#include "IconbarTheme.hh"
36// forward declaration 34
37class Toolbar; 35#include "EventHandler.hh"
36#include "FbWindow.hh"
37#include "ArrowButton.hh"
38#include "Observer.hh"
39#include "XLayer.hh"
40#include "XLayerItem.hh"
41#include "LayerMenu.hh"
42#include "Resource.hh"
43
44#include <memory>
45
46class BScreen;
47class Strut;
48class Container;
49class IconButton;
50class Shape;
51class ToolbarItem;
52
53namespace FbTk {
54class ImageControl;
55};
38 56
39class Toolbarmenu : public Basemenu { 57typedef Container IconBar;
58/// The toolbar.
59/// Handles iconbar, workspace name view and clock view
60class Toolbar: public FbTk::EventHandler, public FbTk::Observer {
61public:
62
63 /// Toolbar placement on the screen
64 enum Placement{
65 // top and bottom placement
66 TOPLEFT = 1, BOTTOMLEFT, TOPCENTER,
67 BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT,
68 // left and right placement
69 LEFTCENTER, LEFTBOTTOM, LEFTTOP,
70 RIGHTCENTER, RIGHTBOTTOM, RIGHTTOP
71 };
72
73 /// Create a toolbar on the screen with specific width
74 Toolbar(BScreen &screen, FbTk::XLayer &layer, FbTk::Menu &menu, size_t width = 200);
75
76 virtual ~Toolbar();
77
78 void raise();
79 void lower();
80 void toggleHidden();
81
82
83 void moveToLayer(int layernum);
84
85 void saveOnHead(int head);
86
87 /**
88 @name eventhandlers
89 */
90 //@{
91 void buttonPressEvent(XButtonEvent &be);
92 void buttonReleaseEvent(XButtonEvent &be);
93 void enterNotifyEvent(XCrossingEvent &ce);
94 void leaveNotifyEvent(XCrossingEvent &ce);
95 void exposeEvent(XExposeEvent &ee);
96 void keyPressEvent(XKeyEvent &ke);
97 void handleEvent(XEvent &event);
98 //@}
99
100 /// enter edit mode on workspace label
101 void edit();
102 void reconfigure();
103 void setPlacement(Placement where);
104
105 void update(FbTk::Subject *subj);
106
107 FbTk::XLayerItem &layerItem() { return m_layeritem; }
108
109 inline const FbTk::Menu &menu() const { return m_toolbarmenu; }
110 inline FbTk::Menu &menu() { return m_toolbarmenu; }
111 inline FbTk::Menu &placementMenu() { return m_placementmenu; }
112 inline const FbTk::Menu &placementMenu() const { return m_placementmenu; }
113
114 inline FbTk::Menu &layermenu() { return m_layermenu; }
115 inline const FbTk::Menu &layermenu() const { return m_layermenu; }
116
117 /// are we in workspacename editing?
118 inline bool isEditing() const { return m_editing; }
119 /// are we hidden?
120 inline bool isHidden() const { return m_hidden; }
121 /// do we auto hide the toolbar?
122 inline bool doAutoHide() const { return *m_rc_auto_hide; }
123 /// @return X window of the toolbar
124 inline const FbTk::FbWindow &window() const { return frame.window; }
125 inline BScreen &screen() { return m_screen; }
126 inline const BScreen &screen() const { return m_screen; }
127 inline unsigned int width() const { return frame.window.width(); }
128 inline unsigned int height() const { return frame.window.height(); }
129 inline unsigned int exposedHeight() const { return doAutoHide() ? frame.bevel_w : frame.height; }
130 inline int x() const { return isHidden() ? frame.x_hidden : frame.x; }
131 inline int y() const { return isHidden() ? frame.y_hidden : frame.y; }
132 inline Placement placement() const { return *m_rc_placement; }
133 /// @return pointer to iconbar if it got one, else 0
134 inline const ToolbarTheme &theme() const { return m_theme; }
135 inline ToolbarTheme &theme() { return m_theme; }
136 bool isVertical() const;
137
138 inline int getOnHead() const { return *m_rc_on_head; }
139
40private: 140private:
41 class Placementmenu : public Basemenu { 141 void rearrangeItems();
42 private:
43 Toolbarmenu *toolbarmenu;
44
45 protected:
46 virtual void itemSelected(int, int);
47 142
48 public: 143 void updateIconbarGraphics();
49 Placementmenu(Toolbarmenu *); 144 void setupMenus();
50 }; 145 void clearStrut();
146 void updateStrut();
51 147
52 Toolbar *toolbar; 148 bool m_editing; ///< edit workspace label mode
53 Placementmenu *placementmenu; 149 bool m_hidden; ///< hidden state
54 150
55 friend class Placementmenu; 151 /// Toolbar frame
56 friend class Toolbar; 152 struct Frame {
153 Frame(FbTk::EventHandler &evh, int screen_num);
154 ~Frame();
57 155
156 FbTk::FbWindow window;
58 157
59protected: 158 int x, y, x_hidden, y_hidden, grab_x, grab_y;
60 virtual void itemSelected(int, int); 159 unsigned int width, height, bevel_w;
61 virtual void internal_hide(void); 160 } frame;
161 // background pixmap
162 Pixmap m_window_pm;
62 163
63public: 164 BScreen &m_screen; ///< screen connection
64 Toolbarmenu(Toolbar *);
65 ~Toolbarmenu(void);
66 165
67 inline Basemenu *getPlacementmenu(void) { return placementmenu; } 166 FbTk::Timer m_hide_timer; ///< timer to for auto hide toolbar
167 FbTk::Menu &m_toolbarmenu;
168 FbTk::Menu m_placementmenu;
169 LayerMenu<Toolbar> m_layermenu;
68 170
69 void reconfigure(void); 171 // themes
70}; 172 ToolbarTheme m_theme;
173 ToolTheme m_clock_theme, m_workspace_theme;
174 IconbarTheme m_iconbar_theme;
71 175
176 FbTk::XLayerItem m_layeritem;
177 typedef std::list<ToolbarItem *> ItemList;
178 ItemList m_item_list;
72 179
73class Toolbar : public TimeoutHandler { 180 Strut *m_strut; ///< created and destroyed by BScreen
74private:
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 181
105 friend class HideHandler; 182 // resources
106 friend class Toolbarmenu; 183 FbTk::Resource<bool> m_rc_auto_hide, m_rc_maximize_over;
107 friend class Toolbarmenu::Placementmenu; 184 FbTk::Resource<int> m_rc_width_percent;
185 FbTk::Resource<Fluxbox::Layer> m_rc_layernum;
186 FbTk::Resource<int> m_rc_on_head;
187 FbTk::Resource<Placement> m_rc_placement;
188 FbTk::Resource<int> m_rc_height;
189 std::auto_ptr<Shape> m_shape;
108 190
109 191
110public: 192 bool m_resize_lock; ///< to lock rearrangeItems or not
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}; 193};
161 194
162 195
163#endif // __Toolbar_hh 196#endif // TOOLBAR_HH