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.hh86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
new file mode 100644
index 0000000..8aaf561
--- /dev/null
+++ b/src/FbTk/Button.hh
@@ -0,0 +1,86 @@
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.5 2003/08/13 09:25:16 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 /// sets graphic context for drawing
54 void setGC(GC gc) { m_gc = gc; }
55 /// sets background pixmap, this will override background color
56 void setBackgroundPixmap(Pixmap pm);
57 /// sets background color
58 void setBackgroundColor(const Color &color);
59
60 /**
61 @name eventhandlers
62 */
63 //@{
64 virtual void buttonPressEvent(XButtonEvent &event);
65 virtual void buttonReleaseEvent(XButtonEvent &event);
66 virtual void exposeEvent(XExposeEvent &event);
67 //@}
68
69 /// @return true if the button is pressed, else false
70 bool pressed() const { return m_pressed; }
71
72 GC gc() const { return m_gc; }
73
74private:
75 Pixmap m_foreground_pm; ///< foreground pixmap
76 Pixmap m_background_pm; ///< background pixmap
77 Color m_background_color; ///< background color
78 Pixmap m_pressed_pm; ///< pressed pixmap
79 GC m_gc; ///< graphic context for button
80 bool m_pressed; ///< if the button is pressed
81 RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num
82};
83
84};
85
86#endif // FBTK_BUTTON_HH