00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THEME_PRIV_H
00030 #define THEME_PRIV_H
00031
00032 #include "paragui.h"
00033 #include "pgcolor.h"
00034
00035 #include <string>
00036 #include <vector>
00037
00038 #include "pgfilearchive.h"
00039 #include "pgtheme.h"
00040 #include "pgfont.h"
00041
00042 #ifdef HASH_MAP_INC
00043 #include HASH_MAP_INC
00044 #else
00045 #include <map>
00046 #endif
00047
00048 class THEME_FONT {
00049 public:
00050 THEME_FONT() {
00051 size = 14;
00052 index = 0;
00053 style = PG_Font::NORMAL;
00054 }
00055 std::string name;
00056 std::string value;
00057 int size;
00058 int index;
00059 PG_Font::Style style;
00060 };
00061
00062 class THEME_STRING {
00063 public:
00064 virtual ~THEME_STRING() {}
00065
00066 std::string name;
00067 std::string value;
00068 };
00069
00070 class THEME_FILENAME {
00071 public:
00072 THEME_FILENAME() {
00073 surface = NULL;
00074 }
00075
00076 virtual ~THEME_FILENAME() {
00077 PG_FileArchive::UnloadSurface(surface);
00078 }
00079
00080 std::string name;
00081 std::string value;
00082 Uint32 colorkey;
00083 bool hasColorKey;
00084 SDL_Surface* surface;
00085 };
00086
00087 class THEME_PROPERTY {
00088 public:
00089 std::string name;
00090 long value;
00091 };
00092
00093 class THEME_GRADIENT : public PG_Gradient {
00094 public:
00095 std::string name;
00096 };
00097
00098 #ifdef HASH_MAP_INC
00099
00100
00101 struct pg_hashstr {
00102 size_t operator()(const std::string& s1) const {
00103 #if PG_VERSIONNUM(__GNUC__, __GNUC_MINOR__, 0) >= PG_VERSIONNUM(3, 1, 0)
00104 return __gnu_cxx::hash<const char *>()(s1.c_str());
00105 #else
00106
00107 return hash<const char *>()(s1.c_str());
00108 #endif
00109
00110 }
00111 };
00112 #endif
00113
00114 class THEME_OBJECT {
00115 public:
00116
00117 THEME_OBJECT();
00118 virtual ~THEME_OBJECT();
00119
00120 SDL_Surface* FindSurface(const std::string& name);
00121 PG_Gradient* FindGradient(const std::string& name);
00122 long FindProperty(const std::string& name);
00123 const std::string& FindString(const std::string& name);
00124 THEME_FONT* font;
00125
00126 std::string type;
00127 std::string name;
00128
00129 std::vector<THEME_STRING*> strings;
00130
00131 #ifdef HASH_MAP_INC
00132
00133 typedef STL_MAP<std::string, THEME_FILENAME*, pg_hashstr> MAP_FILENAME;
00134 typedef STL_MAP<std::string, THEME_GRADIENT*, pg_hashstr> MAP_GRADIENT;
00135 typedef STL_MAP<std::string, THEME_PROPERTY*, pg_hashstr> MAP_PROPERTY;
00136 #else
00137
00138 typedef std::map<std::string, THEME_FILENAME*> MAP_FILENAME;
00139 typedef std::map<std::string, THEME_GRADIENT*> MAP_GRADIENT;
00140 typedef std::map<std::string, THEME_PROPERTY*> MAP_PROPERTY;
00141 #endif
00142
00143 MAP_FILENAME filename;
00144 MAP_GRADIENT gradient;
00145 MAP_PROPERTY property;
00146 };
00147
00148 class THEME_WIDGET {
00149 public:
00150
00151 THEME_WIDGET() {}
00152 ;
00153 virtual ~THEME_WIDGET();
00154
00155 THEME_OBJECT* FindObject(const std::string& objectname);
00156
00157 std::string type;
00158
00159 #ifdef HASH_MAP_INC
00160
00161 typedef STL_MAP<std::string, THEME_OBJECT*, pg_hashstr> MAP_OBJECT;
00162 #else
00163
00164 typedef std::map<std::string, THEME_OBJECT*> MAP_OBJECT;
00165 #endif
00166
00167 MAP_OBJECT object;
00168 };
00169
00170 class THEME_THEME : public PG_Theme {
00171 public:
00172
00173 THEME_THEME() {
00174 defaultfont = NULL;
00175 };
00176
00177 virtual ~THEME_THEME();
00178
00179 const std::string& FindDefaultFontName();
00180 int FindDefaultFontSize();
00181 PG_Font::Style FindDefaultFontStyle();
00182
00183 const std::string& FindFontName(const std::string&, const std::string&);
00184 int FindFontSize(const std::string&, const std::string&);
00185 PG_Font::Style FindFontStyle(const std::string&, const std::string&);
00186
00187 SDL_Surface* FindSurface(const std::string& widgettype, const std::string& object, const std::string& name);
00188 PG_Gradient* FindGradient(const std::string& widgettype, const std::string& object, const std::string& name);
00189 void GetProperty(const std::string& widgettype, const std::string& object, const std::string& name, long& prop);
00190 void GetProperty(const std::string& widgettype, const std::string& object, const std::string& name, Uint8& prop);
00191 void GetProperty(const std::string& widgettype, const std::string& object, const std::string& name, bool& prop);
00192 void GetProperty(const std::string& widgettype, const std::string& object, const std::string& name, int& prop);
00193 void GetProperty(const std::string& widgettype, const std::string& object, const std::string& name, PG_Draw::BkMode& prop);
00194 void GetAlignment(const std::string& widgettype, const std::string& object, const std::string& name, PG_Label::TextAlign& align);
00195 void GetColor(const std::string& widgettype, const std::string& object, const std::string& name, PG_Color& color);
00196 const std::string& FindString(const std::string& widgettype, const std::string& object, const std::string& name);
00197
00198 THEME_FONT* defaultfont;
00199
00200 std::string title;
00201 std::string description;
00202 std::string author;
00203 std::string email;
00204
00205 #ifdef HASH_MAP_INC
00206
00207 typedef STL_MAP<std::string, THEME_WIDGET*, pg_hashstr> MAP_WIDGET;
00208 #else
00209
00210 typedef std::map<std::string, THEME_WIDGET*> MAP_WIDGET;
00211 #endif
00212
00213 MAP_WIDGET widget;
00214
00215 THEME_WIDGET* FindWidget(const std::string& widgettype);
00216 THEME_OBJECT* FindObject(const std::string& widgettype, const std::string& objectname);
00217 };
00218
00219 #endif // THEME_PRIV_H