vdr
1.7.27
|
00001 /* 00002 * skins.h: The optical appearance of the OSD 00003 * 00004 * See the main source file 'vdr.c' for copyright information and 00005 * how to reach the author. 00006 * 00007 * $Id: skins.h 2.2 2012/03/11 14:38:23 kls Exp $ 00008 */ 00009 00010 #ifndef __SKINS_H 00011 #define __SKINS_H 00012 00013 #include "channels.h" 00014 #include "epg.h" 00015 #include "keys.h" 00016 #include "osd.h" 00017 #include "recording.h" 00018 #include "themes.h" 00019 #include "thread.h" 00020 #include "tools.h" 00021 00022 enum eMessageType { mtStatus = 0, mtInfo, mtWarning, mtError }; // will be used to calculate color offsets! 00023 00024 class cSkinDisplay { 00025 private: 00026 static cSkinDisplay *current; 00027 int editableWidth; //XXX this is not nice, but how else could we know this value? 00028 public: 00029 cSkinDisplay(void); 00030 virtual ~cSkinDisplay(); 00031 static int AvgCharWidth(void) { return Setup.FontOsdSize * 4 / 6; } 00033 int EditableWidth(void) { return editableWidth; } 00034 void SetEditableWidth(int Width) { editableWidth = Width; } 00038 virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) {} 00041 virtual void SetMessage(eMessageType Type, const char *Text) {} 00044 virtual void Flush(void) {} 00046 static cSkinDisplay *Current(void) { return current; } 00048 }; 00049 00050 class cSkinDisplayChannel : public cSkinDisplay { 00054 public: 00055 virtual void SetChannel(const cChannel *Channel, int Number) = 0; 00059 virtual void SetEvents(const cEvent *Present, const cEvent *Following) = 0; 00062 virtual void SetMessage(eMessageType Type, const char *Text) = 0; 00067 /*TODO 00068 SetButtons 00069 Red = Video options 00070 Green = Info now 00071 Yellow = Info next 00072 */ 00073 }; 00074 00075 class cSkinDisplayMenu : public cSkinDisplay { 00092 public: 00093 enum { MaxTabs = 6 }; 00094 private: 00095 int tabs[MaxTabs]; 00096 protected: 00097 cTextScroller textScroller; 00098 int Tab(int n) { return (n >= 0 && n < MaxTabs) ? tabs[n] : 0; } 00101 const char *GetTabbedText(const char *s, int Tab); 00105 public: 00106 cSkinDisplayMenu(void); 00107 virtual void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0); 00110 virtual void Scroll(bool Up, bool Page); 00116 virtual int MaxItems(void) = 0; 00118 virtual void Clear(void) = 0; 00120 virtual void SetTitle(const char *Title) = 0; 00122 virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL) = 0; 00125 virtual void SetMessage(eMessageType Type, const char *Text) = 0; 00130 virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable) = 0; 00142 /*TODO 00143 virtual void SetItem(const cEvent *Event, int Index, bool Current, bool Selectable, bool NowNext???, bool Schedule???); 00144 virtual void SetItem(const cTimer *Timer, int Index, bool Current, bool Selectable); 00145 virtual void SetItem(const cChannel *Channel, int Index, bool Current, bool Selectable); 00146 virtual void SetItem(const cRecording *Recording, int Index, bool Current, bool Selectable); 00147 --> false: call SetItem(text) 00148 */ 00149 virtual void SetScrollbar(int Total, int Offset); 00154 virtual void SetEvent(const cEvent *Event) = 0; 00159 virtual void SetRecording(const cRecording *Recording) = 0; 00164 virtual void SetText(const char *Text, bool FixedFont) = 0; 00169 //XXX ??? virtual void SetHelp(const char *Help) = 0; 00170 virtual int GetTextAreaWidth(void) const; 00176 virtual const cFont *GetTextAreaFont(bool FixedFont) const; 00183 }; 00184 00185 class cSkinDisplayReplay : public cSkinDisplay { 00188 protected: 00189 const cMarks *marks; 00190 class cProgressBar : public cBitmap { 00191 protected: 00192 int total; 00193 int Pos(int p) { return p * Width() / total; } 00194 void Mark(int x, bool Start, bool Current, tColor ColorMark, tColor ColorCurrent); 00195 public: 00196 cProgressBar(int Width, int Height, int Current, int Total, const cMarks *Marks, tColor ColorSeen, tColor ColorRest, tColor ColorSelected, tColor ColorMark, tColor ColorCurrent); 00197 }; 00198 public: 00199 cSkinDisplayReplay(void); 00200 virtual void SetMarks(const cMarks *Marks); 00203 virtual void SetTitle(const char *Title) = 0; 00205 virtual void SetMode(bool Play, bool Forward, int Speed) = 0; 00209 virtual void SetProgress(int Current, int Total) = 0; 00213 virtual void SetCurrent(const char *Current) = 0; 00219 virtual void SetTotal(const char *Total) = 0; 00222 virtual void SetJump(const char *Jump) = 0; 00228 virtual void SetMessage(eMessageType Type, const char *Text) = 0; 00233 }; 00234 00235 class cSkinDisplayVolume : public cSkinDisplay { 00237 public: 00238 virtual void SetVolume(int Current, int Total, bool Mute) = 0; 00242 }; 00243 00244 class cSkinDisplayTracks : public cSkinDisplay { 00246 public: 00247 virtual void SetTrack(int Index, const char * const *Tracks) = 0; 00250 virtual void SetAudioChannel(int AudioChannel) = 0; 00253 }; 00254 00255 class cSkinDisplayMessage : public cSkinDisplay { 00257 public: 00258 virtual void SetMessage(eMessageType Type, const char *Text) = 0; 00261 }; 00262 00263 class cSkin : public cListObject { 00264 private: 00265 char *name; 00266 cTheme *theme; 00267 public: 00268 cSkin(const char *Name, cTheme *Theme = NULL); 00281 virtual ~cSkin(); 00282 const char *Name(void) { return name; } 00283 cTheme *Theme(void) { return theme; } 00284 virtual const char *Description(void) = 0; 00290 virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo) = 0; 00296 virtual cSkinDisplayMenu *DisplayMenu(void) = 0; 00299 virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly) = 0; 00304 virtual cSkinDisplayVolume *DisplayVolume(void) = 0; 00307 virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks) = 0; 00313 virtual cSkinDisplayMessage *DisplayMessage(void) = 0; 00316 }; 00317 00318 class cSkins : public cList<cSkin> { 00319 private: 00320 cSkin *current; 00321 cSkinDisplayMessage *displayMessage; 00322 cMutex queueMessageMutex; 00323 public: 00324 cSkins(void); 00325 ~cSkins(); 00326 bool SetCurrent(const char *Name = NULL); 00329 cSkin *Current(void) { return current; } 00331 bool IsOpen(void) { return cSkinDisplay::Current(); } 00333 eKeys Message(eMessageType Type, const char *s, int Seconds = 0); 00341 int QueueMessage(eMessageType Type, const char *s, int Seconds = 0, int Timeout = 0); 00366 void ProcessQueuedMessages(void); 00368 void Flush(void); 00370 virtual void Clear(void); 00372 }; 00373 00374 extern cSkins Skins; 00375 00376 #endif //__SKINS_H