]> git.tdb.fi Git - libs/gltk.git/blob - source/toggle.h
Add Text class with multiline support
[libs/gltk.git] / source / toggle.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_TOGGLE_H_
9 #define MSP_GLTK_TOGGLE_H_
10
11 #include <sigc++/signal.h>
12 #include "text.h"
13 #include "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 /**
19 Allows toggling a value between two states.
20 */
21 class Toggle: public Widget
22 {
23 public:
24         class Loader: public Widget::Loader
25         {
26         public:
27                 Loader(Toggle &);
28                 Toggle &get_object() const;
29         private:
30                 virtual void finish();
31                 void text(const std::string &);
32         };
33
34 private:
35         Text text;
36         bool pressed;
37         bool value;
38         bool exclusive;
39
40 public:
41         sigc::signal<void, bool> signal_toggled;
42
43         Toggle(const Resources &, const std::string & =std::string());
44
45         void set_text(const std::string &);
46         void set_exclusive(bool);
47         bool get_exclusive() const { return exclusive; }
48         void set_value(bool);
49         bool get_value() const { return value; }
50
51         virtual void button_press(int, int, unsigned);
52         virtual void button_release(int, int, unsigned);
53 private:
54         virtual const char *get_class() const { return "toggle"; }
55         virtual void render_special(const Part &) const;
56
57         void exclude_siblings();
58 };
59
60 } // namespace GLtk
61 } // namespace Msp
62
63 #endif