⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skincurses.c

📁 These files contain the source code of the "Video Disk Recorder", which is based on the DVB driver
💻 C
📖 第 1 页 / 共 2 页
字号:
  int y = 2;  cTextScroller ts;  char t[32];  snprintf(t, sizeof(t), "%s  %s", *DateString(Recording->start), *TimeString(Recording->start));  ts.Set(osd, 0, y, OsdWidth, OsdHeight - y - 2, t, &Font, clrYellow, clrBackground);  y += ts.Height();  y += 1;  const char *Title = Info->Title();  if (isempty(Title))     Title = Recording->Name();  ts.Set(osd, 0, y, OsdWidth, OsdHeight - y - 2, Title, &Font, clrCyan, clrBackground);  y += ts.Height();  if (!isempty(Info->ShortText())) {     ts.Set(osd, 0, y, OsdWidth, OsdHeight - y - 2, Info->ShortText(), &Font, clrYellow, clrBackground);     y += ts.Height();     }  y += 1;  if (!isempty(Info->Description())) {     textScroller.Set(osd, 0, y, OsdWidth - 2, OsdHeight - y - 2, Info->Description(), &Font, clrCyan, clrBackground);     SetScrollbar();     }}void cSkinCursesDisplayMenu::SetText(const char *Text, bool FixedFont){  textScroller.Set(osd, 0, 2, OsdWidth - 2, OsdHeight - 4, Text, &Font, clrWhite, clrBackground);  SetScrollbar();}void cSkinCursesDisplayMenu::Flush(void){  cString date = DayDateTime();  osd->DrawText(OsdWidth - strlen(date) - 2, 0, date, clrBlack, clrCyan, &Font);  osd->Flush();}// --- cSkinCursesDisplayReplay ----------------------------------------------class cSkinCursesDisplayReplay : public cSkinDisplayReplay {private:  cOsd *osd;  bool message;public:  cSkinCursesDisplayReplay(bool ModeOnly);  virtual ~cSkinCursesDisplayReplay();  virtual void SetTitle(const char *Title);  virtual void SetMode(bool Play, bool Forward, int Speed);  virtual void SetProgress(int Current, int Total);  virtual void SetCurrent(const char *Current);  virtual void SetTotal(const char *Total);  virtual void SetJump(const char *Jump);  virtual void SetMessage(eMessageType Type, const char *Text);  virtual void Flush(void);  };cSkinCursesDisplayReplay::cSkinCursesDisplayReplay(bool ModeOnly){  message = false;  osd = new cCursesOsd(0, OsdHeight - 3);  osd->DrawRectangle(0, 0, OsdWidth - 1, 2, ModeOnly ? clrTransparent : clrBackground);}cSkinCursesDisplayReplay::~cSkinCursesDisplayReplay(){  delete osd;}void cSkinCursesDisplayReplay::SetTitle(const char *Title){  osd->DrawText(0, 0, Title, clrWhite, clrBackground, &Font, OsdWidth);}void cSkinCursesDisplayReplay::SetMode(bool Play, bool Forward, int Speed){  if (Setup.ShowReplayMode) {     const char *Mode;     if (Speed == -1) Mode = Play    ? "  >  " : " ||  ";     else if (Play)   Mode = Forward ? " X>> " : " <<X ";     else             Mode = Forward ? " X|> " : " <|X ";     char buf[16];     strn0cpy(buf, Mode, sizeof(buf));     char *p = strchr(buf, 'X');     if (p)        *p = Speed > 0 ? '1' + Speed - 1 : ' ';     SetJump(buf);     }}void cSkinCursesDisplayReplay::SetProgress(int Current, int Total){  int p = Total > 0 ? OsdWidth * Current / Total : 0;  osd->DrawRectangle(0, 1, p, 1, clrGreen);  osd->DrawRectangle(p, 1, OsdWidth, 1, clrWhite);}void cSkinCursesDisplayReplay::SetCurrent(const char *Current){  osd->DrawText(0, 2, Current, clrWhite, clrBackground, &Font, strlen(Current) + 3);}void cSkinCursesDisplayReplay::SetTotal(const char *Total){  osd->DrawText(OsdWidth - strlen(Total), 2, Total, clrWhite, clrBackground, &Font);}void cSkinCursesDisplayReplay::SetJump(const char *Jump){  osd->DrawText(OsdWidth / 4, 2, Jump, clrWhite, clrBackground, &Font, OsdWidth / 2, 0, taCenter);}void cSkinCursesDisplayReplay::SetMessage(eMessageType Type, const char *Text){  if (Text) {     osd->SaveRegion(0, 2, OsdWidth - 1, 2);     osd->DrawText(0, 2, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, OsdWidth, 0, taCenter);     message = true;     }  else {     osd->RestoreRegion();     message = false;     }}void cSkinCursesDisplayReplay::Flush(void){  osd->Flush();}// --- cSkinCursesDisplayVolume ----------------------------------------------class cSkinCursesDisplayVolume : public cSkinDisplayVolume {private:  cOsd *osd;public:  cSkinCursesDisplayVolume(void);  virtual ~cSkinCursesDisplayVolume();  virtual void SetVolume(int Current, int Total, bool Mute);  virtual void Flush(void);  };cSkinCursesDisplayVolume::cSkinCursesDisplayVolume(void){  osd = new cCursesOsd(0, OsdHeight - 1);}cSkinCursesDisplayVolume::~cSkinCursesDisplayVolume(){  delete osd;}void cSkinCursesDisplayVolume::SetVolume(int Current, int Total, bool Mute){  if (Mute) {     osd->DrawRectangle(0, 0, OsdWidth - 1, 0, clrTransparent);     osd->DrawText(0, 0, tr("Key$Mute"), clrGreen, clrBackground, &Font);     }  else {     const char *Prompt = tr("Volume ");     int l = strlen(Prompt);     int p = (OsdWidth - l) * Current / Total;     osd->DrawText(0, 0, Prompt, clrGreen, clrBackground, &Font);     osd->DrawRectangle(l, 0, l + p - 1, 0, clrGreen);     osd->DrawRectangle(l + p, 0, OsdWidth - 1, 0, clrWhite);     }}void cSkinCursesDisplayVolume::Flush(void){  osd->Flush();}// --- cSkinCursesDisplayTracks ----------------------------------------------class cSkinCursesDisplayTracks : public cSkinDisplayTracks {private:  cOsd *osd;  int itemsWidth;  int currentIndex;  void SetItem(const char *Text, int Index, bool Current);public:  cSkinCursesDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);  virtual ~cSkinCursesDisplayTracks();  virtual void SetTrack(int Index, const char * const *Tracks);  virtual void SetAudioChannel(int AudioChannel) {}  virtual void Flush(void);  };cSkinCursesDisplayTracks::cSkinCursesDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks){  currentIndex = -1;  itemsWidth = Font.Width(Title);  for (int i = 0; i < NumTracks; i++)      itemsWidth = max(itemsWidth, Font.Width(Tracks[i]));  itemsWidth = min(itemsWidth, OsdWidth);  osd = new cCursesOsd(0, 0);  osd->DrawRectangle(0, 0, OsdWidth - 1, OsdHeight - 1, clrBackground);  osd->DrawText(0, 0, Title, clrBlack, clrCyan, &Font, itemsWidth);  for (int i = 0; i < NumTracks; i++)      SetItem(Tracks[i], i, false);}cSkinCursesDisplayTracks::~cSkinCursesDisplayTracks(){  delete osd;}void cSkinCursesDisplayTracks::SetItem(const char *Text, int Index, bool Current){  int y = 1 + Index;  int ColorFg, ColorBg;  if (Current) {     ColorFg = clrBlack;     ColorBg = clrCyan;     currentIndex = Index;     }  else {     ColorFg = clrWhite;     ColorBg = clrBackground;     }  osd->DrawText(0, y, Text, ColorFg, ColorBg, &Font, itemsWidth);}void cSkinCursesDisplayTracks::SetTrack(int Index, const char * const *Tracks){  if (currentIndex >= 0)     SetItem(Tracks[currentIndex], currentIndex, false);  SetItem(Tracks[Index], Index, true);}void cSkinCursesDisplayTracks::Flush(void){  osd->Flush();}// --- cSkinCursesDisplayMessage ---------------------------------------------class cSkinCursesDisplayMessage : public cSkinDisplayMessage {private:  cOsd *osd;public:  cSkinCursesDisplayMessage(void);  virtual ~cSkinCursesDisplayMessage();  virtual void SetMessage(eMessageType Type, const char *Text);  virtual void Flush(void);  };cSkinCursesDisplayMessage::cSkinCursesDisplayMessage(void){  osd = new cCursesOsd(0, OsdHeight - 1);}cSkinCursesDisplayMessage::~cSkinCursesDisplayMessage(){  delete osd;}void cSkinCursesDisplayMessage::SetMessage(eMessageType Type, const char *Text){  osd->DrawText(0, 0, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, OsdWidth, 0, taCenter);}void cSkinCursesDisplayMessage::Flush(void){  osd->Flush();}// --- cSkinCurses -----------------------------------------------------------class cSkinCurses : public cSkin {public:  cSkinCurses(void);  virtual const char *Description(void);  virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo);  virtual cSkinDisplayMenu *DisplayMenu(void);  virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly);  virtual cSkinDisplayVolume *DisplayVolume(void);  virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);  virtual cSkinDisplayMessage *DisplayMessage(void);  };cSkinCurses::cSkinCurses(void):cSkin("curses"){}const char *cSkinCurses::Description(void){  return tr("Text mode");}cSkinDisplayChannel *cSkinCurses::DisplayChannel(bool WithInfo){  return new cSkinCursesDisplayChannel(WithInfo);}cSkinDisplayMenu *cSkinCurses::DisplayMenu(void){  return new cSkinCursesDisplayMenu;}cSkinDisplayReplay *cSkinCurses::DisplayReplay(bool ModeOnly){  return new cSkinCursesDisplayReplay(ModeOnly);}cSkinDisplayVolume *cSkinCurses::DisplayVolume(void){  return new cSkinCursesDisplayVolume;}cSkinDisplayTracks *cSkinCurses::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks){  return new cSkinCursesDisplayTracks(Title, NumTracks, Tracks);}cSkinDisplayMessage *cSkinCurses::DisplayMessage(void){  return new cSkinCursesDisplayMessage;}// --- cPluginSkinCurses -----------------------------------------------------class cPluginSkinCurses : public cPlugin {private:  // Add any member variables or functions you may need here.public:  cPluginSkinCurses(void);  virtual ~cPluginSkinCurses();  virtual const char *Version(void) { return VERSION; }  virtual const char *Description(void) { return DESCRIPTION; }  virtual const char *CommandLineHelp(void);  virtual bool ProcessArgs(int argc, char *argv[]);  virtual bool Initialize(void);  virtual bool Start(void);  virtual void Housekeeping(void);  virtual const char *MainMenuEntry(void) { return MAINMENUENTRY; }  virtual cOsdObject *MainMenuAction(void);  virtual cMenuSetupPage *SetupMenu(void);  virtual bool SetupParse(const char *Name, const char *Value);  };cPluginSkinCurses::cPluginSkinCurses(void){  // Initialize any member variables here.  // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL  // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!}cPluginSkinCurses::~cPluginSkinCurses(){  // Clean up after yourself!  endwin();}const char *cPluginSkinCurses::CommandLineHelp(void){  // Return a string that describes all known command line options.  return NULL;}bool cPluginSkinCurses::ProcessArgs(int argc, char *argv[]){  // Implement command line argument processing here if applicable.  return true;}bool cPluginSkinCurses::Initialize(void){  // Initialize any background activities the plugin shall perform.  WINDOW *w = initscr();  if (w) {     OsdWidth  = w->_maxx - w->_begx + 1;     OsdHeight = w->_maxy - w->_begy + 1;     return true;     }  return false;}bool cPluginSkinCurses::Start(void){  // Start any background activities the plugin shall perform.  cSkin *Skin = new cSkinCurses;  // This skin is normally used for debugging, so let's make it the current one:  Skins.SetCurrent(Skin->Name());  return true;}void cPluginSkinCurses::Housekeeping(void){  // Perform any cleanup or other regular tasks.}cOsdObject *cPluginSkinCurses::MainMenuAction(void){  // Perform the action when selected from the main VDR menu.  return NULL;}cMenuSetupPage *cPluginSkinCurses::SetupMenu(void){  // Return a setup menu in case the plugin supports one.  return NULL;}bool cPluginSkinCurses::SetupParse(const char *Name, const char *Value){  // Parse your own setup parameters and store their values.  return false;}VDRPLUGINCREATOR(cPluginSkinCurses); // Don't touch this!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -