vdr  2.0.4
themes.h
Go to the documentation of this file.
1 /*
2  * themes.h: Color themes used by skins
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: themes.h 2.1 2012/10/07 11:11:43 kls Exp $
8  */
9 
10 #ifndef __THEMES_H
11 #define __THEMES_H
12 
13 #include "i18n.h"
14 #include "tools.h"
15 #include "osd.h"
16 
17 class cTheme {
18 public:
19  enum { MaxThemeColors = 128 };
20 private:
21  char *name;
25  bool FileNameOk(const char *FileName, bool SetName = false);
26 public:
27  cTheme(void);
29  ~cTheme();
30  const char *Name(void) { return name; }
31  const char *Description(void);
35  bool Load(const char *FileName, bool OnlyDescriptions = false);
37  bool Save(const char *FileName);
44  int AddColor(const char *Name, tColor Color);
53  tColor Color(int Subject);
56  };
57 
58 // A helper macro that simplifies defining theme colors.
59 #define THEME_CLR(Theme, Subject, Color) static const tColor Subject = Theme.AddColor(#Subject, Color)
60 
61 class cThemes {
62 private:
63  int numThemes;
64  char **names;
65  char **fileNames;
66  char **descriptions;
67  static char *themesDirectory;
68  void Clear(void);
69 public:
70  cThemes(void);
71  ~cThemes();
72  bool Load(const char *SkinName);
73  int NumThemes(void) { return numThemes; }
74  const char *Name(int Index) { return Index < numThemes ? names[Index] : NULL; }
75  const char *FileName(int Index) { return Index < numThemes ? fileNames[Index] : NULL; }
76  const char * const *Descriptions(void) { return descriptions; }
77  int GetThemeIndex(const char *Description);
78  static void SetThemesDirectory(const char *ThemesDirectory);
79  static void Load(const char *SkinName, const char *ThemeName, cTheme *Theme);
80  static void Save(const char *SkinName, cTheme *Theme);
81  };
82 
83 #endif //__THEMES_H
84