]> git.tdb.fi Git - libs/gltk.git/blob - source/button.h
Add icon support to Button
[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 "widget.h"
14
15 namespace Msp {
16 namespace GLtk {
17
18 /**
19 A clickable button widget.  Buttons can have a text label, which is displayed
20 in a spacial part "text".
21 */
22 class Button: public Widget
23 {
24 public:
25         class Loader: public Widget::Loader
26         {
27         public:
28                 Loader(Button &);
29                 Button &get_object() const;
30         };
31
32 private:
33         std::string text;
34         const GL::Texture2D *icon;
35         bool pressed;
36
37 public:
38         sigc::signal<void> signal_clicked;
39
40         Button(const Resources &, const std::string & =std::string());
41         void set_text(const std::string &);
42         void set_icon(const GL::Texture2D *);
43         virtual void button_press(int, int, unsigned);
44         virtual void button_release(int, int, unsigned);
45         virtual void pointer_motion(int, int);
46 private:
47         virtual const char *get_class() const { return "button"; }
48         virtual void render_special(const Part &) const;
49 };
50
51 } // namespace GLtk
52 } // namespace Msp
53
54 #endif