removed clock pref widget. clock prefs are definitively part of the lua theme.
[kboard.git] / src / pixmaploader.h
blobdce433b3ffb34189edc179c4c446978751200ee2
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 PIXMAPLOADER_H
12 #define PIXMAPLOADER_H
14 #include <QPixmap>
15 #include <QString>
16 #include "loader/theme.h"
18 /**
19 * @class PixmapLoader <pixmaploader.h>
20 * @brief The simple pixmap loading facility.
22 * This is the utility class used by the interface to load pixmap from resource ids.
23 * It acts simply as a wrapper around PixmapLoader::ThemeLoader, making it possible to
24 * use it in a simple and afficient way.
26 * Note that pixmaps will not be all of the specified size, the size is only the base size.
28 class PixmapLoader {
29 private:
30 class ThemeLoader;
31 typedef std::map<QString, ThemeLoader*> ThemeLoadersCache;
33 /** static cache of the loaders, there should be only one for each (theme,variant) pair */
34 static ThemeLoadersCache s_loaders;
36 /** the current loader, or NULL */
37 ThemeLoader *m_loader;
39 /** the current size */
40 int m_size;
42 /** the current theme */
43 QString m_base;
45 /** internal, clears references to the currently used loader, if any. */
46 void flush();
48 /** internal, gets or creates a loader good for the current
49 (theme,variant) pair and refs the size */
50 void initialize();
52 public:
53 /** constructor */
54 PixmapLoader();
55 ~PixmapLoader();
57 /** set the theme path */
58 void setBasePath(const QString& base);
60 /** set the base size of the pixmaps. Note that returned pixmaps's size can be different.
61 * For instance, if the size is 100 the "background" generated by the
62 * chess variant will be 200x200 (and it will be tiled on the Board)
64 void setSize(int s);
66 /** looks up a string id (for instance a predefined id, like "background" or "highlighting") */
67 QPixmap operator()(const QString& id) {
68 return getValue<QPixmap>(id);
71 /** returns a value */
72 template<typename T>
73 T getValue(const QString& id, const ::LuaApi::LuaValueMap* args = NULL);
75 /** returns a static value (not depending on the size) */
76 template<typename T>
77 T getStaticValue(const QString& id, const ::LuaApi::LuaValueMap* args = NULL);
80 #endif // PIXMAPLOADER_H