]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.h
Initial revision
[libs/gltk.git] / source / resources.h
diff --git a/source/resources.h b/source/resources.h
new file mode 100644 (file)
index 0000000..001fa63
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef MSP_GLTK_RESOURCES_H_
+#define MSP_GLTK_RESOURCES_H_
+
+#include <msp/gl/font.h>
+#include <msp/gl/texture.h>
+#include <msp/parser/loader.h>
+#include "graphic.h"
+#include "style.h"
+
+namespace Msp {
+namespace GLtk {
+
+class Resources
+{
+public:
+
+       class Loader: public Msp::Parser::Loader
+       {
+       public:
+               Loader(Resources &);
+       private:
+               Resources &res;
+
+               void font(const std::string &);
+               void texture(const std::string &);
+               void graphic(const std::string &);
+               void style(const std::string &, const std::string &);
+       };
+
+       Resources();
+       ~Resources();
+       const GL::Font &get_font(const std::string &) const;
+       const GL::Font &get_default_font() const;
+       const GL::Texture2D &get_texture(const std::string &) const;
+       const Graphic &get_graphic(const std::string &) const;
+       const Style &get_style(const std::string &, const std::string &) const;
+private:
+       struct StyleId
+       {
+               std::string widget;
+               std::string name;
+
+               StyleId(const std::string &w, const std::string &n): widget(w), name(n) { }
+               bool operator<(const StyleId &) const;
+       };
+
+       typedef std::map<std::string, GL::Font *> FontMap;
+       typedef std::map<std::string, GL::Texture2D *> TextureMap;
+       typedef std::map<std::string, Graphic> GraphicMap;
+       typedef std::map<StyleId, Style> StyleMap;
+
+       FontMap fonts;
+       GL::Font *default_font;
+       TextureMap textures;
+       GraphicMap graphics;
+       StyleMap styles;
+
+       Resources(const Resources &);
+       Resources &operator=(const Resources &);
+};
+
+} // namespace GLtk
+} // namespace Msp
+
+#endif