vdr  2.2.0
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 3.0 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
~cTheme()
Definition: themes.c:26
int numThemes
Definition: themes.h:63
cTheme(void)
Creates a new theme class.
Definition: themes.c:18
char ** descriptions
Definition: themes.h:66
char ** names
Definition: themes.h:64
Definition: themes.h:17
bool Save(const char *FileName)
Saves the theme data to the given file.
Definition: themes.c:160
const char *const * Descriptions(void)
Definition: themes.h:76
bool FileNameOk(const char *FileName, bool SetName=false)
Definition: themes.c:33
const char * Description(void)
Returns a user visible, single line description of this theme.
Definition: themes.c:75
bool Load(const char *FileName, bool OnlyDescriptions=false)
Loads the theme data from the given file.
Definition: themes.c:83
static char * themesDirectory
Definition: themes.h:67
static cTheme Theme
Definition: skinclassic.c:21
Definition: themes.h:61
const char * Name(int Index)
Definition: themes.h:74
const char * Name(void)
Definition: themes.h:30
int AddColor(const char *Name, tColor Color)
Adds a color with the given Name to this theme, initializes it with Color and returns an index into t...
Definition: themes.c:183
tColor colorValues[MaxThemeColors]
Definition: themes.h:24
char * name
Definition: themes.h:21
char ** fileNames
Definition: themes.h:65
const char * FileName(int Index)
Definition: themes.h:75
char * colorNames[MaxThemeColors]
Definition: themes.h:23
int NumThemes(void)
Definition: themes.h:73
tColor Color(int Subject)
Returns the color for the given Subject.
Definition: themes.c:201
uint32_t tColor
Definition: font.h:29
cStringList descriptions
Definition: themes.h:22