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