Removed old commented out code.
[tagua/yd.git] / src / loader / theme.h
blob02061c4640ada392011f64e5f4eb0d9761e5a097
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef LOADER__THEME_H
12 #define LOADER__THEME_H
14 #include <map>
15 #include <QPixmap>
16 #include <QObject>
17 #include "loader/context.h"
18 #include "luaapi/loader.h"
20 namespace Loader {
22 typedef std::map<QRect, QPixmap, ::LuaApi::RectLess> PixmapMap;
23 typedef boost::variant<QPixmap, PixmapMap> PixmapOrMap;
25 /**
26 * @class Theme <loader/theme.h>
27 * @brief A class that represents and caches all images loaded by a theme.
29 * This class will be created once for each lua-scripted theme, and will cache
30 * images loaded from that theme.
32 class Theme : public QObject {
33 Q_OBJECT
35 private:
36 QString m_file;
38 /** there will be one such class for each size, and i will store pixmaps and glyphs */
39 class SizeCache {
40 public:
41 typedef std::map<QString, PixmapOrMap> PixmapsCache;
42 typedef std::map<QString, Glyph> GlyphsCache;
43 int m_ref_count;
44 PixmapsCache m_pixmaps_cache;
45 GlyphsCache m_glyphs_cache;
47 SizeCache()
48 : m_ref_count(0) {}
51 typedef std::map<int, SizeCache> Cache;
53 Context m_context;
54 LuaApi::Loader m_lua_loader;
55 Cache m_cache;
57 static PixmapOrMap to_pixmap_map(const ::LuaApi::ImageOrMap& m);
59 private slots:
60 void onSettingsChanged();
62 public:
63 /** Constructor, created the class from a lua theme file */
64 Theme(const QString& lua_file);
65 ~Theme();
67 /** References the size \a size, enabling you to get pixmaps of size \a size */
68 void refSize(int size);
70 /** Unreferences the size */
71 void unrefSize(int size);
73 /** Loads a value */
74 template<typename T>
75 T getValue(const QString& key, int size, const ::LuaApi::LuaValueMap* args = NULL);
78 } //end namespace loader
80 #endif //LOADER__THEME_H