aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Button.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-13 09:25:16 (GMT)
committerfluxgen <fluxgen>2003-08-13 09:25:16 (GMT)
commiteac153c43c38dc6d2bfc2d37d5e8e84c2444ca7e (patch)
treeb99ea730878e8244603bb5ec5877d6fd842cdf8f /src/FbTk/Button.cc
parent5855c7825ba57af5f7c86981b811c5749abeb9c0 (diff)
downloadfluxbox-eac153c43c38dc6d2bfc2d37d5e8e84c2444ca7e.zip
fluxbox-eac153c43c38dc6d2bfc2d37d5e8e84c2444ca7e.tar.bz2
Button is a FbWindow
Diffstat (limited to 'src/FbTk/Button.cc')
-rw-r--r--src/FbTk/Button.cc66
1 files changed, 21 insertions, 45 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc
index 8b0a478..f7acb09 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.10 2003/08/11 14:40:15 fluxgen Exp $ 22// $Id: Button.cc,v 1.11 2003/08/13 09:25:16 fluxgen Exp $
23 23
24#include "Button.hh" 24#include "Button.hh"
25 25
@@ -31,8 +31,8 @@ namespace FbTk {
31 31
32Button::Button(int screen_num, int x, int y, 32Button::Button(int screen_num, int x, int y,
33 unsigned int width, unsigned int height): 33 unsigned int width, unsigned int height):
34 m_win(screen_num, x, y, width, height, 34 FbWindow(screen_num, x, y, width, height,
35 ExposureMask | ButtonPressMask | ButtonReleaseMask), 35 ExposureMask | ButtonPressMask | ButtonReleaseMask),
36 m_foreground_pm(0), 36 m_foreground_pm(0),
37 m_background_pm(0), 37 m_background_pm(0),
38 m_pressed_pm(0), 38 m_pressed_pm(0),
@@ -40,24 +40,24 @@ Button::Button(int screen_num, int x, int y,
40 m_pressed(false) { 40 m_pressed(false) {
41 41
42 // add this to eventmanager 42 // add this to eventmanager
43 FbTk::EventManager::instance()->add(*this, m_win); 43 FbTk::EventManager::instance()->add(*this, *this);
44} 44}
45 45
46Button::Button(const FbWindow &parent, int x, int y, 46Button::Button(const FbWindow &parent, int x, int y,
47 unsigned int width, unsigned int height): 47 unsigned int width, unsigned int height):
48 m_win(parent, x, y, width, height, 48 FbWindow(parent, x, y, width, height,
49 ExposureMask | ButtonPressMask | ButtonReleaseMask), 49 ExposureMask | ButtonPressMask | ButtonReleaseMask),
50 m_foreground_pm(0), 50 m_foreground_pm(0),
51 m_background_pm(0), 51 m_background_pm(0),
52 m_pressed_pm(0), 52 m_pressed_pm(0),
53 m_gc(DefaultGC(FbTk::App::instance()->display(), m_win.screenNumber())), 53 m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())),
54 m_pressed(false) { 54 m_pressed(false) {
55 // add this to eventmanager 55 // add this to eventmanager
56 FbTk::EventManager::instance()->add(*this, m_win); 56 FbTk::EventManager::instance()->add(*this, *this);
57} 57}
58 58
59Button::~Button() { 59Button::~Button() {
60 FbTk::EventManager::instance()->remove(m_win); 60 FbTk::EventManager::instance()->remove(*this);
61} 61}
62 62
63void Button::setOnClick(RefCount<Command> &cmd, int button) { 63void Button::setOnClick(RefCount<Command> &cmd, int button) {
@@ -68,18 +68,6 @@ void Button::setOnClick(RefCount<Command> &cmd, int button) {
68 m_onclick[button - 1] = cmd; 68 m_onclick[button - 1] = cmd;
69} 69}
70 70
71void Button::move(int x, int y) {
72 window().move(x, y);
73}
74
75void Button::resize(unsigned int w, unsigned int h) {
76 window().resize(w, h);
77}
78
79void Button::moveResize(int x, int y, unsigned int width, unsigned int height) {
80 window().moveResize(x, y, width, height);
81}
82
83void Button::setPixmap(Pixmap pm) { 71void Button::setPixmap(Pixmap pm) {
84 m_foreground_pm = pm; 72 m_foreground_pm = pm;
85} 73}
@@ -90,40 +78,28 @@ void Button::setPressedPixmap(Pixmap pm) {
90 78
91void Button::setBackgroundColor(const Color &color) { 79void Button::setBackgroundColor(const Color &color) {
92 m_background_color = color; 80 m_background_color = color;
93 window().setBackgroundColor(color); 81 FbTk::FbWindow::setBackgroundColor(color);
94 clear();
95 window().updateTransparent();
96} 82}
97 83
98void Button::setBackgroundPixmap(Pixmap pm) { 84void Button::setBackgroundPixmap(Pixmap pm) {
99 m_background_pm = pm; 85 m_background_pm = pm;
100 window().setBackgroundPixmap(pm); 86 FbTk::FbWindow::setBackgroundPixmap(pm);
101 clear();
102 window().updateTransparent();
103}
104
105void Button::show() {
106 m_win.show();
107}
108
109void Button::hide() {
110 m_win.hide();
111} 87}
112 88
113void Button::buttonPressEvent(XButtonEvent &event) { 89void Button::buttonPressEvent(XButtonEvent &event) {
114 if (m_pressed_pm != 0) 90 if (m_pressed_pm != 0)
115 m_win.setBackgroundPixmap(m_pressed_pm); 91 FbWindow::setBackgroundPixmap(m_pressed_pm);
116 m_pressed = true; 92 m_pressed = true;
117 clear(); 93 clear();
118 window().updateTransparent(); 94 FbWindow::updateTransparent();
119} 95}
120 96
121void Button::buttonReleaseEvent(XButtonEvent &event) { 97void Button::buttonReleaseEvent(XButtonEvent &event) {
122 m_pressed = false; 98 m_pressed = false;
123 if (m_background_pm) 99 if (m_background_pm)
124 m_win.setBackgroundPixmap(m_background_pm); 100 FbWindow::setBackgroundPixmap(m_background_pm);
125 else 101 else
126 m_win.setBackgroundColor(m_background_color); 102 FbWindow::setBackgroundColor(m_background_color);
127 103
128 clear(); // clear background 104 clear(); // clear background
129 105
@@ -131,26 +107,26 @@ void Button::buttonReleaseEvent(XButtonEvent &event) {
131 Display *disp = App::instance()->display(); 107 Display *disp = App::instance()->display();
132 108
133 if (m_gc == 0) // get default gc if we dont have one 109 if (m_gc == 0) // get default gc if we dont have one
134 m_gc = DefaultGC(disp, m_win.screenNumber()); 110 m_gc = DefaultGC(disp, screenNumber());
135 111
136 XCopyArea(disp, m_foreground_pm, m_win.window(), m_gc, 0, 0, width(), height(), 0, 0); 112 XCopyArea(disp, m_foreground_pm, window(), m_gc, 0, 0, width(), height(), 0, 0);
137 } 113 }
138 114
139 if (event.button > 0 && event.button <= 5 && 115 if (event.button > 0 && event.button <= 5 &&
140 m_onclick[event.button -1].get() != 0) 116 m_onclick[event.button -1].get() != 0)
141 m_onclick[event.button - 1]->execute(); 117 m_onclick[event.button - 1]->execute();
142 118
143 window().updateTransparent(); 119 FbWindow::updateTransparent();
144} 120}
145 121
146void Button::exposeEvent(XExposeEvent &event) { 122void Button::exposeEvent(XExposeEvent &event) {
147 if (m_background_pm) 123 if (m_background_pm)
148 m_win.setBackgroundPixmap(m_background_pm); 124 FbWindow::setBackgroundPixmap(m_background_pm);
149 else 125 else
150 m_win.setBackgroundColor(m_background_color); 126 FbWindow::setBackgroundColor(m_background_color);
151 127
152 clear(); 128 clear();
153 window().updateTransparent(event.x, event.y, event.width, event.height); 129 FbWindow::updateTransparent(event.x, event.y, event.width, event.height);
154} 130}
155 131
156}; // end namespace FbTk 132}; // end namespace FbTk