]> git.tdb.fi Git - libs/gltk.git/blob - source/image.h
Add a datafile statement to set an icon for an Image
[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 public:
16         class Loader: public Msp::DataFile::DerivedObjectLoader<Image, Widget::Loader>
17         {
18         public:
19                 Loader(Image &);
20         };
21
22 private:
23         const GL::Texture2D *image;
24         std::string icon_name;
25         bool keep_aspect;
26
27 public:
28         Image(const GL::Texture2D * = 0);
29
30         virtual const char *get_class() const { return "image"; }
31
32 private:
33         virtual void autosize_special(const Part &, Geometry &) const;
34
35 public:
36         void set_image(const GL::Texture2D *);
37         void set_icon(const std::string &);
38         void set_keep_aspect(bool);
39
40 private:
41         void update_icon();
42         virtual void rebuild_special(const Part &);
43         virtual void on_style_change();
44         virtual void on_reparent();
45 };
46
47 } // namespace GLtk
48 } // namespace Msp
49
50 #endif