vdr  2.2.0
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 3.4 2015/01/15 10:45:47 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 "positioner.h"
18 #include "recording.h"
19 #include "themes.h"
20 #include "thread.h"
21 #include "timers.h"
22 #include "tools.h"
23 
24 enum eMessageType { mtStatus = 0, mtInfo, mtWarning, mtError }; // will be used to calculate color offsets!
25 
26 class cSkinDisplay {
27 private:
29  int editableWidth; //XXX this is not nice, but how else could we know this value?
30 public:
31  cSkinDisplay(void);
32  virtual ~cSkinDisplay();
33  static int AvgCharWidth(void) { return Setup.FontOsdSize * 4 / 6; }
35  int EditableWidth(void) { return editableWidth; }
36  void SetEditableWidth(int Width) { editableWidth = Width; }
40  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) {}
43  virtual void SetMessage(eMessageType Type, const char *Text) {}
46  virtual void Flush(void) {}
48  static cSkinDisplay *Current(void) { return current; }
50  };
51 
56 private:
58 public:
59  cSkinDisplayChannel(void);
60  virtual void SetChannel(const cChannel *Channel, int Number) = 0;
64  virtual void SetEvents(const cEvent *Present, const cEvent *Following) = 0;
67  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
72  virtual void SetPositioner(const cPositioner *Positioner);
83  /*TODO
84  SetButtons
85  Red = Video options
86  Green = Info now
87  Yellow = Info next
88  */
89  };
90 
93  mcUnknown = 0,
122  };
123 
130  };
131 
149 public:
150  enum { MaxTabs = 6 };
151 private:
153  int tabs[MaxTabs];
154 protected:
156  int Tab(int n) { return (n >= 0 && n < MaxTabs) ? tabs[n] : 0; }
159  const char *GetTabbedText(const char *s, int Tab);
163 public:
164  cSkinDisplayMenu(void);
165  eMenuCategory MenuCategory(void) const { return menuCategory; }
167  virtual void SetMenuCategory(eMenuCategory MenuCategory);
175  virtual void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0);
178  virtual void SetMenuSortMode(eMenuSortMode MenuSortMode) {}
182  virtual void Scroll(bool Up, bool Page);
188  virtual int MaxItems(void) = 0;
190  virtual void Clear(void) = 0;
192  virtual void SetTitle(const char *Title) = 0;
194  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) = 0;
197  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
202  virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable) = 0;
214  virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch) { return false; }
224  virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) { return false; }
231  virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) { return false; }
240  virtual bool SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) { return false; }
251  virtual void SetScrollbar(int Total, int Offset);
256  virtual void SetEvent(const cEvent *Event) = 0;
261  virtual void SetRecording(const cRecording *Recording) = 0;
266  virtual void SetText(const char *Text, bool FixedFont) = 0;
271  //XXX ??? virtual void SetHelp(const char *Help) = 0;
272  virtual int GetTextAreaWidth(void) const;
278  virtual const cFont *GetTextAreaFont(bool FixedFont) const;
285  };
286 
290 protected:
291  const cMarks *marks;
292  class cProgressBar : public cBitmap {
293  protected:
294  int total;
295  int Pos(int p) { return int(int64_t(p) * Width() / total); }
296  void Mark(int x, bool Start, bool Current, tColor ColorMark, tColor ColorCurrent);
297  public:
298  cProgressBar(int Width, int Height, int Current, int Total, const cMarks *Marks, tColor ColorSeen, tColor ColorRest, tColor ColorSelected, tColor ColorMark, tColor ColorCurrent);
299  };
300 public:
301  cSkinDisplayReplay(void);
302  virtual void SetMarks(const cMarks *Marks);
305  virtual void SetRecording(const cRecording *Recording);
310  virtual void SetTitle(const char *Title) = 0;
312  virtual void SetMode(bool Play, bool Forward, int Speed) = 0;
316  virtual void SetProgress(int Current, int Total) = 0;
320  virtual void SetCurrent(const char *Current) = 0;
326  virtual void SetTotal(const char *Total) = 0;
329  virtual void SetJump(const char *Jump) = 0;
335  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
340  };
341 
344 public:
345  virtual void SetVolume(int Current, int Total, bool Mute) = 0;
349  };
350 
353 public:
354  virtual void SetTrack(int Index, const char * const *Tracks) = 0;
357  virtual void SetAudioChannel(int AudioChannel) = 0;
360  };
361 
364 public:
365  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
368  };
369 
370 class cSkin : public cListObject {
371 private:
372  char *name;
374 public:
375  cSkin(const char *Name, cTheme *Theme = NULL);
388  virtual ~cSkin();
389  const char *Name(void) { return name; }
390  cTheme *Theme(void) { return theme; }
391  virtual const char *Description(void) = 0;
397  virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo) = 0;
403  virtual cSkinDisplayMenu *DisplayMenu(void) = 0;
406  virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly) = 0;
411  virtual cSkinDisplayVolume *DisplayVolume(void) = 0;
414  virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) = 0;
420  virtual cSkinDisplayMessage *DisplayMessage(void) = 0;
423  };
424 
425 class cSkins : public cList<cSkin> {
426 private:
430 public:
431  cSkins(void);
432  ~cSkins();
433  bool SetCurrent(const char *Name = NULL);
436  cSkin *Current(void) { return current; }
438  bool IsOpen(void) { return cSkinDisplay::Current(); }
440  eKeys Message(eMessageType Type, const char *s, int Seconds = 0);
448  int QueueMessage(eMessageType Type, const char *s, int Seconds = 0, int Timeout = 0);
473  void ProcessQueuedMessages(void);
475  void Flush(void);
477  virtual void Clear(void);
479  };
480 
481 extern cSkins Skins;
482 
483 #endif //__SKINS_H
static int AvgCharWidth(void)
Returns the average width of a character in pixel (just a raw estimate).
Definition: skins.h:33
Definition: epg.h:71
Definition: skins.h:128
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:214
eMessageType
Definition: skins.h:24
Definition: skins.h:121
int EditableWidth(void)
Definition: skins.h:35
cSkin * current
Definition: skins.h:427
const cPositioner * positioner
< This class is used to display the current channel, together with the present and following EPG even...
Definition: skins.h:57
eMenuCategory MenuCategory(void) const
Returns the menu category, set by a previous call to SetMenuCategory().
Definition: skins.h:165
Definition: tools.h:489
int editableWidth
Definition: skins.h:29
cSkinDisplayMessage * displayMessage
Definition: skins.h:428
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
Definition: skins.h:48
const char * Name(void)
Definition: skins.h:389
cTheme * theme
Definition: skins.h:373
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:40
Definition: osd.h:169
static cSkinDisplay * current
Definition: skins.h:28
Definition: timers.h:27
Definition: skins.h:107
A steerable satellite dish generally points to the south on the northern hemisphere, and to the north on the southern hemisphere (unless you&#39;re located directly on the equator, in which case the general direction is "up").
Definition: positioner.h:31
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:240
Definition: skins.h:100
Definition: skins.h:119
char * name
Definition: skins.h:372
cTextScroller textScroller
Definition: skins.h:155
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition: skins.h:46
Definition: themes.h:17
cTheme * Theme(void)
Definition: skins.h:390
virtual void SetMenuSortMode(eMenuSortMode MenuSortMode)
Sets the mode by which the items in this menu are sorted.
Definition: skins.h:178
cSkinDisplay(void)
Definition: skins.c:55
Definition: skins.h:127
int Tab(int n)
Returns the offset of the given tab from the left border of the item display area.
Definition: skins.h:156
Definition: skins.h:24
Definition: skins.h:94
cSetup Setup
Definition: config.c:373
static cTheme Theme
Definition: skinclassic.c:21
Definition: thread.h:63
Definition: skins.h:425
Definition: skins.h:370
bool IsOpen(void)
Returns true if there is currently a skin display object active.
Definition: skins.h:438
Definition: skins.h:24
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:36
cMutex queueMessageMutex
Definition: skins.h:429
Definition: skins.h:24
eMenuCategory menuCategory
Definition: skins.h:152
eMenuCategory
Definition: skins.h:91
int FontOsdSize
Definition: config.h:330
const cMarks * marks
< This class implements the progress display used during replay of a recording.
Definition: skins.h:291
virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable)
Sets the item at the given Index to Timer.
Definition: skins.h:224
cSkin * Current(void)
Returns a pointer to the current skin.
Definition: skins.h:436
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition: skins.h:43
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:231
eKeys
Definition: keys.h:16
cSkins Skins
Definition: skins.c:219
Definition: font.h:37
uint32_t tColor
Definition: font.h:29
eMenuSortMode
Definition: skins.h:124
virtual ~cSkinDisplay()
Definition: skins.c:61
Definition: skins.h:118