]> git.tdb.fi Git - libs/gltk.git/blob - source/toggle.h
Make autosize_special const and add a const autosize overload
[libs/gltk.git] / source / toggle.h
1 #ifndef MSP_GLTK_TOGGLE_H_
2 #define MSP_GLTK_TOGGLE_H_
3
4 #include <sigc++/signal.h>
5 #include "text.h"
6 #include "widget.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 /**
12 Allows toggling a value between two states.
13 */
14 class Toggle: public Widget
15 {
16 public:
17         class Loader: public DataFile::DerivedObjectLoader<Toggle, Widget::Loader>
18         {
19         public:
20                 Loader(Toggle &);
21         private:
22                 virtual void finish();
23                 void text(const std::string &);
24         };
25
26         sigc::signal<void, bool> signal_toggled;
27
28 private:
29         Text text;
30         bool pressed;
31         bool value;
32         bool exclusive;
33
34 public:
35         Toggle(const std::string & = std::string());
36
37         virtual const char *get_class() const { return "toggle"; }
38
39 private:
40         virtual void autosize_special(const Part &, Geometry &) const;
41
42 public:
43         void set_text(const std::string &);
44         void set_exclusive(bool);
45         bool get_exclusive() const { return exclusive; }
46 private:
47         void exclude_siblings();
48 public:
49         void set_value(bool);
50         bool get_value() const { return value; }
51
52 private:
53         virtual void rebuild_special(const Part &);
54
55 public:
56         virtual void button_press(int, int, unsigned);
57         virtual void button_release(int, int, unsigned);
58 private:
59         virtual void on_style_change();
60 };
61
62 } // namespace GLtk
63 } // namespace Msp
64
65 #endif