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