vdr  1.7.31
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.5 2012/05/12 11:10:30 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 "tools.h"
21 
22 enum eMessageType { mtStatus = 0, mtInfo, mtWarning, mtError }; // will be used to calculate color offsets!
23 
24 class cSkinDisplay {
25 private:
26  static cSkinDisplay *current;
27  int editableWidth; //XXX this is not nice, but how else could we know this value?
28 public:
29  cSkinDisplay(void);
30  virtual ~cSkinDisplay();
31  static int AvgCharWidth(void) { return Setup.FontOsdSize * 4 / 6; }
33  int EditableWidth(void) { return editableWidth; }
34  void SetEditableWidth(int Width) { editableWidth = Width; }
38  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) {}
41  virtual void SetMessage(eMessageType Type, const char *Text) {}
44  virtual void Flush(void) {}
46  static cSkinDisplay *Current(void) { return current; }
48  };
49 
50 class cSkinDisplayChannel : public cSkinDisplay {
54 public:
55  virtual void SetChannel(const cChannel *Channel, int Number) = 0;
59  virtual void SetEvents(const cEvent *Present, const cEvent *Following) = 0;
62  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
67  /*TODO
68  SetButtons
69  Red = Video options
70  Green = Info now
71  Yellow = Info next
72  */
73  };
74 
76 
77 class cSkinDisplayMenu : public cSkinDisplay {
94 public:
95  enum { MaxTabs = 6 };
96 private:
98  int tabs[MaxTabs];
99 protected:
101  int Tab(int n) { return (n >= 0 && n < MaxTabs) ? tabs[n] : 0; }
104  const char *GetTabbedText(const char *s, int Tab);
108 public:
109  cSkinDisplayMenu(void);
110  eMenuCategory MenuCategory(void) const { return menuCategory; }
120  virtual void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0);
123  virtual void Scroll(bool Up, bool Page);
129  virtual int MaxItems(void) = 0;
131  virtual void Clear(void) = 0;
133  virtual void SetTitle(const char *Title) = 0;
135  virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) = 0;
138  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
143  virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable) = 0;
155  /*TODO
156  virtual void SetItem(const cEvent *Event, int Index, bool Current, bool Selectable, bool NowNext???, bool Schedule???);
157  virtual void SetItem(const cTimer *Timer, int Index, bool Current, bool Selectable);
158  virtual void SetItem(const cChannel *Channel, int Index, bool Current, bool Selectable);
159  virtual void SetItem(const cRecording *Recording, int Index, bool Current, bool Selectable);
160  --> false: call SetItem(text)
161  */
162  virtual void SetScrollbar(int Total, int Offset);
167  virtual void SetEvent(const cEvent *Event) = 0;
172  virtual void SetRecording(const cRecording *Recording) = 0;
177  virtual void SetText(const char *Text, bool FixedFont) = 0;
182  //XXX ??? virtual void SetHelp(const char *Help) = 0;
183  virtual int GetTextAreaWidth(void) const;
189  virtual const cFont *GetTextAreaFont(bool FixedFont) const;
196  };
197 
198 class cSkinDisplayReplay : public cSkinDisplay {
201 protected:
202  const cMarks *marks;
203  class cProgressBar : public cBitmap {
204  protected:
205  int total;
206  int Pos(int p) { return p * Width() / total; }
207  void Mark(int x, bool Start, bool Current, tColor ColorMark, tColor ColorCurrent);
208  public:
209  cProgressBar(int Width, int Height, int Current, int Total, const cMarks *Marks, tColor ColorSeen, tColor ColorRest, tColor ColorSelected, tColor ColorMark, tColor ColorCurrent);
210  };
211 public:
212  cSkinDisplayReplay(void);
213  virtual void SetMarks(const cMarks *Marks);
216  virtual void SetRecording(const cRecording *Recording);
221  virtual void SetTitle(const char *Title) = 0;
223  virtual void SetMode(bool Play, bool Forward, int Speed) = 0;
227  virtual void SetProgress(int Current, int Total) = 0;
231  virtual void SetCurrent(const char *Current) = 0;
237  virtual void SetTotal(const char *Total) = 0;
240  virtual void SetJump(const char *Jump) = 0;
246  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
251  };
252 
253 class cSkinDisplayVolume : public cSkinDisplay {
255 public:
256  virtual void SetVolume(int Current, int Total, bool Mute) = 0;
260  };
261 
262 class cSkinDisplayTracks : public cSkinDisplay {
264 public:
265  virtual void SetTrack(int Index, const char * const *Tracks) = 0;
268  virtual void SetAudioChannel(int AudioChannel) = 0;
271  };
272 
273 class cSkinDisplayMessage : public cSkinDisplay {
275 public:
276  virtual void SetMessage(eMessageType Type, const char *Text) = 0;
279  };
280 
281 class cSkin : public cListObject {
282 private:
283  char *name;
284  cTheme *theme;
285 public:
286  cSkin(const char *Name, cTheme *Theme = NULL);
299  virtual ~cSkin();
300  const char *Name(void) { return name; }
301  cTheme *Theme(void) { return theme; }
302  virtual const char *Description(void) = 0;
308  virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo) = 0;
314  virtual cSkinDisplayMenu *DisplayMenu(void) = 0;
317  virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly) = 0;
322  virtual cSkinDisplayVolume *DisplayVolume(void) = 0;
325  virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) = 0;
331  virtual cSkinDisplayMessage *DisplayMessage(void) = 0;
334  };
335 
336 class cSkins : public cList<cSkin> {
337 private:
338  cSkin *current;
341 public:
342  cSkins(void);
343  ~cSkins();
344  bool SetCurrent(const char *Name = NULL);
347  cSkin *Current(void) { return current; }
349  bool IsOpen(void) { return cSkinDisplay::Current(); }
351  eKeys Message(eMessageType Type, const char *s, int Seconds = 0);
359  int QueueMessage(eMessageType Type, const char *s, int Seconds = 0, int Timeout = 0);
384  void ProcessQueuedMessages(void);
386  void Flush(void);
388  virtual void Clear(void);
390  };
391 
392 extern cSkins Skins;
393 
394 #endif //__SKINS_H