vdr 2.8.1
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 5.2 2026/01/19 11:09: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 [[deprecated("there is no more limit to the number of theme colors")]]
20 static constexpr int MaxThemeColors = 128;
21private:
26 bool FileNameOk(const char *FileName, bool SetName = false);
27public:
28 cTheme(void);
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:
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[0]; }
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
cString name
Definition themes.h:22
const char * Description(void)
Returns a user visible, single line description of this theme.
Definition themes.c:62
const char * Name(void)
Definition themes.h:30
bool Save(const char *FileName)
Saves the theme data to the given file.
Definition themes.c:148
cStringList descriptions
Definition themes.h:23
static constexpr int MaxThemeColors
Definition themes.h:20
bool FileNameOk(const char *FileName, bool SetName=false)
Definition themes.c:22
cStringList colorNames
Definition themes.h:24
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:169
tColor Color(int Subject)
Returns the color for the given Subject.
Definition themes.c:182
cTheme(void)
Creates a new theme class.
Definition themes.c:17
cVector< tColor > colorValues
Definition themes.h:25
bool Load(const char *FileName, bool OnlyDescriptions=false)
Loads the theme data from the given file.
Definition themes.c:70
cStringList fileNames
Definition themes.h:65
static void SetThemesDirectory(const char *ThemesDirectory)
Definition themes.c:257
int numThemes
Definition themes.h:63
int NumThemes(void)
Definition themes.h:73
cStringList names
Definition themes.h:64
static cString themesDirectory
Definition themes.h:67
int GetThemeIndex(const char *Description)
Definition themes.c:245
~cThemes()
Definition themes.c:196
cThemes(void)
Definition themes.c:191
const char * Name(int Index)
Definition themes.h:74
void Clear(void)
Definition themes.c:201
bool Load(const char *SkinName)
Definition themes.c:209
const char *const * Descriptions(void)
Definition themes.h:76
static void Save(const char *SkinName, cTheme *Theme)
Definition themes.c:270
cStringList 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