vdr
1.7.27
|
00001 /* 00002 * osdbase.h: Basic interface to the On Screen Display 00003 * 00004 * See the main source file 'vdr.c' for copyright information and 00005 * how to reach the author. 00006 * 00007 * $Id: osdbase.h 2.2 2012/03/02 15:49:57 kls Exp $ 00008 */ 00009 00010 #ifndef __OSDBASE_H 00011 #define __OSDBASE_H 00012 00013 #include "config.h" 00014 #include "osd.h" 00015 #include "skins.h" 00016 #include "tools.h" 00017 00018 enum eOSState { osUnknown, 00019 osContinue, 00020 osSchedule, 00021 osChannels, 00022 osTimers, 00023 osRecordings, 00024 osPlugin, 00025 osSetup, 00026 osCommands, 00027 osPause, 00028 osRecord, 00029 osReplay, 00030 osStopRecord, 00031 osStopReplay, 00032 osCancelEdit, 00033 osCancelTransfer, 00034 osSwitchDvb, 00035 osBack, 00036 osEnd, 00037 os_User, // the following values can be used locally 00038 osUser1, 00039 osUser2, 00040 osUser3, 00041 osUser4, 00042 osUser5, 00043 osUser6, 00044 osUser7, 00045 osUser8, 00046 osUser9, 00047 osUser10, 00048 }; 00049 00050 class cOsdItem : public cListObject { 00051 private: 00052 char *text; 00053 eOSState state; 00054 bool selectable; 00055 protected: 00056 bool fresh; 00057 public: 00058 cOsdItem(eOSState State = osUnknown); 00059 cOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true); 00060 virtual ~cOsdItem(); 00061 bool Selectable(void) const { return selectable; } 00062 void SetText(const char *Text, bool Copy = true); 00063 void SetSelectable(bool Selectable); 00064 void SetFresh(bool Fresh); 00065 const char *Text(void) const { return text; } 00066 virtual void Set(void) {} 00067 virtual eOSState ProcessKey(eKeys Key); 00068 }; 00069 00070 class cOsdObject { 00071 friend class cOsdMenu; 00072 private: 00073 bool isMenu; 00074 bool needsFastResponse; 00075 protected: 00076 void SetNeedsFastResponse(bool NeedsFastResponse) { needsFastResponse = NeedsFastResponse; } 00077 public: 00078 cOsdObject(bool FastResponse = false) { isMenu = false; needsFastResponse = FastResponse; } 00079 virtual ~cOsdObject() {} 00080 virtual bool NeedsFastResponse(void) { return needsFastResponse; } 00081 bool IsMenu(void) const { return isMenu; } 00082 virtual void Show(void); 00083 virtual eOSState ProcessKey(eKeys Key) { return osUnknown; } 00084 }; 00085 00086 class cOsdMenu : public cOsdObject, public cList<cOsdItem> { 00087 private: 00088 static cSkinDisplayMenu *displayMenu; 00089 static int displayMenuCount; 00090 static int displayMenuItems; 00091 char *title; 00092 int cols[cSkinDisplayMenu::MaxTabs]; 00093 int first, current, marked; 00094 cOsdMenu *subMenu; 00095 const char *helpRed, *helpGreen, *helpYellow, *helpBlue; 00096 bool helpDisplayed; 00097 char *status; 00098 int digit; 00099 bool hasHotkeys; 00100 int key_nr; 00101 cTimeMs lastActivity; 00102 void DisplayHelp(bool Force = false); 00103 protected: 00104 void SetDisplayMenu(void); 00105 cSkinDisplayMenu *DisplayMenu(void) { return displayMenu; } 00106 const char *hk(const char *s); 00107 void SetCols(int c0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); 00108 void SetHasHotkeys(bool HasHotkeys = true); 00109 virtual void Clear(void); 00110 const char *Title(void) { return title; } 00111 bool SelectableItem(int idx); 00112 void SetCurrent(cOsdItem *Item); 00113 void RefreshCurrent(void); 00114 void DisplayCurrent(bool Current); 00115 void DisplayItem(cOsdItem *Item); 00116 void CursorUp(void); 00117 void CursorDown(void); 00118 void PageUp(void); 00119 void PageDown(void); 00120 void Mark(void); 00121 eOSState HotKey(eKeys Key); 00122 eOSState AddSubMenu(cOsdMenu *SubMenu); 00123 eOSState CloseSubMenu(); 00124 bool HasSubMenu(void) { return subMenu; } 00125 cOsdMenu *SubMenu(void) { return subMenu; } 00126 void SetStatus(const char *s); 00127 void SetTitle(const char *Title); 00128 void SetHelp(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); 00129 virtual void Del(int Index); 00130 public: 00131 cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); 00132 virtual ~cOsdMenu(); 00133 virtual bool NeedsFastResponse(void) { return subMenu ? subMenu->NeedsFastResponse() : cOsdObject::NeedsFastResponse(); } 00134 int Current(void) const { return current; } 00135 void Add(cOsdItem *Item, bool Current = false, cOsdItem *After = NULL); 00136 void Ins(cOsdItem *Item, bool Current = false, cOsdItem *Before = NULL); 00137 virtual void Display(void); 00138 virtual eOSState ProcessKey(eKeys Key); 00139 }; 00140 00141 #endif //__OSDBASE_H