]> git.tdb.fi Git - libs/gltk.git/blob - source/toggle.h
305c3ca0617f4d2707c509958a3fe72a07469456
[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 "widget.h"
13
14 namespace Msp {
15 namespace GLtk {
16
17 /**
18 Allows toggling a value between two states.
19 */
20 class Toggle: public Widget
21 {
22 public:
23         class Loader: public Widget::Loader
24         {
25         public:
26                 Loader(Toggle &);
27                 Toggle &get_object() const;
28         };
29
30 private:
31         std::string text;
32         bool value;
33
34 public:
35         sigc::signal<void, bool> signal_toggled;
36
37         Toggle(const Resources &);
38
39         bool get_value() const { return value; }
40
41         virtual void button_release(int, int, unsigned);
42         virtual void pointer_enter();
43         virtual void pointer_leave();
44 private:
45         virtual const char *get_class() const { return "toggle"; }
46         virtual void render_special(const Part &) const;
47 };
48
49 } // namespace GLtk
50 } // namespace Msp
51
52 #endif