aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Button.hh
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.hh
parent3d8a063bd02a6c42414e202cce81be27415d1abb (diff)
downloadfluxbox-560e8bdd6a1cc519d29306cec65f58f70eff0375.zip
fluxbox-560e8bdd6a1cc519d29306cec65f58f70eff0375.tar.bz2
button
Diffstat (limited to 'src/FbTk/Button.hh')
-rw-r--r--src/FbTk/Button.hh98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
new file mode 100644
index 0000000..5d0842d
--- /dev/null
+++ b/src/FbTk/Button.hh
@@ -0,0 +1,98 @@
1// Button.hh 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.hh,v 1.1 2002/12/13 20:24:33 fluxgen Exp $
23
24#ifndef FBTK_BUTTON_HH
25#define FBTK_BUTTON_HH
26
27#include "EventHandler.hh"
28#include "NotCopyable.hh"
29#include "RefCount.hh"
30#include "FbWindow.hh"
31#include "Command.hh"
32
33#include <X11/Xlib.h>
34#include <memory>
35
36namespace FbTk {
37
38class Color;
39
40class Button:public EventHandler,
41 private NotCopyable {
42public:
43 Button(int screen_num, int x, int y, unsigned int width, unsigned int height);
44 Button(FbWindow &parent, int x, int y, unsigned int width, unsigned int height);
45 virtual ~Button();
46 /// sets action when the button is clicked
47 void setOnClick(RefCount<Command> &com) { m_onclick = com; }
48 void move(int x, int y);
49 void resize(unsigned int width, unsigned int height);
50 void moveResize(int x, int y, unsigned int width, unsigned int height);
51 /// sets the pixmap to be viewd when the button is in normal state (ie not pressed)
52 void setPixmap(Pixmap pm);
53 /// sets the pixmap to be viewed when the button is pressed
54 void setPressedPixmap(Pixmap pm);
55 void setGC(GC gc) { m_gc = gc; }
56 /// sets background pixmap, this will override background color
57 void setBackgroundPixmap(Pixmap pm);
58 /// sets background color
59 void setBackgroundColor(const Color &color);
60 /// show button
61 void show();
62 /// hide button
63 void hide();
64 virtual void clear() { m_win.clear(); }
65 /**
66 @name eventhandlers
67 */
68 //@{
69 virtual void buttonPressEvent(XButtonEvent &event);
70 virtual void buttonReleaseEvent(XButtonEvent &event);
71 virtual void exposeEvent(XExposeEvent &event);
72 //@}
73 /// @return true if the button is pressed, else false
74 bool pressed() const { return m_pressed; }
75 /**
76 @name position and size of the button
77 */
78 //@{
79 int x() const { return m_win.x(); }
80 int y() const { return m_win.y(); }
81 unsigned int width() const { return m_win.width(); }
82 unsigned int height() const { return m_win.height(); }
83 //@}
84 FbWindow &window() { return m_win; }
85 const FbWindow &window() const { return m_win; }
86 GC gc() const { return m_gc; }
87private:
88 FbTk::FbWindow m_win; ///< window for button
89 Pixmap m_foreground_pm; ///< foreground pixmap
90 Pixmap m_pressed_pm; ///< pressed pixmap
91 GC m_gc; ///< graphic context for button
92 bool m_pressed; ///< if the button is pressed
93 RefCount<Command> m_onclick; ///< what to do when this button is clicked
94};
95
96};
97
98#endif // FBTK_BUTTON_HH