vdr 2.6.3
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
17class cTheme {
18public:
19 enum { MaxThemeColors = 128 };
20private:
21 char *name;
25 bool FileNameOk(const char *FileName, bool SetName = false);
26public:
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
61class cThemes {
62private:
64 char **names;
65 char **fileNames;
67 static char *themesDirectory;
68 void Clear(void);
69public:
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
Definition: themes.h:17
const char * Description(void)
Returns a user visible, single line description of this theme.
Definition: themes.c:75
const char * Name(void)
Definition: themes.h:30
bool Save(const char *FileName)
Saves the theme data to the given file.
Definition: themes.c:160
cStringList descriptions
Definition: themes.h:22
~cTheme()
Definition: themes.c:26
bool FileNameOk(const char *FileName, bool SetName=false)
Definition: themes.c:33
char * colorNames[MaxThemeColors]
Definition: themes.h:23
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 Color(int Subject)
Returns the color for the given Subject.
Definition: themes.c:201
@ MaxThemeColors
Definition: themes.h:19
tColor colorValues[MaxThemeColors]
Definition: themes.h:24
char * name
Definition: themes.h:21
cTheme(void)
Creates a new theme class.
Definition: themes.c:18
bool Load(const char *FileName, bool OnlyDescriptions=false)
Loads the theme data from the given file.
Definition: themes.c:83
Definition: themes.h:61
static void SetThemesDirectory(const char *ThemesDirectory)
Definition: themes.c:295
static char * themesDirectory
Definition: themes.h:67
int numThemes
Definition: themes.h:63
int NumThemes(void)
Definition: themes.h:73
char ** fileNames
Definition: themes.h:65
int GetThemeIndex(const char *Description)
Definition: themes.c:283
~cThemes()
Definition: themes.c:218
cThemes(void)
Definition: themes.c:210
const char * Name(int Index)
Definition: themes.h:74
void Clear(void)
Definition: themes.c:223
bool Load(const char *SkinName)
Definition: themes.c:239
const char *const * Descriptions(void)
Definition: themes.h:76
static void Save(const char *SkinName, cTheme *Theme)
Definition: themes.c:309
char ** names
Definition: themes.h:64
char ** descriptions
Definition: themes.h:66
const char * FileName(int Index)
Definition: themes.h:75
uint32_t tColor
Definition: font.h:30
static cTheme Theme
Definition: skinclassic.c:21