]> git.tdb.fi Git - libs/gltk.git/blob - source/image.h
77357561ead0a54fc147681e580bd67fa80c989c
[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 "mspgltk_api.h"
6 #include "widget.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 /**
12 A widget for displaying images.
13 */
14 class MSPGLTK_API Image: public Widget
15 {
16 public:
17         class Loader: public Msp::DataFile::DerivedObjectLoader<Image, Widget::Loader>
18         {
19         public:
20                 Loader(Image &);
21         };
22
23 private:
24         const GL::Texture2D *image;
25         std::string icon_name;
26         bool keep_aspect;
27
28 public:
29         Image(const GL::Texture2D * = 0);
30
31         virtual const char *get_class() const { return "image"; }
32
33 private:
34         virtual void autosize_special(const Part &, Geometry &) const;
35
36 public:
37         void set_image(const GL::Texture2D *);
38         void set_icon(const std::string &);
39         void set_keep_aspect(bool);
40
41 private:
42         void update_icon();
43         virtual void rebuild_special(const Part &);
44         virtual void on_style_change();
45         virtual void on_reparent();
46 };
47
48 } // namespace GLtk
49 } // namespace Msp
50
51 #endif