aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Button.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Button.hh')
-rw-r--r--src/FbTk/Button.hh90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
new file mode 100644
index 0000000..dbbdeda
--- /dev/null
+++ b/src/FbTk/Button.hh
@@ -0,0 +1,90 @@
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.7 2003/10/13 23:43:11 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#include "Color.hh"
33
34#include <X11/Xlib.h>
35#include <memory>
36
37namespace FbTk {
38
39class Button:public FbTk::FbWindow, public EventHandler,
40 private NotCopyable {
41public:
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);
44 virtual ~Button();
45
46 /// sets action when the button is clicked with #button mouse btn
47 void setOnClick(RefCount<Command> &com, int button = 1);
48
49 /// sets foreground pixmap
50 void setPixmap(Pixmap pm);
51 /// sets the pixmap to be viewed when the button is pressed
52 void setPressedPixmap(Pixmap pm);
53 void setPressedColor(const FbTk::Color &color);
54 /// sets graphic context for drawing
55 void setGC(GC gc) { m_gc = gc; }
56 /// sets background pixmap, this will override background color
57 virtual void setBackgroundPixmap(Pixmap pm);
58 /// sets background color
59 virtual void setBackgroundColor(const Color &color);
60
61 /**
62 @name eventhandlers
63 */
64 //@{
65 virtual void buttonPressEvent(XButtonEvent &event);
66 virtual void buttonReleaseEvent(XButtonEvent &event);
67 virtual void exposeEvent(XExposeEvent &event);
68 //@}
69
70 /// @return true if the button is pressed, else false
71 bool pressed() const { return m_pressed; }
72
73 GC gc() const { return m_gc; }
74 Pixmap backgroundPixmap() const { return m_background_pm; }
75 const Color &backgroundColor() const { return m_background_color; }
76 Pixmap foregroundPixmap() const { return m_foreground_pm; }
77private:
78 Pixmap m_foreground_pm; ///< foreground pixmap
79 Pixmap m_background_pm; ///< background pixmap
80 Color m_background_color; ///< background color
81 Pixmap m_pressed_pm; ///< pressed pixmap
82 Color m_pressed_color;
83 GC m_gc; ///< graphic context for button
84 bool m_pressed; ///< if the button is pressed
85 RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num
86};
87
88};
89
90#endif // FBTK_BUTTON_HH