aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-25 11:28:43 (GMT)
committerfluxgen <fluxgen>2002-12-25 11:28:43 (GMT)
commit885ddd9322ea4a175e992e4a6fe757d19e8e86e2 (patch)
treed4dab0e28e646cf13534f29762a5101cfae703ec
parent2202914053a7fe1d586dfed19ad41965b51fa4b1 (diff)
downloadfluxbox-885ddd9322ea4a175e992e4a6fe757d19e8e86e2.zip
fluxbox-885ddd9322ea4a175e992e4a6fe757d19e8e86e2.tar.bz2
using number for buttons and max five buttons
-rw-r--r--src/FbTk/Button.cc30
-rw-r--r--src/FbTk/Button.hh17
2 files changed, 18 insertions, 29 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc
index b415724..0c568a2 100644
--- a/src/FbTk/Button.cc
+++ b/src/FbTk/Button.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Button.cc,v 1.2 2002/12/16 11:05:35 fluxgen Exp $ 22// $Id: Button.cc,v 1.3 2002/12/25 11:27:29 fluxgen Exp $
23 23
24#include "Button.hh" 24#include "Button.hh"
25 25
@@ -56,6 +56,14 @@ Button::~Button() {
56 FbTk::EventManager::instance()->remove(m_win); 56 FbTk::EventManager::instance()->remove(m_win);
57} 57}
58 58
59void Button::setOnClick(RefCount<Command> &cmd, int button) {
60 // we only handle buttons 1 to 5
61 if (button > 5 || button == 0)
62 return;
63 //set on click command for the button
64 m_onclick[button - 1] = cmd;
65}
66
59void Button::move(int x, int y) { 67void Button::move(int x, int y) {
60 m_win.move(x, y); 68 m_win.move(x, y);
61} 69}
@@ -124,23 +132,9 @@ void Button::buttonReleaseEvent(XButtonEvent &event) {
124 event.x > width() || event.y > height()) 132 event.x > width() || event.y > height())
125 return; 133 return;
126 134
127 // call commands 135 if (event.button > 0 && event.button <= 5)
128 switch (event.button) { 136 m_onclick[event.button - 1]->execute();
129 case Button1: 137
130 if (*m_onclick_left != 0)
131 m_onclick_left->execute();
132 break;
133 case Button2:
134 if (*m_onclick_middle != 0)
135 m_onclick_middle->execute();
136 break;
137 case Button3:
138 if (*m_onclick_right != 0)
139 m_onclick_right->execute();
140 break;
141 };
142
143
144} 138}
145 139
146void Button::exposeEvent(XExposeEvent &event) { 140void Button::exposeEvent(XExposeEvent &event) {
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
index c49815d..a96dcd8 100644
--- a/src/FbTk/Button.hh
+++ b/src/FbTk/Button.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Button.hh,v 1.2 2002/12/16 11:02:41 fluxgen Exp $ 22// $Id: Button.hh,v 1.3 2002/12/25 11:28:43 fluxgen Exp $
23 23
24#ifndef FBTK_BUTTON_HH 24#ifndef FBTK_BUTTON_HH
25#define FBTK_BUTTON_HH 25#define FBTK_BUTTON_HH
@@ -41,13 +41,10 @@ class Button:public EventHandler,
41public: 41public:
42 Button(int screen_num, int x, int y, unsigned int width, unsigned int height); 42 Button(int screen_num, int x, int y, unsigned int width, unsigned int height);
43 Button(const FbWindow &parent, int x, int y, unsigned int width, unsigned int height); 43 Button(const FbWindow &parent, int x, int y, unsigned int width, unsigned int height);
44 virtual ~Button(); 44 virtual ~Button();
45 /// sets action when the button is clicked with left mouse btn 45
46 void setOnClick(RefCount<Command> &com) { m_onclick_left = com; } 46 /// sets action when the button is clicked with #button mouse btn
47 /// sets action when the button is clicked with middle mouse btn 47 void setOnClick(RefCount<Command> &com, int button = 1);
48 void setOnClickMiddle(RefCount<Command> &com) { m_onclick_middle = com; }
49 /// sets action when the button is clicked with right mouse btn
50 void setOnClickRight(RefCount<Command> &com) { m_onclick_right = com; }
51 48
52 void move(int x, int y); 49 void move(int x, int y);
53 void resize(unsigned int width, unsigned int height); 50 void resize(unsigned int width, unsigned int height);
@@ -100,9 +97,7 @@ private:
100 Pixmap m_pressed_pm; ///< pressed pixmap 97 Pixmap m_pressed_pm; ///< pressed pixmap
101 GC m_gc; ///< graphic context for button 98 GC m_gc; ///< graphic context for button
102 bool m_pressed; ///< if the button is pressed 99 bool m_pressed; ///< if the button is pressed
103 RefCount<Command> m_onclick_left; ///< what to do when this button is clicked with lmb 100 RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num
104 RefCount<Command> m_onclick_middle; ///< what to do when this button is clicked with mmb
105 RefCount<Command> m_onclick_right; ///< what to do when this button is clicked with rmb
106}; 101};
107 102
108}; 103};