]> git.tdb.fi Git - libs/gltk.git/blob - source/resources.h
Restore parent to 0 if an exception occurs while setting things up
[libs/gltk.git] / source / resources.h
1 #ifndef MSP_GLTK_RESOURCES_H_
2 #define MSP_GLTK_RESOURCES_H_
3
4 #include <msp/gl/font.h>
5 #include <msp/gl/texture.h>
6 #include <msp/datafile/collection.h>
7 #include <msp/datafile/directorysource.h>
8 #include <msp/fs/path.h>
9 #include "graphic.h"
10 #include "style.h"
11
12 namespace Msp {
13 namespace GLtk {
14
15 /**
16 Stores resources such as styles and graphics.  All widgets require a Resources
17 instance in constructor.
18 */
19 class Resources: public DataFile::Collection
20 {
21 private:
22         FS::Path path;
23         GL::Font *default_font;
24         DataFile::DirectorySource *dir_src;
25
26 public:
27         class Loader: public Collection::Loader
28         {
29         private:
30                 Resources &res;
31
32         public:
33                 Loader(Resources &);
34         private:
35                 void default_font(const std::string &);
36                 void font(const std::string &);
37         };
38
39 public:
40         Resources();
41         Resources(const FS::Path &);
42 private:
43         void init();
44 public:
45         ~Resources();
46
47         const GL::Font &get_default_font() const;
48
49 private:
50         GL::Texture2D *create_texture(const std::string &);
51 };
52
53 } // namespace GLtk
54 } // namespace Msp
55
56 #endif