vdr  2.0.5
skins.h
Go to the documentation of this file.
1 /*
2  * skins.h: The optical appearance of the OSD
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: skins.h 2.9 2012/12/21 11:09:13 kls Exp $
8  */
9 
10 #ifndef __SKINS_H
11 #define __SKINS_H
12 
13 #include "channels.h"
14 #include "epg.h"
15 #include "keys.h"
16 #include "osd.h"
17 #include "recording.h"
18 #include "themes.h"
19 #include "thread.h"
20 #include "timers.h"
21 #include "tools.h"
22 
23 enum eMessageType { mtStatus = 0, mtInfo, mtWarning, mtError }; // will be used to calculate color offsets!
24 
25 class cSkinDisplay {
26 private:
28  int editableWidth; //XXX this is not nice, but how else could we know this value?
29 public:
30  cSkinDisplay(void);
31  virtual ~cSkinDisplay();
32  static int AvgCharWidth(void) { return Setup.FontOsdSize * 4 / 6; }
34  int EditableWidth(void) { return editableWidth; }
35  void SetEditableWidth(int Width) { editableWidth = Width; }
39  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) {}
42  virtual void SetMessage(eMessageType Type, const char *Text) {}
45  virtual void Flush(void) {}
47  static cSkinDisplay *Current(void) { return current; }
49  };
50 
55 public:
56  virtual void SetChannel(const cChannel *Channel, int Number) = 0;
60  virtual void SetEvents(const cEvent *Present, const cEvent *Following) = 0;
63  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
68  /*TODO
69  SetButtons
70  Red = Video options
71  Green = Info now
72  Yellow = Info next
73  */
74  };
75 
78  mcUnknown = 0,
106  };
107 
125 public:
126  enum { MaxTabs = 6 };
127 private:
129  int tabs[MaxTabs];
130 protected:
132  int Tab(int n) { return (n >= 0 && n < MaxTabs) ? tabs[n] : 0; }
135  const char *GetTabbedText(const char *s, int Tab);
139 public:
140  cSkinDisplayMenu(void);
141  eMenuCategory MenuCategory(void) const { return menuCategory; }
151  virtual void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0);
154  virtual void Scroll(bool Up, bool Page);
160  virtual int MaxItems(void) = 0;
162  virtual void Clear(void) = 0;
164  virtual void SetTitle(const char *Title) = 0;
166  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) = 0;
169  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
174  virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable) = 0;
186  virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch) { return false; }
196  virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) { return false; }
203  virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) { return false; }
212  virtual bool SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) { return false; }
223  virtual void SetScrollbar(int Total, int Offset);
228  virtual void SetEvent(const cEvent *Event) = 0;
233  virtual void SetRecording(const cRecording *Recording) = 0;
238  virtual void SetText(const char *Text, bool FixedFont) = 0;
243  //XXX ??? virtual void SetHelp(const char *Help) = 0;
244  virtual int GetTextAreaWidth(void) const;
250  virtual const cFont *GetTextAreaFont(bool FixedFont) const;
257  };
258 
262 protected:
263  const cMarks *marks;
264  class cProgressBar : public cBitmap {
265  protected:
266  int total;
267  int Pos(int p) { return p * Width() / total; }
268  void Mark(int x, bool Start, bool Current, tColor ColorMark, tColor ColorCurrent);
269  public:
270  cProgressBar(int Width, int Height, int Current, int Total, const cMarks *Marks, tColor ColorSeen, tColor ColorRest, tColor ColorSelected, tColor ColorMark, tColor ColorCurrent);
271  };
272 public:
273  cSkinDisplayReplay(void);
274  virtual void SetMarks(const cMarks *Marks);
277  virtual void SetRecording(const cRecording *Recording);
282  virtual void SetTitle(const char *Title) = 0;
284  virtual void SetMode(bool Play, bool Forward, int Speed) = 0;
288  virtual void SetProgress(int Current, int Total) = 0;
292  virtual void SetCurrent(const char *Current) = 0;
298  virtual void SetTotal(const char *Total) = 0;
301  virtual void SetJump(const char *Jump) = 0;
307  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
312  };
313 
316 public:
317  virtual void SetVolume(int Current, int Total, bool Mute) = 0;
321  };
322 
325 public:
326  virtual void SetTrack(int Index, const char * const *Tracks) = 0;
329  virtual void SetAudioChannel(int AudioChannel) = 0;
332  };
333 
336 public:
337  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
340  };
341 
342 class cSkin : public cListObject {
343 private:
344  char *name;
346 public:
347  cSkin(const char *Name, cTheme *Theme = NULL);
360  virtual ~cSkin();
361  const char *Name(void) { return name; }
362  cTheme *Theme(void) { return theme; }
363  virtual const char *Description(void) = 0;
369  virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo) = 0;
375  virtual cSkinDisplayMenu *DisplayMenu(void) = 0;
378  virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly) = 0;
383  virtual cSkinDisplayVolume *DisplayVolume(void) = 0;
386  virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) = 0;
392  virtual cSkinDisplayMessage *DisplayMessage(void) = 0;
395  };
396 
397 class cSkins : public cList<cSkin> {
398 private:
402 public:
403  cSkins(void);
404  ~cSkins();
405  bool SetCurrent(const char *Name = NULL);
408  cSkin *Current(void) { return current; }
410  bool IsOpen(void) { return cSkinDisplay::Current(); }
412  eKeys Message(eMessageType Type, const char *s, int Seconds = 0);
420  int QueueMessage(eMessageType Type, const char *s, int Seconds = 0, int Timeout = 0);
445  void ProcessQueuedMessages(void);
447  void Flush(void);
449  virtual void Clear(void);
451  };
452 
453 extern cSkins Skins;
454 
455 #endif //__SKINS_H
cSkins(void)
Definition: skins.c:205
virtual void SetMessage(eMessageType Type, const char *Text)=0
< This class implements a simple message display.
virtual void Scroll(bool Up, bool Page)
If this menu contains a text area that can be scrolled, this function will be called to actually scro...
Definition: skins.c:91
static int AvgCharWidth(void)
Returns the average width of a character in pixel (just a raw estimate).
Definition: skins.h:32
Definition: epg.h:71
virtual void SetTrack(int Index, const char *const *Tracks)=0
< This class implements the track display.
int tabs[MaxTabs]
Definition: skins.h:129
virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch)
Sets the item at the given Index to Event.
Definition: skins.h:186
eMessageType
Definition: skins.h:23
Definition: skins.h:105
virtual cSkinDisplayVolume * DisplayVolume(void)=0
Creates and returns a new object for displaying the current volume.
int EditableWidth(void)
Definition: skins.h:34
cSkin * current
Definition: skins.h:399
cSkinDisplayReplay(void)
Definition: skins.c:170
virtual ~cSkin()
Definition: skins.c:196
virtual void SetVolume(int Current, int Total, bool Mute)=0
< This class implements the volume/mute display.
virtual void SetRecording(const cRecording *Recording)=0
Sets the Recording that shall be displayed, using the entire central area of the menu.
int QueueMessage(eMessageType Type, const char *s, int Seconds=0, int Timeout=0)
Like Message(), but this function may be called from a background thread.
Definition: skins.c:277
void ProcessQueuedMessages(void)
Processes the first queued message, if any.
Definition: skins.c:333
virtual void SetMessage(eMessageType Type, const char *Text)=0
Sets a one line message Text, with the given Type.
virtual void SetScrollbar(int Total, int Offset)
Sets the Total number of items in the currently displayed list, and the Offset of the first item that...
Definition: skins.c:117
eMenuCategory MenuCategory(void) const
Returns the menu category, set by a previous call to SetMenuCategory().
Definition: skins.h:141
Definition: tools.h:479
int editableWidth
Definition: skins.h:28
cSkinDisplayMessage * displayMessage
Definition: skins.h:400
virtual cSkinDisplayMenu * DisplayMenu(void)=0
Creates and returns a new object for displaying a menu.
virtual void SetMode(bool Play, bool Forward, int Speed)=0
Sets the current replay mode, which can be used to display some indicator, showing the user whether w...
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
Definition: skins.h:47
const char * Name(void)
Definition: skins.h:361
virtual void SetEvent(const cEvent *Event)=0
Sets the Event that shall be displayed, using the entire central area of the menu.
cSkinDisplayMenu(void)
Definition: skins.c:68
cProgressBar(int Width, int Height, int Current, int Total, const cMarks *Marks, tColor ColorSeen, tColor ColorRest, tColor ColorSelected, tColor ColorMark, tColor ColorCurrent)
Definition: skins.c:133
virtual void SetJump(const char *Jump)=0
Sets the prompt that allows the user to enter a jump point.
cTheme * theme
Definition: skins.h:345
virtual void SetText(const char *Text, bool FixedFont)=0
Sets the Text that shall be displayed, using the entire central area of the menu. ...
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable)=0
Sets the item at the given Index to Text.
virtual void SetButtons(const char *Red, const char *Green=NULL, const char *Yellow=NULL, const char *Blue=NULL)
Sets the color buttons to the given strings, provided this cSkinDisplay actually has a color button d...
Definition: skins.h:39
virtual void SetRecording(const cRecording *Recording)
Sets the recording that is currently being played.
Definition: skins.c:175
Definition: osd.h:169
static cSkinDisplay * current
Definition: skins.h:27
int Width(void) const
Definition: osd.h:188
Definition: timers.h:27
Definition: skins.h:91
eTimerMatch
Definition: timers.h:25
virtual bool SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New)
Sets the item at the given Index to Recording.
Definition: skins.h:212
virtual void SetMarks(const cMarks *Marks)
Sets the editing marks to Marks, which shall be used to display the progress bar through a cProgressB...
Definition: skins.c:180
virtual void SetTabs(int Tab1, int Tab2=0, int Tab3=0, int Tab4=0, int Tab5=0)
Sets the tab columns to the given values, which are the number of characters in each column...
Definition: skins.c:79
Definition: skins.h:85
Definition: skins.h:103
char * name
Definition: skins.h:344
cTextScroller textScroller
Definition: skins.h:131
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skins.h:45
Definition: themes.h:17
cTheme * Theme(void)
Definition: skins.h:362
virtual const char * Description(void)=0
Returns a user visible, single line description of this skin, which may consist of arbitrary text and...
int Height(void) const
Definition: osd.h:189
virtual void Clear(void)
Free up all registered skins.
Definition: skins.c:381
cSkin(const char *Name, cTheme *Theme=NULL)
Creates a new skin class, with the given Name and Theme.
Definition: skins.c:187
virtual cSkinDisplayReplay * DisplayReplay(bool ModeOnly)=0
Creates and returns a new object for displaying replay progress.
void Flush(void)
Flushes the currently active cSkinDisplay, if any.
Definition: skins.c:375
cSkinDisplay(void)
Definition: skins.c:55
Definition: skins.h:89
int Tab(int n)
Returns the offset of the given tab from the left border of the item display area.
Definition: skins.h:132
Definition: skins.h:23
virtual void SetMessage(eMessageType Type, const char *Text)=0
Sets a one line message Text, with the given Type.
Definition: skins.h:79
cSetup Setup
Definition: config.c:373
Definition: thread.h:63
Definition: skins.h:397
~cSkins()
Definition: skins.c:210
Definition: skins.h:342
bool IsOpen(void)
Returns true if there is currently a skin display object active.
Definition: skins.h:410
eKeys Message(eMessageType Type, const char *s, int Seconds=0)
Displays the given message, either through a currently visible display object that is capable of doin...
Definition: skins.c:234
Definition: skins.h:23
void SetEditableWidth(int Width)
If an item is set through a call to cSkinDisplayMenu::SetItem(), this function shall be called to set...
Definition: skins.h:35
cMutex queueMessageMutex
Definition: skins.h:401
Definition: skins.h:23
eMenuCategory menuCategory
Definition: skins.h:128
virtual void SetProgress(int Current, int Total)=0
This function will be called whenever the position in or the total length of the recording has change...
virtual void SetMessage(eMessageType Type, const char *Text)=0
Sets a one line message Text, with the given Type.
virtual cSkinDisplayMessage * DisplayMessage(void)=0
Creates and returns a new object for displaying a message.
eMenuCategory
Definition: skins.h:76
virtual void SetTotal(const char *Total)=0
Sets the total length of the recording, as a user readable string if the form "h:mm:ss".
virtual void SetMenuCategory(eMenuCategory MenuCategory)
Sets the current menu category.
Definition: skins.c:74
virtual const cFont * GetTextAreaFont(bool FixedFont) const
Returns a pointer to the font which is used to display text with SetText().
Definition: skins.c:126
virtual void SetAudioChannel(int AudioChannel)=0
Sets the audio channel indicator.
virtual int MaxItems(void)=0
Returns the maximum number of items the menu can display.
int FontOsdSize
Definition: config.h:323
virtual void SetTitle(const char *Title)=0
Sets the title of this menu to Title.
void Mark(int x, bool Start, bool Current, tColor ColorMark, tColor ColorCurrent)
Definition: skins.c:158
virtual void SetCurrent(const char *Current)=0
Sets the current position within the recording, as a user readable string if the form "h:mm:ss...
virtual void SetEvents(const cEvent *Present, const cEvent *Following)=0
Sets the Present and Following EPG events.
const char * GetTabbedText(const char *s, int Tab)
Returns the part of the given string that follows the given Tab (where 0 indicates the beginning of t...
Definition: skins.c:96
const cMarks * marks
< This class implements the progress display used during replay of a recording.
Definition: skins.h:263
virtual void Clear(void)=0
Clears the entire central area of the menu.
virtual void SetTitle(const char *Title)=0
Sets the title of the recording.
virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable)
Sets the item at the given Index to Timer.
Definition: skins.h:196
cSkin * Current(void)
Returns a pointer to the current skin.
Definition: skins.h:408
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skins.h:42
virtual cSkinDisplayTracks * DisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)=0
Creates and returns a new object for displaying the available tracks.
bool SetCurrent(const char *Name=NULL)
Sets the current skin to the one indicated by name.
Definition: skins.c:215
virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider)
Sets the item at the given Index to Channel.
Definition: skins.h:203
virtual cSkinDisplayChannel * DisplayChannel(bool WithInfo)=0
Creates and returns a new object for displaying the current channel.
eKeys
Definition: keys.h:16
virtual void SetButtons(const char *Red, const char *Green=NULL, const char *Yellow=NULL, const char *Blue=NULL)=0
Sets the color buttons to the given strings.
cSkins Skins
Definition: skins.c:203
Definition: font.h:37
virtual int GetTextAreaWidth(void) const
Returns the width in pixel of the area which is used to display text with SetText().
Definition: skins.c:121
uint32_t tColor
Definition: font.h:29
virtual ~cSkinDisplay()
Definition: skins.c:61
virtual void SetChannel(const cChannel *Channel, int Number)=0
< This class is used to display the current channel, together with the present and following EPG even...
Definition: skins.h:102