aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-13 20:37:55 (GMT)
committerfluxgen <fluxgen>2002-12-13 20:37:55 (GMT)
commitc5023fd19368c18386758e4c2f8826688b17cee1 (patch)
treeeb5176a53305fdf54b32a5771b98f301ab001e2b /src
parentf018f1f99eb444e4e2089ad8d3d072225f978ccd (diff)
downloadfluxbox-c5023fd19368c18386758e4c2f8826688b17cee1.zip
fluxbox-c5023fd19368c18386758e4c2f8826688b17cee1.tar.bz2
using ArrowButton for arrows in toolbar
Diffstat (limited to 'src')
-rw-r--r--src/Toolbar.cc213
-rw-r--r--src/Toolbar.hh32
2 files changed, 69 insertions, 176 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 9db04d1..5774578 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -1,8 +1,8 @@
1// Toolbar.cc for Fluxbox 1// Toolbar.cc for Fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Toolbar.cc for Blackbox - an X11 Window manager 4// Toolbar.cc for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
6// 6//
7// Permission is hereby granted, free of charge, to any person obtaining a 7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"), 8// copy of this software and associated documentation files (the "Software"),
@@ -22,7 +22,7 @@
22// 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
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.cc,v 1.49 2002/12/04 22:36:47 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.50 2002/12/13 20:37:55 fluxgen Exp $
26 26
27#include "Toolbar.hh" 27#include "Toolbar.hh"
28 28
@@ -39,6 +39,8 @@
39#include "ToolbarTheme.hh" 39#include "ToolbarTheme.hh"
40#include "EventManager.hh" 40#include "EventManager.hh"
41#include "Text.hh" 41#include "Text.hh"
42#include "ArrowButton.hh"
43#include "SimpleCommand.hh"
42 44
43// use GNU extensions 45// use GNU extensions
44#ifndef _GNU_SOURCE 46#ifndef _GNU_SOURCE
@@ -74,68 +76,62 @@ using namespace std;
74Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num): 76Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num):
75 window(screen_num, // screen (parent) 77 window(screen_num, // screen (parent)
76 0, 0, // pos 78 0, 0, // pos
77 1, 1, // 79 1, 1, // size
80 // event mask
78 ButtonPressMask | ButtonReleaseMask | 81 ButtonPressMask | ButtonReleaseMask |
79 EnterWindowMask | LeaveWindowMask, 82 EnterWindowMask | LeaveWindowMask,
80 true), // override redirect 83 true), // override redirect
81 workspace_label(window, // parent 84 workspace_label(window, // parent
82 0, 0, //pos 85 0, 0, //pos
83 1, 1, // size 86 1, 1, // size
87 // event mask
84 ButtonPressMask | ButtonReleaseMask | 88 ButtonPressMask | ButtonReleaseMask |
85 ExposureMask | KeyPressMask), 89 ExposureMask | KeyPressMask),
86 window_label(window, // parent 90 window_label(window, // parent
87 0, 0, // pos 91 0, 0, // pos
88 1, 1, // size 92 1, 1, // size
93 // event mask
89 ButtonPressMask | ButtonReleaseMask | 94 ButtonPressMask | ButtonReleaseMask |
90 ExposureMask), 95 ExposureMask),
91 clock (window, //parent 96 clock (window, //parent
92 0, 0, // pos 97 0, 0, // pos
93 1, 1, // size 98 1, 1, // size
99 // event mask
94 ButtonPressMask | ButtonReleaseMask | 100 ButtonPressMask | ButtonReleaseMask |
95 ExposureMask), 101 ExposureMask),
96 psbutton(window, // parent 102 psbutton(ArrowButton::LEFT, // arrow type
103 window, // parent
97 0, 0, // pos 104 0, 0, // pos
98 1, 1, // size 105 1, 1), // size
99 ButtonPressMask | ButtonReleaseMask | 106 nsbutton(ArrowButton::RIGHT, // arrow type
100 ExposureMask), 107 window, // parent
101 nsbutton(window, 108 0, 0, // pos
102 0, 0, 109 1, 1), // size
103 1, 1, 110 pwbutton(ArrowButton::LEFT, // arrow type
104 ButtonPressMask | ButtonReleaseMask | 111 window, // parent
105 ExposureMask), 112 0, 0, // pos
106 pwbutton(window, 113 1, 1), // size
107 0, 0, 114 nwbutton(ArrowButton::RIGHT, // arrow type
108 1, 1, 115 window, // parent
109 ButtonPressMask | ButtonReleaseMask | 116 0, 0, // pos
110 ExposureMask), 117 1, 1) // size
111 nwbutton(window, 118
112 0, 0,
113 1, 1,
114 ButtonPressMask | ButtonReleaseMask |
115 ExposureMask)
116{ 119{
117 FbTk::EventManager &evm = *FbTk::EventManager::instance(); 120 FbTk::EventManager &evm = *FbTk::EventManager::instance();
121 // add windows to eventmanager
118 evm.add(evh, window); 122 evm.add(evh, window);
119 evm.add(evh, workspace_label); 123 evm.add(evh, workspace_label);
120 evm.add(evh, window_label); 124 evm.add(evh, window_label);
121 evm.add(evh, clock); 125 evm.add(evh, clock);
122 evm.add(evh, psbutton);
123 evm.add(evh, nsbutton);
124 evm.add(evh, pwbutton);
125 evm.add(evh, nwbutton);
126
127} 126}
128 127
129Toolbar::Frame::~Frame() { 128Toolbar::Frame::~Frame() {
130 FbTk::EventManager &evm = *FbTk::EventManager::instance(); 129 FbTk::EventManager &evm = *FbTk::EventManager::instance();
130 // remove windows from eventmanager
131 evm.remove(window); 131 evm.remove(window);
132 evm.remove(workspace_label); 132 evm.remove(workspace_label);
133 evm.remove(window_label); 133 evm.remove(window_label);
134 evm.remove(clock); 134 evm.remove(clock);
135 evm.remove(psbutton);
136 evm.remove(nsbutton);
137 evm.remove(pwbutton);
138 evm.remove(nwbutton);
139} 135}
140 136
141Toolbar::Toolbar(BScreen *scrn, size_t width): 137Toolbar::Toolbar(BScreen *scrn, size_t width):
@@ -185,6 +181,16 @@ Toolbar::Toolbar(BScreen *scrn, size_t width):
185 XMapSubwindows(display, frame.window.window()); 181 XMapSubwindows(display, frame.window.window());
186 frame.window.show(); 182 frame.window.show();
187 183
184 // finaly: setup Commands for the buttons in the frame
185 FbTk::RefCount<FbTk::Command> nextworkspace(new FbTk::SimpleCommand<BScreen>(*screen(), &BScreen::nextWorkspace));
186 FbTk::RefCount<FbTk::Command> prevworkspace(new FbTk::SimpleCommand<BScreen>(*screen(), &BScreen::prevWorkspace));
187 FbTk::RefCount<FbTk::Command> nextwindow(new FbTk::SimpleCommand<BScreen>(*screen(), &BScreen::nextFocus));
188 FbTk::RefCount<FbTk::Command> prevwindow(new FbTk::SimpleCommand<BScreen>(*screen(), &BScreen::prevFocus));
189 frame.psbutton.setOnClick(prevworkspace);
190 frame.nsbutton.setOnClick(nextworkspace);
191 frame.pwbutton.setOnClick(prevwindow);
192 frame.nwbutton.setOnClick(nextwindow);
193
188 reconfigure(); 194 reconfigure();
189 195
190} 196}
@@ -434,13 +440,25 @@ void Toolbar::reconfigure() {
434 if (tmp) 440 if (tmp)
435 image_ctrl.removeImage(tmp); 441 image_ctrl.removeImage(tmp);
436 442
443 // pressed button pixmap
437 tmp = frame.pbutton; 444 tmp = frame.pbutton;
438 texture = &(m_theme.pressedButton()); 445 texture = &(m_theme.pressedButton());
439 if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { 446 if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
440 frame.pbutton = None; 447 frame.pbutton = None;
441 } else 448 } else {
442 frame.pbutton = 449 frame.pbutton =
443 image_ctrl.renderImage(frame.button_w, frame.button_w, *texture); 450 image_ctrl.renderImage(frame.button_w, frame.button_w, *texture);
451 frame.psbutton.setPressedPixmap(frame.pbutton);
452 frame.nsbutton.setPressedPixmap(frame.pbutton);
453 frame.pwbutton.setPressedPixmap(frame.pbutton);
454 frame.nwbutton.setPressedPixmap(frame.pbutton);
455 }
456 // setup button gc
457 frame.psbutton.setGC(m_theme.buttonPicGC());
458 frame.nsbutton.setGC(m_theme.buttonPicGC());
459 frame.pwbutton.setGC(m_theme.buttonPicGC());
460 frame.nwbutton.setGC(m_theme.buttonPicGC());
461
444 if (tmp) 462 if (tmp)
445 image_ctrl.removeImage(tmp); 463 image_ctrl.removeImage(tmp);
446 464
@@ -458,10 +476,6 @@ void Toolbar::reconfigure() {
458 476
459 redrawWindowLabel(); 477 redrawWindowLabel();
460 redrawWorkspaceLabel(); 478 redrawWorkspaceLabel();
461 redrawPrevWorkspaceButton();
462 redrawNextWorkspaceButton();
463 redrawPrevWindowButton();
464 redrawNextWindowButton();
465 checkClock(true); 479 checkClock(true);
466 480
467 m_toolbarmenu.reconfigure(); 481 m_toolbarmenu.reconfigure();
@@ -646,90 +660,6 @@ void Toolbar::redrawWorkspaceLabel(bool redraw) {
646 dx, dy); 660 dx, dy);
647} 661}
648 662
649
650void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) {
651 if (redraw) {
652 drawButtonBase(frame.psbutton, pressed);
653 }
654
655 int hh = frame.button_w / 2, hw = frame.button_w / 2;
656
657 XPoint pts[3];
658 pts[0].x = hw - 2; pts[0].y = hh;
659 pts[1].x = 4; pts[1].y = 2;
660 pts[2].x = 0; pts[2].y = -4;
661
662 XFillPolygon(display, frame.psbutton.window(), m_theme.buttonPicGC(),
663 pts, 3, Convex, CoordModePrevious);
664}
665
666
667void Toolbar::redrawNextWorkspaceButton(bool pressed, bool redraw) {
668 if (redraw) {
669 drawButtonBase(frame.nsbutton, pressed);
670 }
671
672 int hh = frame.button_w / 2, hw = frame.button_w / 2;
673
674 XPoint pts[3];
675 pts[0].x = hw - 2; pts[0].y = hh - 2;
676 pts[1].x = 4; pts[1].y = 2;
677 pts[2].x = -4; pts[2].y = 2;
678
679 XFillPolygon(display, frame.nsbutton.window(), m_theme.buttonPicGC(),
680 pts, 3, Convex, CoordModePrevious);
681}
682
683
684void Toolbar::redrawPrevWindowButton(bool pressed, bool redraw) {
685 if (redraw) {
686 drawButtonBase(frame.pwbutton, pressed);
687 }
688
689 int hh = frame.button_w / 2, hw = frame.button_w / 2;
690
691 XPoint pts[3];
692 pts[0].x = hw - 2; pts[0].y = hh;
693 pts[1].x = 4; pts[1].y = 2;
694 pts[2].x = 0; pts[2].y = -4;
695
696 XFillPolygon(display, frame.pwbutton.window(), m_theme.buttonPicGC(),
697 pts, 3, Convex, CoordModePrevious);
698}
699
700
701void Toolbar::redrawNextWindowButton(bool pressed, bool redraw) {
702 if (redraw) {
703 drawButtonBase(frame.nwbutton, pressed);
704 }
705
706 int hh = frame.button_w / 2, hw = frame.button_w / 2;
707
708 XPoint pts[3];
709 pts[0].x = hw - 2; pts[0].y = hh - 2;
710 pts[1].x = 4; pts[1].y = 2;
711 pts[2].x = -4; pts[2].y = 2;
712
713 XFillPolygon(display, frame.nwbutton.window(), m_theme.buttonPicGC(),
714 pts, 3, Convex, CoordModePrevious);
715}
716
717void Toolbar::drawButtonBase(FbTk::FbWindow &win, bool pressed) {
718 if (pressed) {
719 if (frame.pbutton)
720 win.setBackgroundPixmap(frame.pbutton);
721 else
722 win.setBackgroundColor(m_theme.pressedButton().color());
723 } else {
724 if (frame.button)
725 win.setBackgroundPixmap(frame.button);
726 else
727 win.setBackgroundColor(m_theme.button().color());
728 }
729 win.clear();
730
731}
732
733void Toolbar::edit() { 663void Toolbar::edit() {
734 Window window; 664 Window window;
735 int foo; 665 int foo;
@@ -762,15 +692,7 @@ void Toolbar::edit() {
762void Toolbar::buttonPressEvent(XButtonEvent &be) { 692void Toolbar::buttonPressEvent(XButtonEvent &be) {
763 FluxboxWindow *fluxboxwin=0; 693 FluxboxWindow *fluxboxwin=0;
764 if (be.button == 1) { 694 if (be.button == 1) {
765 if (be.window == frame.psbutton) 695 if ( m_iconbar.get() != 0 ) {
766 redrawPrevWorkspaceButton(true, true);
767 else if (be.window == frame.nsbutton)
768 redrawNextWorkspaceButton(true, true);
769 else if (be.window == frame.pwbutton)
770 redrawPrevWindowButton(true, true);
771 else if (be.window == frame.nwbutton)
772 redrawNextWindowButton(true, true);
773 else if ( m_iconbar.get() != 0 ) {
774 if ( (fluxboxwin = m_iconbar->findWindow(be.window)) ) 696 if ( (fluxboxwin = m_iconbar->findWindow(be.window)) )
775 fluxboxwin->deiconify(); 697 fluxboxwin->deiconify();
776 } 698 }
@@ -834,31 +756,7 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
834 756
835void Toolbar::buttonReleaseEvent(XButtonEvent &re) { 757void Toolbar::buttonReleaseEvent(XButtonEvent &re) {
836 if (re.button == 1) { 758 if (re.button == 1) {
837 if (re.window == frame.psbutton) { 759 if (re.window == frame.workspace_label) {
838 redrawPrevWorkspaceButton(false, true);
839
840 if (re.x >= 0 && re.x < (signed) frame.button_w &&
841 re.y >= 0 && re.y < (signed) frame.button_w)
842 screen()->prevWorkspace(1);
843 } else if (re.window == frame.nsbutton) {
844 redrawNextWorkspaceButton(false, true);
845
846 if (re.x >= 0 && re.x < (signed) frame.button_w &&
847 re.y >= 0 && re.y < (signed) frame.button_w)
848 screen()->nextWorkspace(1);
849 } else if (re.window == frame.pwbutton) {
850 redrawPrevWindowButton(false, true);
851
852 if (re.x >= 0 && re.x < (signed) frame.button_w &&
853 re.y >= 0 && re.y < (signed) frame.button_w)
854 screen()->prevFocus();
855 } else if (re.window == frame.nwbutton) {
856 redrawNextWindowButton(false, true);
857
858 if (re.x >= 0 && re.x < (signed) frame.button_w &&
859 re.y >= 0 && re.y < (signed) frame.button_w)
860 screen()->nextFocus();
861 } else if (re.window == frame.workspace_label) {
862 Basemenu *menu = screen()->getWorkspacemenu(); 760 Basemenu *menu = screen()->getWorkspacemenu();
863 //move the workspace label and make it visible 761 //move the workspace label and make it visible
864 menu->move(re.x_root, re.y_root); 762 menu->move(re.x_root, re.y_root);
@@ -923,11 +821,6 @@ void Toolbar::exposeEvent(XExposeEvent &ee) {
923 checkClock(true); 821 checkClock(true);
924 else if (ee.window == frame.workspace_label && (! editing)) 822 else if (ee.window == frame.workspace_label && (! editing))
925 redrawWorkspaceLabel(); 823 redrawWorkspaceLabel();
926 else if (ee.window == frame.window_label) redrawWindowLabel();
927 else if (ee.window == frame.psbutton) redrawPrevWorkspaceButton();
928 else if (ee.window == frame.nsbutton) redrawNextWorkspaceButton();
929 else if (ee.window == frame.pwbutton) redrawPrevWindowButton();
930 else if (ee.window == frame.nwbutton) redrawNextWindowButton();
931 else if (m_iconbar.get() != 0) 824 else if (m_iconbar.get() != 0)
932 m_iconbar->exposeEvent(&ee); 825 m_iconbar->exposeEvent(&ee);
933} 826}
diff --git a/src/Toolbar.hh b/src/Toolbar.hh
index e7888f7..069c8a1 100644
--- a/src/Toolbar.hh
+++ b/src/Toolbar.hh
@@ -1,5 +1,5 @@
1// Toolbar.hh for Fluxbox 1// Toolbar.hh for Fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Toolbar.hh for Blackbox - an X11 Window manager 4// Toolbar.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
@@ -22,7 +22,7 @@
22// 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
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Toolbar.hh,v 1.17 2002/12/03 16:54:13 fluxgen Exp $ 25// $Id: Toolbar.hh,v 1.18 2002/12/13 20:36:36 fluxgen Exp $
26 26
27#ifndef TOOLBAR_HH 27#ifndef TOOLBAR_HH
28#define TOOLBAR_HH 28#define TOOLBAR_HH
@@ -33,6 +33,7 @@
33#include "ToolbarTheme.hh" 33#include "ToolbarTheme.hh"
34#include "EventHandler.hh" 34#include "EventHandler.hh"
35#include "FbWindow.hh" 35#include "FbWindow.hh"
36#include "ArrowButton.hh"
36 37
37#include <memory> 38#include <memory>
38 39
@@ -90,24 +91,27 @@ private:
90}; 91};
91 92
92 93
94
95/// The toolbar.
93/** 96/**
94 the toolbar. 97 Handles iconbar, workspace name view and clock view
95*/ 98 */
96class Toolbar : public TimeoutHandler, public FbTk::EventHandler { 99class Toolbar : public TimeoutHandler, public FbTk::EventHandler {
97public: 100public:
98 /** 101
99 Toolbar placement on the screen 102 ///Toolbar placement on the screen
100 */
101 enum Placement{ 103 enum Placement{
102 // top bottom placement 104 // top and bottom placement
103 TOPLEFT = 1, BOTTOMLEFT, TOPCENTER, 105 TOPLEFT = 1, BOTTOMLEFT, TOPCENTER,
104 BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT, 106 BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT,
105 // left right placement 107 // left and right placement
106 LEFTCENTER, LEFTBOTTOM, LEFTTOP, 108 LEFTCENTER, LEFTBOTTOM, LEFTTOP,
107 RIGHTCENTER, RIGHTBOTTOM, RIGHTTOP 109 RIGHTCENTER, RIGHTBOTTOM, RIGHTTOP
108 }; 110 };
109 111
112 /// create a toolbar on the screen with specific width
110 explicit Toolbar(BScreen *screen, size_t width = 200); 113 explicit Toolbar(BScreen *screen, size_t width = 200);
114 /// destructor
111 virtual ~Toolbar(); 115 virtual ~Toolbar();
112 116
113 /// add icon to iconbar 117 /// add icon to iconbar
@@ -152,10 +156,6 @@ public:
152 156
153 void redrawWindowLabel(bool redraw= false); 157 void redrawWindowLabel(bool redraw= false);
154 void redrawWorkspaceLabel(bool redraw= false); 158 void redrawWorkspaceLabel(bool redraw= false);
155 void redrawPrevWorkspaceButton(bool pressed = false, bool redraw = false);
156 void redrawNextWorkspaceButton(bool pressed = false, bool redraw = false);
157 void redrawPrevWindowButton(bool pressed = false, bool redraw = false);
158 void redrawNextWindowButton(bool pressed = false, bool redraw = false);
159 /// enter edit mode on workspace label 159 /// enter edit mode on workspace label
160 void edit(); 160 void edit();
161 void reconfigure(); 161 void reconfigure();
@@ -166,7 +166,6 @@ public:
166 166
167 167
168private: 168private:
169 void drawButtonBase(FbTk::FbWindow &win, bool pressed);
170 169
171 bool on_top; ///< always on top 170 bool on_top; ///< always on top
172 bool editing; ///< edit workspace label mode 171 bool editing; ///< edit workspace label mode
@@ -174,12 +173,13 @@ private:
174 bool do_auto_hide; ///< do we auto hide 173 bool do_auto_hide; ///< do we auto hide
175 Display *display; ///< display connection 174 Display *display; ///< display connection
176 175
176 /// Toolbar frame
177 struct Frame { 177 struct Frame {
178 Frame(FbTk::EventHandler &evh, int screen_num); 178 Frame(FbTk::EventHandler &evh, int screen_num);
179 ~Frame(); 179 ~Frame();
180 Pixmap base, label, wlabel, clk, button, pbutton; 180 Pixmap base, label, wlabel, clk, button, pbutton;
181 FbTk::FbWindow window, workspace_label, window_label, clock, psbutton, nsbutton, 181 FbTk::FbWindow window, workspace_label, window_label, clock;
182 pwbutton, nwbutton; 182 ArrowButton psbutton, nsbutton, pwbutton, nwbutton;
183 183
184 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y; 184 int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
185 unsigned int width, height, window_label_w, workspace_label_w, clock_w, 185 unsigned int width, height, window_label_w, workspace_label_w, clock_w,