aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Button.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-13 20:24:33 (GMT)
committerfluxgen <fluxgen>2002-12-13 20:24:33 (GMT)
commit560e8bdd6a1cc519d29306cec65f58f70eff0375 (patch)
treeef9b369b05c879f2839428482af6a31c3d15df69 /src/FbTk/Button.cc
parent3d8a063bd02a6c42414e202cce81be27415d1abb (diff)
downloadfluxbox_pavel-560e8bdd6a1cc519d29306cec65f58f70eff0375.zip
fluxbox_pavel-560e8bdd6a1cc519d29306cec65f58f70eff0375.tar.bz2
button
Diffstat (limited to 'src/FbTk/Button.cc')
-rw-r--r--src/FbTk/Button.cc115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc
new file mode 100644
index 0000000..9ea99ed
--- /dev/null
+++ b/src/FbTk/Button.cc
@@ -0,0 +1,115 @@
1// Button.cc for FbTk - fluxbox toolkit
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: Button.cc,v 1.1 2002/12/13 20:24:33 fluxgen Exp $
23
24#include "Button.hh"
25
26#include "Command.hh"
27#include "EventManager.hh"
28
29namespace FbTk {
30
31Button::Button(int screen_num, int x, int y,
32 unsigned int width, unsigned int height):
33 m_win(screen_num, x, y, width, height,
34 ExposureMask | ButtonPressMask | ButtonReleaseMask),
35 m_foreground_pm(0),
36 m_pressed_pm(0),
37 m_gc(0) {
38 // add this to eventmanager
39 FbTk::EventManager::instance()->add(*this, m_win);
40}
41
42Button::Button(FbWindow &parent, int x, int y,
43 size_t width, size_t height):
44 m_win(parent, x, y, width, height,
45 ExposureMask | ButtonPressMask | ButtonReleaseMask),
46 m_foreground_pm(0),
47 m_pressed_pm(0),
48 m_gc(0) {
49 // add this to eventmanager
50 FbTk::EventManager::instance()->add(*this, m_win);
51}
52
53Button::~Button() {
54 FbTk::EventManager::instance()->remove(m_win);
55}
56
57void Button::move(int x, int y) {
58 m_win.move(x, y);
59}
60
61void Button::resize(unsigned int w, unsigned int h) {
62 m_win.resize(w, h);
63}
64
65void Button::moveResize(int x, int y, unsigned int width, unsigned int height) {
66 m_win.moveResize(x, y, width, height);
67}
68
69void Button::setPixmap(Pixmap pm) {
70 m_foreground_pm = pm;
71}
72
73void Button::setPressedPixmap(Pixmap pm) {
74 m_pressed_pm = pm;
75}
76
77void Button::setBackgroundColor(const Color &color) {
78 m_win.setBackgroundColor(color);
79}
80
81void Button::setBackgroundPixmap(Pixmap pm) {
82 m_win.setBackgroundPixmap(pm);
83 m_foreground_pm = pm;
84}
85
86void Button::show() {
87 m_win.show();
88}
89
90void Button::hide() {
91 m_win.hide();
92}
93
94void Button::buttonPressEvent(XButtonEvent &event) {
95 m_win.setBackgroundPixmap(m_pressed_pm);
96 m_win.clear();
97 m_pressed = true;
98}
99
100void 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;
109}
110
111void Button::exposeEvent(XExposeEvent &event) {
112 m_win.clear();
113}
114
115}; // end namespace FbTk