]> git.tdb.fi Git - libs/gltk.git/blob - source/toggle.h
Add Dropdown widget
[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         private:
29                 virtual void finish();
30         };
31
32 private:
33         std::string text;
34         bool pressed;
35         bool value;
36
37 public:
38         sigc::signal<void, bool> signal_toggled;
39
40         Toggle(const Resources &);
41
42         void set_value(bool);
43         bool get_value() const { return value; }
44
45         virtual void button_press(int, int, unsigned);
46         virtual void button_release(int, int, unsigned);
47         virtual void pointer_enter();
48         virtual void pointer_leave();
49 private:
50         virtual const char *get_class() const { return "toggle"; }
51         virtual void render_special(const Part &) const;
52 };
53
54 } // namespace GLtk
55 } // namespace Msp
56
57 #endif