vdr  1.7.27
themes.h
Go to the documentation of this file.
00001 /*
00002  * themes.h: Color themes used by skins
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: themes.h 2.0 2007/08/05 14:10:22 kls Exp $
00008  */
00009 
00010 #ifndef __THEMES_H
00011 #define __THEMES_H
00012 
00013 #include "i18n.h"
00014 #include "tools.h"
00015 #include "osd.h"
00016 
00017 class cTheme {
00018 public:
00019   enum { MaxThemeColors = 128 };
00020 private:
00021   char *name;
00022   cStringList descriptions;
00023   char *colorNames[MaxThemeColors];
00024   tColor colorValues[MaxThemeColors];
00025   bool FileNameOk(const char *FileName, bool SetName = false);
00026 public:
00027   cTheme(void);
00029   ~cTheme();
00030   const char *Name(void) { return name; }
00031   const char *Description(void);
00035   bool Load(const char *FileName, bool OnlyDescriptions = false);
00037   bool Save(const char *FileName);
00044   int AddColor(const char *Name, tColor Color);
00053   tColor Color(int Subject);
00056   };
00057 
00058 // A helper macro that simplifies defining theme colors.
00059 #define THEME_CLR(Theme, Subject, Color) static const int Subject = Theme.AddColor(#Subject, Color)
00060 
00061 class cThemes {
00062 private:
00063   int numThemes;
00064   char **names;
00065   char **fileNames;
00066   char **descriptions;
00067   static char *themesDirectory;
00068   void Clear(void);
00069 public:
00070   cThemes(void);
00071   ~cThemes();
00072   bool Load(const char *SkinName);
00073   int NumThemes(void) { return numThemes; }
00074   const char *Name(int Index) { return Index < numThemes ? names[Index] : NULL; }
00075   const char *FileName(int Index) { return Index < numThemes ? fileNames[Index] : NULL; }
00076   const char * const *Descriptions(void) { return descriptions; }
00077   int GetThemeIndex(const char *Description);
00078   static void SetThemesDirectory(const char *ThemesDirectory);
00079   static void Load(const char *SkinName, const char *ThemeName, cTheme *Theme);
00080   static void Save(const char *SkinName, cTheme *Theme);
00081   };
00082 
00083 #endif //__THEMES_H