]> git.tdb.fi Git - libs/gltk.git/blob - source/button.h
Rearrange members
[libs/gltk.git] / source / button.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_BUTTON_H_
9 #define MSP_GLTK_BUTTON_H_
10
11 #include <sigc++/sigc++.h>
12 #include <msp/gl/texture2d.h>
13 #include "text.h"
14 #include "widget.h"
15
16 namespace Msp {
17 namespace GLtk {
18
19 /**
20 A clickable button widget.  Buttons can have a text label, which is displayed
21 in a spacial part "text".
22 */
23 class Button: public Widget
24 {
25 public:
26         class Loader: public Widget::Loader
27         {
28         public:
29                 Loader(Button &);
30         private:
31                 void text(const std::string &);
32         };
33
34         sigc::signal<void> signal_clicked;
35
36 private:
37         Text text;
38         const GL::Texture2D *icon;
39         bool pressed;
40
41 public:
42         Button(const std::string & = std::string());
43
44         virtual const char *get_class() const { return "button"; }
45
46         void set_text(const std::string &);
47         void set_icon(const GL::Texture2D *);
48
49 private:
50         virtual void render_special(const Part &) const;
51
52 public:
53         virtual void button_press(int, int, unsigned);
54         virtual void button_release(int, int, unsigned);
55         virtual void pointer_motion(int, int);
56 private:
57         virtual void on_style_change();
58 };
59
60 } // namespace GLtk
61 } // namespace Msp
62
63 #endif