aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-16 11:05:35 (GMT)
committerfluxgen <fluxgen>2002-12-16 11:05:35 (GMT)
commit3327fb7e1132e1bd8e9648e1fad546d5382a09de (patch)
treeb5211dba2b2d15c41dd5ccdb1e7efe99731c0fd1 /src/FbTk
parentce899439c9c26a767bcfc39aab8d5ea94fa9dacc (diff)
downloadfluxbox_pavel-3327fb7e1132e1bd8e9648e1fad546d5382a09de.zip
fluxbox_pavel-3327fb7e1132e1bd8e9648e1fad546d5382a09de.tar.bz2
fixed some bugs and the new commands
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Button.cc63
1 files changed, 49 insertions, 14 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc
index 9ea99ed..b415724 100644
--- a/src/FbTk/Button.cc
+++ b/src/FbTk/Button.cc
@@ -19,12 +19,13 @@
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.1 2002/12/13 20:24:33 fluxgen Exp $ 22// $Id: Button.cc,v 1.2 2002/12/16 11:05:35 fluxgen Exp $
23 23
24#include "Button.hh" 24#include "Button.hh"
25 25
26#include "Command.hh" 26#include "Command.hh"
27#include "EventManager.hh" 27#include "EventManager.hh"
28#include "App.hh"
28 29
29namespace FbTk { 30namespace FbTk {
30 31
@@ -34,18 +35,19 @@ Button::Button(int screen_num, int x, int y,
34 ExposureMask | ButtonPressMask | ButtonReleaseMask), 35 ExposureMask | ButtonPressMask | ButtonReleaseMask),
35 m_foreground_pm(0), 36 m_foreground_pm(0),
36 m_pressed_pm(0), 37 m_pressed_pm(0),
37 m_gc(0) { 38 m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)) {
39
38 // add this to eventmanager 40 // add this to eventmanager
39 FbTk::EventManager::instance()->add(*this, m_win); 41 FbTk::EventManager::instance()->add(*this, m_win);
40} 42}
41 43
42Button::Button(FbWindow &parent, int x, int y, 44Button::Button(const FbWindow &parent, int x, int y,
43 size_t width, size_t height): 45 size_t width, size_t height):
44 m_win(parent, x, y, width, height, 46 m_win(parent, x, y, width, height,
45 ExposureMask | ButtonPressMask | ButtonReleaseMask), 47 ExposureMask | ButtonPressMask | ButtonReleaseMask),
46 m_foreground_pm(0), 48 m_foreground_pm(0),
47 m_pressed_pm(0), 49 m_pressed_pm(0),
48 m_gc(0) { 50 m_gc(DefaultGC(FbTk::App::instance()->display(), m_win.screenNumber())) {
49 // add this to eventmanager 51 // add this to eventmanager
50 FbTk::EventManager::instance()->add(*this, m_win); 52 FbTk::EventManager::instance()->add(*this, m_win);
51} 53}
@@ -76,11 +78,14 @@ void Button::setPressedPixmap(Pixmap pm) {
76 78
77void Button::setBackgroundColor(const Color &color) { 79void Button::setBackgroundColor(const Color &color) {
78 m_win.setBackgroundColor(color); 80 m_win.setBackgroundColor(color);
81 m_background_color = color;
82 clear();
79} 83}
80 84
81void Button::setBackgroundPixmap(Pixmap pm) { 85void Button::setBackgroundPixmap(Pixmap pm) {
82 m_win.setBackgroundPixmap(pm); 86 m_win.setBackgroundPixmap(pm);
83 m_foreground_pm = pm; 87 m_background_pm = pm;
88 clear();
84} 89}
85 90
86void Button::show() { 91void Button::show() {
@@ -93,19 +98,49 @@ void Button::hide() {
93 98
94void Button::buttonPressEvent(XButtonEvent &event) { 99void Button::buttonPressEvent(XButtonEvent &event) {
95 m_win.setBackgroundPixmap(m_pressed_pm); 100 m_win.setBackgroundPixmap(m_pressed_pm);
96 m_win.clear(); 101 m_pressed = true;
97 m_pressed = true; 102 clear();
103
98} 104}
99 105
100void Button::buttonReleaseEvent(XButtonEvent &event) { 106void Button::buttonReleaseEvent(XButtonEvent &event) {
101 // set normal pixmap
102 m_win.setBackgroundPixmap(m_foreground_pm);
103 m_win.clear();
104
105 if (*m_onclick != 0) // check on click action
106 m_onclick->execute(); // do on click action
107
108 m_pressed = false; 107 m_pressed = false;
108 if (m_background_pm)
109 m_win.setBackgroundPixmap(m_background_pm);
110 else
111 m_win.setBackgroundColor(m_background_color);
112 clear(); // clear background
113
114 if (m_foreground_pm) { // draw foreground
115 Display *disp = App::instance()->display();
116
117 if (m_gc == 0) // get default gc
118 m_gc = DefaultGC(disp, m_win.screenNumber());
119
120 XCopyArea(disp, m_foreground_pm, m_win.window(), m_gc, 0, 0, width(), height(), 0, 0);
121 }
122
123 if (event.x < 0 || event.y < 0 ||
124 event.x > width() || event.y > height())
125 return;
126
127 // call commands
128 switch (event.button) {
129 case Button1:
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
109} 144}
110 145
111void Button::exposeEvent(XExposeEvent &event) { 146void Button::exposeEvent(XExposeEvent &event) {