]> git.tdb.fi Git - libs/gltk.git/blob - source/image.h
Add support for displaying named icons in an Image widget
[libs/gltk.git] / source / image.h
1 #ifndef MSP_GLTK_IMAGE_H_
2 #define MSP_GLTK_IMAGE_H_
3
4 #include <msp/gl/texture2d.h>
5 #include "widget.h"
6
7 namespace Msp {
8 namespace GLtk {
9
10 /**
11 A widget for displaying images.
12 */
13 class Image: public Widget
14 {
15 private:
16         const GL::Texture2D *image;
17         std::string icon_name;
18         bool keep_aspect;
19
20 public:
21         Image(const GL::Texture2D * = 0);
22
23         virtual const char *get_class() const { return "image"; }
24
25 private:
26         virtual void autosize_special(const Part &, Geometry &) const;
27
28 public:
29         void set_image(const GL::Texture2D *);
30         void set_icon(const std::string &);
31         void set_keep_aspect(bool);
32
33 private:
34         void update_icon();
35         virtual void rebuild_special(const Part &);
36         virtual void on_style_change();
37         virtual void on_reparent();
38 };
39
40 } // namespace GLtk
41 } // namespace Msp
42
43 #endif