From 7a79059414ea2f10cba1710de0e37dcbbdfbfa42 Mon Sep 17 00:00:00 2001 From: kamel5 Date: Thu, 11 Jul 2019 11:07:13 +0200 Subject: [PATCH] Change files to unix --- channelgroup.c | 196 ++--- channelgroup.h | 88 +- channeljump.c | 190 ++-- channeljump.h | 58 +- config.c | 680 +++++++-------- config.h | 516 +++++------ detailview.c | 2 +- detailview.h | 2 +- dummygrid.c | 2 +- dummygrid.h | 2 +- epggrid.c | 388 ++++----- epggrid.h | 66 +- fontmanager.c | 192 ++-- fontmanager.h | 82 +- footer.c | 334 +++---- footer.h | 2 +- geometrymanager.c | 152 ++-- geometrymanager.h | 108 +-- grid.c | 164 ++-- grid.h | 116 +-- headergrid.c | 268 +++--- headergrid.h | 42 +- imagecache.c | 1440 +++++++++++++++--------------- imagecache.h | 184 ++-- osdmanager.c | 76 +- osdmanager.h | 46 +- searchtimer.c | 1258 +++++++++++++-------------- searchtimer.h | 272 +++--- statusheader.c | 286 +++--- statusheader.h | 50 +- styledpixmap.c | 410 ++++----- styledpixmap.h | 116 +-- timeline.c | 564 ++++++------ timeline.h | 58 +- timer.c | 356 ++++---- timer.h | 104 +-- tvguideosd.c | 1576 ++++++++++++++++----------------- tvguideosd.h | 130 +-- view.c | 2124 ++++++++++++++++++++++----------------------- view.h | 298 +++---- 40 files changed, 6499 insertions(+), 6499 deletions(-) diff --git a/channelgroup.c b/channelgroup.c index 3278f8c..cc1864c 100644 --- a/channelgroup.c +++ b/channelgroup.c @@ -1,98 +1,98 @@ -#include -#include "channelgroup.h" -#include "tools.h" - -cChannelGroup::cChannelGroup(const char *name) { - channelStart = 0; - channelStop = 0; - this->name = name; -} - -cChannelGroup::~cChannelGroup(void) { -} - -void cChannelGroup::Dump(void) { - esyslog("tvguide: Group %s, startChannel %d, stopChannel %d", name, channelStart, channelStop); -} - -// --- cChannelGroupGrid ------------------------------------------------------------- - -cChannelGroupGrid::cChannelGroupGrid(const char *name) { - this->name = name; -} - -cChannelGroupGrid::~cChannelGroupGrid(void) { -} - -void cChannelGroupGrid::SetBackground() { - if (isColor1) { - color = theme.Color(clrGrid1); - colorBlending = theme.Color(clrGrid1Blending); - } else { - color = theme.Color(clrGrid2); - colorBlending = theme.Color(clrGrid2Blending); - } -} - -void cChannelGroupGrid::SetGeometry(int start, int end) { - int x, y, width, height; - if (tvguideConfig.displayMode == eVertical) { - x = geoManager.timeLineWidth + start*geoManager.colWidth; - y = geoManager.statusHeaderHeight; - width = (end - start + 1) * geoManager.colWidth; - height = geoManager.channelGroupsHeight; - } else if (tvguideConfig.displayMode == eHorizontal) { - x = 0; - y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + start*geoManager.rowHeight; - width = geoManager.channelGroupsWidth; - height = (end - start + 1) * geoManager.rowHeight; - } - pixmap = osdManager.requestPixmap(1, cRect(x, y, width, height)); -} - -void cChannelGroupGrid::Draw(void) { - if (tvguideConfig.style == eStyleGraphical) { - drawBackgroundGraphical(bgChannelGroup); - } else { - drawBackground(); - drawBorder(); - } - tColor colorText = theme.Color(clrFont); - tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; - if (tvguideConfig.displayMode == eVertical) { - DrawVertical(colorText, colorTextBack); - } else if (tvguideConfig.displayMode == eHorizontal) { - DrawHorizontal(colorText, colorTextBack); - } -} - -void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) { - int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2; - cString text = CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str(); - int textWidth = fontManager.FontChannelGroups->Width(*text); - int x = (Width() - textWidth) / 2; - pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups); -} - -void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) { - std::string nameUpper = name; - std::transform(nameUpper.begin(), nameUpper.end(),nameUpper.begin(), ::toupper); - int numChars = nameUpper.length(); - int charHeight = fontManager.FontChannelGroupsHorizontal->Height(); - int textHeight = numChars * charHeight; - int y = 5; - if ((textHeight +5) < Height()) { - y = (Height() - textHeight) / 2; - } - for (int i=0; i < numChars; i++) { - if (((y + 2*charHeight) > Height()) && ((i+1)Width("...")) / 2; - pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); - break; - } - cString currentChar = cString::sprintf("%c", nameUpper.at(i)); - int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2; - pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); - y += fontManager.FontChannelGroupsHorizontal->Height(); - } -} +#include +#include "channelgroup.h" +#include "tools.h" + +cChannelGroup::cChannelGroup(const char *name) { + channelStart = 0; + channelStop = 0; + this->name = name; +} + +cChannelGroup::~cChannelGroup(void) { +} + +void cChannelGroup::Dump(void) { + esyslog("tvguide: Group %s, startChannel %d, stopChannel %d", name, channelStart, channelStop); +} + +// --- cChannelGroupGrid ------------------------------------------------------------- + +cChannelGroupGrid::cChannelGroupGrid(const char *name) { + this->name = name; +} + +cChannelGroupGrid::~cChannelGroupGrid(void) { +} + +void cChannelGroupGrid::SetBackground() { + if (isColor1) { + color = theme.Color(clrGrid1); + colorBlending = theme.Color(clrGrid1Blending); + } else { + color = theme.Color(clrGrid2); + colorBlending = theme.Color(clrGrid2Blending); + } +} + +void cChannelGroupGrid::SetGeometry(int start, int end) { + int x, y, width, height; + if (tvguideConfig.displayMode == eVertical) { + x = geoManager.timeLineWidth + start*geoManager.colWidth; + y = geoManager.statusHeaderHeight; + width = (end - start + 1) * geoManager.colWidth; + height = geoManager.channelGroupsHeight; + } else if (tvguideConfig.displayMode == eHorizontal) { + x = 0; + y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + start*geoManager.rowHeight; + width = geoManager.channelGroupsWidth; + height = (end - start + 1) * geoManager.rowHeight; + } + pixmap = osdManager.requestPixmap(1, cRect(x, y, width, height)); +} + +void cChannelGroupGrid::Draw(void) { + if (tvguideConfig.style == eStyleGraphical) { + drawBackgroundGraphical(bgChannelGroup); + } else { + drawBackground(); + drawBorder(); + } + tColor colorText = theme.Color(clrFont); + tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; + if (tvguideConfig.displayMode == eVertical) { + DrawVertical(colorText, colorTextBack); + } else if (tvguideConfig.displayMode == eHorizontal) { + DrawHorizontal(colorText, colorTextBack); + } +} + +void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) { + int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2; + cString text = CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str(); + int textWidth = fontManager.FontChannelGroups->Width(*text); + int x = (Width() - textWidth) / 2; + pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups); +} + +void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) { + std::string nameUpper = name; + std::transform(nameUpper.begin(), nameUpper.end(),nameUpper.begin(), ::toupper); + int numChars = nameUpper.length(); + int charHeight = fontManager.FontChannelGroupsHorizontal->Height(); + int textHeight = numChars * charHeight; + int y = 5; + if ((textHeight +5) < Height()) { + y = (Height() - textHeight) / 2; + } + for (int i=0; i < numChars; i++) { + if (((y + 2*charHeight) > Height()) && ((i+1)Width("...")) / 2; + pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); + break; + } + cString currentChar = cString::sprintf("%c", nameUpper.at(i)); + int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2; + pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal); + y += fontManager.FontChannelGroupsHorizontal->Height(); + } +} diff --git a/channelgroup.h b/channelgroup.h index e09f6de..e54e072 100644 --- a/channelgroup.h +++ b/channelgroup.h @@ -1,44 +1,44 @@ -#ifndef __TVGUIDE_CHANNELGROUP_H -#define __TVGUIDE_CHANNELGROUP_H - -#include -#include "styledpixmap.h" - - -// --- cChannelGroup ------------------------------------------------------------- - -class cChannelGroup { -private: - int channelStart; - int channelStop; - const char *name; -public: - cChannelGroup(const char *name); - virtual ~cChannelGroup(void); - void SetChannelStart(int start) { channelStart = start; }; - int StartChannel(void) { return channelStart; }; - void SetChannelStop(int stop) { channelStop = stop; }; - int StopChannel(void) { return channelStop; }; - const char* GetName(void) { return name; }; - void Dump(void); -}; - -// --- cChannelGroupGrid ------------------------------------------------------------- - -class cChannelGroupGrid : public cListObject, public cStyledPixmap { -private: - const char *name; - bool isColor1; - void DrawHorizontal(tColor colorText, tColor colorTextBack); - void DrawVertical(tColor colorText, tColor colorTextBack); -public: - cChannelGroupGrid(const char *name); - virtual ~cChannelGroupGrid(void); - void SetColor(bool color) {isColor1 = color;}; - void SetBackground(void); - void SetGeometry(int start, int end); - void Draw(void); -}; - - -#endif //__TVGUIDE_CHANNELGROUP_H \ No newline at end of file +#ifndef __TVGUIDE_CHANNELGROUP_H +#define __TVGUIDE_CHANNELGROUP_H + +#include +#include "styledpixmap.h" + + +// --- cChannelGroup ------------------------------------------------------------- + +class cChannelGroup { +private: + int channelStart; + int channelStop; + const char *name; +public: + cChannelGroup(const char *name); + virtual ~cChannelGroup(void); + void SetChannelStart(int start) { channelStart = start; }; + int StartChannel(void) { return channelStart; }; + void SetChannelStop(int stop) { channelStop = stop; }; + int StopChannel(void) { return channelStop; }; + const char* GetName(void) { return name; }; + void Dump(void); +}; + +// --- cChannelGroupGrid ------------------------------------------------------------- + +class cChannelGroupGrid : public cListObject, public cStyledPixmap { +private: + const char *name; + bool isColor1; + void DrawHorizontal(tColor colorText, tColor colorTextBack); + void DrawVertical(tColor colorText, tColor colorTextBack); +public: + cChannelGroupGrid(const char *name); + virtual ~cChannelGroupGrid(void); + void SetColor(bool color) {isColor1 = color;}; + void SetBackground(void); + void SetGeometry(int start, int end); + void Draw(void); +}; + + +#endif //__TVGUIDE_CHANNELGROUP_H diff --git a/channeljump.c b/channeljump.c index 7e641f5..425b085 100644 --- a/channeljump.c +++ b/channeljump.c @@ -1,95 +1,95 @@ -#include -#include "config.h" -#include "geometrymanager.h" -#include "osdmanager.h" -#include "fontmanager.h" -#include "channelgroups.h" -#include "channeljump.h" - -cChannelJump::cChannelJump(cChannelGroups *channelGroups) { - this->channelGroups = channelGroups; - pixmapText = NULL; - channel = 0; - if (!tvguideConfig.hideLastGroup) { -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - maxChannels = Channels->MaxNumber(); -#else - maxChannels = Channels.MaxNumber(); -#endif - } else { - maxChannels = channelGroups->GetLastValidChannel(); - } - timeout = Setup.ChannelEntryTimeout; - startTime = cTimeMs::Now(); - SetPixmaps(); - Draw(); -} - -cChannelJump::~cChannelJump(void) { - osdManager.releasePixmap(pixmapBack); - osdManager.releasePixmap(pixmapText); -} - -void cChannelJump::SetPixmaps(void) { - int x = (geoManager.osdWidth - geoManager.channelJumpWidth)/2; - int y = (geoManager.osdHeight - geoManager.channelJumpHeight)/2; - - pixmapBack = osdManager.requestPixmap(4, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); - pixmap = osdManager.requestPixmap(5, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); - pixmapText = osdManager.requestPixmap(6, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); -} - -void cChannelJump::Draw(void) { - if (tvguideConfig.style == eStyleGraphical) { - drawBackgroundGraphical(bgChannelJump); - } else { - pixmap->Fill(theme.Color(clrBackground)); - drawBorder(); - } - pixmapBack->Fill(clrTransparent); - pixmapBack->DrawRectangle(cRect(5, Height()/2, Width()-10, Height()-3), theme.Color(clrBackground)); -} - -void cChannelJump::DrawText(void) { - pixmapText->Fill(clrTransparent); - - cString header = cString::sprintf("%s:", tr("Channel")); - - const cFont *font = fontManager.FontMessageBox; - const cFont *fontHeader = fontManager.FontMessageBoxLarge; - - int xHeader = (Width() - fontHeader->Width(*header)) / 2; - int yHeader = (Height()/2 - fontHeader->Height()) / 2; - pixmapText->DrawText(cPoint(xHeader, yHeader), *header, theme.Color(clrFont), clrTransparent, fontHeader); - - cString strChannel = BuildChannelString(); - int xChannel = (Width() - font->Width(*strChannel)) / 2; - int yChannel = Height()/2 + (Height()/2 - font->Height()) / 2; - pixmapText->DrawText(cPoint(xChannel, yChannel), *strChannel, theme.Color(clrFont), clrTransparent, font); - -} - -void cChannelJump::Set(int num) { - startTime = cTimeMs::Now(); - if (channel == 0) { - channel = num; - return; - } - int newChannel = channel * 10 + num; - if (newChannel <= maxChannels) - channel = newChannel; -} - -cString cChannelJump::BuildChannelString(void) { - if (channel*10 <= maxChannels) - return cString::sprintf("%d-", channel); - else - return cString::sprintf("%d", channel); -} - - bool cChannelJump::TimeOut(void) { - if ((cTimeMs::Now() - startTime) > timeout) - return true; - return false; - } \ No newline at end of file +#include +#include "config.h" +#include "geometrymanager.h" +#include "osdmanager.h" +#include "fontmanager.h" +#include "channelgroups.h" +#include "channeljump.h" + +cChannelJump::cChannelJump(cChannelGroups *channelGroups) { + this->channelGroups = channelGroups; + pixmapText = NULL; + channel = 0; + if (!tvguideConfig.hideLastGroup) { +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + maxChannels = Channels->MaxNumber(); +#else + maxChannels = Channels.MaxNumber(); +#endif + } else { + maxChannels = channelGroups->GetLastValidChannel(); + } + timeout = Setup.ChannelEntryTimeout; + startTime = cTimeMs::Now(); + SetPixmaps(); + Draw(); +} + +cChannelJump::~cChannelJump(void) { + osdManager.releasePixmap(pixmapBack); + osdManager.releasePixmap(pixmapText); +} + +void cChannelJump::SetPixmaps(void) { + int x = (geoManager.osdWidth - geoManager.channelJumpWidth)/2; + int y = (geoManager.osdHeight - geoManager.channelJumpHeight)/2; + + pixmapBack = osdManager.requestPixmap(4, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); + pixmap = osdManager.requestPixmap(5, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); + pixmapText = osdManager.requestPixmap(6, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight)); +} + +void cChannelJump::Draw(void) { + if (tvguideConfig.style == eStyleGraphical) { + drawBackgroundGraphical(bgChannelJump); + } else { + pixmap->Fill(theme.Color(clrBackground)); + drawBorder(); + } + pixmapBack->Fill(clrTransparent); + pixmapBack->DrawRectangle(cRect(5, Height()/2, Width()-10, Height()-3), theme.Color(clrBackground)); +} + +void cChannelJump::DrawText(void) { + pixmapText->Fill(clrTransparent); + + cString header = cString::sprintf("%s:", tr("Channel")); + + const cFont *font = fontManager.FontMessageBox; + const cFont *fontHeader = fontManager.FontMessageBoxLarge; + + int xHeader = (Width() - fontHeader->Width(*header)) / 2; + int yHeader = (Height()/2 - fontHeader->Height()) / 2; + pixmapText->DrawText(cPoint(xHeader, yHeader), *header, theme.Color(clrFont), clrTransparent, fontHeader); + + cString strChannel = BuildChannelString(); + int xChannel = (Width() - font->Width(*strChannel)) / 2; + int yChannel = Height()/2 + (Height()/2 - font->Height()) / 2; + pixmapText->DrawText(cPoint(xChannel, yChannel), *strChannel, theme.Color(clrFont), clrTransparent, font); + +} + +void cChannelJump::Set(int num) { + startTime = cTimeMs::Now(); + if (channel == 0) { + channel = num; + return; + } + int newChannel = channel * 10 + num; + if (newChannel <= maxChannels) + channel = newChannel; +} + +cString cChannelJump::BuildChannelString(void) { + if (channel*10 <= maxChannels) + return cString::sprintf("%d-", channel); + else + return cString::sprintf("%d", channel); +} + + bool cChannelJump::TimeOut(void) { + if ((cTimeMs::Now() - startTime) > timeout) + return true; + return false; + } diff --git a/channeljump.h b/channeljump.h index 86dec2e..67d810d 100644 --- a/channeljump.h +++ b/channeljump.h @@ -1,29 +1,29 @@ -#ifndef __TVGUIDE_CHANNELJUMP_H -#define __TVGUIDE_CHANNELJUMP_H - -#include "styledpixmap.h" - -// --- cChannelJump ------------------------------------------------------------- - -class cChannelJump : public cStyledPixmap { -private: - int channel; - cChannelGroups *channelGroups; - int maxChannels; - long unsigned int startTime; - long unsigned int timeout; - cPixmap *pixmapBack; - cPixmap *pixmapText; - void SetPixmaps(void); - void Draw(void); - cString BuildChannelString(void); -public: - cChannelJump(cChannelGroups *channelGroups); - virtual ~cChannelJump(void); - void Set(int num); - void DrawText(void); - bool TimeOut(void); - int GetChannel(void) { return channel; }; -}; - -#endif //__TVGUIDE_CHANNELJUMP_H +#ifndef __TVGUIDE_CHANNELJUMP_H +#define __TVGUIDE_CHANNELJUMP_H + +#include "styledpixmap.h" + +// --- cChannelJump ------------------------------------------------------------- + +class cChannelJump : public cStyledPixmap { +private: + int channel; + cChannelGroups *channelGroups; + int maxChannels; + long unsigned int startTime; + long unsigned int timeout; + cPixmap *pixmapBack; + cPixmap *pixmapText; + void SetPixmaps(void); + void Draw(void); + cString BuildChannelString(void); +public: + cChannelJump(cChannelGroups *channelGroups); + virtual ~cChannelJump(void); + void Set(int num); + void DrawText(void); + bool TimeOut(void); + int GetChannel(void) { return channel; }; +}; + +#endif //__TVGUIDE_CHANNELJUMP_H diff --git a/config.c b/config.c index 198f82a..84c878e 100644 --- a/config.c +++ b/config.c @@ -1,340 +1,340 @@ -#include -#include "config.h" - -cTvguideConfig::cTvguideConfig() { - debugImageLoading = 0; - showMainMenuEntry = 1; - replaceOriginalSchedule = 0; - displayMode = eHorizontal; - showTimeInGrid = 1; - channelCols = 5; - channelRows = 10; - displayTime = 160; - displayHorizontalTime = 160; - displayStatusHeader = 1; - displayChannelGroups = 1; - displayTimeBase = 1; - headerHeightPercent = 20; - channelGroupsPercent = 5; - epgViewBorder = 50; - scaleVideo = 1; - decorateVideo = 1; - timeLineWidthPercent = 8; - timeLineHeightPercent = 4; - displayChannelName = 1; - channelHeaderWidthPercent = 20; - channelHeaderHeightPercent = 15; - footerHeightPercent = 7; - stepMinutes = 30; - bigStepHours = 3; - hugeStepHours = 24; - channelJumpMode = eNumJump; - jumpChannels = 0; - blueKeyMode = 2; - closeOnSwitch = 1; - numkeyMode = 0; - useRemoteTimers = 0; - hideLastGroup = 0; - hideChannelLogos = 0; - logoWidthRatio = 13; - logoHeightRatio = 10; - logoExtension = 0; - hideEpgImages = 0; - epgImageWidth = 315; - epgImageHeight = 240; - numAdditionalEPGPictures = 9; - epgImageWidthLarge = 525; - epgImageHeightLarge = 400; - detailedViewScrollStep = 5; - instRecFolderMode = eFolderRoot; - instRecFixedFolder = ""; - favWhatsOnNow = 1; - favWhatsOnNext = 1; - favUseTime1 = 0; - favUseTime2 = 0; - favUseTime3 = 0; - favUseTime4 = 0; - favTime1 = 0; - favTime2 = 0; - favTime3 = 0; - favTime4 = 0; - descUser1 = ""; - descUser2 = ""; - descUser3 = ""; - descUser4 = ""; - favLimitChannels = 0; - favStartChannel = 0; - favStopChannel = 0; - switchMode = 0; - switchMinsBefore = 2; - fontIndex = 0; - fontNameDefault = "VDRSymbols Sans:Book"; - FontButtonDelta = 0; - FontDetailViewDelta = 0; - FontDetailViewSmallDelta = 0; - FontDetailHeaderDelta = 0; - FontMessageBoxDelta = 0; - FontMessageBoxLargeDelta = 0; - FontStatusHeaderDelta = 0; - FontStatusHeaderLargeDelta = 0; - FontChannelHeaderDelta = 0; - FontChannelGroupsDelta = 0; - FontGridDelta = 0; - FontGridSmallDelta = 0; - FontTimeLineWeekdayDelta = 0; - FontTimeLineDateDelta = 0; - FontTimeLineTimeDelta = 0; - FontChannelHeaderHorizontalDelta = 0; - FontChannelGroupsHorizontalDelta = 0; - FontGridHorizontalDelta = 0; - FontGridHorizontalSmallDelta = 0; - FontTimeLineDateHorizontalDelta = 0; - FontTimeLineTimeHorizontalDelta = 0; - FontRecMenuItemDelta = 0; - FontRecMenuItemSmallDelta = 0; - FontRecMenuItemLargeDelta = 0; - timeFormat = 1; - useNopacityTheme = 1; - themeIndex = -1; - themeIndexCurrent = -1; - themeName = ""; - nOpacityTheme = ""; - style = eStyleBlendingDefault; - roundedCorners = 0; - displayRerunsDetailEPGView = 1; - numReruns = 5; - useSubtitleRerun = 1; - numLogosInitial = 30; - numLogosMax = 50; - limitLogoCache = 1; - logoPathSet = false; - imagesPathSet = false; - iconsPathSet = false; -} - -cTvguideConfig::~cTvguideConfig() { -} - -void cTvguideConfig::setDynamicValues() { - numGrids = (displayMode == eVertical)?channelCols:channelRows; - jumpChannels = numGrids; -} - -bool cTvguideConfig::LoadTheme() { - //is correct theme already loaded? - if (nOpacityTheme.size() == 0) - nOpacityTheme = Setup.OSDTheme; - if ((themeIndex > -1) && (themeIndex == themeIndexCurrent)) { - if (!nOpacityTheme.compare(Setup.OSDTheme)) { - return false; - } else { - nOpacityTheme = Setup.OSDTheme; - } - } - //Load available Themes - cThemes themes; - themes.Load(*cString("tvguide")); - int numThemesAvailable = themes.NumThemes(); - - //Check for nOpacity Theme - if (useNopacityTheme) { - std::string nOpacity = "nOpacity"; - std::string currentSkin = Setup.OSDSkin; - std::string currentSkinTheme = Setup.OSDTheme; - if (!currentSkin.compare(nOpacity)) { - for (int curThemeIndex = 0; curThemeIndex < numThemesAvailable; curThemeIndex++) { - std::string curThemeName = themes.Name(curThemeIndex); - if (!curThemeName.compare(currentSkinTheme)) { - themeIndex = curThemeIndex; - break; - } - } - } - } - - if (themeIndex == -1) { - for (int curThemeIndex = 0; curThemeIndex < numThemesAvailable; curThemeIndex++) { - std::string curThemeName = themes.Name(curThemeIndex); - if (!curThemeName.compare("default")) { - themeIndex = curThemeIndex; - break; - } - } - - } - - if (themeIndex == -1) - themeIndex = 0; - - themeIndexCurrent = themeIndex; - - const char *themePath = themes.FileName(themeIndex); - if (access(themePath, F_OK) == 0) { - ::theme.Load(themePath); - themeName = themes.Name(themeIndex); - } - esyslog("tvguide: set Theme to %s", *themeName); - return true; -} - - -void cTvguideConfig::SetStyle(void) { - if (theme.Color(clrStyle) == CLR_STYLE_FLAT) { - style = eStyleFlat; - esyslog("tvguide: set flat style"); - } else if (theme.Color(clrStyle) == CLR_STYLE_BLENDING_DEFAULT) { - style = eStyleBlendingDefault; - esyslog("tvguide: set blending style"); - } else if (theme.Color(clrStyle) == CLR_STYLE_GRAPHICAL) { - style = eStyleGraphical; - esyslog("tvguide: set graphical style"); - } else { - style = eStyleBlendingMagick; - esyslog("tvguide: set magick blending style"); - } - -} - -void cTvguideConfig::SetLogoPath(cString path) { - logoPath = checkSlashAtEnd(*path); - logoPathSet = true; - esyslog("tvguide: Logo Path set to %s", *logoPath); -} - -void cTvguideConfig::SetImagesPath(cString path) { - epgImagePath = checkSlashAtEnd(*path); - imagesPathSet = true; - esyslog("tvguide: EPG Image Path set to %s", *epgImagePath); -} - -void cTvguideConfig::SetIconsPath(cString path) { - iconPath = checkSlashAtEnd(*path); - iconsPathSet = true; - esyslog("tvguide: Icon Path set to %s", *iconPath); -} - -void cTvguideConfig::SetDefaultPathes(void) { - logoPathDefault = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); - iconPathDefault = cString::sprintf("%s/icons/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); - epgImagePathDefault = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N)); - - if (!logoPathSet) { - logoPath = logoPathDefault; - } - if (!imagesPathSet) { - epgImagePath = epgImagePathDefault; - } - if (!iconsPathSet) { - iconPath = iconPathDefault; - } -} - -cString cTvguideConfig::checkSlashAtEnd(std::string path) { - try { - if (!(path.at(path.size()-1) == '/')) - return cString::sprintf("%s/", path.c_str()); - } catch (...) {return path.c_str();} - return path.c_str(); -} - -bool cTvguideConfig::SetupParse(const char *Name, const char *Value) { - if (strcmp(Name, "timeFormat") == 0) timeFormat = atoi(Value); - else if (strcmp(Name, "debugImageLoading") == 0) debugImageLoading = atoi(Value); - else if (strcmp(Name, "showMainMenuEntry") == 0) showMainMenuEntry = atoi(Value); - else if (strcmp(Name, "replaceOriginalSchedule") == 0) replaceOriginalSchedule = atoi(Value); - else if (strcmp(Name, "useNopacityTheme") == 0) useNopacityTheme = atoi(Value); - else if (strcmp(Name, "themeIndex") == 0) themeIndex = atoi(Value); - else if (strcmp(Name, "displayMode") == 0) displayMode = atoi(Value); - else if (strcmp(Name, "showTimeInGrid") == 0) showTimeInGrid = atoi(Value); - else if (strcmp(Name, "displayStatusHeader") == 0) displayStatusHeader = atoi(Value); - else if (strcmp(Name, "displayChannelGroups") == 0) displayChannelGroups = atoi(Value); - else if (strcmp(Name, "displayTimeBase") == 0) displayTimeBase = atoi(Value); - else if (strcmp(Name, "headerHeightPercent") == 0) headerHeightPercent = atoi(Value); - else if (strcmp(Name, "channelGroupsPercent") == 0) channelGroupsPercent = atoi(Value); - else if (strcmp(Name, "epgViewBorder") == 0) epgViewBorder = atoi(Value); - else if (strcmp(Name, "scaleVideo") == 0) scaleVideo = atoi(Value); - else if (strcmp(Name, "decorateVideo") == 0) decorateVideo = atoi(Value); - else if (strcmp(Name, "roundedCorners") == 0) roundedCorners = atoi(Value); - else if (strcmp(Name, "channelCols") == 0) channelCols = atoi(Value); - else if (strcmp(Name, "channelRows") == 0) channelRows = atoi(Value); - else if (strcmp(Name, "displayTime") == 0) displayTime = atoi(Value); - else if (strcmp(Name, "displayHorizontalTime") == 0) displayHorizontalTime = atoi(Value); - else if (strcmp(Name, "hideChannelLogos") == 0) hideChannelLogos = atoi(Value); - else if (strcmp(Name, "logoExtension") == 0) logoExtension = atoi(Value); - else if (strcmp(Name, "logoWidthRatio") == 0) logoWidthRatio = atoi(Value); - else if (strcmp(Name, "logoHeightRatio") == 0) logoHeightRatio = atoi(Value); - else if (strcmp(Name, "bigStepHours") == 0) bigStepHours = atoi(Value); - else if (strcmp(Name, "hugeStepHours") == 0) hugeStepHours = atoi(Value); - else if (strcmp(Name, "channelJumpMode") == 0) channelJumpMode = atoi(Value); - else if (strcmp(Name, "blueKeyMode") == 0) blueKeyMode = atoi(Value); - else if (strcmp(Name, "numkeyMode") == 0) numkeyMode = atoi(Value); - else if (strcmp(Name, "closeOnSwitch") == 0) closeOnSwitch = atoi(Value); - else if (strcmp(Name, "useRemoteTimers") == 0) useRemoteTimers = atoi(Value); - else if (strcmp(Name, "hideLastGroup") == 0) hideLastGroup = atoi(Value); - else if (strcmp(Name, "hideEpgImages") == 0) hideEpgImages = atoi(Value); - else if (strcmp(Name, "epgImageWidth") == 0) epgImageWidth = atoi(Value); - else if (strcmp(Name, "epgImageHeight") == 0) epgImageHeight = atoi(Value); - else if (strcmp(Name, "numAdditionalEPGPictures") == 0) numAdditionalEPGPictures = atoi(Value); - else if (strcmp(Name, "epgImageWidthLarge") == 0) epgImageWidthLarge = atoi(Value); - else if (strcmp(Name, "epgImageHeightLarge") == 0) epgImageHeightLarge = atoi(Value); - else if (strcmp(Name, "detailedViewScrollStep") == 0) detailedViewScrollStep = atoi(Value); - else if (strcmp(Name, "timeLineWidthPercent") == 0) timeLineWidthPercent = atoi(Value); - else if (strcmp(Name, "timeLineHeightPercent") == 0) timeLineHeightPercent = atoi(Value); - else if (strcmp(Name, "displayChannelName") == 0) displayChannelName = atoi(Value); - else if (strcmp(Name, "channelHeaderWidthPercent") == 0) channelHeaderWidthPercent = atoi(Value); - else if (strcmp(Name, "channelHeaderHeightPercent") == 0) channelHeaderHeightPercent = atoi(Value); - else if (strcmp(Name, "footerHeightPercent") == 0) footerHeightPercent = atoi(Value); - else if (strcmp(Name, "instRecFolderMode") == 0) instRecFolderMode = atoi(Value); - else if (strcmp(Name, "instRecFixedFolder") == 0) instRecFixedFolder = Value; - else if (strcmp(Name, "favWhatsOnNow") == 0) favWhatsOnNow = atoi(Value); - else if (strcmp(Name, "favWhatsOnNext") == 0) favWhatsOnNext = atoi(Value); - else if (strcmp(Name, "favUseTime1") == 0) favUseTime1 = atoi(Value); - else if (strcmp(Name, "favUseTime2") == 0) favUseTime2 = atoi(Value); - else if (strcmp(Name, "favUseTime3") == 0) favUseTime3 = atoi(Value); - else if (strcmp(Name, "favUseTime4") == 0) favUseTime4 = atoi(Value); - else if (strcmp(Name, "favTime1") == 0) favTime1 = atoi(Value); - else if (strcmp(Name, "favTime2") == 0) favTime2 = atoi(Value); - else if (strcmp(Name, "favTime3") == 0) favTime3 = atoi(Value); - else if (strcmp(Name, "favTime4") == 0) favTime4 = atoi(Value); - else if (strcmp(Name, "descUser1") == 0) descUser1 = Value; - else if (strcmp(Name, "descUser2") == 0) descUser2 = Value; - else if (strcmp(Name, "descUser3") == 0) descUser3 = Value; - else if (strcmp(Name, "descUser4") == 0) descUser4 = Value; - else if (strcmp(Name, "favLimitChannels") == 0) favLimitChannels = atoi(Value); - else if (strcmp(Name, "favStartChannel") == 0) favStartChannel = atoi(Value); - else if (strcmp(Name, "favStopChannel") == 0) favStopChannel = atoi(Value); - else if (strcmp(Name, "switchMode") == 0) switchMode = atoi(Value); - else if (strcmp(Name, "switchMinsBefore") == 0) switchMinsBefore = atoi(Value); - else if (strcmp(Name, "fontIndex") == 0) fontIndex = atoi(Value); - else if (strcmp(Name, "FontButtonDelta") == 0) FontButtonDelta = atoi(Value); - else if (strcmp(Name, "FontDetailViewDelta") == 0) FontDetailViewDelta = atoi(Value); - else if (strcmp(Name, "FontDetailHeaderDelta") == 0) FontDetailHeaderDelta = atoi(Value); - else if (strcmp(Name, "FontMessageBoxDelta") == 0) FontMessageBoxDelta = atoi(Value); - else if (strcmp(Name, "FontMessageBoxLargeDelta") == 0) FontMessageBoxLargeDelta = atoi(Value); - else if (strcmp(Name, "FontStatusHeaderDelta") == 0) FontStatusHeaderDelta = atoi(Value); - else if (strcmp(Name, "FontStatusHeaderLargeDelta") == 0) FontStatusHeaderLargeDelta = atoi(Value); - else if (strcmp(Name, "FontChannelHeaderDelta") == 0) FontChannelHeaderDelta = atoi(Value); - else if (strcmp(Name, "FontChannelGroupsDelta") == 0) FontChannelGroupsDelta = atoi(Value); - else if (strcmp(Name, "FontGridDelta") == 0) FontGridDelta = atoi(Value); - else if (strcmp(Name, "FontGridSmallDelta") == 0) FontGridSmallDelta = atoi(Value); - else if (strcmp(Name, "FontTimeLineWeekdayDelta") == 0) FontTimeLineWeekdayDelta = atoi(Value); - else if (strcmp(Name, "FontTimeLineDateDelta") == 0) FontTimeLineDateDelta = atoi(Value); - else if (strcmp(Name, "FontTimeLineTimeDelta") == 0) FontTimeLineTimeDelta = atoi(Value); - else if (strcmp(Name, "FontChannelHeaderHorizontalDelta") == 0) FontChannelHeaderHorizontalDelta = atoi(Value); - else if (strcmp(Name, "FontChannelGroupsHorizontalDelta") == 0) FontChannelGroupsHorizontalDelta = atoi(Value); - else if (strcmp(Name, "FontGridHorizontalDelta") == 0) FontGridHorizontalDelta = atoi(Value); - else if (strcmp(Name, "FontGridHorizontalSmallDelta") == 0) FontGridHorizontalSmallDelta = atoi(Value); - else if (strcmp(Name, "FontTimeLineDateHorizontalDelta") == 0) FontTimeLineDateHorizontalDelta = atoi(Value); - else if (strcmp(Name, "FontTimeLineTimeHorizontalDelta") == 0) FontTimeLineTimeHorizontalDelta = atoi(Value); - else if (strcmp(Name, "FontRecMenuItemDelta") == 0) FontRecMenuItemDelta = atoi(Value); - else if (strcmp(Name, "FontRecMenuItemSmallDelta") == 0) FontRecMenuItemSmallDelta = atoi(Value); - else if (strcmp(Name, "FontRecMenuItemLargeDelta") == 0) FontRecMenuItemLargeDelta = atoi(Value); - else if (strcmp(Name, "displayRerunsDetailEPGView") == 0) displayRerunsDetailEPGView = atoi(Value); - else if (strcmp(Name, "numReruns") == 0) numReruns = atoi(Value); - else if (strcmp(Name, "useSubtitleRerun") == 0) useSubtitleRerun = atoi(Value); - else if (strcmp(Name, "numLogosInitial") == 0) numLogosInitial = atoi(Value); - else if (strcmp(Name, "numLogosMax") == 0) numLogosMax = atoi(Value); - else if (strcmp(Name, "limitLogoCache") == 0) limitLogoCache = atoi(Value); - else return false; - return true; -} +#include +#include "config.h" + +cTvguideConfig::cTvguideConfig() { + debugImageLoading = 0; + showMainMenuEntry = 1; + replaceOriginalSchedule = 0; + displayMode = eHorizontal; + showTimeInGrid = 1; + channelCols = 5; + channelRows = 10; + displayTime = 160; + displayHorizontalTime = 160; + displayStatusHeader = 1; + displayChannelGroups = 1; + displayTimeBase = 1; + headerHeightPercent = 20; + channelGroupsPercent = 5; + epgViewBorder = 50; + scaleVideo = 1; + decorateVideo = 1; + timeLineWidthPercent = 8; + timeLineHeightPercent = 4; + displayChannelName = 1; + channelHeaderWidthPercent = 20; + channelHeaderHeightPercent = 15; + footerHeightPercent = 7; + stepMinutes = 30; + bigStepHours = 3; + hugeStepHours = 24; + channelJumpMode = eNumJump; + jumpChannels = 0; + blueKeyMode = 2; + closeOnSwitch = 1; + numkeyMode = 0; + useRemoteTimers = 0; + hideLastGroup = 0; + hideChannelLogos = 0; + logoWidthRatio = 13; + logoHeightRatio = 10; + logoExtension = 0; + hideEpgImages = 0; + epgImageWidth = 315; + epgImageHeight = 240; + numAdditionalEPGPictures = 9; + epgImageWidthLarge = 525; + epgImageHeightLarge = 400; + detailedViewScrollStep = 5; + instRecFolderMode = eFolderRoot; + instRecFixedFolder = ""; + favWhatsOnNow = 1; + favWhatsOnNext = 1; + favUseTime1 = 0; + favUseTime2 = 0; + favUseTime3 = 0; + favUseTime4 = 0; + favTime1 = 0; + favTime2 = 0; + favTime3 = 0; + favTime4 = 0; + descUser1 = ""; + descUser2 = ""; + descUser3 = ""; + descUser4 = ""; + favLimitChannels = 0; + favStartChannel = 0; + favStopChannel = 0; + switchMode = 0; + switchMinsBefore = 2; + fontIndex = 0; + fontNameDefault = "VDRSymbols Sans:Book"; + FontButtonDelta = 0; + FontDetailViewDelta = 0; + FontDetailViewSmallDelta = 0; + FontDetailHeaderDelta = 0; + FontMessageBoxDelta = 0; + FontMessageBoxLargeDelta = 0; + FontStatusHeaderDelta = 0; + FontStatusHeaderLargeDelta = 0; + FontChannelHeaderDelta = 0; + FontChannelGroupsDelta = 0; + FontGridDelta = 0; + FontGridSmallDelta = 0; + FontTimeLineWeekdayDelta = 0; + FontTimeLineDateDelta = 0; + FontTimeLineTimeDelta = 0; + FontChannelHeaderHorizontalDelta = 0; + FontChannelGroupsHorizontalDelta = 0; + FontGridHorizontalDelta = 0; + FontGridHorizontalSmallDelta = 0; + FontTimeLineDateHorizontalDelta = 0; + FontTimeLineTimeHorizontalDelta = 0; + FontRecMenuItemDelta = 0; + FontRecMenuItemSmallDelta = 0; + FontRecMenuItemLargeDelta = 0; + timeFormat = 1; + useNopacityTheme = 1; + themeIndex = -1; + themeIndexCurrent = -1; + themeName = ""; + nOpacityTheme = ""; + style = eStyleBlendingDefault; + roundedCorners = 0; + displayRerunsDetailEPGView = 1; + numReruns = 5; + useSubtitleRerun = 1; + numLogosInitial = 30; + numLogosMax = 50; + limitLogoCache = 1; + logoPathSet = false; + imagesPathSet = false; + iconsPathSet = false; +} + +cTvguideConfig::~cTvguideConfig() { +} + +void cTvguideConfig::setDynamicValues() { + numGrids = (displayMode == eVertical)?channelCols:channelRows; + jumpChannels = numGrids; +} + +bool cTvguideConfig::LoadTheme() { + //is correct theme already loaded? + if (nOpacityTheme.size() == 0) + nOpacityTheme = Setup.OSDTheme; + if ((themeIndex > -1) && (themeIndex == themeIndexCurrent)) { + if (!nOpacityTheme.compare(Setup.OSDTheme)) { + return false; + } else { + nOpacityTheme = Setup.OSDTheme; + } + } + //Load available Themes + cThemes themes; + themes.Load(*cString("tvguide")); + int numThemesAvailable = themes.NumThemes(); + + //Check for nOpacity Theme + if (useNopacityTheme) { + std::string nOpacity = "nOpacity"; + std::string currentSkin = Setup.OSDSkin; + std::string currentSkinTheme = Setup.OSDTheme; + if (!currentSkin.compare(nOpacity)) { + for (int curThemeIndex = 0; curThemeIndex < numThemesAvailable; curThemeIndex++) { + std::string curThemeName = themes.Name(curThemeIndex); + if (!curThemeName.compare(currentSkinTheme)) { + themeIndex = curThemeIndex; + break; + } + } + } + } + + if (themeIndex == -1) { + for (int curThemeIndex = 0; curThemeIndex < numThemesAvailable; curThemeIndex++) { + std::string curThemeName = themes.Name(curThemeIndex); + if (!curThemeName.compare("default")) { + themeIndex = curThemeIndex; + break; + } + } + + } + + if (themeIndex == -1) + themeIndex = 0; + + themeIndexCurrent = themeIndex; + + const char *themePath = themes.FileName(themeIndex); + if (access(themePath, F_OK) == 0) { + ::theme.Load(themePath); + themeName = themes.Name(themeIndex); + } + esyslog("tvguide: set Theme to %s", *themeName); + return true; +} + + +void cTvguideConfig::SetStyle(void) { + if (theme.Color(clrStyle) == CLR_STYLE_FLAT) { + style = eStyleFlat; + esyslog("tvguide: set flat style"); + } else if (theme.Color(clrStyle) == CLR_STYLE_BLENDING_DEFAULT) { + style = eStyleBlendingDefault; + esyslog("tvguide: set blending style"); + } else if (theme.Color(clrStyle) == CLR_STYLE_GRAPHICAL) { + style = eStyleGraphical; + esyslog("tvguide: set graphical style"); + } else { + style = eStyleBlendingMagick; + esyslog("tvguide: set magick blending style"); + } + +} + +void cTvguideConfig::SetLogoPath(cString path) { + logoPath = checkSlashAtEnd(*path); + logoPathSet = true; + esyslog("tvguide: Logo Path set to %s", *logoPath); +} + +void cTvguideConfig::SetImagesPath(cString path) { + epgImagePath = checkSlashAtEnd(*path); + imagesPathSet = true; + esyslog("tvguide: EPG Image Path set to %s", *epgImagePath); +} + +void cTvguideConfig::SetIconsPath(cString path) { + iconPath = checkSlashAtEnd(*path); + iconsPathSet = true; + esyslog("tvguide: Icon Path set to %s", *iconPath); +} + +void cTvguideConfig::SetDefaultPathes(void) { + logoPathDefault = cString::sprintf("%s/logos/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); + iconPathDefault = cString::sprintf("%s/icons/", cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); + epgImagePathDefault = cString::sprintf("%s/epgimages/", cPlugin::CacheDirectory(PLUGIN_NAME_I18N)); + + if (!logoPathSet) { + logoPath = logoPathDefault; + } + if (!imagesPathSet) { + epgImagePath = epgImagePathDefault; + } + if (!iconsPathSet) { + iconPath = iconPathDefault; + } +} + +cString cTvguideConfig::checkSlashAtEnd(std::string path) { + try { + if (!(path.at(path.size()-1) == '/')) + return cString::sprintf("%s/", path.c_str()); + } catch (...) {return path.c_str();} + return path.c_str(); +} + +bool cTvguideConfig::SetupParse(const char *Name, const char *Value) { + if (strcmp(Name, "timeFormat") == 0) timeFormat = atoi(Value); + else if (strcmp(Name, "debugImageLoading") == 0) debugImageLoading = atoi(Value); + else if (strcmp(Name, "showMainMenuEntry") == 0) showMainMenuEntry = atoi(Value); + else if (strcmp(Name, "replaceOriginalSchedule") == 0) replaceOriginalSchedule = atoi(Value); + else if (strcmp(Name, "useNopacityTheme") == 0) useNopacityTheme = atoi(Value); + else if (strcmp(Name, "themeIndex") == 0) themeIndex = atoi(Value); + else if (strcmp(Name, "displayMode") == 0) displayMode = atoi(Value); + else if (strcmp(Name, "showTimeInGrid") == 0) showTimeInGrid = atoi(Value); + else if (strcmp(Name, "displayStatusHeader") == 0) displayStatusHeader = atoi(Value); + else if (strcmp(Name, "displayChannelGroups") == 0) displayChannelGroups = atoi(Value); + else if (strcmp(Name, "displayTimeBase") == 0) displayTimeBase = atoi(Value); + else if (strcmp(Name, "headerHeightPercent") == 0) headerHeightPercent = atoi(Value); + else if (strcmp(Name, "channelGroupsPercent") == 0) channelGroupsPercent = atoi(Value); + else if (strcmp(Name, "epgViewBorder") == 0) epgViewBorder = atoi(Value); + else if (strcmp(Name, "scaleVideo") == 0) scaleVideo = atoi(Value); + else if (strcmp(Name, "decorateVideo") == 0) decorateVideo = atoi(Value); + else if (strcmp(Name, "roundedCorners") == 0) roundedCorners = atoi(Value); + else if (strcmp(Name, "channelCols") == 0) channelCols = atoi(Value); + else if (strcmp(Name, "channelRows") == 0) channelRows = atoi(Value); + else if (strcmp(Name, "displayTime") == 0) displayTime = atoi(Value); + else if (strcmp(Name, "displayHorizontalTime") == 0) displayHorizontalTime = atoi(Value); + else if (strcmp(Name, "hideChannelLogos") == 0) hideChannelLogos = atoi(Value); + else if (strcmp(Name, "logoExtension") == 0) logoExtension = atoi(Value); + else if (strcmp(Name, "logoWidthRatio") == 0) logoWidthRatio = atoi(Value); + else if (strcmp(Name, "logoHeightRatio") == 0) logoHeightRatio = atoi(Value); + else if (strcmp(Name, "bigStepHours") == 0) bigStepHours = atoi(Value); + else if (strcmp(Name, "hugeStepHours") == 0) hugeStepHours = atoi(Value); + else if (strcmp(Name, "channelJumpMode") == 0) channelJumpMode = atoi(Value); + else if (strcmp(Name, "blueKeyMode") == 0) blueKeyMode = atoi(Value); + else if (strcmp(Name, "numkeyMode") == 0) numkeyMode = atoi(Value); + else if (strcmp(Name, "closeOnSwitch") == 0) closeOnSwitch = atoi(Value); + else if (strcmp(Name, "useRemoteTimers") == 0) useRemoteTimers = atoi(Value); + else if (strcmp(Name, "hideLastGroup") == 0) hideLastGroup = atoi(Value); + else if (strcmp(Name, "hideEpgImages") == 0) hideEpgImages = atoi(Value); + else if (strcmp(Name, "epgImageWidth") == 0) epgImageWidth = atoi(Value); + else if (strcmp(Name, "epgImageHeight") == 0) epgImageHeight = atoi(Value); + else if (strcmp(Name, "numAdditionalEPGPictures") == 0) numAdditionalEPGPictures = atoi(Value); + else if (strcmp(Name, "epgImageWidthLarge") == 0) epgImageWidthLarge = atoi(Value); + else if (strcmp(Name, "epgImageHeightLarge") == 0) epgImageHeightLarge = atoi(Value); + else if (strcmp(Name, "detailedViewScrollStep") == 0) detailedViewScrollStep = atoi(Value); + else if (strcmp(Name, "timeLineWidthPercent") == 0) timeLineWidthPercent = atoi(Value); + else if (strcmp(Name, "timeLineHeightPercent") == 0) timeLineHeightPercent = atoi(Value); + else if (strcmp(Name, "displayChannelName") == 0) displayChannelName = atoi(Value); + else if (strcmp(Name, "channelHeaderWidthPercent") == 0) channelHeaderWidthPercent = atoi(Value); + else if (strcmp(Name, "channelHeaderHeightPercent") == 0) channelHeaderHeightPercent = atoi(Value); + else if (strcmp(Name, "footerHeightPercent") == 0) footerHeightPercent = atoi(Value); + else if (strcmp(Name, "instRecFolderMode") == 0) instRecFolderMode = atoi(Value); + else if (strcmp(Name, "instRecFixedFolder") == 0) instRecFixedFolder = Value; + else if (strcmp(Name, "favWhatsOnNow") == 0) favWhatsOnNow = atoi(Value); + else if (strcmp(Name, "favWhatsOnNext") == 0) favWhatsOnNext = atoi(Value); + else if (strcmp(Name, "favUseTime1") == 0) favUseTime1 = atoi(Value); + else if (strcmp(Name, "favUseTime2") == 0) favUseTime2 = atoi(Value); + else if (strcmp(Name, "favUseTime3") == 0) favUseTime3 = atoi(Value); + else if (strcmp(Name, "favUseTime4") == 0) favUseTime4 = atoi(Value); + else if (strcmp(Name, "favTime1") == 0) favTime1 = atoi(Value); + else if (strcmp(Name, "favTime2") == 0) favTime2 = atoi(Value); + else if (strcmp(Name, "favTime3") == 0) favTime3 = atoi(Value); + else if (strcmp(Name, "favTime4") == 0) favTime4 = atoi(Value); + else if (strcmp(Name, "descUser1") == 0) descUser1 = Value; + else if (strcmp(Name, "descUser2") == 0) descUser2 = Value; + else if (strcmp(Name, "descUser3") == 0) descUser3 = Value; + else if (strcmp(Name, "descUser4") == 0) descUser4 = Value; + else if (strcmp(Name, "favLimitChannels") == 0) favLimitChannels = atoi(Value); + else if (strcmp(Name, "favStartChannel") == 0) favStartChannel = atoi(Value); + else if (strcmp(Name, "favStopChannel") == 0) favStopChannel = atoi(Value); + else if (strcmp(Name, "switchMode") == 0) switchMode = atoi(Value); + else if (strcmp(Name, "switchMinsBefore") == 0) switchMinsBefore = atoi(Value); + else if (strcmp(Name, "fontIndex") == 0) fontIndex = atoi(Value); + else if (strcmp(Name, "FontButtonDelta") == 0) FontButtonDelta = atoi(Value); + else if (strcmp(Name, "FontDetailViewDelta") == 0) FontDetailViewDelta = atoi(Value); + else if (strcmp(Name, "FontDetailHeaderDelta") == 0) FontDetailHeaderDelta = atoi(Value); + else if (strcmp(Name, "FontMessageBoxDelta") == 0) FontMessageBoxDelta = atoi(Value); + else if (strcmp(Name, "FontMessageBoxLargeDelta") == 0) FontMessageBoxLargeDelta = atoi(Value); + else if (strcmp(Name, "FontStatusHeaderDelta") == 0) FontStatusHeaderDelta = atoi(Value); + else if (strcmp(Name, "FontStatusHeaderLargeDelta") == 0) FontStatusHeaderLargeDelta = atoi(Value); + else if (strcmp(Name, "FontChannelHeaderDelta") == 0) FontChannelHeaderDelta = atoi(Value); + else if (strcmp(Name, "FontChannelGroupsDelta") == 0) FontChannelGroupsDelta = atoi(Value); + else if (strcmp(Name, "FontGridDelta") == 0) FontGridDelta = atoi(Value); + else if (strcmp(Name, "FontGridSmallDelta") == 0) FontGridSmallDelta = atoi(Value); + else if (strcmp(Name, "FontTimeLineWeekdayDelta") == 0) FontTimeLineWeekdayDelta = atoi(Value); + else if (strcmp(Name, "FontTimeLineDateDelta") == 0) FontTimeLineDateDelta = atoi(Value); + else if (strcmp(Name, "FontTimeLineTimeDelta") == 0) FontTimeLineTimeDelta = atoi(Value); + else if (strcmp(Name, "FontChannelHeaderHorizontalDelta") == 0) FontChannelHeaderHorizontalDelta = atoi(Value); + else if (strcmp(Name, "FontChannelGroupsHorizontalDelta") == 0) FontChannelGroupsHorizontalDelta = atoi(Value); + else if (strcmp(Name, "FontGridHorizontalDelta") == 0) FontGridHorizontalDelta = atoi(Value); + else if (strcmp(Name, "FontGridHorizontalSmallDelta") == 0) FontGridHorizontalSmallDelta = atoi(Value); + else if (strcmp(Name, "FontTimeLineDateHorizontalDelta") == 0) FontTimeLineDateHorizontalDelta = atoi(Value); + else if (strcmp(Name, "FontTimeLineTimeHorizontalDelta") == 0) FontTimeLineTimeHorizontalDelta = atoi(Value); + else if (strcmp(Name, "FontRecMenuItemDelta") == 0) FontRecMenuItemDelta = atoi(Value); + else if (strcmp(Name, "FontRecMenuItemSmallDelta") == 0) FontRecMenuItemSmallDelta = atoi(Value); + else if (strcmp(Name, "FontRecMenuItemLargeDelta") == 0) FontRecMenuItemLargeDelta = atoi(Value); + else if (strcmp(Name, "displayRerunsDetailEPGView") == 0) displayRerunsDetailEPGView = atoi(Value); + else if (strcmp(Name, "numReruns") == 0) numReruns = atoi(Value); + else if (strcmp(Name, "useSubtitleRerun") == 0) useSubtitleRerun = atoi(Value); + else if (strcmp(Name, "numLogosInitial") == 0) numLogosInitial = atoi(Value); + else if (strcmp(Name, "numLogosMax") == 0) numLogosMax = atoi(Value); + else if (strcmp(Name, "limitLogoCache") == 0) limitLogoCache = atoi(Value); + else return false; + return true; +} diff --git a/config.h b/config.h index 062ee9b..2f277b5 100644 --- a/config.h +++ b/config.h @@ -1,258 +1,258 @@ -#ifndef __TVGUIDE_CONFIG_H -#define __TVGUIDE_CONFIG_H - -#include -#include -#include "osdmanager.h" -#include "geometrymanager.h" -#include "fontmanager.h" -#include "imagecache.h" - -enum { - e12Hours, - e24Hours -}; - -enum { - eVertical, - eHorizontal -}; - -enum { - eNumJump, - eGroupJump -}; - -enum { - eStyleGraphical, - eStyleBlendingMagick, - eStyleBlendingDefault, - eStyleFlat -}; - - -enum eBlueKeyMode { - eBlueKeySwitch = 0, - eBlueKeyEPG, - eBlueKeyFavorites -}; - -enum eInstRecFolderMode { - eFolderRoot = 0, - eFolderSelect, - eFolderFixed -}; - -class cTvguideConfig { - private: - cString checkSlashAtEnd(std::string path); - public: - cTvguideConfig(); - ~cTvguideConfig(); - int debugImageLoading; - int showMainMenuEntry; - int replaceOriginalSchedule; - int displayMode; - int showTimeInGrid; - int channelCols; - int channelRows; - int numGrids; - int displayTime; - int displayHorizontalTime; - int displayStatusHeader; - int displayChannelGroups; - int displayTimeBase; - int headerHeightPercent; - int channelGroupsPercent; - int epgViewBorder; - int scaleVideo; - int decorateVideo; - int timeLineWidthPercent; - int timeLineHeightPercent; - int displayChannelName; - int channelHeaderWidthPercent; - int channelHeaderHeightPercent; - int footerHeightPercent; - int stepMinutes; - int bigStepHours; - int hugeStepHours; - int channelJumpMode; - int jumpChannels; - int blueKeyMode; - int closeOnSwitch; - int numkeyMode; - int useRemoteTimers; - int hideLastGroup; - int hideChannelLogos; - int logoWidthRatio; - int logoHeightRatio; - cString logoPath; - int logoExtension; - int hideEpgImages; - int epgImageWidth; - int epgImageHeight; - int numAdditionalEPGPictures; - int epgImageWidthLarge; - int epgImageHeightLarge; - int detailedViewScrollStep; - cString epgImagePath; - cString iconPath; - cString logoPathDefault; - cString iconPathDefault; - cString epgImagePathDefault; - int instRecFolderMode; - std::string instRecFixedFolder; - int favWhatsOnNow; - int favWhatsOnNext; - int favUseTime1; - int favUseTime2; - int favUseTime3; - int favUseTime4; - int favTime1; - int favTime2; - int favTime3; - int favTime4; - std::string descUser1; - std::string descUser2; - std::string descUser3; - std::string descUser4; - int favLimitChannels; - int favStartChannel; - int favStopChannel; - int switchMode; - int switchMinsBefore; - int fontIndex; - const char *fontNameDefault; - int FontButtonDelta; - int FontDetailViewDelta; - int FontDetailViewSmallDelta; - int FontDetailHeaderDelta; - int FontMessageBoxDelta; - int FontMessageBoxLargeDelta; - int FontStatusHeaderDelta; - int FontStatusHeaderLargeDelta; - int FontChannelHeaderDelta; - int FontChannelGroupsDelta; - int FontGridDelta; - int FontGridSmallDelta; - int FontTimeLineWeekdayDelta; - int FontTimeLineDateDelta; - int FontTimeLineTimeDelta; - int FontChannelHeaderHorizontalDelta; - int FontChannelGroupsHorizontalDelta; - int FontGridHorizontalDelta; - int FontGridHorizontalSmallDelta; - int FontTimeLineDateHorizontalDelta; - int FontTimeLineTimeHorizontalDelta; - int FontRecMenuItemDelta; - int FontRecMenuItemSmallDelta; - int FontRecMenuItemLargeDelta; - int timeFormat; - int useNopacityTheme; - int themeIndex; - int themeIndexCurrent; - cString themeName; - std::string nOpacityTheme; - int style; - int roundedCorners; - int displayRerunsDetailEPGView; - int numReruns; - int useSubtitleRerun; - int numLogosInitial; - int numLogosMax; - int limitLogoCache; - bool logoPathSet; - bool imagesPathSet; - bool iconsPathSet; - bool LoadTheme(); - void SetStyle(void); - void setDynamicValues(void); - void SetLogoPath(cString path); - void SetImagesPath(cString path); - void SetIconsPath(cString path); - void SetDefaultPathes(void); - bool SetupParse(const char *Name, const char *Value); -}; - -#ifdef DEFINE_CONFIG - cTvguideConfig tvguideConfig; - cOsdManager osdManager; - cGeometryManager geoManager; - cFontManager fontManager; - cImageCache imgCache; - cTheme theme; - cPlugin* pRemoteTimers = NULL; -#else - extern cTvguideConfig tvguideConfig; - extern cOsdManager osdManager; - extern cGeometryManager geoManager; - extern cFontManager fontManager; - extern cImageCache imgCache; - extern cTheme theme; - extern cPlugin* pRemoteTimers; -#endif - - -// --- Theme ------------------------------------------------------------- -//Style SETUP -#define CLR_STYLE_BLENDING_MAGICK 0xFFFFFFFF -#define CLR_STYLE_BLENDING_DEFAULT 0xAAAAAAAA -#define CLR_STYLE_GRAPHICAL 0x66666666 -#define CLR_STYLE_FLAT 0x00000000 - -THEME_CLR(theme, clrStyle, CLR_STYLE_BLENDING_DEFAULT); -THEME_CLR(theme, clrBackgroundOSD, 0xB012273f); -THEME_CLR(theme, clrBackground, 0xFF12273f); -THEME_CLR(theme, clrGrid1, 0x00000000); -THEME_CLR(theme, clrGrid1Blending, 0x00000000); -THEME_CLR(theme, clrGrid2, 0x00000000); -THEME_CLR(theme, clrGrid2Blending, 0x00000000); -THEME_CLR(theme, clrHighlight, 0xAA3A3A55); -THEME_CLR(theme, clrHighlightBlending, 0xDD000000); -THEME_CLR(theme, clrGridFontBack, clrTransparent); -THEME_CLR(theme, clrGridActiveFontBack, 0xFFAFD533); -THEME_CLR(theme, clrFont, clrWhite); -THEME_CLR(theme, clrFontActive, 0xFF363636); -THEME_CLR(theme, clrFontHeader, 0xFF363636); -THEME_CLR(theme, clrFontButtons, clrWhite); -THEME_CLR(theme, clrStatusHeader, 0x00000000); -THEME_CLR(theme, clrStatusHeaderBlending, 0x00000000); -THEME_CLR(theme, clrHeader, 0x00000000); -THEME_CLR(theme, clrHeaderBlending, 0x00000000); -THEME_CLR(theme, clrBorder, 0x00000000); -THEME_CLR(theme, clrTimeline1, clrWhite); -THEME_CLR(theme, clrTimeline1Blending, 0xFF828282); -THEME_CLR(theme, clrTimeline2, clrBlack); -THEME_CLR(theme, clrTimeline2Blending, 0xFF3F3F3F); -THEME_CLR(theme, clrTimeBase, 0xA0FF0000); -THEME_CLR(theme, clrTabInactive, 0xA01F3D7A); -THEME_CLR(theme, clrButtonRed, 0xFFFF0000); -THEME_CLR(theme, clrButtonRedBorder, 0x00000000); -THEME_CLR(theme, clrButtonGreen, 0x00000000); -THEME_CLR(theme, clrButtonGreenBorder, 0x00000000); -THEME_CLR(theme, clrButtonYellow, 0x00000000); -THEME_CLR(theme, clrButtonYellowBorder, 0x00000000); -THEME_CLR(theme, clrButtonBlue, 0x00000000); -THEME_CLR(theme, clrButtonBlueBorder, 0x00000000); -THEME_CLR(theme, clrButtonBlend, 0xDD000000); -THEME_CLR(theme, clrRecMenuBackground, 0xAA000000); -THEME_CLR(theme, clrRecMenuTimerConflictBackground, 0xFFCCCCCC); -THEME_CLR(theme, clrRecMenuTimerConflictBar, 0xFF222222); -THEME_CLR(theme, clrRecMenuTimerConflictOverlap, 0xAAFF0000); -THEME_CLR(theme, clrRecMenuDayActive, 0xFF00FF00); -THEME_CLR(theme, clrRecMenuDayInactive, 0xFFFF0000); -THEME_CLR(theme, clrRecMenuDayHighlight, 0x44FFFFFF); -THEME_CLR(theme, clrRecMenuTextBack, 0xFF000000); -THEME_CLR(theme, clrRecMenuTextActiveBack, 0xFF939376); -THEME_CLR(theme, clrRecMenuKeyboardBack, 0xFF000000); -THEME_CLR(theme, clrRecMenuKeyboardBorder, clrWhite); -THEME_CLR(theme, clrRecMenuKeyboardHigh, 0x40BB0000); -THEME_CLR(theme, clrButtonRedKeyboard, 0xFFBB0000); -THEME_CLR(theme, clrButtonGreenKeyboard, 0xFF00BB00); -THEME_CLR(theme, clrButtonYellowKeyboard, 0xFFBBBB00); -THEME_CLR(theme, clrRecMenuTimelineTimer, 0xB012273f); -THEME_CLR(theme, clrRecMenuTimelineBack, 0xFF828282); -THEME_CLR(theme, clrRecMenuTimelineActive, 0xFF3F3F3F); -THEME_CLR(theme, clrRecMenuTimelineConflict, 0x30FF0000); -THEME_CLR(theme, clrRecMenuTimelineConflictOverlap, 0x90FF0000); -#endif //__TVGUIDE_CONFIG_H +#ifndef __TVGUIDE_CONFIG_H +#define __TVGUIDE_CONFIG_H + +#include +#include +#include "osdmanager.h" +#include "geometrymanager.h" +#include "fontmanager.h" +#include "imagecache.h" + +enum { + e12Hours, + e24Hours +}; + +enum { + eVertical, + eHorizontal +}; + +enum { + eNumJump, + eGroupJump +}; + +enum { + eStyleGraphical, + eStyleBlendingMagick, + eStyleBlendingDefault, + eStyleFlat +}; + + +enum eBlueKeyMode { + eBlueKeySwitch = 0, + eBlueKeyEPG, + eBlueKeyFavorites +}; + +enum eInstRecFolderMode { + eFolderRoot = 0, + eFolderSelect, + eFolderFixed +}; + +class cTvguideConfig { + private: + cString checkSlashAtEnd(std::string path); + public: + cTvguideConfig(); + ~cTvguideConfig(); + int debugImageLoading; + int showMainMenuEntry; + int replaceOriginalSchedule; + int displayMode; + int showTimeInGrid; + int channelCols; + int channelRows; + int numGrids; + int displayTime; + int displayHorizontalTime; + int displayStatusHeader; + int displayChannelGroups; + int displayTimeBase; + int headerHeightPercent; + int channelGroupsPercent; + int epgViewBorder; + int scaleVideo; + int decorateVideo; + int timeLineWidthPercent; + int timeLineHeightPercent; + int displayChannelName; + int channelHeaderWidthPercent; + int channelHeaderHeightPercent; + int footerHeightPercent; + int stepMinutes; + int bigStepHours; + int hugeStepHours; + int channelJumpMode; + int jumpChannels; + int blueKeyMode; + int closeOnSwitch; + int numkeyMode; + int useRemoteTimers; + int hideLastGroup; + int hideChannelLogos; + int logoWidthRatio; + int logoHeightRatio; + cString logoPath; + int logoExtension; + int hideEpgImages; + int epgImageWidth; + int epgImageHeight; + int numAdditionalEPGPictures; + int epgImageWidthLarge; + int epgImageHeightLarge; + int detailedViewScrollStep; + cString epgImagePath; + cString iconPath; + cString logoPathDefault; + cString iconPathDefault; + cString epgImagePathDefault; + int instRecFolderMode; + std::string instRecFixedFolder; + int favWhatsOnNow; + int favWhatsOnNext; + int favUseTime1; + int favUseTime2; + int favUseTime3; + int favUseTime4; + int favTime1; + int favTime2; + int favTime3; + int favTime4; + std::string descUser1; + std::string descUser2; + std::string descUser3; + std::string descUser4; + int favLimitChannels; + int favStartChannel; + int favStopChannel; + int switchMode; + int switchMinsBefore; + int fontIndex; + const char *fontNameDefault; + int FontButtonDelta; + int FontDetailViewDelta; + int FontDetailViewSmallDelta; + int FontDetailHeaderDelta; + int FontMessageBoxDelta; + int FontMessageBoxLargeDelta; + int FontStatusHeaderDelta; + int FontStatusHeaderLargeDelta; + int FontChannelHeaderDelta; + int FontChannelGroupsDelta; + int FontGridDelta; + int FontGridSmallDelta; + int FontTimeLineWeekdayDelta; + int FontTimeLineDateDelta; + int FontTimeLineTimeDelta; + int FontChannelHeaderHorizontalDelta; + int FontChannelGroupsHorizontalDelta; + int FontGridHorizontalDelta; + int FontGridHorizontalSmallDelta; + int FontTimeLineDateHorizontalDelta; + int FontTimeLineTimeHorizontalDelta; + int FontRecMenuItemDelta; + int FontRecMenuItemSmallDelta; + int FontRecMenuItemLargeDelta; + int timeFormat; + int useNopacityTheme; + int themeIndex; + int themeIndexCurrent; + cString themeName; + std::string nOpacityTheme; + int style; + int roundedCorners; + int displayRerunsDetailEPGView; + int numReruns; + int useSubtitleRerun; + int numLogosInitial; + int numLogosMax; + int limitLogoCache; + bool logoPathSet; + bool imagesPathSet; + bool iconsPathSet; + bool LoadTheme(); + void SetStyle(void); + void setDynamicValues(void); + void SetLogoPath(cString path); + void SetImagesPath(cString path); + void SetIconsPath(cString path); + void SetDefaultPathes(void); + bool SetupParse(const char *Name, const char *Value); +}; + +#ifdef DEFINE_CONFIG + cTvguideConfig tvguideConfig; + cOsdManager osdManager; + cGeometryManager geoManager; + cFontManager fontManager; + cImageCache imgCache; + cTheme theme; + cPlugin* pRemoteTimers = NULL; +#else + extern cTvguideConfig tvguideConfig; + extern cOsdManager osdManager; + extern cGeometryManager geoManager; + extern cFontManager fontManager; + extern cImageCache imgCache; + extern cTheme theme; + extern cPlugin* pRemoteTimers; +#endif + + +// --- Theme ------------------------------------------------------------- +//Style SETUP +#define CLR_STYLE_BLENDING_MAGICK 0xFFFFFFFF +#define CLR_STYLE_BLENDING_DEFAULT 0xAAAAAAAA +#define CLR_STYLE_GRAPHICAL 0x66666666 +#define CLR_STYLE_FLAT 0x00000000 + +THEME_CLR(theme, clrStyle, CLR_STYLE_BLENDING_DEFAULT); +THEME_CLR(theme, clrBackgroundOSD, 0xB012273f); +THEME_CLR(theme, clrBackground, 0xFF12273f); +THEME_CLR(theme, clrGrid1, 0x00000000); +THEME_CLR(theme, clrGrid1Blending, 0x00000000); +THEME_CLR(theme, clrGrid2, 0x00000000); +THEME_CLR(theme, clrGrid2Blending, 0x00000000); +THEME_CLR(theme, clrHighlight, 0xAA3A3A55); +THEME_CLR(theme, clrHighlightBlending, 0xDD000000); +THEME_CLR(theme, clrGridFontBack, clrTransparent); +THEME_CLR(theme, clrGridActiveFontBack, 0xFFAFD533); +THEME_CLR(theme, clrFont, clrWhite); +THEME_CLR(theme, clrFontActive, 0xFF363636); +THEME_CLR(theme, clrFontHeader, 0xFF363636); +THEME_CLR(theme, clrFontButtons, clrWhite); +THEME_CLR(theme, clrStatusHeader, 0x00000000); +THEME_CLR(theme, clrStatusHeaderBlending, 0x00000000); +THEME_CLR(theme, clrHeader, 0x00000000); +THEME_CLR(theme, clrHeaderBlending, 0x00000000); +THEME_CLR(theme, clrBorder, 0x00000000); +THEME_CLR(theme, clrTimeline1, clrWhite); +THEME_CLR(theme, clrTimeline1Blending, 0xFF828282); +THEME_CLR(theme, clrTimeline2, clrBlack); +THEME_CLR(theme, clrTimeline2Blending, 0xFF3F3F3F); +THEME_CLR(theme, clrTimeBase, 0xA0FF0000); +THEME_CLR(theme, clrTabInactive, 0xA01F3D7A); +THEME_CLR(theme, clrButtonRed, 0xFFFF0000); +THEME_CLR(theme, clrButtonRedBorder, 0x00000000); +THEME_CLR(theme, clrButtonGreen, 0x00000000); +THEME_CLR(theme, clrButtonGreenBorder, 0x00000000); +THEME_CLR(theme, clrButtonYellow, 0x00000000); +THEME_CLR(theme, clrButtonYellowBorder, 0x00000000); +THEME_CLR(theme, clrButtonBlue, 0x00000000); +THEME_CLR(theme, clrButtonBlueBorder, 0x00000000); +THEME_CLR(theme, clrButtonBlend, 0xDD000000); +THEME_CLR(theme, clrRecMenuBackground, 0xAA000000); +THEME_CLR(theme, clrRecMenuTimerConflictBackground, 0xFFCCCCCC); +THEME_CLR(theme, clrRecMenuTimerConflictBar, 0xFF222222); +THEME_CLR(theme, clrRecMenuTimerConflictOverlap, 0xAAFF0000); +THEME_CLR(theme, clrRecMenuDayActive, 0xFF00FF00); +THEME_CLR(theme, clrRecMenuDayInactive, 0xFFFF0000); +THEME_CLR(theme, clrRecMenuDayHighlight, 0x44FFFFFF); +THEME_CLR(theme, clrRecMenuTextBack, 0xFF000000); +THEME_CLR(theme, clrRecMenuTextActiveBack, 0xFF939376); +THEME_CLR(theme, clrRecMenuKeyboardBack, 0xFF000000); +THEME_CLR(theme, clrRecMenuKeyboardBorder, clrWhite); +THEME_CLR(theme, clrRecMenuKeyboardHigh, 0x40BB0000); +THEME_CLR(theme, clrButtonRedKeyboard, 0xFFBB0000); +THEME_CLR(theme, clrButtonGreenKeyboard, 0xFF00BB00); +THEME_CLR(theme, clrButtonYellowKeyboard, 0xFFBBBB00); +THEME_CLR(theme, clrRecMenuTimelineTimer, 0xB012273f); +THEME_CLR(theme, clrRecMenuTimelineBack, 0xFF828282); +THEME_CLR(theme, clrRecMenuTimelineActive, 0xFF3F3F3F); +THEME_CLR(theme, clrRecMenuTimelineConflict, 0x30FF0000); +THEME_CLR(theme, clrRecMenuTimelineConflictOverlap, 0x90FF0000); +#endif //__TVGUIDE_CONFIG_H diff --git a/detailview.c b/detailview.c index ec927c6..bfc3bd5 100644 --- a/detailview.c +++ b/detailview.c @@ -171,4 +171,4 @@ eOSState cDetailView::ProcessKey(eKeys Key) { break; } return state; -} \ No newline at end of file +} diff --git a/detailview.h b/detailview.h index 58f653e..7642257 100644 --- a/detailview.h +++ b/detailview.h @@ -25,4 +25,4 @@ public: eOSState ProcessKey(eKeys Key); }; -#endif //__TVGUIDE_DETAILVIEW_H \ No newline at end of file +#endif //__TVGUIDE_DETAILVIEW_H diff --git a/dummygrid.c b/dummygrid.c index 2ab9056..757848d 100644 --- a/dummygrid.c +++ b/dummygrid.c @@ -108,4 +108,4 @@ void cDummyGrid::debug() { viewportHeight, Duration()/60, active); -} \ No newline at end of file +} diff --git a/dummygrid.h b/dummygrid.h index f0837f6..6545785 100644 --- a/dummygrid.h +++ b/dummygrid.h @@ -31,4 +31,4 @@ public: void debug(); }; -#endif //__TVGUIDE_DUMMYGRID_H \ No newline at end of file +#endif //__TVGUIDE_DUMMYGRID_H diff --git a/epggrid.c b/epggrid.c index d3eb3bb..467b5fd 100644 --- a/epggrid.c +++ b/epggrid.c @@ -1,194 +1,194 @@ -#include "services/remotetimers.h" -#include "channelcolumn.h" -#include "tools.h" -#include "epggrid.h" - -cEpgGrid::cEpgGrid(cChannelColumn *c, const cEvent *event) : cGrid(c) { - this->event = event; - extText = new cTextWrapper(); - hasTimer = false; - SetTimer(); - hasSwitchTimer = false; - SetSwitchTimer(); - dummy = false; -} - -cEpgGrid::~cEpgGrid(void) { - delete extText; -} - -void cEpgGrid::SetViewportHeight() { - int viewportHeightOld = viewportHeight; - if ( column->Start() > StartTime() ) { - viewportHeight = (min((int)EndTime(), column->Stop()) - column->Start()) /60; - } else if ( column->Stop() < EndTime() ) { - viewportHeight = (column->Stop() - StartTime()) /60; - if (viewportHeight < 0) viewportHeight = 0; - } else { - viewportHeight = Duration() / 60; - } - viewportHeight *= geoManager.minutePixel; - if (viewportHeight != viewportHeightOld) - dirty = true; -} - -void cEpgGrid::PositionPixmap() { - if (tvguideConfig.displayMode == eVertical) { - int x0 = column->getX(); - int y0 = geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight; - if ( column->Start() < StartTime() ) { - y0 += (StartTime() - column->Start())/60*geoManager.minutePixel; - } - if (!pixmap) { - pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, geoManager.colWidth, viewportHeight), - cRect(0, 0, geoManager.colWidth, Duration()/60*geoManager.minutePixel)); - } else { - pixmap->SetViewPort(cRect(x0, y0, geoManager.colWidth, viewportHeight)); - } - } else if (tvguideConfig.displayMode == eHorizontal) { - int x0 = geoManager.channelHeaderWidth + geoManager.channelGroupsWidth; - int y0 = column->getY(); - if ( column->Start() < StartTime() ) { - x0 += (StartTime() - column->Start())/60*geoManager.minutePixel; - } - if (!pixmap) { - pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, viewportHeight, geoManager.rowHeight), - cRect(0, 0, Duration()/60*geoManager.minutePixel, geoManager.rowHeight)); - } else { - pixmap->SetViewPort(cRect(x0, y0, viewportHeight, geoManager.rowHeight )); - } - } - -} - -void cEpgGrid::SetTimer() { - hasTimer = false; - if (tvguideConfig.useRemoteTimers && pRemoteTimers) { - RemoteTimers_Event_v1_0 rt; - rt.event = event; - if (pRemoteTimers->Service("RemoteTimers::GetTimerByEvent-v1.0", &rt)) - hasTimer = true; -#if VDRVERSNUM >= 20301 - } else { - eTimerMatch TimerMatch = tmNone; - LOCK_TIMERS_READ; - const cTimers *timers = Timers; - if (timers->GetMatch(event, &TimerMatch) && (TimerMatch == tmFull)) - hasTimer = true; -#else - } else if (column->HasTimer()) { - hasTimer = event->HasTimer(); -#endif - } -} - -void cEpgGrid::SetSwitchTimer() { - if (column->HasSwitchTimer()) { - hasSwitchTimer = SwitchTimers.EventInSwitchList(event); - } else { - hasSwitchTimer = false; - } -} - -void cEpgGrid::setText() { - if (tvguideConfig.displayMode == eVertical) { - cString strText; - strText = cString::sprintf("%s - %s:\n%s", *(event->GetTimeString()), *(event->GetEndTimeString()), event->Title()); - text->Set(*(strText), fontManager.FontGrid, geoManager.colWidth-2*borderWidth); - extText->Set(event->ShortText(), fontManager.FontGridSmall, geoManager.colWidth-2*borderWidth); - } else if (tvguideConfig.displayMode == eHorizontal) { - timeString = cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString())); - } -} - -void cEpgGrid::drawText() { - tColor colorText = (active)?theme.Color(clrFontActive):theme.Color(clrFont); - tColor colorTextBack; - if (tvguideConfig.style == eStyleFlat) - colorTextBack = color; - else if (tvguideConfig.style == eStyleGraphical) - colorTextBack = (active)?theme.Color(clrGridActiveFontBack):theme.Color(clrGridFontBack); - else - colorTextBack = clrTransparent; - if (tvguideConfig.displayMode == eVertical) { - if (Height()/geoManager.minutePixel < 6) - return; - int textHeight = fontManager.FontGrid->Height(); - int textLines = text->Lines(); - for (int i=0; iDrawText(cPoint(borderWidth, borderWidth + i*textHeight), text->GetLine(i), colorText, colorTextBack, fontManager.FontGrid); - } - int extTextLines = extText->Lines(); - int offset = (textLines+1)*textHeight - 0.5*textHeight; - textHeight = fontManager.FontGridSmall->Height(); - if ((Height()-textHeight-10) > offset) { - for (int i=0; iDrawText(cPoint(borderWidth, borderWidth + offset + i*textHeight), extText->GetLine(i), colorText, colorTextBack, fontManager.FontGridSmall); - } - } - } else if (tvguideConfig.displayMode == eHorizontal) { - if (Width()/geoManager.minutePixel < 10) { - int titleY = (geoManager.rowHeight - fontManager.FontGridHorizontal->Height())/2; - pixmap->DrawText(cPoint(borderWidth - 2, titleY), "...", colorText, colorTextBack, fontManager.FontGridHorizontal); - return; - } - cString strTitle = CutText(event->Title(), viewportHeight, fontManager.FontGridHorizontal).c_str(); - int titleY = 0; - if (tvguideConfig.showTimeInGrid) { - pixmap->DrawText(cPoint(borderWidth, borderWidth), *timeString, colorText, colorTextBack, fontManager.FontGridHorizontalSmall); - titleY = fontManager.FontGridHorizontalSmall->Height() + (geoManager.rowHeight - fontManager.FontGridHorizontalSmall->Height() - fontManager.FontGridHorizontal->Height())/2; - } else { - titleY = (geoManager.rowHeight - fontManager.FontGridHorizontal->Height())/2; - } - pixmap->DrawText(cPoint(borderWidth, titleY), *strTitle, colorText, colorTextBack, fontManager.FontGridHorizontal); - } - if (hasSwitchTimer) - drawIcon("Switch", theme.Color(clrButtonYellow)); - if (hasTimer) { - const cTimer *timer = NULL; -#if VDRVERSNUM >= 20301 - { - LOCK_TIMERS_READ; - timer = Timers->GetMatch(event); - } -#else - timer = Timers.GetMatch(event); -#endif - if (timer) -#ifdef SWITCHONLYPATCH - if (timer->HasFlags(tfSwitchOnly)) - drawIcon("Switch", theme.Color(clrButtonYellow)); - else if (timer->HasFlags(tfActive)) -#else /* SWITCHONLY */ - if (timer->HasFlags(tfActive)) -#endif /* SWITCHONLY */ - drawIcon("REC", theme.Color(clrButtonRed)); - else - drawIcon("REC", theme.Color(clrButtonGreen)); - } -} - -void cEpgGrid::drawIcon(cString iconText, tColor color) { - - const cFont *font = (tvguideConfig.displayMode == eVertical) - ?fontManager.FontGrid - :fontManager.FontGridHorizontalSmall; - int textWidth = font->Width(*iconText)+2*borderWidth; - int textHeight = font->Height()+10; - pixmap->DrawRectangle( cRect(Width() - textWidth - borderWidth, Height() - textHeight - borderWidth, textWidth, textHeight), color); - pixmap->DrawText(cPoint(Width() - textWidth, Height() - textHeight - borderWidth/2), *iconText, theme.Color(clrFont), color, font); -} - -cString cEpgGrid::getTimeString(void) { - return cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString())); -} - -void cEpgGrid::debug() { - esyslog("tvguide epggrid: %s: %s, %s, viewportHeight: %d px, Duration: %d min, active: %d", - column->Name(), - *(event->GetTimeString()), - event->Title(), - viewportHeight, - event->Duration()/60, - active); -} +#include "services/remotetimers.h" +#include "channelcolumn.h" +#include "tools.h" +#include "epggrid.h" + +cEpgGrid::cEpgGrid(cChannelColumn *c, const cEvent *event) : cGrid(c) { + this->event = event; + extText = new cTextWrapper(); + hasTimer = false; + SetTimer(); + hasSwitchTimer = false; + SetSwitchTimer(); + dummy = false; +} + +cEpgGrid::~cEpgGrid(void) { + delete extText; +} + +void cEpgGrid::SetViewportHeight() { + int viewportHeightOld = viewportHeight; + if ( column->Start() > StartTime() ) { + viewportHeight = (min((int)EndTime(), column->Stop()) - column->Start()) /60; + } else if ( column->Stop() < EndTime() ) { + viewportHeight = (column->Stop() - StartTime()) /60; + if (viewportHeight < 0) viewportHeight = 0; + } else { + viewportHeight = Duration() / 60; + } + viewportHeight *= geoManager.minutePixel; + if (viewportHeight != viewportHeightOld) + dirty = true; +} + +void cEpgGrid::PositionPixmap() { + if (tvguideConfig.displayMode == eVertical) { + int x0 = column->getX(); + int y0 = geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight; + if ( column->Start() < StartTime() ) { + y0 += (StartTime() - column->Start())/60*geoManager.minutePixel; + } + if (!pixmap) { + pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, geoManager.colWidth, viewportHeight), + cRect(0, 0, geoManager.colWidth, Duration()/60*geoManager.minutePixel)); + } else { + pixmap->SetViewPort(cRect(x0, y0, geoManager.colWidth, viewportHeight)); + } + } else if (tvguideConfig.displayMode == eHorizontal) { + int x0 = geoManager.channelHeaderWidth + geoManager.channelGroupsWidth; + int y0 = column->getY(); + if ( column->Start() < StartTime() ) { + x0 += (StartTime() - column->Start())/60*geoManager.minutePixel; + } + if (!pixmap) { + pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, viewportHeight, geoManager.rowHeight), + cRect(0, 0, Duration()/60*geoManager.minutePixel, geoManager.rowHeight)); + } else { + pixmap->SetViewPort(cRect(x0, y0, viewportHeight, geoManager.rowHeight )); + } + } + +} + +void cEpgGrid::SetTimer() { + hasTimer = false; + if (tvguideConfig.useRemoteTimers && pRemoteTimers) { + RemoteTimers_Event_v1_0 rt; + rt.event = event; + if (pRemoteTimers->Service("RemoteTimers::GetTimerByEvent-v1.0", &rt)) + hasTimer = true; +#if VDRVERSNUM >= 20301 + } else { + eTimerMatch TimerMatch = tmNone; + LOCK_TIMERS_READ; + const cTimers *timers = Timers; + if (timers->GetMatch(event, &TimerMatch) && (TimerMatch == tmFull)) + hasTimer = true; +#else + } else if (column->HasTimer()) { + hasTimer = event->HasTimer(); +#endif + } +} + +void cEpgGrid::SetSwitchTimer() { + if (column->HasSwitchTimer()) { + hasSwitchTimer = SwitchTimers.EventInSwitchList(event); + } else { + hasSwitchTimer = false; + } +} + +void cEpgGrid::setText() { + if (tvguideConfig.displayMode == eVertical) { + cString strText; + strText = cString::sprintf("%s - %s:\n%s", *(event->GetTimeString()), *(event->GetEndTimeString()), event->Title()); + text->Set(*(strText), fontManager.FontGrid, geoManager.colWidth-2*borderWidth); + extText->Set(event->ShortText(), fontManager.FontGridSmall, geoManager.colWidth-2*borderWidth); + } else if (tvguideConfig.displayMode == eHorizontal) { + timeString = cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString())); + } +} + +void cEpgGrid::drawText() { + tColor colorText = (active)?theme.Color(clrFontActive):theme.Color(clrFont); + tColor colorTextBack; + if (tvguideConfig.style == eStyleFlat) + colorTextBack = color; + else if (tvguideConfig.style == eStyleGraphical) + colorTextBack = (active)?theme.Color(clrGridActiveFontBack):theme.Color(clrGridFontBack); + else + colorTextBack = clrTransparent; + if (tvguideConfig.displayMode == eVertical) { + if (Height()/geoManager.minutePixel < 6) + return; + int textHeight = fontManager.FontGrid->Height(); + int textLines = text->Lines(); + for (int i=0; iDrawText(cPoint(borderWidth, borderWidth + i*textHeight), text->GetLine(i), colorText, colorTextBack, fontManager.FontGrid); + } + int extTextLines = extText->Lines(); + int offset = (textLines+1)*textHeight - 0.5*textHeight; + textHeight = fontManager.FontGridSmall->Height(); + if ((Height()-textHeight-10) > offset) { + for (int i=0; iDrawText(cPoint(borderWidth, borderWidth + offset + i*textHeight), extText->GetLine(i), colorText, colorTextBack, fontManager.FontGridSmall); + } + } + } else if (tvguideConfig.displayMode == eHorizontal) { + if (Width()/geoManager.minutePixel < 10) { + int titleY = (geoManager.rowHeight - fontManager.FontGridHorizontal->Height())/2; + pixmap->DrawText(cPoint(borderWidth - 2, titleY), "...", colorText, colorTextBack, fontManager.FontGridHorizontal); + return; + } + cString strTitle = CutText(event->Title(), viewportHeight, fontManager.FontGridHorizontal).c_str(); + int titleY = 0; + if (tvguideConfig.showTimeInGrid) { + pixmap->DrawText(cPoint(borderWidth, borderWidth), *timeString, colorText, colorTextBack, fontManager.FontGridHorizontalSmall); + titleY = fontManager.FontGridHorizontalSmall->Height() + (geoManager.rowHeight - fontManager.FontGridHorizontalSmall->Height() - fontManager.FontGridHorizontal->Height())/2; + } else { + titleY = (geoManager.rowHeight - fontManager.FontGridHorizontal->Height())/2; + } + pixmap->DrawText(cPoint(borderWidth, titleY), *strTitle, colorText, colorTextBack, fontManager.FontGridHorizontal); + } + if (hasSwitchTimer) + drawIcon("Switch", theme.Color(clrButtonYellow)); + if (hasTimer) { + const cTimer *timer = NULL; +#if VDRVERSNUM >= 20301 + { + LOCK_TIMERS_READ; + timer = Timers->GetMatch(event); + } +#else + timer = Timers.GetMatch(event); +#endif + if (timer) +#ifdef SWITCHONLYPATCH + if (timer->HasFlags(tfSwitchOnly)) + drawIcon("Switch", theme.Color(clrButtonYellow)); + else if (timer->HasFlags(tfActive)) +#else /* SWITCHONLY */ + if (timer->HasFlags(tfActive)) +#endif /* SWITCHONLY */ + drawIcon("REC", theme.Color(clrButtonRed)); + else + drawIcon("REC", theme.Color(clrButtonGreen)); + } +} + +void cEpgGrid::drawIcon(cString iconText, tColor color) { + + const cFont *font = (tvguideConfig.displayMode == eVertical) + ?fontManager.FontGrid + :fontManager.FontGridHorizontalSmall; + int textWidth = font->Width(*iconText)+2*borderWidth; + int textHeight = font->Height()+10; + pixmap->DrawRectangle( cRect(Width() - textWidth - borderWidth, Height() - textHeight - borderWidth, textWidth, textHeight), color); + pixmap->DrawText(cPoint(Width() - textWidth, Height() - textHeight - borderWidth/2), *iconText, theme.Color(clrFont), color, font); +} + +cString cEpgGrid::getTimeString(void) { + return cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString())); +} + +void cEpgGrid::debug() { + esyslog("tvguide epggrid: %s: %s, %s, viewportHeight: %d px, Duration: %d min, active: %d", + column->Name(), + *(event->GetTimeString()), + event->Title(), + viewportHeight, + event->Duration()/60, + active); +} diff --git a/epggrid.h b/epggrid.h index 1333ef1..5f017ca 100644 --- a/epggrid.h +++ b/epggrid.h @@ -1,33 +1,33 @@ -#ifndef __TVGUIDE_EPGGRID_H -#define __TVGUIDE_EPGGRID_H - -#include -#include "grid.h" - -// --- cEpgGrid ------------------------------------------------------------- - -class cEpgGrid : public cGrid { -private: - const cTimer *timer; - const cEvent *event; - cTextWrapper *extText; - cString timeString; - void drawText(); - void drawIcon(cString iconText, tColor color); - time_t Duration(void) { return event->Duration(); }; -public: - cEpgGrid(cChannelColumn *c, const cEvent *event); - virtual ~cEpgGrid(void); - void SetViewportHeight(); - void PositionPixmap(); - void setText(void); - const cEvent *GetEvent() {return event;}; - time_t StartTime() { return event->StartTime(); }; - time_t EndTime() { return event->EndTime(); }; - void SetTimer(); - void SetSwitchTimer(); - cString getTimeString(void); - void debug(); -}; - -#endif //__TVGUIDE_EPGGRID_H +#ifndef __TVGUIDE_EPGGRID_H +#define __TVGUIDE_EPGGRID_H + +#include +#include "grid.h" + +// --- cEpgGrid ------------------------------------------------------------- + +class cEpgGrid : public cGrid { +private: + const cTimer *timer; + const cEvent *event; + cTextWrapper *extText; + cString timeString; + void drawText(); + void drawIcon(cString iconText, tColor color); + time_t Duration(void) { return event->Duration(); }; +public: + cEpgGrid(cChannelColumn *c, const cEvent *event); + virtual ~cEpgGrid(void); + void SetViewportHeight(); + void PositionPixmap(); + void setText(void); + const cEvent *GetEvent() {return event;}; + time_t StartTime() { return event->StartTime(); }; + time_t EndTime() { return event->EndTime(); }; + void SetTimer(); + void SetSwitchTimer(); + cString getTimeString(void); + void debug(); +}; + +#endif //__TVGUIDE_EPGGRID_H diff --git a/fontmanager.c b/fontmanager.c index b55621a..ced4879 100644 --- a/fontmanager.c +++ b/fontmanager.c @@ -1,96 +1,96 @@ -#include "geometrymanager.h" -#include "config.h" -#include "fontmanager.h" - -cFontManager::cFontManager() { -} - -cFontManager::~cFontManager() { - DeleteFonts(); -} - -void cFontManager::SetFonts() { - InitialiseFontType(); - //Common Fonts - FontButton = CreateFont(geoManager.footerHeight/3 + 4 + tvguideConfig.FontButtonDelta); - FontDetailView = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontDetailViewDelta); - FontDetailViewSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontDetailViewSmallDelta); - FontDetailHeader = CreateFont(geoManager.osdHeight/27 + tvguideConfig.FontDetailHeaderDelta); - FontDetailHeaderLarge = CreateFont(geoManager.osdHeight/20 + tvguideConfig.FontDetailHeaderDelta); - FontMessageBox = CreateFont(geoManager.osdHeight/33 + tvguideConfig.FontMessageBoxDelta); - FontMessageBoxLarge = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontMessageBoxLargeDelta); - FontStatusHeader = CreateFont(geoManager.statusHeaderHeight/6 - 4 + tvguideConfig.FontStatusHeaderDelta); - FontStatusHeaderLarge = CreateFont(geoManager.statusHeaderHeight/5 + tvguideConfig.FontStatusHeaderLargeDelta); - //Fonts for vertical Display - FontChannelHeader = CreateFont(geoManager.colWidth/10 + tvguideConfig.FontChannelHeaderDelta); - FontChannelGroups = CreateFont(geoManager.colWidth/8 + tvguideConfig.FontChannelGroupsDelta); - FontGrid = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridDelta); - FontGridSmall = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridSmallDelta); - FontTimeLineWeekday = CreateFont(geoManager.timeLineWidth/3 + tvguideConfig.FontTimeLineWeekdayDelta); - FontTimeLineDate = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineDateDelta); - FontTimeLineTime = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineTimeDelta); - //Fonts for horizontal Display - FontChannelHeaderHorizontal = CreateFont(geoManager.rowHeight/3 + tvguideConfig.FontChannelHeaderHorizontalDelta); - FontChannelGroupsHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontChannelGroupsHorizontalDelta); - FontGridHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontGridHorizontalDelta); - FontGridHorizontalSmall = CreateFont(geoManager.rowHeight/4 + tvguideConfig.FontGridHorizontalSmallDelta); - FontTimeLineDateHorizontal = CreateFont(geoManager.timeLineHeight/2 + 5 + tvguideConfig.FontTimeLineDateHorizontalDelta); - FontTimeLineTimeHorizontal = CreateFont(geoManager.timeLineHeight/2 + tvguideConfig.FontTimeLineTimeHorizontalDelta); - //Fonts for RecMenu - FontRecMenuItem = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontRecMenuItemDelta); - FontRecMenuItemSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontRecMenuItemSmallDelta); - FontRecMenuItemLarge = CreateFont(geoManager.osdHeight/25 + tvguideConfig.FontRecMenuItemLargeDelta); -} - -void cFontManager::DeleteFonts() { - delete FontButton; - delete FontDetailView; - delete FontDetailViewSmall; - delete FontDetailHeader; - delete FontDetailHeaderLarge; - delete FontMessageBox; - delete FontMessageBoxLarge; - delete FontStatusHeader; - delete FontStatusHeaderLarge; - delete FontChannelHeader; - delete FontChannelGroups; - delete FontGrid; - delete FontGridSmall; - delete FontTimeLineWeekday; - delete FontTimeLineDate; - delete FontTimeLineTime; - delete FontChannelHeaderHorizontal; - delete FontChannelGroupsHorizontal; - delete FontGridHorizontal; - delete FontGridHorizontalSmall; - delete FontTimeLineDateHorizontal; - delete FontTimeLineTimeHorizontal; - delete FontRecMenuItem; - delete FontRecMenuItemSmall; - delete FontRecMenuItemLarge; -} - -void cFontManager::InitialiseFontType(void) { - if (tvguideConfig.fontIndex == 0) { - fontName = tvguideConfig.fontNameDefault; - } else { - cStringList availableFonts; - cFont::GetAvailableFontNames(&availableFonts); - if (availableFonts[tvguideConfig.fontIndex-1]) { - fontName = availableFonts[tvguideConfig.fontIndex-1]; - } else - fontName = tvguideConfig.fontNameDefault; - } - cFont *test = NULL; - test = cFont::CreateFont(*fontName, 30); - if (!test) { - fontName = DefaultFontSml; - } - delete test; - esyslog("tvguide: Set Font to %s", *fontName); -} - -cFont *cFontManager::CreateFont(int size) { - return cFont::CreateFont(*fontName, size); -} - +#include "geometrymanager.h" +#include "config.h" +#include "fontmanager.h" + +cFontManager::cFontManager() { +} + +cFontManager::~cFontManager() { + DeleteFonts(); +} + +void cFontManager::SetFonts() { + InitialiseFontType(); + //Common Fonts + FontButton = CreateFont(geoManager.footerHeight/3 + 4 + tvguideConfig.FontButtonDelta); + FontDetailView = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontDetailViewDelta); + FontDetailViewSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontDetailViewSmallDelta); + FontDetailHeader = CreateFont(geoManager.osdHeight/27 + tvguideConfig.FontDetailHeaderDelta); + FontDetailHeaderLarge = CreateFont(geoManager.osdHeight/20 + tvguideConfig.FontDetailHeaderDelta); + FontMessageBox = CreateFont(geoManager.osdHeight/33 + tvguideConfig.FontMessageBoxDelta); + FontMessageBoxLarge = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontMessageBoxLargeDelta); + FontStatusHeader = CreateFont(geoManager.statusHeaderHeight/6 - 4 + tvguideConfig.FontStatusHeaderDelta); + FontStatusHeaderLarge = CreateFont(geoManager.statusHeaderHeight/5 + tvguideConfig.FontStatusHeaderLargeDelta); + //Fonts for vertical Display + FontChannelHeader = CreateFont(geoManager.colWidth/10 + tvguideConfig.FontChannelHeaderDelta); + FontChannelGroups = CreateFont(geoManager.colWidth/8 + tvguideConfig.FontChannelGroupsDelta); + FontGrid = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridDelta); + FontGridSmall = CreateFont(geoManager.colWidth/12 + tvguideConfig.FontGridSmallDelta); + FontTimeLineWeekday = CreateFont(geoManager.timeLineWidth/3 + tvguideConfig.FontTimeLineWeekdayDelta); + FontTimeLineDate = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineDateDelta); + FontTimeLineTime = CreateFont(geoManager.timeLineWidth/4 + tvguideConfig.FontTimeLineTimeDelta); + //Fonts for horizontal Display + FontChannelHeaderHorizontal = CreateFont(geoManager.rowHeight/3 + tvguideConfig.FontChannelHeaderHorizontalDelta); + FontChannelGroupsHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontChannelGroupsHorizontalDelta); + FontGridHorizontal = CreateFont(geoManager.rowHeight/3 + 5 + tvguideConfig.FontGridHorizontalDelta); + FontGridHorizontalSmall = CreateFont(geoManager.rowHeight/4 + tvguideConfig.FontGridHorizontalSmallDelta); + FontTimeLineDateHorizontal = CreateFont(geoManager.timeLineHeight/2 + 5 + tvguideConfig.FontTimeLineDateHorizontalDelta); + FontTimeLineTimeHorizontal = CreateFont(geoManager.timeLineHeight/2 + tvguideConfig.FontTimeLineTimeHorizontalDelta); + //Fonts for RecMenu + FontRecMenuItem = CreateFont(geoManager.osdHeight/30 + tvguideConfig.FontRecMenuItemDelta); + FontRecMenuItemSmall = CreateFont(geoManager.osdHeight/40 + tvguideConfig.FontRecMenuItemSmallDelta); + FontRecMenuItemLarge = CreateFont(geoManager.osdHeight/25 + tvguideConfig.FontRecMenuItemLargeDelta); +} + +void cFontManager::DeleteFonts() { + delete FontButton; + delete FontDetailView; + delete FontDetailViewSmall; + delete FontDetailHeader; + delete FontDetailHeaderLarge; + delete FontMessageBox; + delete FontMessageBoxLarge; + delete FontStatusHeader; + delete FontStatusHeaderLarge; + delete FontChannelHeader; + delete FontChannelGroups; + delete FontGrid; + delete FontGridSmall; + delete FontTimeLineWeekday; + delete FontTimeLineDate; + delete FontTimeLineTime; + delete FontChannelHeaderHorizontal; + delete FontChannelGroupsHorizontal; + delete FontGridHorizontal; + delete FontGridHorizontalSmall; + delete FontTimeLineDateHorizontal; + delete FontTimeLineTimeHorizontal; + delete FontRecMenuItem; + delete FontRecMenuItemSmall; + delete FontRecMenuItemLarge; +} + +void cFontManager::InitialiseFontType(void) { + if (tvguideConfig.fontIndex == 0) { + fontName = tvguideConfig.fontNameDefault; + } else { + cStringList availableFonts; + cFont::GetAvailableFontNames(&availableFonts); + if (availableFonts[tvguideConfig.fontIndex-1]) { + fontName = availableFonts[tvguideConfig.fontIndex-1]; + } else + fontName = tvguideConfig.fontNameDefault; + } + cFont *test = NULL; + test = cFont::CreateFont(*fontName, 30); + if (!test) { + fontName = DefaultFontSml; + } + delete test; + esyslog("tvguide: Set Font to %s", *fontName); +} + +cFont *cFontManager::CreateFont(int size) { + return cFont::CreateFont(*fontName, size); +} + diff --git a/fontmanager.h b/fontmanager.h index 7253043..9191d25 100644 --- a/fontmanager.h +++ b/fontmanager.h @@ -1,41 +1,41 @@ -#ifndef __TVGUIDE_FONTMANAGER_H -#define __TVGUIDE_FONTMANAGER_H - -#include - -class cFontManager { - cString fontName; - void InitialiseFontType(void); - cFont *CreateFont(int size); - public: - cFontManager(); - ~cFontManager(); - void SetFonts(void); - void DeleteFonts(void); - cFont *FontChannelHeader; - cFont *FontChannelHeaderHorizontal; - cFont *FontChannelGroups; - cFont *FontChannelGroupsHorizontal; - cFont *FontStatusHeader; - cFont *FontStatusHeaderLarge; - cFont *FontGrid; - cFont *FontGridSmall; - cFont *FontGridHorizontal; - cFont *FontGridHorizontalSmall; - cFont *FontTimeLineWeekday; - cFont *FontTimeLineDate; - cFont *FontTimeLineDateHorizontal; - cFont *FontTimeLineTime; - cFont *FontTimeLineTimeHorizontal; - cFont *FontButton; - cFont *FontDetailView; - cFont *FontDetailViewSmall; - cFont *FontDetailHeader; - cFont *FontDetailHeaderLarge; - cFont *FontMessageBox; - cFont *FontMessageBoxLarge; - cFont *FontRecMenuItem; - cFont *FontRecMenuItemSmall; - cFont *FontRecMenuItemLarge; -}; -#endif //__TVGUIDE_FONTMANAGER_H \ No newline at end of file +#ifndef __TVGUIDE_FONTMANAGER_H +#define __TVGUIDE_FONTMANAGER_H + +#include + +class cFontManager { + cString fontName; + void InitialiseFontType(void); + cFont *CreateFont(int size); + public: + cFontManager(); + ~cFontManager(); + void SetFonts(void); + void DeleteFonts(void); + cFont *FontChannelHeader; + cFont *FontChannelHeaderHorizontal; + cFont *FontChannelGroups; + cFont *FontChannelGroupsHorizontal; + cFont *FontStatusHeader; + cFont *FontStatusHeaderLarge; + cFont *FontGrid; + cFont *FontGridSmall; + cFont *FontGridHorizontal; + cFont *FontGridHorizontalSmall; + cFont *FontTimeLineWeekday; + cFont *FontTimeLineDate; + cFont *FontTimeLineDateHorizontal; + cFont *FontTimeLineTime; + cFont *FontTimeLineTimeHorizontal; + cFont *FontButton; + cFont *FontDetailView; + cFont *FontDetailViewSmall; + cFont *FontDetailHeader; + cFont *FontDetailHeaderLarge; + cFont *FontMessageBox; + cFont *FontMessageBoxLarge; + cFont *FontRecMenuItem; + cFont *FontRecMenuItemSmall; + cFont *FontRecMenuItemLarge; +}; +#endif //__TVGUIDE_FONTMANAGER_H diff --git a/footer.c b/footer.c index 7a5b9e5..7c51ff7 100644 --- a/footer.c +++ b/footer.c @@ -1,167 +1,167 @@ -#include -#include "imageloader.h" -#include "tools.h" -#include "footer.h" - -cFooter::cFooter(cChannelGroups *channelGroups) { - this->channelGroups = channelGroups; - currentGroup = -1; - buttonY = (geoManager.footerHeight - geoManager.buttonHeight)/2; - SetButtonPositions(); - footer = osdManager.requestPixmap(2, cRect( 0, - geoManager.footerY, - geoManager.osdWidth, - geoManager.footerHeight), - cRect::Null); - footer->Fill(clrTransparent); -} - -cFooter::~cFooter(void) { - osdManager.releasePixmap(footer); -} - -void cFooter::drawRedButton() { - cString text(tr("Search & Rec")); - DrawButton(*text, theme.Color(clrButtonRed), theme.Color(clrButtonRedBorder), oeButtonRed, positionButtons[0]); -} - -void cFooter::drawGreenButton() { - cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels back")); - DrawButton(*text, theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]); -} - -void cFooter::drawGreenButton(const char *text) { - std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton); - DrawButton(cuttedText.c_str(), theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]); -} - -void cFooter::drawYellowButton() { - cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels forward")); - DrawButton(*text, theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]); -} - -void cFooter::drawYellowButton(const char *text) { - std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton); - DrawButton(cuttedText.c_str(), theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]); -} - -void cFooter::drawBlueButton(bool detailedEPG) { - cString text; - if (tvguideConfig.blueKeyMode == eBlueKeySwitch) - text = tr("Switch to Channel"); - else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { - if (!detailedEPG) - text = tr("Detailed EPG"); - else - text = tr("Close detailed EPG"); - } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { - if (!detailedEPG) - text = tr("Favorites"); - else - text = tr("Switch to Channel"); - } - DrawButton(*text, theme.Color(clrButtonBlue), theme.Color(clrButtonBlueBorder), oeButtonBlue, positionButtons[3]); -} - -void cFooter::UpdateGroupButtons(const cChannel *channel, bool force) { - if (!channel) - return; - int group = channelGroups->GetGroup(channel); - if ((group != currentGroup) || force) { - currentGroup = group; - drawGreenButton(channelGroups->GetPrev(group)); - drawYellowButton(channelGroups->GetNext(group)); - } -} - -void cFooter::SetDetailedViewMode(bool fromRecMenu) { - ClearButton(positionButtons[1]); - ClearButton(positionButtons[2]); - if (fromRecMenu) { - ClearButton(positionButtons[0]); - ClearButton(positionButtons[3]); - } else if (tvguideConfig.blueKeyMode != eBlueKeySwitch) { - ClearButton(positionButtons[3]); - drawBlueButton(true); - } -} - -void cFooter::LeaveDetailedViewMode(const cChannel *channel) { - drawRedButton(); - drawBlueButton(); - if (tvguideConfig.channelJumpMode == eNumJump) { - drawGreenButton(); - drawYellowButton(); - } else { - UpdateGroupButtons(channel, true); - } -} - -void cFooter::SetButtonPositions(void) { - for (int i=0; i < 4; i++) { - positionButtons[i] = -1; - } - /* - red button = 0 - green button = 1 - yellow button = 2 - blue button = 3 - */ - for (int button=0; button<4; button++) { - if (Setup.ColorKey0 == button) { - positionButtons[button] = 0; - continue; - } - if (Setup.ColorKey1 == button) { - positionButtons[button] = 1; - continue; - } - if (Setup.ColorKey2 == button) { - positionButtons[button] = 2; - continue; - } - if (Setup.ColorKey3 == button) { - positionButtons[button] = 3; - continue; - } - } -} - -void cFooter::DrawButton(const char *text, tColor color, tColor borderColor, eOsdElementType buttonType, int num) { - tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; - int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder; - - if ((tvguideConfig.style == eStyleBlendingMagick) || (tvguideConfig.style == eStyleBlendingDefault)) { - cImageLoader imgLoader; - imgLoader.DrawBackground(theme.Color(clrButtonBlend), color, geoManager.buttonWidth-4, geoManager.buttonHeight-4); - footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor); - footer->DrawImage(cPoint(left+2, buttonY+2), imgLoader.GetImage()); - if (tvguideConfig.roundedCorners) { - int borderRadius = 12; - int borderWidth = 2; - DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor); - } - } else if (tvguideConfig.style == eStyleGraphical) { - cImage *button = imgCache.GetOsdElement(buttonType); - if (button) { - footer->DrawImage(cPoint(left, buttonY), *button); - } - } else { - footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor); - footer->DrawRectangle(cRect(left+1, buttonY+1, geoManager.buttonWidth-2, geoManager.buttonHeight-2), color); - if (tvguideConfig.roundedCorners) { - int borderRadius = 12; - int borderWidth = 1; - DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor); - } - } - - int textWidth = fontManager.FontButton->Width(text); - int textHeight = fontManager.FontButton->Height(); - footer->DrawText(cPoint(left + (geoManager.buttonWidth-textWidth)/2, buttonY + (geoManager.buttonHeight-textHeight)/2), text, theme.Color(clrFontButtons), colorTextBack, fontManager.FontButton); -} - -void cFooter::ClearButton(int num) { - int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder; - footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), clrTransparent); -} \ No newline at end of file +#include +#include "imageloader.h" +#include "tools.h" +#include "footer.h" + +cFooter::cFooter(cChannelGroups *channelGroups) { + this->channelGroups = channelGroups; + currentGroup = -1; + buttonY = (geoManager.footerHeight - geoManager.buttonHeight)/2; + SetButtonPositions(); + footer = osdManager.requestPixmap(2, cRect( 0, + geoManager.footerY, + geoManager.osdWidth, + geoManager.footerHeight), + cRect::Null); + footer->Fill(clrTransparent); +} + +cFooter::~cFooter(void) { + osdManager.releasePixmap(footer); +} + +void cFooter::drawRedButton() { + cString text(tr("Search & Rec")); + DrawButton(*text, theme.Color(clrButtonRed), theme.Color(clrButtonRedBorder), oeButtonRed, positionButtons[0]); +} + +void cFooter::drawGreenButton() { + cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels back")); + DrawButton(*text, theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]); +} + +void cFooter::drawGreenButton(const char *text) { + std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton); + DrawButton(cuttedText.c_str(), theme.Color(clrButtonGreen), theme.Color(clrButtonGreenBorder), oeButtonGreen, positionButtons[1]); +} + +void cFooter::drawYellowButton() { + cString text = cString::sprintf("%d %s", tvguideConfig.jumpChannels, tr("Channels forward")); + DrawButton(*text, theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]); +} + +void cFooter::drawYellowButton(const char *text) { + std::string cuttedText = CutText(text, geoManager.buttonWidth-6, fontManager.FontButton); + DrawButton(cuttedText.c_str(), theme.Color(clrButtonYellow), theme.Color(clrButtonYellowBorder), oeButtonYellow, positionButtons[2]); +} + +void cFooter::drawBlueButton(bool detailedEPG) { + cString text; + if (tvguideConfig.blueKeyMode == eBlueKeySwitch) + text = tr("Switch to Channel"); + else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { + if (!detailedEPG) + text = tr("Detailed EPG"); + else + text = tr("Close detailed EPG"); + } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { + if (!detailedEPG) + text = tr("Favorites"); + else + text = tr("Switch to Channel"); + } + DrawButton(*text, theme.Color(clrButtonBlue), theme.Color(clrButtonBlueBorder), oeButtonBlue, positionButtons[3]); +} + +void cFooter::UpdateGroupButtons(const cChannel *channel, bool force) { + if (!channel) + return; + int group = channelGroups->GetGroup(channel); + if ((group != currentGroup) || force) { + currentGroup = group; + drawGreenButton(channelGroups->GetPrev(group)); + drawYellowButton(channelGroups->GetNext(group)); + } +} + +void cFooter::SetDetailedViewMode(bool fromRecMenu) { + ClearButton(positionButtons[1]); + ClearButton(positionButtons[2]); + if (fromRecMenu) { + ClearButton(positionButtons[0]); + ClearButton(positionButtons[3]); + } else if (tvguideConfig.blueKeyMode != eBlueKeySwitch) { + ClearButton(positionButtons[3]); + drawBlueButton(true); + } +} + +void cFooter::LeaveDetailedViewMode(const cChannel *channel) { + drawRedButton(); + drawBlueButton(); + if (tvguideConfig.channelJumpMode == eNumJump) { + drawGreenButton(); + drawYellowButton(); + } else { + UpdateGroupButtons(channel, true); + } +} + +void cFooter::SetButtonPositions(void) { + for (int i=0; i < 4; i++) { + positionButtons[i] = -1; + } + /* + red button = 0 + green button = 1 + yellow button = 2 + blue button = 3 + */ + for (int button=0; button<4; button++) { + if (Setup.ColorKey0 == button) { + positionButtons[button] = 0; + continue; + } + if (Setup.ColorKey1 == button) { + positionButtons[button] = 1; + continue; + } + if (Setup.ColorKey2 == button) { + positionButtons[button] = 2; + continue; + } + if (Setup.ColorKey3 == button) { + positionButtons[button] = 3; + continue; + } + } +} + +void cFooter::DrawButton(const char *text, tColor color, tColor borderColor, eOsdElementType buttonType, int num) { + tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; + int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder; + + if ((tvguideConfig.style == eStyleBlendingMagick) || (tvguideConfig.style == eStyleBlendingDefault)) { + cImageLoader imgLoader; + imgLoader.DrawBackground(theme.Color(clrButtonBlend), color, geoManager.buttonWidth-4, geoManager.buttonHeight-4); + footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor); + footer->DrawImage(cPoint(left+2, buttonY+2), imgLoader.GetImage()); + if (tvguideConfig.roundedCorners) { + int borderRadius = 12; + int borderWidth = 2; + DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor); + } + } else if (tvguideConfig.style == eStyleGraphical) { + cImage *button = imgCache.GetOsdElement(buttonType); + if (button) { + footer->DrawImage(cPoint(left, buttonY), *button); + } + } else { + footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), borderColor); + footer->DrawRectangle(cRect(left+1, buttonY+1, geoManager.buttonWidth-2, geoManager.buttonHeight-2), color); + if (tvguideConfig.roundedCorners) { + int borderRadius = 12; + int borderWidth = 1; + DrawRoundedCorners(footer, left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight, borderRadius, borderWidth, borderColor); + } + } + + int textWidth = fontManager.FontButton->Width(text); + int textHeight = fontManager.FontButton->Height(); + footer->DrawText(cPoint(left + (geoManager.buttonWidth-textWidth)/2, buttonY + (geoManager.buttonHeight-textHeight)/2), text, theme.Color(clrFontButtons), colorTextBack, fontManager.FontButton); +} + +void cFooter::ClearButton(int num) { + int left = num * geoManager.buttonWidth + (2 * num + 1) * geoManager.buttonBorder; + footer->DrawRectangle(cRect(left, buttonY, geoManager.buttonWidth, geoManager.buttonHeight), clrTransparent); +} diff --git a/footer.h b/footer.h index e923476..15fbf6a 100644 --- a/footer.h +++ b/footer.h @@ -30,4 +30,4 @@ public: void LeaveDetailedViewMode(const cChannel *channel); }; -#endif //__TVGUIDE_FOOTER_H \ No newline at end of file +#endif //__TVGUIDE_FOOTER_H diff --git a/geometrymanager.c b/geometrymanager.c index b8779a1..35da932 100644 --- a/geometrymanager.c +++ b/geometrymanager.c @@ -1,76 +1,76 @@ -#include - -#include "config.h" -#include "geometrymanager.h" - -cGeometryManager::cGeometryManager() { - osdWidth = 0; - osdHeight = 0; -} - -cGeometryManager::~cGeometryManager() { -} - -bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) { - if (!force && (this->osdWidth == osdWidth) && (this->osdHeight == osdHeight)) { - esyslog("tvgudie: GeoManager SetGeometry nothing to change"); - return false; - } - this->osdWidth = osdWidth; - this->osdHeight = osdHeight; - esyslog("tvguide: Set OSD to %d x %d px", osdWidth, osdHeight); - - statusHeaderHeight = (tvguideConfig.displayStatusHeader)?(tvguideConfig.headerHeightPercent * osdHeight / 100):0; - tvFrameWidth = statusHeaderHeight * 16 / 9; - headerContentWidth = (tvguideConfig.scaleVideo)?(osdWidth - tvFrameWidth):osdWidth; - channelGroupsWidth = (tvguideConfig.displayChannelGroups)?(tvguideConfig.channelGroupsPercent * osdWidth / 100):0; - channelGroupsHeight = (tvguideConfig.displayChannelGroups)?(tvguideConfig.channelGroupsPercent * osdHeight / 100):0; - channelHeaderWidth = tvguideConfig.channelHeaderWidthPercent * osdWidth / 100; - channelHeaderHeight = tvguideConfig.channelHeaderHeightPercent * osdHeight / 100; - timeLineWidth = tvguideConfig.timeLineWidthPercent * osdWidth / 100; - timeLineHeight = tvguideConfig.timeLineHeightPercent * osdHeight / 100; - footerHeight = tvguideConfig.footerHeightPercent * osdHeight / 100; - footerY = osdHeight - footerHeight; - - if (tvguideConfig.displayMode == eVertical) { - colWidth = (osdWidth - timeLineWidth) / tvguideConfig.channelCols; - rowHeight = 0; - minutePixel = (osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / tvguideConfig.displayTime; - channelLogoWidth = colWidth; - channelLogoHeight = channelHeaderHeight; - logoWidth = channelLogoWidth/2 - 15; - logoHeight = logoWidth * tvguideConfig.logoHeightRatio / tvguideConfig.logoWidthRatio; - timeLineGridWidth = timeLineWidth; - timeLineGridHeight = minutePixel * 30; - dateVieverWidth = timeLineWidth; - dateVieverHeight = (channelHeaderHeight + channelGroupsHeight) * 2 / 3; - clockWidth = dateVieverWidth; - clockHeight = (channelHeaderHeight + channelGroupsHeight) - dateVieverHeight; - } else if (tvguideConfig.displayMode == eHorizontal) { - colWidth = 0; - rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / tvguideConfig.channelRows; - minutePixel = (osdWidth - channelHeaderWidth - channelGroupsWidth) / tvguideConfig.displayHorizontalTime; - channelLogoWidth = channelHeaderWidth; - channelLogoHeight = rowHeight; - logoWidth = channelLogoHeight * tvguideConfig.logoWidthRatio / tvguideConfig.logoHeightRatio; - logoHeight = channelLogoHeight; - timeLineGridWidth = geoManager.minutePixel * 30; - timeLineGridHeight = geoManager.timeLineHeight; - dateVieverWidth = (channelHeaderWidth + channelGroupsWidth) * 3 / 5; - dateVieverHeight = timeLineHeight; - clockWidth = (channelHeaderWidth + channelGroupsWidth) - dateVieverWidth; - clockHeight = timeLineHeight; - } - buttonBorder = footerHeight / 6; - buttonWidth = osdWidth / 4 - 2 * buttonBorder; - buttonHeight = footerHeight - 3 * buttonBorder; - - epgViewHeaderHeight = tvguideConfig.headerHeightPercent * osdHeight / 100; - - borderRecMenus = 10; - - channelJumpWidth = osdWidth * 30 / 100; - channelJumpHeight = osdHeight * 20 / 100; - - return true; -} +#include + +#include "config.h" +#include "geometrymanager.h" + +cGeometryManager::cGeometryManager() { + osdWidth = 0; + osdHeight = 0; +} + +cGeometryManager::~cGeometryManager() { +} + +bool cGeometryManager::SetGeometry(int osdWidth, int osdHeight, bool force) { + if (!force && (this->osdWidth == osdWidth) && (this->osdHeight == osdHeight)) { + esyslog("tvgudie: GeoManager SetGeometry nothing to change"); + return false; + } + this->osdWidth = osdWidth; + this->osdHeight = osdHeight; + esyslog("tvguide: Set OSD to %d x %d px", osdWidth, osdHeight); + + statusHeaderHeight = (tvguideConfig.displayStatusHeader)?(tvguideConfig.headerHeightPercent * osdHeight / 100):0; + tvFrameWidth = statusHeaderHeight * 16 / 9; + headerContentWidth = (tvguideConfig.scaleVideo)?(osdWidth - tvFrameWidth):osdWidth; + channelGroupsWidth = (tvguideConfig.displayChannelGroups)?(tvguideConfig.channelGroupsPercent * osdWidth / 100):0; + channelGroupsHeight = (tvguideConfig.displayChannelGroups)?(tvguideConfig.channelGroupsPercent * osdHeight / 100):0; + channelHeaderWidth = tvguideConfig.channelHeaderWidthPercent * osdWidth / 100; + channelHeaderHeight = tvguideConfig.channelHeaderHeightPercent * osdHeight / 100; + timeLineWidth = tvguideConfig.timeLineWidthPercent * osdWidth / 100; + timeLineHeight = tvguideConfig.timeLineHeightPercent * osdHeight / 100; + footerHeight = tvguideConfig.footerHeightPercent * osdHeight / 100; + footerY = osdHeight - footerHeight; + + if (tvguideConfig.displayMode == eVertical) { + colWidth = (osdWidth - timeLineWidth) / tvguideConfig.channelCols; + rowHeight = 0; + minutePixel = (osdHeight - statusHeaderHeight - channelGroupsHeight - channelHeaderHeight - footerHeight) / tvguideConfig.displayTime; + channelLogoWidth = colWidth; + channelLogoHeight = channelHeaderHeight; + logoWidth = channelLogoWidth/2 - 15; + logoHeight = logoWidth * tvguideConfig.logoHeightRatio / tvguideConfig.logoWidthRatio; + timeLineGridWidth = timeLineWidth; + timeLineGridHeight = minutePixel * 30; + dateVieverWidth = timeLineWidth; + dateVieverHeight = (channelHeaderHeight + channelGroupsHeight) * 2 / 3; + clockWidth = dateVieverWidth; + clockHeight = (channelHeaderHeight + channelGroupsHeight) - dateVieverHeight; + } else if (tvguideConfig.displayMode == eHorizontal) { + colWidth = 0; + rowHeight = (osdHeight - statusHeaderHeight - timeLineHeight - footerHeight) / tvguideConfig.channelRows; + minutePixel = (osdWidth - channelHeaderWidth - channelGroupsWidth) / tvguideConfig.displayHorizontalTime; + channelLogoWidth = channelHeaderWidth; + channelLogoHeight = rowHeight; + logoWidth = channelLogoHeight * tvguideConfig.logoWidthRatio / tvguideConfig.logoHeightRatio; + logoHeight = channelLogoHeight; + timeLineGridWidth = geoManager.minutePixel * 30; + timeLineGridHeight = geoManager.timeLineHeight; + dateVieverWidth = (channelHeaderWidth + channelGroupsWidth) * 3 / 5; + dateVieverHeight = timeLineHeight; + clockWidth = (channelHeaderWidth + channelGroupsWidth) - dateVieverWidth; + clockHeight = timeLineHeight; + } + buttonBorder = footerHeight / 6; + buttonWidth = osdWidth / 4 - 2 * buttonBorder; + buttonHeight = footerHeight - 3 * buttonBorder; + + epgViewHeaderHeight = tvguideConfig.headerHeightPercent * osdHeight / 100; + + borderRecMenus = 10; + + channelJumpWidth = osdWidth * 30 / 100; + channelJumpHeight = osdHeight * 20 / 100; + + return true; +} diff --git a/geometrymanager.h b/geometrymanager.h index c0433d4..04e395b 100644 --- a/geometrymanager.h +++ b/geometrymanager.h @@ -1,54 +1,54 @@ -#ifndef __TVGUIDE_GEOMETRYMANAGER_H -#define __TVGUIDE_GEOMETRYMANAGER_H - -class cGeometryManager { -private: -public: - cGeometryManager(void); - ~cGeometryManager(); - bool SetGeometry(int osdWidth, int osdHeight, bool force = false); - //Common - int osdWidth; - int osdHeight; - int statusHeaderHeight; - int tvFrameWidth; - int headerContentWidth; - //ChannelGroups - int channelGroupsWidth; - int channelGroupsHeight; - //ContentHeader - int channelHeaderWidth; - int channelHeaderHeight; - int logoWidth; - int logoHeight; - //Content - int colWidth; - int rowHeight; - int minutePixel; - int channelLogoWidth; - int channelLogoHeight; - //Timeline - int timeLineWidth; - int timeLineHeight; - int timeLineGridWidth; - int timeLineGridHeight; - int dateVieverWidth; - int dateVieverHeight; - int clockWidth; - int clockHeight; - //Footer - int footerY; - int footerHeight; - int buttonWidth; - int buttonHeight; - int buttonBorder; - //Detailed EPG View - int epgViewHeaderHeight; - //Recording Menus - int borderRecMenus; - //Channel Jump - int channelJumpWidth; - int channelJumpHeight; -}; - -#endif //__TVGUIDE_GEOMETRYMANAGER_H +#ifndef __TVGUIDE_GEOMETRYMANAGER_H +#define __TVGUIDE_GEOMETRYMANAGER_H + +class cGeometryManager { +private: +public: + cGeometryManager(void); + ~cGeometryManager(); + bool SetGeometry(int osdWidth, int osdHeight, bool force = false); + //Common + int osdWidth; + int osdHeight; + int statusHeaderHeight; + int tvFrameWidth; + int headerContentWidth; + //ChannelGroups + int channelGroupsWidth; + int channelGroupsHeight; + //ContentHeader + int channelHeaderWidth; + int channelHeaderHeight; + int logoWidth; + int logoHeight; + //Content + int colWidth; + int rowHeight; + int minutePixel; + int channelLogoWidth; + int channelLogoHeight; + //Timeline + int timeLineWidth; + int timeLineHeight; + int timeLineGridWidth; + int timeLineGridHeight; + int dateVieverWidth; + int dateVieverHeight; + int clockWidth; + int clockHeight; + //Footer + int footerY; + int footerHeight; + int buttonWidth; + int buttonHeight; + int buttonBorder; + //Detailed EPG View + int epgViewHeaderHeight; + //Recording Menus + int borderRecMenus; + //Channel Jump + int channelJumpWidth; + int channelJumpHeight; +}; + +#endif //__TVGUIDE_GEOMETRYMANAGER_H diff --git a/grid.c b/grid.c index 9a878d4..a760081 100644 --- a/grid.c +++ b/grid.c @@ -1,82 +1,82 @@ -#include "channelcolumn.h" -#include "grid.h" - -cGrid::cGrid(cChannelColumn *c) { - this->column = c; - text = new cTextWrapper(); - dirty = true; - active = false; - viewportHeight = 0; - borderWidth = 10; -} - -cGrid::~cGrid(void) { - delete text; -} - -void cGrid::setBackground() { - if (active) { - color = theme.Color(clrHighlight); - colorBlending = theme.Color(clrHighlightBlending); - } else { - if (isColor1) { - color = theme.Color(clrGrid1); - colorBlending = theme.Color(clrGrid1Blending); - } else { - color = theme.Color(clrGrid2); - colorBlending = theme.Color(clrGrid2Blending); - } - } -} - -void cGrid::Draw() { - if (!pixmap) { - return; - } - if (dirty) { - if (tvguideConfig.style == eStyleGraphical) { - drawBackgroundGraphical(bgGrid, active); - drawText(); - } else { - setBackground(); - drawBackground(); - drawText(); - drawBorder(); - } - pixmap->SetLayer(1); - dirty = false; - } -} - -bool cGrid::isFirst(void) { - if (column->isFirst(this)) - return true; - return false; -} - -bool cGrid::Match(time_t t) { - if ((StartTime() < t) && (EndTime() > t)) - return true; - else - return false; -} - -int cGrid::calcOverlap(cGrid *neighbor) { - int overlap = 0; - if (intersects(neighbor)) { - if ((StartTime() <= neighbor->StartTime()) && (EndTime() <= neighbor->EndTime())) { - overlap = EndTime() - neighbor->StartTime(); - } else if ((StartTime() >= neighbor->StartTime()) && (EndTime() >= neighbor->EndTime())) { - overlap = neighbor->EndTime() - StartTime(); - } else if ((StartTime() >= neighbor->StartTime()) && (EndTime() <= neighbor->EndTime())) { - overlap = Duration(); - } else if ((StartTime() <= neighbor->StartTime()) && (EndTime() >= neighbor->EndTime())) { - overlap = neighbor->EndTime() - neighbor->StartTime(); - } - } - return overlap; -} - -bool cGrid::intersects(cGrid *neighbor) { - return ! ( (neighbor->EndTime() <= StartTime()) || (neighbor->StartTime() >= EndTime()) ); -} +#include "channelcolumn.h" +#include "grid.h" + +cGrid::cGrid(cChannelColumn *c) { + this->column = c; + text = new cTextWrapper(); + dirty = true; + active = false; + viewportHeight = 0; + borderWidth = 10; +} + +cGrid::~cGrid(void) { + delete text; +} + +void cGrid::setBackground() { + if (active) { + color = theme.Color(clrHighlight); + colorBlending = theme.Color(clrHighlightBlending); + } else { + if (isColor1) { + color = theme.Color(clrGrid1); + colorBlending = theme.Color(clrGrid1Blending); + } else { + color = theme.Color(clrGrid2); + colorBlending = theme.Color(clrGrid2Blending); + } + } +} + +void cGrid::Draw() { + if (!pixmap) { + return; + } + if (dirty) { + if (tvguideConfig.style == eStyleGraphical) { + drawBackgroundGraphical(bgGrid, active); + drawText(); + } else { + setBackground(); + drawBackground(); + drawText(); + drawBorder(); + } + pixmap->SetLayer(1); + dirty = false; + } +} + +bool cGrid::isFirst(void) { + if (column->isFirst(this)) + return true; + return false; +} + +bool cGrid::Match(time_t t) { + if ((StartTime() < t) && (EndTime() > t)) + return true; + else + return false; +} + +int cGrid::calcOverlap(cGrid *neighbor) { + int overlap = 0; + if (intersects(neighbor)) { + if ((StartTime() <= neighbor->StartTime()) && (EndTime() <= neighbor->EndTime())) { + overlap = EndTime() - neighbor->StartTime(); + } else if ((StartTime() >= neighbor->StartTime()) && (EndTime() >= neighbor->EndTime())) { + overlap = neighbor->EndTime() - StartTime(); + } else if ((StartTime() >= neighbor->StartTime()) && (EndTime() <= neighbor->EndTime())) { + overlap = Duration(); + } else if ((StartTime() <= neighbor->StartTime()) && (EndTime() >= neighbor->EndTime())) { + overlap = neighbor->EndTime() - neighbor->StartTime(); + } + } + return overlap; +} + +bool cGrid::intersects(cGrid *neighbor) { + return ! ( (neighbor->EndTime() <= StartTime()) || (neighbor->StartTime() >= EndTime()) ); +} diff --git a/grid.h b/grid.h index 1e4b350..0d53535 100644 --- a/grid.h +++ b/grid.h @@ -1,58 +1,58 @@ -#ifndef __TVGUIDE_GRID_H -#define __TVGUIDE_GRID_H - -#include -#include "styledpixmap.h" - -class cChannelColumn; - -// --- cEpgGrid ------------------------------------------------------------- - -class cGrid : public cListObject, public cStyledPixmap { -protected: - cTextWrapper *text; - int viewportHeight; - int borderWidth; - void setBackground(); - bool isColor1; - bool active; - bool dirty; - bool hasTimer; - bool hasSwitchTimer; - bool intersects(cGrid *neighbor); - virtual time_t Duration(void) { return 0; }; - virtual void drawText(void) {}; - bool dummy; -public: - cGrid(cChannelColumn *c); - virtual ~cGrid(void); - cChannelColumn *column; - virtual void SetViewportHeight(void) {}; - virtual void PositionPixmap(void) {}; - virtual void setText(void) {}; - void Draw(void); - void SetDirty(void) {dirty = true;}; - void SetActive(void) {dirty = true; active = true;}; - void SetInActive(void) {dirty = true; active = false;}; - void SetColor(bool color) {isColor1 = color;}; - bool IsColor1(void) {return isColor1;}; - bool isFirst(void); - virtual const cEvent *GetEvent(void) { return NULL; }; - bool Match(time_t t); - virtual time_t StartTime(void) { return 0; }; - virtual time_t EndTime(void) { return 0; }; - virtual void SetStartTime(time_t start) {}; - virtual void SetEndTime(time_t end) {}; - int calcOverlap(cGrid *neighbor); - virtual void SetTimer(void) {}; - virtual void SetSwitchTimer(void) {}; - virtual cString getText(void) { return cString("");}; - virtual cString getTimeString(void) { return cString("");}; - bool Active(void) { return active; }; - bool HasTimer(void) {return hasTimer;}; - bool HasSwitchTimer(void) {return hasSwitchTimer;}; - bool isDummy(void) { return dummy; }; - virtual void debug() {}; -}; - -#endif //__TVGUIDE_GRID_H +#ifndef __TVGUIDE_GRID_H +#define __TVGUIDE_GRID_H + +#include +#include "styledpixmap.h" + +class cChannelColumn; + +// --- cEpgGrid ------------------------------------------------------------- + +class cGrid : public cListObject, public cStyledPixmap { +protected: + cTextWrapper *text; + int viewportHeight; + int borderWidth; + void setBackground(); + bool isColor1; + bool active; + bool dirty; + bool hasTimer; + bool hasSwitchTimer; + bool intersects(cGrid *neighbor); + virtual time_t Duration(void) { return 0; }; + virtual void drawText(void) {}; + bool dummy; +public: + cGrid(cChannelColumn *c); + virtual ~cGrid(void); + cChannelColumn *column; + virtual void SetViewportHeight(void) {}; + virtual void PositionPixmap(void) {}; + virtual void setText(void) {}; + void Draw(void); + void SetDirty(void) {dirty = true;}; + void SetActive(void) {dirty = true; active = true;}; + void SetInActive(void) {dirty = true; active = false;}; + void SetColor(bool color) {isColor1 = color;}; + bool IsColor1(void) {return isColor1;}; + bool isFirst(void); + virtual const cEvent *GetEvent(void) { return NULL; }; + bool Match(time_t t); + virtual time_t StartTime(void) { return 0; }; + virtual time_t EndTime(void) { return 0; }; + virtual void SetStartTime(time_t start) {}; + virtual void SetEndTime(time_t end) {}; + int calcOverlap(cGrid *neighbor); + virtual void SetTimer(void) {}; + virtual void SetSwitchTimer(void) {}; + virtual cString getText(void) { return cString("");}; + virtual cString getTimeString(void) { return cString("");}; + bool Active(void) { return active; }; + bool HasTimer(void) {return hasTimer;}; + bool HasSwitchTimer(void) {return hasSwitchTimer;}; + bool isDummy(void) { return dummy; }; + virtual void debug() {}; +}; + +#endif //__TVGUIDE_GRID_H diff --git a/headergrid.c b/headergrid.c index 94f0c9c..1fb4f5a 100644 --- a/headergrid.c +++ b/headergrid.c @@ -1,134 +1,134 @@ -#include "imageloader.h" -#include "tools.h" -#include "headergrid.h" - -cHeaderGrid::cHeaderGrid(void) : cGrid(NULL) { - pixmap = NULL; - pixmapLogo = NULL; -} - -cHeaderGrid::~cHeaderGrid(void) { - osdManager.releasePixmap(pixmapLogo); -} - -void cHeaderGrid::createBackground(int num) { - color = theme.Color(clrHeader); - colorBlending = theme.Color(clrHeaderBlending); - int x, y; - if (tvguideConfig.displayMode == eVertical) { - x = geoManager.timeLineWidth + num*geoManager.colWidth; - y = geoManager.statusHeaderHeight + geoManager.channelGroupsHeight; - } else if (tvguideConfig.displayMode == eHorizontal) { - x = geoManager.channelGroupsWidth; - y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + num*geoManager.rowHeight; - } - pixmap = osdManager.requestPixmap(1, cRect(x, y, geoManager.channelLogoWidth, geoManager.channelLogoHeight)); - pixmapLogo = osdManager.requestPixmap(2, cRect(x, y, geoManager.channelLogoWidth, geoManager.channelLogoHeight)); - if ((!pixmap) || (!pixmapLogo)){ - return; - } - pixmapLogo->Fill(clrTransparent); - if (tvguideConfig.style == eStyleGraphical) { - drawBackgroundGraphical(bgChannelHeader); - } else { - drawBackground(); - drawBorder(); - } -} - -void cHeaderGrid::drawChannel(const cChannel *channel) { - if (tvguideConfig.displayMode == eVertical) { - drawChannelVertical(channel); - } else if (tvguideConfig.displayMode == eHorizontal) { - drawChannelHorizontal(channel); - } -} - -// Draw Channel horizontal view - -void cHeaderGrid::drawChannelHorizontal(const cChannel *channel) { - int logoWidth = geoManager.logoWidth; - int logoX = tvguideConfig.displayChannelName ? 5 : (Width() - logoWidth) / 2; - int textX = 5; - int textY = (Height() - fontManager.FontChannelHeaderHorizontal->Height()) / 2; - bool logoFound = false; - if (!tvguideConfig.hideChannelLogos) { - cImage *logo = imgCache.GetLogo(channel); - if (logo) { - const int logoheight = logo->Height(); - pixmapLogo->DrawImage(cPoint(logoX, (Height() - logoheight) / 2), *logo); - logoFound = true; - } - } - bool drawText = false; - int textWidthMax = Width() - 10; - if (!logoFound) { - drawText = true; - } - if (tvguideConfig.displayChannelName) { - drawText = true; - textX += logoWidth + 5; - textWidthMax -= textX; - } - if (drawText) { - tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; - cString strChannel = cString::sprintf("%d %s", channel->Number(), channel->Name()); - strChannel = CutText(*strChannel, textWidthMax, fontManager.FontChannelHeaderHorizontal).c_str(); - pixmap->DrawText(cPoint(textX, textY), *strChannel, theme.Color(clrFontHeader), colorTextBack, fontManager.FontChannelHeaderHorizontal); - } -} - -// Draw Channel vertical view - -void cHeaderGrid::drawChannelVertical(const cChannel *channel) { - int logoWidth = geoManager.logoWidth; - int logoHeight = geoManager.logoHeight; - cTextWrapper tw; - cString headerText = cString::sprintf("%d - %s", channel->Number(), channel->Name()); - tw.Set(*headerText, fontManager.FontChannelHeader, geoManager.colWidth - 8); - int lines = tw.Lines(); - int lineHeight = fontManager.FontChannelHeader->Height(); - int yStart = (geoManager.channelHeaderHeight - lines * lineHeight) / 2 + 8; - bool logoFound = false; - if (!tvguideConfig.hideChannelLogos) { - cImage *logo = imgCache.GetLogo(channel); - if (logo) { - pixmapLogo->DrawImage(cPoint((Width() - logoWidth) / 2, 6), *logo); - logoFound = true; - } - } - bool drawText = false; - if (!logoFound) { - drawText = true; - } else if (tvguideConfig.displayChannelName) { - drawText = true; - yStart = logoHeight; - } - if (!drawText) - return; - tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; - for (int i = 0; i < lines; i++) { - int textWidth = fontManager.FontChannelHeader->Width(tw.GetLine(i)); - int xText = (geoManager.colWidth - textWidth) / 2; - if (xText < 0) - xText = 0; - pixmap->DrawText(cPoint(xText, yStart + i * lineHeight), tw.GetLine(i), theme.Color(clrFontHeader), colorTextBack, fontManager.FontChannelHeader); - } -} - -void cHeaderGrid::setPosition(int num) { - int x, y, width, height; - if (tvguideConfig.displayMode == eVertical) { - x = geoManager.timeLineWidth + num*geoManager.colWidth; - y = geoManager.statusHeaderHeight + geoManager.channelGroupsHeight; - width = geoManager.colWidth; - height = geoManager.channelHeaderHeight; - } else if (tvguideConfig.displayMode == eHorizontal) { - x = geoManager.channelGroupsWidth; - y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + num*geoManager.rowHeight; - width = geoManager.channelHeaderWidth; - height = geoManager.rowHeight; - } - pixmap->SetViewPort(cRect(x, y, width, height)); - pixmapLogo->SetViewPort(cRect(x, y, width, height)); -} +#include "imageloader.h" +#include "tools.h" +#include "headergrid.h" + +cHeaderGrid::cHeaderGrid(void) : cGrid(NULL) { + pixmap = NULL; + pixmapLogo = NULL; +} + +cHeaderGrid::~cHeaderGrid(void) { + osdManager.releasePixmap(pixmapLogo); +} + +void cHeaderGrid::createBackground(int num) { + color = theme.Color(clrHeader); + colorBlending = theme.Color(clrHeaderBlending); + int x, y; + if (tvguideConfig.displayMode == eVertical) { + x = geoManager.timeLineWidth + num*geoManager.colWidth; + y = geoManager.statusHeaderHeight + geoManager.channelGroupsHeight; + } else if (tvguideConfig.displayMode == eHorizontal) { + x = geoManager.channelGroupsWidth; + y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + num*geoManager.rowHeight; + } + pixmap = osdManager.requestPixmap(1, cRect(x, y, geoManager.channelLogoWidth, geoManager.channelLogoHeight)); + pixmapLogo = osdManager.requestPixmap(2, cRect(x, y, geoManager.channelLogoWidth, geoManager.channelLogoHeight)); + if ((!pixmap) || (!pixmapLogo)){ + return; + } + pixmapLogo->Fill(clrTransparent); + if (tvguideConfig.style == eStyleGraphical) { + drawBackgroundGraphical(bgChannelHeader); + } else { + drawBackground(); + drawBorder(); + } +} + +void cHeaderGrid::drawChannel(const cChannel *channel) { + if (tvguideConfig.displayMode == eVertical) { + drawChannelVertical(channel); + } else if (tvguideConfig.displayMode == eHorizontal) { + drawChannelHorizontal(channel); + } +} + +// Draw Channel horizontal view + +void cHeaderGrid::drawChannelHorizontal(const cChannel *channel) { + int logoWidth = geoManager.logoWidth; + int logoX = tvguideConfig.displayChannelName ? 5 : (Width() - logoWidth) / 2; + int textX = 5; + int textY = (Height() - fontManager.FontChannelHeaderHorizontal->Height()) / 2; + bool logoFound = false; + if (!tvguideConfig.hideChannelLogos) { + cImage *logo = imgCache.GetLogo(channel); + if (logo) { + const int logoheight = logo->Height(); + pixmapLogo->DrawImage(cPoint(logoX, (Height() - logoheight) / 2), *logo); + logoFound = true; + } + } + bool drawText = false; + int textWidthMax = Width() - 10; + if (!logoFound) { + drawText = true; + } + if (tvguideConfig.displayChannelName) { + drawText = true; + textX += logoWidth + 5; + textWidthMax -= textX; + } + if (drawText) { + tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; + cString strChannel = cString::sprintf("%d %s", channel->Number(), channel->Name()); + strChannel = CutText(*strChannel, textWidthMax, fontManager.FontChannelHeaderHorizontal).c_str(); + pixmap->DrawText(cPoint(textX, textY), *strChannel, theme.Color(clrFontHeader), colorTextBack, fontManager.FontChannelHeaderHorizontal); + } +} + +// Draw Channel vertical view + +void cHeaderGrid::drawChannelVertical(const cChannel *channel) { + int logoWidth = geoManager.logoWidth; + int logoHeight = geoManager.logoHeight; + cTextWrapper tw; + cString headerText = cString::sprintf("%d - %s", channel->Number(), channel->Name()); + tw.Set(*headerText, fontManager.FontChannelHeader, geoManager.colWidth - 8); + int lines = tw.Lines(); + int lineHeight = fontManager.FontChannelHeader->Height(); + int yStart = (geoManager.channelHeaderHeight - lines * lineHeight) / 2 + 8; + bool logoFound = false; + if (!tvguideConfig.hideChannelLogos) { + cImage *logo = imgCache.GetLogo(channel); + if (logo) { + pixmapLogo->DrawImage(cPoint((Width() - logoWidth) / 2, 6), *logo); + logoFound = true; + } + } + bool drawText = false; + if (!logoFound) { + drawText = true; + } else if (tvguideConfig.displayChannelName) { + drawText = true; + yStart = logoHeight; + } + if (!drawText) + return; + tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; + for (int i = 0; i < lines; i++) { + int textWidth = fontManager.FontChannelHeader->Width(tw.GetLine(i)); + int xText = (geoManager.colWidth - textWidth) / 2; + if (xText < 0) + xText = 0; + pixmap->DrawText(cPoint(xText, yStart + i * lineHeight), tw.GetLine(i), theme.Color(clrFontHeader), colorTextBack, fontManager.FontChannelHeader); + } +} + +void cHeaderGrid::setPosition(int num) { + int x, y, width, height; + if (tvguideConfig.displayMode == eVertical) { + x = geoManager.timeLineWidth + num*geoManager.colWidth; + y = geoManager.statusHeaderHeight + geoManager.channelGroupsHeight; + width = geoManager.colWidth; + height = geoManager.channelHeaderHeight; + } else if (tvguideConfig.displayMode == eHorizontal) { + x = geoManager.channelGroupsWidth; + y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + num*geoManager.rowHeight; + width = geoManager.channelHeaderWidth; + height = geoManager.rowHeight; + } + pixmap->SetViewPort(cRect(x, y, width, height)); + pixmapLogo->SetViewPort(cRect(x, y, width, height)); +} diff --git a/headergrid.h b/headergrid.h index a4f0962..d1a3f66 100644 --- a/headergrid.h +++ b/headergrid.h @@ -1,21 +1,21 @@ -#ifndef __TVGUIDE_HEADERGRID_H -#define __TVGUIDE_HEADERGRID_H - -#include "grid.h" - -// --- cHeaderGrid ------------------------------------------------------------- - -class cHeaderGrid : public cGrid { -private: - cPixmap *pixmapLogo; - void drawChannelHorizontal(const cChannel *channel); - void drawChannelVertical(const cChannel *channel); -public: - cHeaderGrid(void); - virtual ~cHeaderGrid(void); - void createBackground(int num); - void drawChannel(const cChannel *channel); - void setPosition(int num); -}; - -#endif //__TVGUIDE_HEADERGRID_H \ No newline at end of file +#ifndef __TVGUIDE_HEADERGRID_H +#define __TVGUIDE_HEADERGRID_H + +#include "grid.h" + +// --- cHeaderGrid ------------------------------------------------------------- + +class cHeaderGrid : public cGrid { +private: + cPixmap *pixmapLogo; + void drawChannelHorizontal(const cChannel *channel); + void drawChannelVertical(const cChannel *channel); +public: + cHeaderGrid(void); + virtual ~cHeaderGrid(void); + void createBackground(int num); + void drawChannel(const cChannel *channel); + void setPosition(int num); +}; + +#endif //__TVGUIDE_HEADERGRID_H diff --git a/imagecache.c b/imagecache.c index bc1a88f..63a938e 100644 --- a/imagecache.c +++ b/imagecache.c @@ -1,720 +1,720 @@ -#include -#include -#include -#include -#include "config.h" -#include "imagescaler.h" -#include "tools.h" -#include "imagecache.h" - -cImageCache::cImageCache() : cImageMagickWrapper() { - tempStaticLogo = NULL; - groupsHead = NULL; - groupsBottom = NULL; - groupsLeft = NULL; - groupsRight = NULL; - imgLeft = NULL; - imgLeftActive = NULL; - imgRight = NULL; - imgRightActive = NULL; - imgHead = NULL; - imgHeadActive = NULL; - imgBottom = NULL; - imgBottomActive = NULL; -} - -cImageCache::~cImageCache() { - Clear(); -} - -void cImageCache::CreateCache(void) { - if (tvguideConfig.style != eStyleGraphical) - return; - esyslog("tvguide: Creating Image Cache"); - int start = cTimeMs::Now(); - int startNext = cTimeMs::Now(); - CreateOsdIconCache(); - esyslog("tvguide: Osd Icon Cash created in %d ms", int(cTimeMs::Now()-startNext)); - startNext = cTimeMs::Now(); - PrepareGridIconCache(); - CreateGridIconCache(); - esyslog("tvguide: Grid Icon Cash created in %d ms", int(cTimeMs::Now()-startNext)); - startNext = cTimeMs::Now(); - CreateChannelGroupCache(); - esyslog("tvguide: Channelgroup Cash created in %d ms", int(cTimeMs::Now()-startNext)); - startNext = cTimeMs::Now(); - CreateLogoCache(); - esyslog("tvguide: Logo Cash created in %d ms", int(cTimeMs::Now()-startNext)); - startNext = cTimeMs::Now(); - esyslog("tvguide: Complete Image Cash created in %d ms", int(cTimeMs::Now()-start)); -} - -void cImageCache::CreateOsdIconCache(void) { - bool success = false; - //Status Header - std::string imgStatusHeaderContentFull = "osdElements/statusheader_content_full"; - std::string imgStatusHeaderContentWindowed = "osdElements/statusheader_content_windowed"; - std::string imgStatusHeaderTVFrame = "osdElements/statusheader_tvframe"; - success = LoadIcon(imgStatusHeaderContentFull); - if (success) - InsertIntoOsdElementCache(oeStatusHeaderContentFull, geoManager.headerContentWidth, geoManager.statusHeaderHeight); - success = LoadIcon(imgStatusHeaderContentWindowed); - if (success) - InsertIntoOsdElementCache(oeStatusHeaderContentWindowed, geoManager.headerContentWidth, geoManager.statusHeaderHeight); - success = LoadIcon(imgStatusHeaderTVFrame); - if (success) - InsertIntoOsdElementCache(oeStatusHeaderTVFrame, geoManager.tvFrameWidth, geoManager.statusHeaderHeight); - - - //Color Buttons - std::string imgButtonRed = "osdElements/buttonred"; - std::string imgButtonGreen = "osdElements/buttongreen"; - std::string imgButtonYellow = "osdElements/buttonyellow"; - std::string imgButtonBlue = "osdElements/buttonblue"; - success = LoadIcon(imgButtonRed); - if (success) - InsertIntoOsdElementCache(oeButtonRed, geoManager.buttonWidth, geoManager.buttonHeight); - success = LoadIcon(imgButtonGreen); - if (success) - InsertIntoOsdElementCache(oeButtonGreen, geoManager.buttonWidth, geoManager.buttonHeight); - success = LoadIcon(imgButtonYellow); - if (success) - InsertIntoOsdElementCache(oeButtonYellow, geoManager.buttonWidth, geoManager.buttonHeight); - success = LoadIcon(imgButtonBlue); - if (success) - InsertIntoOsdElementCache(oeButtonBlue, geoManager.buttonWidth, geoManager.buttonHeight); - - //Channel Logo Background - if (tvguideConfig.displayMode == eHorizontal) { - success = LoadIcon("osdElements/channellogoback_horizontal"); - } else { - success = LoadIcon("osdElements/channellogoback_vertical"); - } - if (success) - InsertIntoOsdElementCache(oeLogoBack, geoManager.channelLogoWidth, geoManager.channelLogoHeight); - - //Timeline Elements - std::string imgTimeline1, imgTimeline2, imgDateViewer; - if (tvguideConfig.displayMode == eHorizontal) { - imgTimeline1 = "osdElements/timeline1_horizontal"; - imgTimeline2 = "osdElements/timeline2_horizontal"; - imgDateViewer = "osdElements/timeline2_horizontal"; - } else { - imgTimeline1 = "osdElements/timeline1_vertical"; - imgTimeline2 = "osdElements/timeline2_vertical"; - imgDateViewer = "osdElements/date_vertical"; - } - std::string imgClock = "osdElements/clock"; - success = LoadIcon(imgTimeline1); - if (success) - InsertIntoOsdElementCache(oeTimeline1, geoManager.timeLineGridWidth, geoManager.timeLineGridHeight); - success = LoadIcon(imgTimeline2); - if (success) - InsertIntoOsdElementCache(oeTimeline2, geoManager.timeLineGridWidth, geoManager.timeLineGridHeight); - success = LoadIcon(imgDateViewer); - if (success) - InsertIntoOsdElementCache(oeDateViewer, geoManager.dateVieverWidth, geoManager.dateVieverHeight); - success = LoadIcon(imgClock); - if (success) - InsertIntoOsdElementCache(oeClock, geoManager.clockWidth, geoManager.clockHeight); - - //Channel Jump - success = LoadIcon("osdElements/channel_jump"); - if (success) - InsertIntoOsdElementCache(oeChannelJump, geoManager.channelJumpWidth, geoManager.channelJumpHeight); -} - -void cImageCache::PrepareGridIconCache(void) { - bool success = false; - //Create Buffers for Background - gridsAvailable = true; - std::string grid, grid_active; - if (tvguideConfig.displayMode == eHorizontal) { - grid = "osdElements/grid_horizontal"; - grid_active = "osdElements/grid_active_horizontal"; - } else { - grid = "osdElements/grid_vertical"; - grid_active = "osdElements/grid_active_vertical"; - } - success = LoadIcon(grid); - if (success) { - bufferGrid = buffer; - } else { - gridsAvailable = false; - } - success = LoadIcon(grid_active); - if (success) { - bufferGridActive = buffer; - } else { - gridsAvailable = false; - } - //Create Grid Background Templates - imgLeft = NULL; - imgLeftActive = NULL; - imgRight = NULL; - imgRightActive = NULL; - imgHead = NULL; - imgHeadActive = NULL; - imgBottom = NULL; - imgBottomActive = NULL; - - if (tvguideConfig.displayMode == eHorizontal) { - std::string left = "osdElements/grid_left"; - std::string right = "osdElements/grid_right"; - std::string left_active = "osdElements/grid_active_left"; - std::string right_active = "osdElements/grid_active_right"; - cornerWidth = 0; - cornerHeight = geoManager.rowHeight; - //first image determinates width - success = LoadIcon(left); - if (!success) - return; - int widthOriginal = 0; - int heightOriginal = 0; - widthOriginal = buffer.columns(); - heightOriginal = buffer.rows(); - cornerWidth = widthOriginal * cornerHeight / heightOriginal; - imgLeft = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(right); - if (success) - imgRight = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(left_active); - if (success) - imgLeftActive = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(right_active); - if (success) - imgRightActive = CreateImage(cornerWidth, cornerHeight, false); - } else { - std::string head = "osdElements/grid_head"; - std::string bottom = "osdElements/grid_bottom"; - std::string head_active = "osdElements/grid_active_head"; - std::string bottom_active = "osdElements/grid_active_bottom"; - cornerWidth = geoManager.colWidth; - cornerHeight = 0; - //first image determinates height - success = LoadIcon(head); - if (!success) - return; - int widthOriginal = 0; - int heightOriginal = 0; - widthOriginal = buffer.columns(); - heightOriginal = buffer.rows(); - cornerHeight = heightOriginal * cornerWidth / widthOriginal; - imgHead = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(bottom); - if (success) - imgBottom = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(head_active); - if (success) - imgHeadActive = CreateImage(cornerWidth, cornerHeight, false); - success = LoadIcon(bottom_active); - if (success) - imgBottomActive = CreateImage(cornerWidth, cornerHeight, false); - } -} - -void cImageCache::CreateGridIconCache(void) { - if (tvguideConfig.displayMode == eHorizontal) { - int gridHeight = geoManager.rowHeight; - for (int minutes = 5; minutes <= 120; minutes += 5) { - GetGrid(minutes * geoManager.minutePixel, gridHeight, false); - } - } else { - int gridWidth = geoManager.colWidth; - for (int minutes = 5; minutes <= 120; minutes += 5) { - GetGrid(gridWidth, minutes * geoManager.minutePixel, false); - } - } -} - -void cImageCache::CreateChannelGroupCache(void) { - bool success = false; - groupsHead = NULL; - groupsBottom = NULL; - groupsLeft = NULL; - groupsRight = NULL; - if (tvguideConfig.displayMode == eHorizontal) { - std::string channelGroupHead = "osdElements/channelgroup_head"; - std::string channelGroupBottom = "osdElements/channelgroup_bottom"; - int width = geoManager.channelGroupsWidth; - int heightHeadBottom = 0; - success = LoadIcon(channelGroupHead); - if (success) { - int widthOriginal = buffer.columns(); - int heightOriginal = buffer.rows(); - heightHeadBottom = heightOriginal * width / widthOriginal; - groupsHead = CreateImage(width, heightHeadBottom, false); - } - success = LoadIcon(channelGroupBottom); - if (success && heightHeadBottom) { - groupsBottom = CreateImage(width, heightHeadBottom, false); - } - for (int size = 1; size <= tvguideConfig.numGrids; ++size) { - InsertIntoGroupsCacheHorizontal(size); - } - } else { - std::string channelGroupLeft = "osdElements/channelgroup_left"; - std::string channelGroupRight = "osdElements/channelgroup_right"; - int widthHeadBottom = 0; - int height = geoManager.channelGroupsHeight; - success = LoadIcon(channelGroupLeft); - if (success) { - int widthOriginal = buffer.columns(); - int heightOriginal = buffer.rows(); - widthHeadBottom = widthOriginal * height / heightOriginal; - groupsLeft = CreateImage(widthHeadBottom, height, false); - } - success = LoadIcon(channelGroupRight); - if (success && widthHeadBottom) { - groupsRight = CreateImage(widthHeadBottom, height, false); - } - for (int size = 1; size <= tvguideConfig.numGrids; ++size) { - InsertIntoGroupsCacheVertical(size); - } - } - -} - -void cImageCache::CreateLogoCache(void) { - if (tvguideConfig.hideChannelLogos) - return; - if (tvguideConfig.numLogosInitial > 0) { - int channelsCached = 0; -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel)) { -#else - for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { -#endif - if (channelsCached >= tvguideConfig.numLogosInitial) - break; - if (!channel->GroupSep()) { - bool success = LoadLogo(channel); - if (success) { - channelsCached++; - InsertIntoLogoCache(*channel->GetChannelID().ToString()); - } - } - - } - } -} - - -cImage *cImageCache::GetOsdElement(eOsdElementType type) { - std::map::iterator hit = osdElementCache.find(type); - if (hit != osdElementCache.end()) { - return (cImage*)hit->second; - } - return NULL; -} - -cImage *cImageCache::GetGrid(int width, int height, bool active) { - if (!gridsAvailable) - return NULL; - std::stringstream gridImageName; - gridImageName << width << "x" << height; - if (active) - gridImageName << "active"; - std::string gridImg = gridImageName.str(); - std::map::iterator hit = gridCache.find(gridImg); - if (hit != gridCache.end()) { - return (cImage*)hit->second; - } else { - InsertIntoGridCache(gridImg, width, height, active); - hit = gridCache.find(gridImg); - if (hit != gridCache.end()) { - return (cImage*)hit->second; - } - } - return NULL; -} - -cImage *cImageCache::GetChannelGroup(int width, int height) { - std::stringstream groupName; - groupName << width << "x" << height; - std::map::iterator hit = groupsCache.find(groupName.str()); - if (hit != groupsCache.end()) { - return (cImage*)hit->second; - } - return NULL; -} - -cImage *cImageCache::GetLogo(const cChannel *channel) { - if (!channel) - return NULL; - - std::map::iterator hit = logoCache.find(*channel->GetChannelID().ToString()); - - if (hit != logoCache.end()) { - return (cImage*)hit->second; - } else { - bool success = LoadLogo(channel); - if (success) { - if ((tvguideConfig.limitLogoCache) && ((int)logoCache.size() >= tvguideConfig.numLogosMax)) { - //logo cache is full, don't cache anymore - if (tempStaticLogo) { - delete tempStaticLogo; - tempStaticLogo = NULL; - } - tempStaticLogo = CreateImage(geoManager.logoWidth, geoManager.logoHeight); - return tempStaticLogo; - } else { - //add requested logo to cache - InsertIntoLogoCache(*channel->GetChannelID().ToString()); - hit = logoCache.find(*channel->GetChannelID().ToString()); - if (hit != logoCache.end()) { - return (cImage*)hit->second; - } - } - } - } - return NULL; -} - -cImage *cImageCache::GetIcon(std::string name, int width, int height) { - std::stringstream iconName; - iconName << name << width << "x" << height; - std::map::iterator hit = iconCache.find(iconName.str()); - if (hit != iconCache.end()) { - return (cImage*)hit->second; - } else { - std::stringstream iconPath; - iconPath << "recmenuicons/" << name; - bool success = LoadIcon(iconPath.str()); - if (success) { - cImage *image = CreateImage(width, height); - iconCache.insert(std::pair(iconName.str(), image)); - hit = iconCache.find(iconName.str()); - if (hit != iconCache.end()) { - return (cImage*)hit->second; - } - } - } - return NULL; -} - -void cImageCache::InsertIntoOsdElementCache(eOsdElementType type, int width, int height) { - cImage *image = CreateImage(width, height, false); - if (image) - osdElementCache.insert(std::pair(type, image)); -} - -void cImageCache::InsertIntoGridCache(std::string name, int width, int height, bool active) { - cImage *image = CreateGrid(width, height, active); - if (image) { - if (tvguideConfig.displayMode == eHorizontal) { - AddCornersHorizontal(image, active); - } else { - AddCornersVertical(image, active); - } - gridCache.insert(std::pair(name, image)); - } -} - -cImage *cImageCache::CreateGrid(int width, int height, bool active) { - if (width > geoManager.osdWidth || width < 6 || height > geoManager.osdHeight || height < 6) - return NULL; - Image *currentGridBuffer = NULL; - if (active) - currentGridBuffer = &bufferGridActive; - else - currentGridBuffer = &bufferGrid; - int w, h; - w = currentGridBuffer->columns(); - h = currentGridBuffer->rows(); - const PixelPacket *pixels = currentGridBuffer->getConstPixels(0, 0, w, h); - cImage *image = NULL; - image = new cImage(cSize(width, height)); - if (!image) - return NULL; - tColor *imgData = (tColor *)image->Data(); - if (w != width || h != height) { - ImageScaler scaler; - scaler.SetImageParameters(imgData, width, width, height, w, h); - for (const void *pixels_end = &pixels[w*h]; pixels < pixels_end; ++pixels) - scaler.PutSourcePixel(pixels->blue / ((MaxRGB + 1) / 256), - pixels->green / ((MaxRGB + 1) / 256), - pixels->red / ((MaxRGB + 1) / 256), - ~((unsigned char)(pixels->opacity / ((MaxRGB + 1) / 256)))); - return image; - } - for (const void *pixels_end = &pixels[width*height]; pixels < pixels_end; ++pixels) - *imgData++ = ((~int(pixels->opacity / ((MaxRGB + 1) / 256)) << 24) | - (int(pixels->green / ((MaxRGB + 1) / 256)) << 8) | - (int(pixels->red / ((MaxRGB + 1) / 256)) << 16) | - (int(pixels->blue / ((MaxRGB + 1) / 256)) )); - return image; -} - -void cImageCache::AddCornersHorizontal(cImage *img, bool active) { - int imgWidth = img->Width(); - cImage *cornerLeft = NULL; - cImage *cornerRight = NULL; - if (active) { - cornerLeft = imgLeftActive; - cornerRight = imgRightActive; - } else { - cornerLeft = imgLeft; - cornerRight = imgRight; - } - if (!cornerLeft || !cornerRight) - return; - int maxX = std::min(cornerWidth, imgWidth); - for (int row = 0; row < cornerHeight; row++) { - for (int col = 0; col < maxX; ++col) { - img->SetPixel(cPoint(col, row), cornerLeft->GetPixel(cPoint(col, row))); - img->SetPixel(cPoint(imgWidth - maxX + col, row), cornerRight->GetPixel(cPoint(col, row))); - } - } -} - -void cImageCache::AddCornersVertical(cImage *img, bool active) { - int imgHeight = img->Height(); - cImage *cornerHead = NULL; - cImage *cornerBottom = NULL; - if (active) { - cornerHead = imgHeadActive; - cornerBottom = imgBottomActive; - } else { - cornerHead = imgHead; - cornerBottom = imgBottom; - } - if (!cornerHead || !cornerBottom) - return; - int maxY = std::min(cornerHeight, imgHeight); - for (int row = 0; row < maxY; row++) { - for (int col = 0; col < cornerWidth; ++col) { - img->SetPixel(cPoint(col, row), cornerHead->GetPixel(cPoint(col, row))); - img->SetPixel(cPoint(col, imgHeight - maxY + row), cornerBottom->GetPixel(cPoint(col, row))); - } - } -} - -void cImageCache::InsertIntoGroupsCacheHorizontal(int size) { - int width = geoManager.channelGroupsWidth; - bool success = LoadIcon("osdElements/channelgroup_horizontal"); - if (success) { - int height = size * geoManager.rowHeight; - std::stringstream name; - name << width << "x" << height; - cImage *image = CreateImage(width, height, false); - if (image) { - AddCornersGroupHorizontal(image); - groupsCache.insert(std::pair(name.str(), image)); - } - } -} - -void cImageCache::InsertIntoGroupsCacheVertical(int size) { - int height = geoManager.channelGroupsHeight; - bool success = LoadIcon("osdElements/channelgroup_vertical"); - if (success) { - int width = size * geoManager.colWidth; - std::stringstream name; - name << width << "x" << height; - cImage *image = CreateImage(width, height, false); - if (image) { - AddCornersGroupVertical(image); - groupsCache.insert(std::pair(name.str(), image)); - } - } -} - -void cImageCache::AddCornersGroupHorizontal(cImage *img) { - if (!groupsHead || !groupsBottom || !img) - return; - int imgWidth = img->Width(); - int imgHeight = img->Height(); - int heightHeadBottom = groupsHead->Height(); - int maxY = std::min(heightHeadBottom, imgHeight); - for (int row = 0; row < maxY; row++) { - for (int col = 0; col < imgWidth; ++col) { - img->SetPixel(cPoint(col, row), groupsHead->GetPixel(cPoint(col, row))); - img->SetPixel(cPoint(col, imgHeight - maxY + row), groupsBottom->GetPixel(cPoint(col, row))); - } - } -} - -void cImageCache::AddCornersGroupVertical(cImage *img) { - if (!groupsLeft || !groupsRight || !img) - return; - int imgWidth = img->Width(); - int imgHeight = img->Height(); - int widthLeftRight = groupsLeft->Width(); - int maxX = std::min(widthLeftRight, imgWidth); - for (int row = 0; row < imgHeight; row++) { - for (int col = 0; col < maxX; ++col) { - img->SetPixel(cPoint(col, row), groupsLeft->GetPixel(cPoint(col, row))); - img->SetPixel(cPoint(imgWidth - maxX + col, row), groupsRight->GetPixel(cPoint(col, row))); - } - } -} - -bool cImageCache::LoadIcon(std::string name) { - bool success = false; - if (tvguideConfig.iconsPathSet) { - cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPath, *tvguideConfig.themeName); - success = LoadImage(name, *iconPathTheme, "png"); - if (success) { - return true; - } else { - success = LoadImage(name, *tvguideConfig.iconPath, "png"); - if (success) { - return true; - } - } - } - if (!success) { - cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPathDefault, *tvguideConfig.themeName); - success = LoadImage(name, *iconPathTheme, "png"); - if (success) { - return true; - } else { - success = LoadImage(name, *tvguideConfig.iconPathDefault, "png"); - if (success) { - return true; - } - } - } - return false; -} - -bool cImageCache::LoadLogo(const cChannel *channel) { - if (!channel) - return false; - std::string channelID = StrToLowerCase(*(channel->GetChannelID().ToString())); - std::string logoLower = StrToLowerCase(channel->Name()); - bool success = false; - cString extension; - if (tvguideConfig.logoExtension == 0) { - extension = "png"; - } else if (tvguideConfig.logoExtension == 1) { - extension = "jpg"; - } - - if (tvguideConfig.logoPathSet) { - success = LoadImage(channelID.c_str(), *tvguideConfig.logoPath, *extension); - if (success) - return true; - success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPath, *extension); - if (success) - return true; - } - success = LoadImage(channelID.c_str(), *tvguideConfig.logoPathDefault, *extension); - if (success) - return true; - success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPathDefault, *extension); - return success; -} - -void cImageCache::InsertIntoLogoCache(std::string channelID) { - cImage *image = CreateImage(geoManager.logoWidth, geoManager.logoHeight); - logoCache.insert(std::pair(channelID, image)); -} - -std::string cImageCache::GetCacheSize(eCacheType type) { - std::stringstream result; - int sizeByte = 0; - int numImages = 0; - if (type == ctOsdElement) { - for(std::map::const_iterator it = osdElementCache.begin(); it != osdElementCache.end(); it++) { - cImage *img = (cImage*)it->second; - if (img) - sizeByte += img->Width() * img->Height() * sizeof(tColor); - } - numImages = osdElementCache.size(); - } else if ((type == ctGrid) || (type == ctLogo) || (type == ctChannelGroup) || (type == ctIcon)) { - std::map *cache; - if (type == ctGrid) - cache = &gridCache; - else if (type == ctLogo) - cache = &logoCache; - else if (type == ctChannelGroup) - cache = &groupsCache; - else if (type == ctIcon) - cache = &iconCache; - - for(std::map::const_iterator it = cache->begin(); it != cache->end(); it++) { - cImage *img = (cImage*)it->second; - if (img) - sizeByte += img->Width() * img->Height() * sizeof(tColor); - } - numImages = cache->size(); - } - result << numImages << " " << tr("images") << " / " << sizeByte/1024 << " KByte"; - return result.str(); -} - -void cImageCache::Clear(void) { - for(std::map::const_iterator it = osdElementCache.begin(); it != osdElementCache.end(); it++) { - cImage *img = (cImage*)it->second; - delete img; - } - osdElementCache.clear(); - - for(std::map::const_iterator it = gridCache.begin(); it != gridCache.end(); it++) { - cImage *img = (cImage*)it->second; - delete img; - } - gridCache.clear(); - - for(std::map::const_iterator it = groupsCache.begin(); it != groupsCache.end(); it++) { - cImage *img = (cImage*)it->second; - delete img; - } - groupsCache.clear(); - - for(std::map::const_iterator it = logoCache.begin(); it != logoCache.end(); it++) { - cImage *img = (cImage*)it->second; - delete img; - } - logoCache.clear(); - - for(std::map::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { - cImage *img = (cImage*)it->second; - delete img; - } - iconCache.clear(); - - if (tempStaticLogo) - delete tempStaticLogo; - if (groupsHead) - delete groupsHead; - if (groupsBottom) - delete groupsBottom; - if (groupsLeft) - delete groupsLeft; - if (groupsRight) - delete groupsRight; - if (imgLeft) - delete imgLeft; - if (imgLeftActive) - delete imgLeftActive; - if (imgRight) - delete imgRight; - if (imgRightActive) - delete imgRightActive; - if (imgHead) - delete imgHead; - if (imgHeadActive) - delete imgHeadActive; - if (imgBottom) - delete imgBottom; - if (imgBottomActive) - delete imgBottomActive; - - tempStaticLogo = NULL; - groupsHead = NULL; - groupsBottom = NULL; - groupsLeft = NULL; - groupsRight = NULL; - imgLeft = NULL; - imgLeftActive = NULL; - imgRight = NULL; - imgRightActive = NULL; - imgHead = NULL; - imgHeadActive = NULL; - imgBottom = NULL; - imgBottomActive = NULL; -} +#include +#include +#include +#include +#include "config.h" +#include "imagescaler.h" +#include "tools.h" +#include "imagecache.h" + +cImageCache::cImageCache() : cImageMagickWrapper() { + tempStaticLogo = NULL; + groupsHead = NULL; + groupsBottom = NULL; + groupsLeft = NULL; + groupsRight = NULL; + imgLeft = NULL; + imgLeftActive = NULL; + imgRight = NULL; + imgRightActive = NULL; + imgHead = NULL; + imgHeadActive = NULL; + imgBottom = NULL; + imgBottomActive = NULL; +} + +cImageCache::~cImageCache() { + Clear(); +} + +void cImageCache::CreateCache(void) { + if (tvguideConfig.style != eStyleGraphical) + return; + esyslog("tvguide: Creating Image Cache"); + int start = cTimeMs::Now(); + int startNext = cTimeMs::Now(); + CreateOsdIconCache(); + esyslog("tvguide: Osd Icon Cash created in %d ms", int(cTimeMs::Now()-startNext)); + startNext = cTimeMs::Now(); + PrepareGridIconCache(); + CreateGridIconCache(); + esyslog("tvguide: Grid Icon Cash created in %d ms", int(cTimeMs::Now()-startNext)); + startNext = cTimeMs::Now(); + CreateChannelGroupCache(); + esyslog("tvguide: Channelgroup Cash created in %d ms", int(cTimeMs::Now()-startNext)); + startNext = cTimeMs::Now(); + CreateLogoCache(); + esyslog("tvguide: Logo Cash created in %d ms", int(cTimeMs::Now()-startNext)); + startNext = cTimeMs::Now(); + esyslog("tvguide: Complete Image Cash created in %d ms", int(cTimeMs::Now()-start)); +} + +void cImageCache::CreateOsdIconCache(void) { + bool success = false; + //Status Header + std::string imgStatusHeaderContentFull = "osdElements/statusheader_content_full"; + std::string imgStatusHeaderContentWindowed = "osdElements/statusheader_content_windowed"; + std::string imgStatusHeaderTVFrame = "osdElements/statusheader_tvframe"; + success = LoadIcon(imgStatusHeaderContentFull); + if (success) + InsertIntoOsdElementCache(oeStatusHeaderContentFull, geoManager.headerContentWidth, geoManager.statusHeaderHeight); + success = LoadIcon(imgStatusHeaderContentWindowed); + if (success) + InsertIntoOsdElementCache(oeStatusHeaderContentWindowed, geoManager.headerContentWidth, geoManager.statusHeaderHeight); + success = LoadIcon(imgStatusHeaderTVFrame); + if (success) + InsertIntoOsdElementCache(oeStatusHeaderTVFrame, geoManager.tvFrameWidth, geoManager.statusHeaderHeight); + + + //Color Buttons + std::string imgButtonRed = "osdElements/buttonred"; + std::string imgButtonGreen = "osdElements/buttongreen"; + std::string imgButtonYellow = "osdElements/buttonyellow"; + std::string imgButtonBlue = "osdElements/buttonblue"; + success = LoadIcon(imgButtonRed); + if (success) + InsertIntoOsdElementCache(oeButtonRed, geoManager.buttonWidth, geoManager.buttonHeight); + success = LoadIcon(imgButtonGreen); + if (success) + InsertIntoOsdElementCache(oeButtonGreen, geoManager.buttonWidth, geoManager.buttonHeight); + success = LoadIcon(imgButtonYellow); + if (success) + InsertIntoOsdElementCache(oeButtonYellow, geoManager.buttonWidth, geoManager.buttonHeight); + success = LoadIcon(imgButtonBlue); + if (success) + InsertIntoOsdElementCache(oeButtonBlue, geoManager.buttonWidth, geoManager.buttonHeight); + + //Channel Logo Background + if (tvguideConfig.displayMode == eHorizontal) { + success = LoadIcon("osdElements/channellogoback_horizontal"); + } else { + success = LoadIcon("osdElements/channellogoback_vertical"); + } + if (success) + InsertIntoOsdElementCache(oeLogoBack, geoManager.channelLogoWidth, geoManager.channelLogoHeight); + + //Timeline Elements + std::string imgTimeline1, imgTimeline2, imgDateViewer; + if (tvguideConfig.displayMode == eHorizontal) { + imgTimeline1 = "osdElements/timeline1_horizontal"; + imgTimeline2 = "osdElements/timeline2_horizontal"; + imgDateViewer = "osdElements/timeline2_horizontal"; + } else { + imgTimeline1 = "osdElements/timeline1_vertical"; + imgTimeline2 = "osdElements/timeline2_vertical"; + imgDateViewer = "osdElements/date_vertical"; + } + std::string imgClock = "osdElements/clock"; + success = LoadIcon(imgTimeline1); + if (success) + InsertIntoOsdElementCache(oeTimeline1, geoManager.timeLineGridWidth, geoManager.timeLineGridHeight); + success = LoadIcon(imgTimeline2); + if (success) + InsertIntoOsdElementCache(oeTimeline2, geoManager.timeLineGridWidth, geoManager.timeLineGridHeight); + success = LoadIcon(imgDateViewer); + if (success) + InsertIntoOsdElementCache(oeDateViewer, geoManager.dateVieverWidth, geoManager.dateVieverHeight); + success = LoadIcon(imgClock); + if (success) + InsertIntoOsdElementCache(oeClock, geoManager.clockWidth, geoManager.clockHeight); + + //Channel Jump + success = LoadIcon("osdElements/channel_jump"); + if (success) + InsertIntoOsdElementCache(oeChannelJump, geoManager.channelJumpWidth, geoManager.channelJumpHeight); +} + +void cImageCache::PrepareGridIconCache(void) { + bool success = false; + //Create Buffers for Background + gridsAvailable = true; + std::string grid, grid_active; + if (tvguideConfig.displayMode == eHorizontal) { + grid = "osdElements/grid_horizontal"; + grid_active = "osdElements/grid_active_horizontal"; + } else { + grid = "osdElements/grid_vertical"; + grid_active = "osdElements/grid_active_vertical"; + } + success = LoadIcon(grid); + if (success) { + bufferGrid = buffer; + } else { + gridsAvailable = false; + } + success = LoadIcon(grid_active); + if (success) { + bufferGridActive = buffer; + } else { + gridsAvailable = false; + } + //Create Grid Background Templates + imgLeft = NULL; + imgLeftActive = NULL; + imgRight = NULL; + imgRightActive = NULL; + imgHead = NULL; + imgHeadActive = NULL; + imgBottom = NULL; + imgBottomActive = NULL; + + if (tvguideConfig.displayMode == eHorizontal) { + std::string left = "osdElements/grid_left"; + std::string right = "osdElements/grid_right"; + std::string left_active = "osdElements/grid_active_left"; + std::string right_active = "osdElements/grid_active_right"; + cornerWidth = 0; + cornerHeight = geoManager.rowHeight; + //first image determinates width + success = LoadIcon(left); + if (!success) + return; + int widthOriginal = 0; + int heightOriginal = 0; + widthOriginal = buffer.columns(); + heightOriginal = buffer.rows(); + cornerWidth = widthOriginal * cornerHeight / heightOriginal; + imgLeft = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(right); + if (success) + imgRight = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(left_active); + if (success) + imgLeftActive = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(right_active); + if (success) + imgRightActive = CreateImage(cornerWidth, cornerHeight, false); + } else { + std::string head = "osdElements/grid_head"; + std::string bottom = "osdElements/grid_bottom"; + std::string head_active = "osdElements/grid_active_head"; + std::string bottom_active = "osdElements/grid_active_bottom"; + cornerWidth = geoManager.colWidth; + cornerHeight = 0; + //first image determinates height + success = LoadIcon(head); + if (!success) + return; + int widthOriginal = 0; + int heightOriginal = 0; + widthOriginal = buffer.columns(); + heightOriginal = buffer.rows(); + cornerHeight = heightOriginal * cornerWidth / widthOriginal; + imgHead = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(bottom); + if (success) + imgBottom = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(head_active); + if (success) + imgHeadActive = CreateImage(cornerWidth, cornerHeight, false); + success = LoadIcon(bottom_active); + if (success) + imgBottomActive = CreateImage(cornerWidth, cornerHeight, false); + } +} + +void cImageCache::CreateGridIconCache(void) { + if (tvguideConfig.displayMode == eHorizontal) { + int gridHeight = geoManager.rowHeight; + for (int minutes = 5; minutes <= 120; minutes += 5) { + GetGrid(minutes * geoManager.minutePixel, gridHeight, false); + } + } else { + int gridWidth = geoManager.colWidth; + for (int minutes = 5; minutes <= 120; minutes += 5) { + GetGrid(gridWidth, minutes * geoManager.minutePixel, false); + } + } +} + +void cImageCache::CreateChannelGroupCache(void) { + bool success = false; + groupsHead = NULL; + groupsBottom = NULL; + groupsLeft = NULL; + groupsRight = NULL; + if (tvguideConfig.displayMode == eHorizontal) { + std::string channelGroupHead = "osdElements/channelgroup_head"; + std::string channelGroupBottom = "osdElements/channelgroup_bottom"; + int width = geoManager.channelGroupsWidth; + int heightHeadBottom = 0; + success = LoadIcon(channelGroupHead); + if (success) { + int widthOriginal = buffer.columns(); + int heightOriginal = buffer.rows(); + heightHeadBottom = heightOriginal * width / widthOriginal; + groupsHead = CreateImage(width, heightHeadBottom, false); + } + success = LoadIcon(channelGroupBottom); + if (success && heightHeadBottom) { + groupsBottom = CreateImage(width, heightHeadBottom, false); + } + for (int size = 1; size <= tvguideConfig.numGrids; ++size) { + InsertIntoGroupsCacheHorizontal(size); + } + } else { + std::string channelGroupLeft = "osdElements/channelgroup_left"; + std::string channelGroupRight = "osdElements/channelgroup_right"; + int widthHeadBottom = 0; + int height = geoManager.channelGroupsHeight; + success = LoadIcon(channelGroupLeft); + if (success) { + int widthOriginal = buffer.columns(); + int heightOriginal = buffer.rows(); + widthHeadBottom = widthOriginal * height / heightOriginal; + groupsLeft = CreateImage(widthHeadBottom, height, false); + } + success = LoadIcon(channelGroupRight); + if (success && widthHeadBottom) { + groupsRight = CreateImage(widthHeadBottom, height, false); + } + for (int size = 1; size <= tvguideConfig.numGrids; ++size) { + InsertIntoGroupsCacheVertical(size); + } + } + +} + +void cImageCache::CreateLogoCache(void) { + if (tvguideConfig.hideChannelLogos) + return; + if (tvguideConfig.numLogosInitial > 0) { + int channelsCached = 0; +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + for (const cChannel *channel = Channels->First(); channel; channel = Channels->Next(channel)) { +#else + for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { +#endif + if (channelsCached >= tvguideConfig.numLogosInitial) + break; + if (!channel->GroupSep()) { + bool success = LoadLogo(channel); + if (success) { + channelsCached++; + InsertIntoLogoCache(*channel->GetChannelID().ToString()); + } + } + + } + } +} + + +cImage *cImageCache::GetOsdElement(eOsdElementType type) { + std::map::iterator hit = osdElementCache.find(type); + if (hit != osdElementCache.end()) { + return (cImage*)hit->second; + } + return NULL; +} + +cImage *cImageCache::GetGrid(int width, int height, bool active) { + if (!gridsAvailable) + return NULL; + std::stringstream gridImageName; + gridImageName << width << "x" << height; + if (active) + gridImageName << "active"; + std::string gridImg = gridImageName.str(); + std::map::iterator hit = gridCache.find(gridImg); + if (hit != gridCache.end()) { + return (cImage*)hit->second; + } else { + InsertIntoGridCache(gridImg, width, height, active); + hit = gridCache.find(gridImg); + if (hit != gridCache.end()) { + return (cImage*)hit->second; + } + } + return NULL; +} + +cImage *cImageCache::GetChannelGroup(int width, int height) { + std::stringstream groupName; + groupName << width << "x" << height; + std::map::iterator hit = groupsCache.find(groupName.str()); + if (hit != groupsCache.end()) { + return (cImage*)hit->second; + } + return NULL; +} + +cImage *cImageCache::GetLogo(const cChannel *channel) { + if (!channel) + return NULL; + + std::map::iterator hit = logoCache.find(*channel->GetChannelID().ToString()); + + if (hit != logoCache.end()) { + return (cImage*)hit->second; + } else { + bool success = LoadLogo(channel); + if (success) { + if ((tvguideConfig.limitLogoCache) && ((int)logoCache.size() >= tvguideConfig.numLogosMax)) { + //logo cache is full, don't cache anymore + if (tempStaticLogo) { + delete tempStaticLogo; + tempStaticLogo = NULL; + } + tempStaticLogo = CreateImage(geoManager.logoWidth, geoManager.logoHeight); + return tempStaticLogo; + } else { + //add requested logo to cache + InsertIntoLogoCache(*channel->GetChannelID().ToString()); + hit = logoCache.find(*channel->GetChannelID().ToString()); + if (hit != logoCache.end()) { + return (cImage*)hit->second; + } + } + } + } + return NULL; +} + +cImage *cImageCache::GetIcon(std::string name, int width, int height) { + std::stringstream iconName; + iconName << name << width << "x" << height; + std::map::iterator hit = iconCache.find(iconName.str()); + if (hit != iconCache.end()) { + return (cImage*)hit->second; + } else { + std::stringstream iconPath; + iconPath << "recmenuicons/" << name; + bool success = LoadIcon(iconPath.str()); + if (success) { + cImage *image = CreateImage(width, height); + iconCache.insert(std::pair(iconName.str(), image)); + hit = iconCache.find(iconName.str()); + if (hit != iconCache.end()) { + return (cImage*)hit->second; + } + } + } + return NULL; +} + +void cImageCache::InsertIntoOsdElementCache(eOsdElementType type, int width, int height) { + cImage *image = CreateImage(width, height, false); + if (image) + osdElementCache.insert(std::pair(type, image)); +} + +void cImageCache::InsertIntoGridCache(std::string name, int width, int height, bool active) { + cImage *image = CreateGrid(width, height, active); + if (image) { + if (tvguideConfig.displayMode == eHorizontal) { + AddCornersHorizontal(image, active); + } else { + AddCornersVertical(image, active); + } + gridCache.insert(std::pair(name, image)); + } +} + +cImage *cImageCache::CreateGrid(int width, int height, bool active) { + if (width > geoManager.osdWidth || width < 6 || height > geoManager.osdHeight || height < 6) + return NULL; + Image *currentGridBuffer = NULL; + if (active) + currentGridBuffer = &bufferGridActive; + else + currentGridBuffer = &bufferGrid; + int w, h; + w = currentGridBuffer->columns(); + h = currentGridBuffer->rows(); + const PixelPacket *pixels = currentGridBuffer->getConstPixels(0, 0, w, h); + cImage *image = NULL; + image = new cImage(cSize(width, height)); + if (!image) + return NULL; + tColor *imgData = (tColor *)image->Data(); + if (w != width || h != height) { + ImageScaler scaler; + scaler.SetImageParameters(imgData, width, width, height, w, h); + for (const void *pixels_end = &pixels[w*h]; pixels < pixels_end; ++pixels) + scaler.PutSourcePixel(pixels->blue / ((MaxRGB + 1) / 256), + pixels->green / ((MaxRGB + 1) / 256), + pixels->red / ((MaxRGB + 1) / 256), + ~((unsigned char)(pixels->opacity / ((MaxRGB + 1) / 256)))); + return image; + } + for (const void *pixels_end = &pixels[width*height]; pixels < pixels_end; ++pixels) + *imgData++ = ((~int(pixels->opacity / ((MaxRGB + 1) / 256)) << 24) | + (int(pixels->green / ((MaxRGB + 1) / 256)) << 8) | + (int(pixels->red / ((MaxRGB + 1) / 256)) << 16) | + (int(pixels->blue / ((MaxRGB + 1) / 256)) )); + return image; +} + +void cImageCache::AddCornersHorizontal(cImage *img, bool active) { + int imgWidth = img->Width(); + cImage *cornerLeft = NULL; + cImage *cornerRight = NULL; + if (active) { + cornerLeft = imgLeftActive; + cornerRight = imgRightActive; + } else { + cornerLeft = imgLeft; + cornerRight = imgRight; + } + if (!cornerLeft || !cornerRight) + return; + int maxX = std::min(cornerWidth, imgWidth); + for (int row = 0; row < cornerHeight; row++) { + for (int col = 0; col < maxX; ++col) { + img->SetPixel(cPoint(col, row), cornerLeft->GetPixel(cPoint(col, row))); + img->SetPixel(cPoint(imgWidth - maxX + col, row), cornerRight->GetPixel(cPoint(col, row))); + } + } +} + +void cImageCache::AddCornersVertical(cImage *img, bool active) { + int imgHeight = img->Height(); + cImage *cornerHead = NULL; + cImage *cornerBottom = NULL; + if (active) { + cornerHead = imgHeadActive; + cornerBottom = imgBottomActive; + } else { + cornerHead = imgHead; + cornerBottom = imgBottom; + } + if (!cornerHead || !cornerBottom) + return; + int maxY = std::min(cornerHeight, imgHeight); + for (int row = 0; row < maxY; row++) { + for (int col = 0; col < cornerWidth; ++col) { + img->SetPixel(cPoint(col, row), cornerHead->GetPixel(cPoint(col, row))); + img->SetPixel(cPoint(col, imgHeight - maxY + row), cornerBottom->GetPixel(cPoint(col, row))); + } + } +} + +void cImageCache::InsertIntoGroupsCacheHorizontal(int size) { + int width = geoManager.channelGroupsWidth; + bool success = LoadIcon("osdElements/channelgroup_horizontal"); + if (success) { + int height = size * geoManager.rowHeight; + std::stringstream name; + name << width << "x" << height; + cImage *image = CreateImage(width, height, false); + if (image) { + AddCornersGroupHorizontal(image); + groupsCache.insert(std::pair(name.str(), image)); + } + } +} + +void cImageCache::InsertIntoGroupsCacheVertical(int size) { + int height = geoManager.channelGroupsHeight; + bool success = LoadIcon("osdElements/channelgroup_vertical"); + if (success) { + int width = size * geoManager.colWidth; + std::stringstream name; + name << width << "x" << height; + cImage *image = CreateImage(width, height, false); + if (image) { + AddCornersGroupVertical(image); + groupsCache.insert(std::pair(name.str(), image)); + } + } +} + +void cImageCache::AddCornersGroupHorizontal(cImage *img) { + if (!groupsHead || !groupsBottom || !img) + return; + int imgWidth = img->Width(); + int imgHeight = img->Height(); + int heightHeadBottom = groupsHead->Height(); + int maxY = std::min(heightHeadBottom, imgHeight); + for (int row = 0; row < maxY; row++) { + for (int col = 0; col < imgWidth; ++col) { + img->SetPixel(cPoint(col, row), groupsHead->GetPixel(cPoint(col, row))); + img->SetPixel(cPoint(col, imgHeight - maxY + row), groupsBottom->GetPixel(cPoint(col, row))); + } + } +} + +void cImageCache::AddCornersGroupVertical(cImage *img) { + if (!groupsLeft || !groupsRight || !img) + return; + int imgWidth = img->Width(); + int imgHeight = img->Height(); + int widthLeftRight = groupsLeft->Width(); + int maxX = std::min(widthLeftRight, imgWidth); + for (int row = 0; row < imgHeight; row++) { + for (int col = 0; col < maxX; ++col) { + img->SetPixel(cPoint(col, row), groupsLeft->GetPixel(cPoint(col, row))); + img->SetPixel(cPoint(imgWidth - maxX + col, row), groupsRight->GetPixel(cPoint(col, row))); + } + } +} + +bool cImageCache::LoadIcon(std::string name) { + bool success = false; + if (tvguideConfig.iconsPathSet) { + cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPath, *tvguideConfig.themeName); + success = LoadImage(name, *iconPathTheme, "png"); + if (success) { + return true; + } else { + success = LoadImage(name, *tvguideConfig.iconPath, "png"); + if (success) { + return true; + } + } + } + if (!success) { + cString iconPathTheme = cString::sprintf("%s%s/", *tvguideConfig.iconPathDefault, *tvguideConfig.themeName); + success = LoadImage(name, *iconPathTheme, "png"); + if (success) { + return true; + } else { + success = LoadImage(name, *tvguideConfig.iconPathDefault, "png"); + if (success) { + return true; + } + } + } + return false; +} + +bool cImageCache::LoadLogo(const cChannel *channel) { + if (!channel) + return false; + std::string channelID = StrToLowerCase(*(channel->GetChannelID().ToString())); + std::string logoLower = StrToLowerCase(channel->Name()); + bool success = false; + cString extension; + if (tvguideConfig.logoExtension == 0) { + extension = "png"; + } else if (tvguideConfig.logoExtension == 1) { + extension = "jpg"; + } + + if (tvguideConfig.logoPathSet) { + success = LoadImage(channelID.c_str(), *tvguideConfig.logoPath, *extension); + if (success) + return true; + success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPath, *extension); + if (success) + return true; + } + success = LoadImage(channelID.c_str(), *tvguideConfig.logoPathDefault, *extension); + if (success) + return true; + success = LoadImage(logoLower.c_str(), *tvguideConfig.logoPathDefault, *extension); + return success; +} + +void cImageCache::InsertIntoLogoCache(std::string channelID) { + cImage *image = CreateImage(geoManager.logoWidth, geoManager.logoHeight); + logoCache.insert(std::pair(channelID, image)); +} + +std::string cImageCache::GetCacheSize(eCacheType type) { + std::stringstream result; + int sizeByte = 0; + int numImages = 0; + if (type == ctOsdElement) { + for(std::map::const_iterator it = osdElementCache.begin(); it != osdElementCache.end(); it++) { + cImage *img = (cImage*)it->second; + if (img) + sizeByte += img->Width() * img->Height() * sizeof(tColor); + } + numImages = osdElementCache.size(); + } else if ((type == ctGrid) || (type == ctLogo) || (type == ctChannelGroup) || (type == ctIcon)) { + std::map *cache; + if (type == ctGrid) + cache = &gridCache; + else if (type == ctLogo) + cache = &logoCache; + else if (type == ctChannelGroup) + cache = &groupsCache; + else if (type == ctIcon) + cache = &iconCache; + + for(std::map::const_iterator it = cache->begin(); it != cache->end(); it++) { + cImage *img = (cImage*)it->second; + if (img) + sizeByte += img->Width() * img->Height() * sizeof(tColor); + } + numImages = cache->size(); + } + result << numImages << " " << tr("images") << " / " << sizeByte/1024 << " KByte"; + return result.str(); +} + +void cImageCache::Clear(void) { + for(std::map::const_iterator it = osdElementCache.begin(); it != osdElementCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + osdElementCache.clear(); + + for(std::map::const_iterator it = gridCache.begin(); it != gridCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + gridCache.clear(); + + for(std::map::const_iterator it = groupsCache.begin(); it != groupsCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + groupsCache.clear(); + + for(std::map::const_iterator it = logoCache.begin(); it != logoCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + logoCache.clear(); + + for(std::map::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + iconCache.clear(); + + if (tempStaticLogo) + delete tempStaticLogo; + if (groupsHead) + delete groupsHead; + if (groupsBottom) + delete groupsBottom; + if (groupsLeft) + delete groupsLeft; + if (groupsRight) + delete groupsRight; + if (imgLeft) + delete imgLeft; + if (imgLeftActive) + delete imgLeftActive; + if (imgRight) + delete imgRight; + if (imgRightActive) + delete imgRightActive; + if (imgHead) + delete imgHead; + if (imgHeadActive) + delete imgHeadActive; + if (imgBottom) + delete imgBottom; + if (imgBottomActive) + delete imgBottomActive; + + tempStaticLogo = NULL; + groupsHead = NULL; + groupsBottom = NULL; + groupsLeft = NULL; + groupsRight = NULL; + imgLeft = NULL; + imgLeftActive = NULL; + imgRight = NULL; + imgRightActive = NULL; + imgHead = NULL; + imgHeadActive = NULL; + imgBottom = NULL; + imgBottomActive = NULL; +} diff --git a/imagecache.h b/imagecache.h index 365e910..6d241bd 100644 --- a/imagecache.h +++ b/imagecache.h @@ -1,92 +1,92 @@ -#ifndef __TVGUIDE_IMAGECACHE_H -#define __TVGUIDE_IMAGECACHE_H - -#define X_DISPLAY_MISSING - -#include -#include -#include "imagemagickwrapper.h" - -enum eCacheType { - ctOsdElement = 0, - ctGrid, - ctLogo, - ctChannelGroup, - ctIcon, -}; - -enum eOsdElementType { - oeNone = -1, - oeStatusHeaderContentFull, - oeStatusHeaderContentWindowed, - oeStatusHeaderTVFrame, - oeButtonRed, - oeButtonGreen, - oeButtonYellow, - oeButtonBlue, - oeLogoBack, - oeTimeline1, - oeTimeline2, - oeDateViewer, - oeClock, - oeChannelJump, -}; - -class cImageCache : public cImageMagickWrapper { -public: - cImageCache(); - ~cImageCache(); - void CreateCache(void); - cImage *GetOsdElement(eOsdElementType type); - cImage *GetGrid(int width, int height, bool active); - cImage *GetChannelGroup(int width, int height); - cImage *GetLogo(const cChannel *channel); - cImage *GetIcon(std::string name, int width, int height); - std::string GetCacheSize(eCacheType type); - void Clear(void); -private: - cImage *tempStaticLogo; - Image bufferGrid; - Image bufferGridActive; - bool gridsAvailable; - int cornerWidth; - int cornerHeight; - cImage *imgLeft; - cImage *imgLeftActive; - cImage *imgRight; - cImage *imgRightActive; - cImage *imgHead; - cImage *imgHeadActive; - cImage *imgBottom; - cImage *imgBottomActive; - cImage *imgChannelgroupHead; - cImage *imgChannelgroupBottom; - cImage *groupsHead; - cImage *groupsBottom; - cImage *groupsLeft; - cImage *groupsRight; - std::map osdElementCache; - std::map gridCache; - std::map groupsCache; - std::map logoCache; - std::map iconCache; - void CreateOsdIconCache(void); - void PrepareGridIconCache(void); - void CreateGridIconCache(void); - void CreateChannelGroupCache(void); - void CreateLogoCache(void); - bool LoadIcon(std::string name); - void InsertIntoOsdElementCache(eOsdElementType type, int width=0, int height=0); - void InsertIntoGridCache(std::string name, int width, int height, bool active); - cImage *CreateGrid(int width, int height, bool active); - void AddCornersHorizontal(cImage *img, bool active); - void AddCornersVertical(cImage *img, bool active); - void InsertIntoGroupsCacheHorizontal(int size); - void InsertIntoGroupsCacheVertical(int size); - void AddCornersGroupHorizontal(cImage *img); - void AddCornersGroupVertical(cImage *img); - bool LoadLogo(const cChannel *channel); - void InsertIntoLogoCache(std::string channelID); -}; - -#endif //__TVGUIDE_IMAGECACHE_H \ No newline at end of file +#ifndef __TVGUIDE_IMAGECACHE_H +#define __TVGUIDE_IMAGECACHE_H + +#define X_DISPLAY_MISSING + +#include +#include +#include "imagemagickwrapper.h" + +enum eCacheType { + ctOsdElement = 0, + ctGrid, + ctLogo, + ctChannelGroup, + ctIcon, +}; + +enum eOsdElementType { + oeNone = -1, + oeStatusHeaderContentFull, + oeStatusHeaderContentWindowed, + oeStatusHeaderTVFrame, + oeButtonRed, + oeButtonGreen, + oeButtonYellow, + oeButtonBlue, + oeLogoBack, + oeTimeline1, + oeTimeline2, + oeDateViewer, + oeClock, + oeChannelJump, +}; + +class cImageCache : public cImageMagickWrapper { +public: + cImageCache(); + ~cImageCache(); + void CreateCache(void); + cImage *GetOsdElement(eOsdElementType type); + cImage *GetGrid(int width, int height, bool active); + cImage *GetChannelGroup(int width, int height); + cImage *GetLogo(const cChannel *channel); + cImage *GetIcon(std::string name, int width, int height); + std::string GetCacheSize(eCacheType type); + void Clear(void); +private: + cImage *tempStaticLogo; + Image bufferGrid; + Image bufferGridActive; + bool gridsAvailable; + int cornerWidth; + int cornerHeight; + cImage *imgLeft; + cImage *imgLeftActive; + cImage *imgRight; + cImage *imgRightActive; + cImage *imgHead; + cImage *imgHeadActive; + cImage *imgBottom; + cImage *imgBottomActive; + cImage *imgChannelgroupHead; + cImage *imgChannelgroupBottom; + cImage *groupsHead; + cImage *groupsBottom; + cImage *groupsLeft; + cImage *groupsRight; + std::map osdElementCache; + std::map gridCache; + std::map groupsCache; + std::map logoCache; + std::map iconCache; + void CreateOsdIconCache(void); + void PrepareGridIconCache(void); + void CreateGridIconCache(void); + void CreateChannelGroupCache(void); + void CreateLogoCache(void); + bool LoadIcon(std::string name); + void InsertIntoOsdElementCache(eOsdElementType type, int width=0, int height=0); + void InsertIntoGridCache(std::string name, int width, int height, bool active); + cImage *CreateGrid(int width, int height, bool active); + void AddCornersHorizontal(cImage *img, bool active); + void AddCornersVertical(cImage *img, bool active); + void InsertIntoGroupsCacheHorizontal(int size); + void InsertIntoGroupsCacheVertical(int size); + void AddCornersGroupHorizontal(cImage *img); + void AddCornersGroupVertical(cImage *img); + bool LoadLogo(const cChannel *channel); + void InsertIntoLogoCache(std::string channelID); +}; + +#endif //__TVGUIDE_IMAGECACHE_H diff --git a/osdmanager.c b/osdmanager.c index eefedf4..93a0bc8 100644 --- a/osdmanager.c +++ b/osdmanager.c @@ -1,38 +1,38 @@ -#include "config.h" -#include "osdmanager.h" - -cOsdManager::cOsdManager(void) { -} - -bool cOsdManager::setOsd() { - osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop()); - if (osd) { - tArea Area = { 0, 0, cOsd::OsdWidth(), cOsd::OsdHeight(), 32 }; - if (osd->SetAreas(&Area, 1) == oeOk) { - return true; - } - } - return false; -} - -void cOsdManager::setBackground() { - - if (tvguideConfig.displayStatusHeader && tvguideConfig.scaleVideo) { - int widthStatus = cOsd::OsdWidth() - geoManager.statusHeaderHeight * 16 / 9; - osd->DrawRectangle(0, 0, widthStatus, geoManager.statusHeaderHeight, theme.Color(clrBackgroundOSD)); - osd->DrawRectangle(0, geoManager.statusHeaderHeight, Width(), Height(), theme.Color(clrBackgroundOSD)); - } - else - osd->DrawRectangle(0, 0, Width(), Height(), theme.Color(clrBackgroundOSD)); - -} - -cPixmap *cOsdManager::requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort) { - return osd->CreatePixmap(Layer, ViewPort, DrawPort); -} - -void cOsdManager::releasePixmap(cPixmap *pixmap) { - if (!pixmap) - return; - osd->DestroyPixmap(pixmap); -} \ No newline at end of file +#include "config.h" +#include "osdmanager.h" + +cOsdManager::cOsdManager(void) { +} + +bool cOsdManager::setOsd() { + osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop()); + if (osd) { + tArea Area = { 0, 0, cOsd::OsdWidth(), cOsd::OsdHeight(), 32 }; + if (osd->SetAreas(&Area, 1) == oeOk) { + return true; + } + } + return false; +} + +void cOsdManager::setBackground() { + + if (tvguideConfig.displayStatusHeader && tvguideConfig.scaleVideo) { + int widthStatus = cOsd::OsdWidth() - geoManager.statusHeaderHeight * 16 / 9; + osd->DrawRectangle(0, 0, widthStatus, geoManager.statusHeaderHeight, theme.Color(clrBackgroundOSD)); + osd->DrawRectangle(0, geoManager.statusHeaderHeight, Width(), Height(), theme.Color(clrBackgroundOSD)); + } + else + osd->DrawRectangle(0, 0, Width(), Height(), theme.Color(clrBackgroundOSD)); + +} + +cPixmap *cOsdManager::requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort) { + return osd->CreatePixmap(Layer, ViewPort, DrawPort); +} + +void cOsdManager::releasePixmap(cPixmap *pixmap) { + if (!pixmap) + return; + osd->DestroyPixmap(pixmap); +} diff --git a/osdmanager.h b/osdmanager.h index a0c7936..3607d40 100644 --- a/osdmanager.h +++ b/osdmanager.h @@ -1,23 +1,23 @@ -#ifndef __TVGUIDE_OSDMANAGER_H -#define __TVGUIDE_OSDMANAGER_H - -#include - -class cOsdManager { - private: - cOsd *osd; - public: - cOsdManager(void); - bool setOsd(); - void setBackground(); - void flush() {osd->Flush();}; - cPixmap *requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); - void releasePixmap(cPixmap *pixmap); - void deleteOsd() {delete osd;}; - int Width() { return osd->Width(); }; - int Height() { return osd->Height(); }; - int Top() { return osd->Top(); }; - int Left() { return osd->Left(); }; -}; - -#endif //__TVGUIDE_OSDMANAGER_H +#ifndef __TVGUIDE_OSDMANAGER_H +#define __TVGUIDE_OSDMANAGER_H + +#include + +class cOsdManager { + private: + cOsd *osd; + public: + cOsdManager(void); + bool setOsd(); + void setBackground(); + void flush() {osd->Flush();}; + cPixmap *requestPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); + void releasePixmap(cPixmap *pixmap); + void deleteOsd() {delete osd;}; + int Width() { return osd->Width(); }; + int Height() { return osd->Height(); }; + int Top() { return osd->Top(); }; + int Left() { return osd->Left(); }; +}; + +#endif //__TVGUIDE_OSDMANAGER_H diff --git a/searchtimer.c b/searchtimer.c index f46e163..2a4651f 100644 --- a/searchtimer.c +++ b/searchtimer.c @@ -1,629 +1,629 @@ -#include -#include -#include -#include -#include -#include -#include "tools.h" -#include "searchtimer.h" - -// -- cTVGuideSearchTimer ----------------------------------------------------------------- -cTVGuideSearchTimer::cTVGuideSearchTimer(void) { - strTimer = ""; - ID = -1; - searchString = ""; - useTime = false; - startTime = 0000; - stopTime = 2359; - useChannel = false; -#if VDRVERSNUM >= 20301 - { - LOCK_CHANNELS_READ; - channelMin = Channels->GetByNumber(cDevice::CurrentChannel()); - channelMax = Channels->GetByNumber(cDevice::CurrentChannel()); - } -#else - channelMin = Channels.GetByNumber(cDevice::CurrentChannel()); - channelMax = Channels.GetByNumber(cDevice::CurrentChannel()); -#endif - channelGroup = ""; - useCase = false; - mode = 0; - useTitle = true; - useSubtitle = true; - useDescription = true; - useDuration = false; - minDuration = 0; - maxDuration = 2359; - useAsSearchTimer = true; - useDayOfWeek = false; - dayOfWeek = 0; - directory = ""; - useEpisode = 0; - priority = 50; - lifetime = 99; - marginStart = 5; - marginStop = 5; - useVPS = false; - action = 0; - useExtEPGInfo = 0; - extEPGInfoValues = ""; - avoidRepeats = 1; - compareTitle = 1; - compareSubtitle = 1; - compareSummary = 1; - compareSummaryMatchInPercent = 90; - compareDate = 0; - allowedRepeats = 1; - catvaluesAvoidRepeat = 0; - repeatsWithinDays = 0; - delAfterDays = 0; - recordingsKeep = 0; - switchMinsBefore = 1; - pauseOnNrRecordings = 0; - blacklistMode = 0; - blacklists = ""; - fuzzyTolerance = 1; - useInFavorites = 0; - menuTemplate = 0; - delMode = 0; - delAfterCountRecs = 0; - delAfterDaysOfFirstRec = 0; - useAsSearchTimerFrom = 0; - useAsSearchTimerTil = 0; - ignoreMissingEPGCats = 0; - unmuteSoundOnSwitch = 0; - contentsFilter = ""; -} - -cTVGuideSearchTimer::~cTVGuideSearchTimer(void) { -} - -bool cTVGuideSearchTimer::operator < (const cTVGuideSearchTimer& other) const { - std::string searchStringOther = other.GetSearchString(); - searchStringOther = StrToLowerCase(searchStringOther); - std::string thisSearchString = StrToLowerCase(searchString); - int comp = thisSearchString.compare(searchStringOther); - if (comp < 0) - return true; - return false; -} - - -void cTVGuideSearchTimer::SetTemplate(std::string tmpl) { - std::stringstream searchTimerString; - searchTimerString << "0:"; - searchTimerString << tmpl; - strTimer = searchTimerString.str(); -} - -int cTVGuideSearchTimer::DayOfWeek(void) { - int vdrDayOfWeek = 0; - if (dayOfWeek >= 0) { - vdrDayOfWeek = pow(2, (dayOfWeek+6)%7); - } else if (dayOfWeek < 0) { - int absDayOfWeek = abs(dayOfWeek); - for (int i=0; i < 7; i++) { - if (absDayOfWeek & (1 << i)) { - vdrDayOfWeek += pow(2, (i+6)%7); - } - } - } - return vdrDayOfWeek; -} - -void cTVGuideSearchTimer::SetDayOfWeek(int VDRDayOfWeek) { - int epgSearchDayOfWeek = 0; - for (int i=0; i < 7; i++) { - if (VDRDayOfWeek & (1 << i)) { - epgSearchDayOfWeek += pow(2, (i+1)%7); - } - } - this->dayOfWeek = epgSearchDayOfWeek * (-1); -} - -/* - 0 - unique search timer id - 1 - the search term - 2 - use time? 0/1 - 3 - start time in HHMM - 4 - stop time in HHMM - 5 - use channel? 0 = no, 1 = Interval, 2 = Channel group, 3 = FTA only - 6 - if 'use channel' = 1 then channel id[|channel id] in VDR format, - one entry or min/max entry separated with |, if 'use channel' = 2 - then the channel group name - 7 - match case? 0/1 - 8 - search mode: - 0 - the whole term must appear as substring - 1 - all single terms (delimiters are blank,',', ';', '|' or '~') - must exist as substrings. - 2 - at least one term (delimiters are blank, ',', ';', '|' or '~') - must exist as substring. - 3 - matches exactly - 4 - regular expression - 9 - use title? 0/1 - 10 - use subtitle? 0/1 - 11 - use description? 0/1 - 12 - use duration? 0/1 - 13 - min duration in hhmm - 14 - max duration in hhmm - 15 - use as search timer? 0/1 - 16 - use day of week? 0/1 - 17 - day of week (0 = Sunday, 1 = Monday...; - -1 Sunday, -2 Monday, -4 Tuesday, ...; -7 Sun, Mon, Tue) - 18 - use series recording? 0/1 - 19 - directory for recording - 20 - priority of recording - 21 - lifetime of recording - 22 - time margin for start in minutes - 23 - time margin for stop in minutes - 24 - use VPS? 0/1 - 25 - action: - 0 = create a timer - 1 = announce only via OSD (no timer) - 2 = switch only (no timer) - 3 = announce via OSD and switch (no timer) - 4 = announce via mail - 26 - use extended EPG info? 0/1 - 27 - extended EPG info values. This entry has the following format - (delimiter is '|' for each category, '#' separates id and value): - 1 - the id of the extended EPG info category as specified in - epgsearchcats.conf - 2 - the value of the extended EPG info category - (a ':' will be translated to "!^colon^!", e.g. in "16:9") - 28 - avoid repeats? 0/1 - 29 - allowed repeats - 30 - compare title when testing for a repeat? 0/1 - 31 - compare subtitle when testing for a repeat? 0/1/2 - 0 - no - 1 - yes - 2 - yes, if present - 32 - compare description when testing for a repeat? 0/1 - 33 - compare extended EPG info when testing for a repeat? - This entry is a bit field of the category IDs. - 34 - accepts repeats only within x days - 35 - delete a recording automatically after x days - 36 - but keep this number of recordings anyway - 37 - minutes before switch (if action = 2) - 38 - pause if x recordings already exist - 39 - blacklist usage mode (0 none, 1 selection, 2 all) - 40 - selected blacklist IDs separated with '|' - 41 - fuzzy tolerance value for fuzzy searching - 42 - use this search in favorites menu (0 no, 1 yes) - 43 - id of a menu search template - 44 - auto deletion mode (0 don't delete search timer, 1 delete after given - count of recordings, 2 delete after given days after first recording) - 45 - count of recordings after which to delete the search timer - 46 - count of days after the first recording after which to delete the search - timer - 47 - first day where the search timer is active (see parameter 16) - 48 - last day where the search timer is active (see parameter 16) - 49 - ignore missing EPG categories? 0/1 - 50 - unmute sound if off when used as switch timer - 51 - percentage of match when comparing the summary of two events (with 'avoid repeats') - 52 - HEX representation of the content descriptors, each descriptor ID is represented with 2 chars - 53 - compare date when testing for a repeat? (0=no, 1=same day, 2=same week, 3=same month) -*/ -bool cTVGuideSearchTimer::Parse(bool readTemplate) { - splitstring s(strTimer.c_str()); - std::vector values = s.split(':', 1); - int numValues = values.size(); - if (numValues < 12) - return false; - for (int value = 0; value < numValues; value++) { - switch (value) { - case 0: - if (!readTemplate) - ID = atoi(values[value].c_str()); - break; - case 1: - if (!readTemplate) { - std::string searchStringMasked = values[value]; - std::replace(searchStringMasked.begin(), searchStringMasked.end(), '|', ':'); - searchString = searchStringMasked; - } - break; - case 2: - useTime = atoi(values[value].c_str()); - break; - case 3: - if (useTime) { - startTime = atoi(values[value].c_str()); - } - break; - case 4: - if (useTime) { - stopTime = atoi(values[value].c_str()); - } - break; - case 5: - useChannel = atoi(values[value].c_str()); - break; - case 6: - if (useChannel == 0) { - channelMin = NULL; - channelMax = NULL; - } else if (useChannel == 1) { - int minNum = 0, maxNum = 0; - int fields = sscanf(values[value].c_str(), "%d-%d", &minNum, &maxNum); - if (fields == 0) { // stored with ID - char *channelMinbuffer = NULL; - char *channelMaxbuffer = NULL; - int channels = sscanf(values[value].c_str(), "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer); -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true); -#else - channelMin = Channels.GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true); -#endif - if (!channelMin) { - esyslog("ERROR: channel '%s' not defined", channelMinbuffer); - channelMin = channelMax = NULL; - useChannel = 0; - } - if (channels == 1) - channelMax = channelMin; - else { -#if VDRVERSNUM >= 20301 - channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true); -#else - channelMax = Channels.GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true); -#endif - if (!channelMax) { - esyslog("ERROR: channel '%s' not defined", channelMaxbuffer); - channelMin = channelMax = NULL; - useChannel = 0; - } - } - free(channelMinbuffer); - free(channelMaxbuffer); - } - } else if (useChannel == 2) - channelGroup = values[value]; - break; - case 7: - useCase = atoi(values[value].c_str()); - break; - case 8: - mode = atoi(values[value].c_str()); - break; - case 9: - useTitle = atoi(values[value].c_str()); - break; - case 10: - useSubtitle = atoi(values[value].c_str()); - break; - case 11: - useDescription = atoi(values[value].c_str()); - break; - case 12: - useDuration = atoi(values[value].c_str()); - break; - case 13: - minDuration = atoi(values[value].c_str()); - break; - case 14: - maxDuration = atoi(values[value].c_str()); - break; - case 15: - useAsSearchTimer = atoi(values[value].c_str()); - break; - case 16: - useDayOfWeek = atoi(values[value].c_str()); - break; - case 17: - dayOfWeek = atoi(values[value].c_str()); - break; - case 18: - useEpisode = atoi(values[value].c_str()); - break; - case 19: - directory = values[value]; - break; - case 20: - priority = atoi(values[value].c_str()); - break; - case 21: - lifetime = atoi(values[value].c_str()); - break; - case 22: - marginStart = atoi(values[value].c_str()); - break; - case 23: - marginStop = atoi(values[value].c_str()); - break; - case 24: - useVPS = atoi(values[value].c_str()); - break; - case 25: - action = atoi(values[value].c_str()); - break; - case 26: - useExtEPGInfo = atoi(values[value].c_str()); - break; - case 27: - extEPGInfoValues = values[value]; - break; - case 28: - avoidRepeats = atoi(values[value].c_str()); - break; - case 29: - allowedRepeats = atoi(values[value].c_str()); - break; - case 30: - compareTitle = atoi(values[value].c_str()); - break; - case 31: - compareSubtitle = atoi(values[value].c_str()); - break; - case 32: - compareSummary = atoi(values[value].c_str()); - break; - case 33: - catvaluesAvoidRepeat = atol(values[value].c_str()); - break; - case 34: - repeatsWithinDays = atoi(values[value].c_str()); - break; - case 35: - delAfterDays = atoi(values[value].c_str()); - break; - case 36: - recordingsKeep = atoi(values[value].c_str()); - break; - case 37: - switchMinsBefore = atoi(values[value].c_str()); - break; - case 38: - pauseOnNrRecordings = atoi(values[value].c_str()); - break; - case 39: - blacklistMode = atoi(values[value].c_str()); - break; - case 40: - blacklists = values[value]; - break; - case 41: - fuzzyTolerance = atoi(values[value].c_str()); - break; - case 42: - useInFavorites = atoi(values[value].c_str()); - break; - case 43: - menuTemplate = atoi(values[value].c_str()); - break; - case 44: - delMode = atoi(values[value].c_str()); - break; - case 45: - delAfterCountRecs = atoi(values[value].c_str()); - break; - case 46: - delAfterDaysOfFirstRec = atoi(values[value].c_str()); - break; - case 47: - useAsSearchTimerFrom = atol(values[value].c_str()); - break; - case 48: - useAsSearchTimerTil = atol(values[value].c_str()); - break; - case 49: - ignoreMissingEPGCats = atoi(values[value].c_str()); - break; - case 50: - unmuteSoundOnSwitch = atoi(values[value].c_str()); - break; - case 51: - compareSummaryMatchInPercent = atoi(values[value].c_str()); - break; - case 52: - contentsFilter = values[value]; - break; - case 53: - compareDate = atoi(values[value].c_str()); - break; - default: - break; - } - } - return true; -} - -std::string cTVGuideSearchTimer::BuildSearchString(void) { - std::stringstream search; - // 0 - 2 - if (ID > -1) - search << ID << ":"; - else - search << ":"; - std::string searchStringMasked = searchString; - std::replace(searchStringMasked.begin(), searchStringMasked.end(), ':', '|'); - search << searchStringMasked << ":"; - search << useTime << ":"; - - // 3 - 6 - if (useTime) { - search << *cString::sprintf("%04d", startTime) << ":"; - search << *cString::sprintf("%04d", stopTime) << ":"; - } else { - search << "::"; - } - - search << useChannel << ":"; - if (useChannel == 1) { - if (channelMin && channelMax) { - if (channelMin->Number() < channelMax->Number()) - search << std::string(channelMin->GetChannelID().ToString()) << "|" << std::string(channelMax->GetChannelID().ToString()) << ":"; - else - search << std::string(channelMin->GetChannelID().ToString()) << ":"; - } else { - search << "0:"; - } - } else if (useChannel == 2) { - search << channelGroup << ":"; - } else { - search << "0:"; - } - // 7 - 14 - search << useCase << ":"; - search << mode << ":"; - search << useTitle << ":"; - search << useSubtitle << ":"; - search << useDescription << ":"; - search << useDuration << ":"; - if (useDuration) { - search << *cString::sprintf("%04d", minDuration) << ":"; - search << *cString::sprintf("%04d", maxDuration) << ":"; - } else { - search << "::"; - } - //15 - 53 - search << useAsSearchTimer << ":"; - search << useDayOfWeek << ":"; - search << dayOfWeek << ":"; - search << useEpisode << ":"; - search << directory << ":"; - search << priority << ":"; - search << lifetime << ":"; - search << marginStart << ":"; - search << marginStop << ":"; - search << useVPS << ":"; - search << action << ":"; - search << useExtEPGInfo << ":"; - search << extEPGInfoValues << ":"; - search << avoidRepeats << ":"; - search << allowedRepeats << ":"; - search << compareTitle << ":"; - search << compareSubtitle << ":"; - search << compareSummary << ":"; - search << catvaluesAvoidRepeat << ":"; - search << repeatsWithinDays << ":"; - search << delAfterDays << ":"; - search << recordingsKeep << ":"; - search << switchMinsBefore << ":"; - search << pauseOnNrRecordings << ":"; - search << blacklistMode << ":"; - search << blacklists << ":"; - search << fuzzyTolerance << ":"; - search << useInFavorites << ":"; - search << menuTemplate << ":"; - search << delMode << ":"; - search << delAfterCountRecs << ":"; - search << delAfterDaysOfFirstRec << ":"; - search << useAsSearchTimerFrom << ":"; - search << useAsSearchTimerTil << ":"; - search << ignoreMissingEPGCats << ":"; - search << unmuteSoundOnSwitch << ":"; - search << compareSummaryMatchInPercent << ":"; - search << contentsFilter << ":"; - search << compareDate; - - strTimer = search.str(); - return strTimer; -} - -bool cTVGuideSearchTimer::IsActive(void) { - if (useAsSearchTimer) - return true; - return false; -} - -int cTVGuideSearchTimer::GetNumTimers(void) { - int numTimers = 0; - if (ID < 0) - return numTimers; -#if VDRVERSNUM >= 20301 - LOCK_TIMERS_READ; - for (const cTimer *timer = Timers->First(); timer; timer = Timers->Next(timer)) { -#else - for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { -#endif - char* searchID = GetAuxValue(timer, "s-id"); - if (!searchID) continue; - if (ID == atoi(searchID)) - numTimers++; - free(searchID); - } - return numTimers; -} - -int cTVGuideSearchTimer::GetNumRecordings(void) { - int numRecordings = 0; - if (ID < 0) - return numRecordings; -#if VDRVERSNUM >= 20301 - LOCK_RECORDINGS_READ; - for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) { -#else - for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) { -#endif - if (recording->IsEdited()) - continue; - if (!recording->Info()) - continue; - char* searchID = GetAuxValue(recording, "s-id"); - if (!searchID) continue; - if (ID == atoi(searchID)) - numRecordings++; - free(searchID); - } - return numRecordings; -} - -void cTVGuideSearchTimer::GetSearchModes(std::vector *searchModes) { - searchModes->push_back(tr("whole term must appear")); - searchModes->push_back(tr("all terms must exist")); - searchModes->push_back(tr("one term must exist")); - searchModes->push_back(tr("exact match")); - searchModes->push_back(tr("regular expression")); - searchModes->push_back(tr("fuzzy")); -} - -void cTVGuideSearchTimer::GetUseChannelModes(std::vector *useChannelModes) { - useChannelModes->push_back(tr("No")); - useChannelModes->push_back(tr("Interval")); - useChannelModes->push_back(tr("Channel Group")); - useChannelModes->push_back(tr("only FTA")); -} - -void cTVGuideSearchTimer::GetCompareDateModes(std::vector *compareDateModes) { - compareDateModes->push_back(tr("No")); - compareDateModes->push_back(tr("same day")); - compareDateModes->push_back(tr("same week")); - compareDateModes->push_back(tr("same month")); -} - -void cTVGuideSearchTimer::GetSearchTimerModes(std::vector *searchTimerModes) { - searchTimerModes->push_back(tr("Record")); - searchTimerModes->push_back(tr("Announce by OSD")); - searchTimerModes->push_back(tr("Switch only")); - searchTimerModes->push_back(tr("Announce and switch")); - searchTimerModes->push_back(tr("Announce by mail")); - searchTimerModes->push_back(tr("Inactive record")); -} - -void cTVGuideSearchTimer::GetDelModes(std::vector *delModes) { - delModes->push_back(tr("no")); - delModes->push_back(tr("count recordings")); - delModes->push_back(tr("count days")); -} - -void cTVGuideSearchTimer::Dump(void) { - esyslog("tvguide searchtimer: strTimer: %s", strTimer.c_str()); - esyslog("tvguide searchtimer: ID: %d", ID); - esyslog("tvguide searchtimer: searchString: %s", searchString.c_str()); - esyslog("tvguide searchtimer: useTime: %d", useTime); - esyslog("tvguide searchtimer: startTime: %d", startTime); - esyslog("tvguide searchtimer: stopTime: %d", stopTime); - esyslog("tvguide searchtimer: useChannel: %d", useChannel); - if (channelMin) - esyslog("tvguide searchtimer: channelMin: %s", channelMin->Name()); - if (channelMax) - esyslog("tvguide searchtimer: channelMax: %s", channelMax->Name()); - esyslog("tvguide searchtimer: channelGroup: %s", channelGroup.c_str()); - esyslog("tvguide searchtimer: useCase: %d", useCase); - esyslog("tvguide searchtimer: mode: %d", mode); - esyslog("tvguide searchtimer: useTitle: %d", useTitle); - esyslog("tvguide searchtimer: useSubtitle: %d", useSubtitle); - esyslog("tvguide searchtimer: useDescription: %d", useDescription); -} +#include +#include +#include +#include +#include +#include +#include "tools.h" +#include "searchtimer.h" + +// -- cTVGuideSearchTimer ----------------------------------------------------------------- +cTVGuideSearchTimer::cTVGuideSearchTimer(void) { + strTimer = ""; + ID = -1; + searchString = ""; + useTime = false; + startTime = 0000; + stopTime = 2359; + useChannel = false; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + channelMin = Channels->GetByNumber(cDevice::CurrentChannel()); + channelMax = Channels->GetByNumber(cDevice::CurrentChannel()); + } +#else + channelMin = Channels.GetByNumber(cDevice::CurrentChannel()); + channelMax = Channels.GetByNumber(cDevice::CurrentChannel()); +#endif + channelGroup = ""; + useCase = false; + mode = 0; + useTitle = true; + useSubtitle = true; + useDescription = true; + useDuration = false; + minDuration = 0; + maxDuration = 2359; + useAsSearchTimer = true; + useDayOfWeek = false; + dayOfWeek = 0; + directory = ""; + useEpisode = 0; + priority = 50; + lifetime = 99; + marginStart = 5; + marginStop = 5; + useVPS = false; + action = 0; + useExtEPGInfo = 0; + extEPGInfoValues = ""; + avoidRepeats = 1; + compareTitle = 1; + compareSubtitle = 1; + compareSummary = 1; + compareSummaryMatchInPercent = 90; + compareDate = 0; + allowedRepeats = 1; + catvaluesAvoidRepeat = 0; + repeatsWithinDays = 0; + delAfterDays = 0; + recordingsKeep = 0; + switchMinsBefore = 1; + pauseOnNrRecordings = 0; + blacklistMode = 0; + blacklists = ""; + fuzzyTolerance = 1; + useInFavorites = 0; + menuTemplate = 0; + delMode = 0; + delAfterCountRecs = 0; + delAfterDaysOfFirstRec = 0; + useAsSearchTimerFrom = 0; + useAsSearchTimerTil = 0; + ignoreMissingEPGCats = 0; + unmuteSoundOnSwitch = 0; + contentsFilter = ""; +} + +cTVGuideSearchTimer::~cTVGuideSearchTimer(void) { +} + +bool cTVGuideSearchTimer::operator < (const cTVGuideSearchTimer& other) const { + std::string searchStringOther = other.GetSearchString(); + searchStringOther = StrToLowerCase(searchStringOther); + std::string thisSearchString = StrToLowerCase(searchString); + int comp = thisSearchString.compare(searchStringOther); + if (comp < 0) + return true; + return false; +} + + +void cTVGuideSearchTimer::SetTemplate(std::string tmpl) { + std::stringstream searchTimerString; + searchTimerString << "0:"; + searchTimerString << tmpl; + strTimer = searchTimerString.str(); +} + +int cTVGuideSearchTimer::DayOfWeek(void) { + int vdrDayOfWeek = 0; + if (dayOfWeek >= 0) { + vdrDayOfWeek = pow(2, (dayOfWeek+6)%7); + } else if (dayOfWeek < 0) { + int absDayOfWeek = abs(dayOfWeek); + for (int i=0; i < 7; i++) { + if (absDayOfWeek & (1 << i)) { + vdrDayOfWeek += pow(2, (i+6)%7); + } + } + } + return vdrDayOfWeek; +} + +void cTVGuideSearchTimer::SetDayOfWeek(int VDRDayOfWeek) { + int epgSearchDayOfWeek = 0; + for (int i=0; i < 7; i++) { + if (VDRDayOfWeek & (1 << i)) { + epgSearchDayOfWeek += pow(2, (i+1)%7); + } + } + this->dayOfWeek = epgSearchDayOfWeek * (-1); +} + +/* + 0 - unique search timer id + 1 - the search term + 2 - use time? 0/1 + 3 - start time in HHMM + 4 - stop time in HHMM + 5 - use channel? 0 = no, 1 = Interval, 2 = Channel group, 3 = FTA only + 6 - if 'use channel' = 1 then channel id[|channel id] in VDR format, + one entry or min/max entry separated with |, if 'use channel' = 2 + then the channel group name + 7 - match case? 0/1 + 8 - search mode: + 0 - the whole term must appear as substring + 1 - all single terms (delimiters are blank,',', ';', '|' or '~') + must exist as substrings. + 2 - at least one term (delimiters are blank, ',', ';', '|' or '~') + must exist as substring. + 3 - matches exactly + 4 - regular expression + 9 - use title? 0/1 + 10 - use subtitle? 0/1 + 11 - use description? 0/1 + 12 - use duration? 0/1 + 13 - min duration in hhmm + 14 - max duration in hhmm + 15 - use as search timer? 0/1 + 16 - use day of week? 0/1 + 17 - day of week (0 = Sunday, 1 = Monday...; + -1 Sunday, -2 Monday, -4 Tuesday, ...; -7 Sun, Mon, Tue) + 18 - use series recording? 0/1 + 19 - directory for recording + 20 - priority of recording + 21 - lifetime of recording + 22 - time margin for start in minutes + 23 - time margin for stop in minutes + 24 - use VPS? 0/1 + 25 - action: + 0 = create a timer + 1 = announce only via OSD (no timer) + 2 = switch only (no timer) + 3 = announce via OSD and switch (no timer) + 4 = announce via mail + 26 - use extended EPG info? 0/1 + 27 - extended EPG info values. This entry has the following format + (delimiter is '|' for each category, '#' separates id and value): + 1 - the id of the extended EPG info category as specified in + epgsearchcats.conf + 2 - the value of the extended EPG info category + (a ':' will be translated to "!^colon^!", e.g. in "16:9") + 28 - avoid repeats? 0/1 + 29 - allowed repeats + 30 - compare title when testing for a repeat? 0/1 + 31 - compare subtitle when testing for a repeat? 0/1/2 + 0 - no + 1 - yes + 2 - yes, if present + 32 - compare description when testing for a repeat? 0/1 + 33 - compare extended EPG info when testing for a repeat? + This entry is a bit field of the category IDs. + 34 - accepts repeats only within x days + 35 - delete a recording automatically after x days + 36 - but keep this number of recordings anyway + 37 - minutes before switch (if action = 2) + 38 - pause if x recordings already exist + 39 - blacklist usage mode (0 none, 1 selection, 2 all) + 40 - selected blacklist IDs separated with '|' + 41 - fuzzy tolerance value for fuzzy searching + 42 - use this search in favorites menu (0 no, 1 yes) + 43 - id of a menu search template + 44 - auto deletion mode (0 don't delete search timer, 1 delete after given + count of recordings, 2 delete after given days after first recording) + 45 - count of recordings after which to delete the search timer + 46 - count of days after the first recording after which to delete the search + timer + 47 - first day where the search timer is active (see parameter 16) + 48 - last day where the search timer is active (see parameter 16) + 49 - ignore missing EPG categories? 0/1 + 50 - unmute sound if off when used as switch timer + 51 - percentage of match when comparing the summary of two events (with 'avoid repeats') + 52 - HEX representation of the content descriptors, each descriptor ID is represented with 2 chars + 53 - compare date when testing for a repeat? (0=no, 1=same day, 2=same week, 3=same month) +*/ +bool cTVGuideSearchTimer::Parse(bool readTemplate) { + splitstring s(strTimer.c_str()); + std::vector values = s.split(':', 1); + int numValues = values.size(); + if (numValues < 12) + return false; + for (int value = 0; value < numValues; value++) { + switch (value) { + case 0: + if (!readTemplate) + ID = atoi(values[value].c_str()); + break; + case 1: + if (!readTemplate) { + std::string searchStringMasked = values[value]; + std::replace(searchStringMasked.begin(), searchStringMasked.end(), '|', ':'); + searchString = searchStringMasked; + } + break; + case 2: + useTime = atoi(values[value].c_str()); + break; + case 3: + if (useTime) { + startTime = atoi(values[value].c_str()); + } + break; + case 4: + if (useTime) { + stopTime = atoi(values[value].c_str()); + } + break; + case 5: + useChannel = atoi(values[value].c_str()); + break; + case 6: + if (useChannel == 0) { + channelMin = NULL; + channelMax = NULL; + } else if (useChannel == 1) { + int minNum = 0, maxNum = 0; + int fields = sscanf(values[value].c_str(), "%d-%d", &minNum, &maxNum); + if (fields == 0) { // stored with ID + char *channelMinbuffer = NULL; + char *channelMaxbuffer = NULL; + int channels = sscanf(values[value].c_str(), "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer); +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true); +#else + channelMin = Channels.GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true); +#endif + if (!channelMin) { + esyslog("ERROR: channel '%s' not defined", channelMinbuffer); + channelMin = channelMax = NULL; + useChannel = 0; + } + if (channels == 1) + channelMax = channelMin; + else { +#if VDRVERSNUM >= 20301 + channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true); +#else + channelMax = Channels.GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true); +#endif + if (!channelMax) { + esyslog("ERROR: channel '%s' not defined", channelMaxbuffer); + channelMin = channelMax = NULL; + useChannel = 0; + } + } + free(channelMinbuffer); + free(channelMaxbuffer); + } + } else if (useChannel == 2) + channelGroup = values[value]; + break; + case 7: + useCase = atoi(values[value].c_str()); + break; + case 8: + mode = atoi(values[value].c_str()); + break; + case 9: + useTitle = atoi(values[value].c_str()); + break; + case 10: + useSubtitle = atoi(values[value].c_str()); + break; + case 11: + useDescription = atoi(values[value].c_str()); + break; + case 12: + useDuration = atoi(values[value].c_str()); + break; + case 13: + minDuration = atoi(values[value].c_str()); + break; + case 14: + maxDuration = atoi(values[value].c_str()); + break; + case 15: + useAsSearchTimer = atoi(values[value].c_str()); + break; + case 16: + useDayOfWeek = atoi(values[value].c_str()); + break; + case 17: + dayOfWeek = atoi(values[value].c_str()); + break; + case 18: + useEpisode = atoi(values[value].c_str()); + break; + case 19: + directory = values[value]; + break; + case 20: + priority = atoi(values[value].c_str()); + break; + case 21: + lifetime = atoi(values[value].c_str()); + break; + case 22: + marginStart = atoi(values[value].c_str()); + break; + case 23: + marginStop = atoi(values[value].c_str()); + break; + case 24: + useVPS = atoi(values[value].c_str()); + break; + case 25: + action = atoi(values[value].c_str()); + break; + case 26: + useExtEPGInfo = atoi(values[value].c_str()); + break; + case 27: + extEPGInfoValues = values[value]; + break; + case 28: + avoidRepeats = atoi(values[value].c_str()); + break; + case 29: + allowedRepeats = atoi(values[value].c_str()); + break; + case 30: + compareTitle = atoi(values[value].c_str()); + break; + case 31: + compareSubtitle = atoi(values[value].c_str()); + break; + case 32: + compareSummary = atoi(values[value].c_str()); + break; + case 33: + catvaluesAvoidRepeat = atol(values[value].c_str()); + break; + case 34: + repeatsWithinDays = atoi(values[value].c_str()); + break; + case 35: + delAfterDays = atoi(values[value].c_str()); + break; + case 36: + recordingsKeep = atoi(values[value].c_str()); + break; + case 37: + switchMinsBefore = atoi(values[value].c_str()); + break; + case 38: + pauseOnNrRecordings = atoi(values[value].c_str()); + break; + case 39: + blacklistMode = atoi(values[value].c_str()); + break; + case 40: + blacklists = values[value]; + break; + case 41: + fuzzyTolerance = atoi(values[value].c_str()); + break; + case 42: + useInFavorites = atoi(values[value].c_str()); + break; + case 43: + menuTemplate = atoi(values[value].c_str()); + break; + case 44: + delMode = atoi(values[value].c_str()); + break; + case 45: + delAfterCountRecs = atoi(values[value].c_str()); + break; + case 46: + delAfterDaysOfFirstRec = atoi(values[value].c_str()); + break; + case 47: + useAsSearchTimerFrom = atol(values[value].c_str()); + break; + case 48: + useAsSearchTimerTil = atol(values[value].c_str()); + break; + case 49: + ignoreMissingEPGCats = atoi(values[value].c_str()); + break; + case 50: + unmuteSoundOnSwitch = atoi(values[value].c_str()); + break; + case 51: + compareSummaryMatchInPercent = atoi(values[value].c_str()); + break; + case 52: + contentsFilter = values[value]; + break; + case 53: + compareDate = atoi(values[value].c_str()); + break; + default: + break; + } + } + return true; +} + +std::string cTVGuideSearchTimer::BuildSearchString(void) { + std::stringstream search; + // 0 - 2 + if (ID > -1) + search << ID << ":"; + else + search << ":"; + std::string searchStringMasked = searchString; + std::replace(searchStringMasked.begin(), searchStringMasked.end(), ':', '|'); + search << searchStringMasked << ":"; + search << useTime << ":"; + + // 3 - 6 + if (useTime) { + search << *cString::sprintf("%04d", startTime) << ":"; + search << *cString::sprintf("%04d", stopTime) << ":"; + } else { + search << "::"; + } + + search << useChannel << ":"; + if (useChannel == 1) { + if (channelMin && channelMax) { + if (channelMin->Number() < channelMax->Number()) + search << std::string(channelMin->GetChannelID().ToString()) << "|" << std::string(channelMax->GetChannelID().ToString()) << ":"; + else + search << std::string(channelMin->GetChannelID().ToString()) << ":"; + } else { + search << "0:"; + } + } else if (useChannel == 2) { + search << channelGroup << ":"; + } else { + search << "0:"; + } + // 7 - 14 + search << useCase << ":"; + search << mode << ":"; + search << useTitle << ":"; + search << useSubtitle << ":"; + search << useDescription << ":"; + search << useDuration << ":"; + if (useDuration) { + search << *cString::sprintf("%04d", minDuration) << ":"; + search << *cString::sprintf("%04d", maxDuration) << ":"; + } else { + search << "::"; + } + //15 - 53 + search << useAsSearchTimer << ":"; + search << useDayOfWeek << ":"; + search << dayOfWeek << ":"; + search << useEpisode << ":"; + search << directory << ":"; + search << priority << ":"; + search << lifetime << ":"; + search << marginStart << ":"; + search << marginStop << ":"; + search << useVPS << ":"; + search << action << ":"; + search << useExtEPGInfo << ":"; + search << extEPGInfoValues << ":"; + search << avoidRepeats << ":"; + search << allowedRepeats << ":"; + search << compareTitle << ":"; + search << compareSubtitle << ":"; + search << compareSummary << ":"; + search << catvaluesAvoidRepeat << ":"; + search << repeatsWithinDays << ":"; + search << delAfterDays << ":"; + search << recordingsKeep << ":"; + search << switchMinsBefore << ":"; + search << pauseOnNrRecordings << ":"; + search << blacklistMode << ":"; + search << blacklists << ":"; + search << fuzzyTolerance << ":"; + search << useInFavorites << ":"; + search << menuTemplate << ":"; + search << delMode << ":"; + search << delAfterCountRecs << ":"; + search << delAfterDaysOfFirstRec << ":"; + search << useAsSearchTimerFrom << ":"; + search << useAsSearchTimerTil << ":"; + search << ignoreMissingEPGCats << ":"; + search << unmuteSoundOnSwitch << ":"; + search << compareSummaryMatchInPercent << ":"; + search << contentsFilter << ":"; + search << compareDate; + + strTimer = search.str(); + return strTimer; +} + +bool cTVGuideSearchTimer::IsActive(void) { + if (useAsSearchTimer) + return true; + return false; +} + +int cTVGuideSearchTimer::GetNumTimers(void) { + int numTimers = 0; + if (ID < 0) + return numTimers; +#if VDRVERSNUM >= 20301 + LOCK_TIMERS_READ; + for (const cTimer *timer = Timers->First(); timer; timer = Timers->Next(timer)) { +#else + for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { +#endif + char* searchID = GetAuxValue(timer, "s-id"); + if (!searchID) continue; + if (ID == atoi(searchID)) + numTimers++; + free(searchID); + } + return numTimers; +} + +int cTVGuideSearchTimer::GetNumRecordings(void) { + int numRecordings = 0; + if (ID < 0) + return numRecordings; +#if VDRVERSNUM >= 20301 + LOCK_RECORDINGS_READ; + for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) { +#else + for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) { +#endif + if (recording->IsEdited()) + continue; + if (!recording->Info()) + continue; + char* searchID = GetAuxValue(recording, "s-id"); + if (!searchID) continue; + if (ID == atoi(searchID)) + numRecordings++; + free(searchID); + } + return numRecordings; +} + +void cTVGuideSearchTimer::GetSearchModes(std::vector *searchModes) { + searchModes->push_back(tr("whole term must appear")); + searchModes->push_back(tr("all terms must exist")); + searchModes->push_back(tr("one term must exist")); + searchModes->push_back(tr("exact match")); + searchModes->push_back(tr("regular expression")); + searchModes->push_back(tr("fuzzy")); +} + +void cTVGuideSearchTimer::GetUseChannelModes(std::vector *useChannelModes) { + useChannelModes->push_back(tr("No")); + useChannelModes->push_back(tr("Interval")); + useChannelModes->push_back(tr("Channel Group")); + useChannelModes->push_back(tr("only FTA")); +} + +void cTVGuideSearchTimer::GetCompareDateModes(std::vector *compareDateModes) { + compareDateModes->push_back(tr("No")); + compareDateModes->push_back(tr("same day")); + compareDateModes->push_back(tr("same week")); + compareDateModes->push_back(tr("same month")); +} + +void cTVGuideSearchTimer::GetSearchTimerModes(std::vector *searchTimerModes) { + searchTimerModes->push_back(tr("Record")); + searchTimerModes->push_back(tr("Announce by OSD")); + searchTimerModes->push_back(tr("Switch only")); + searchTimerModes->push_back(tr("Announce and switch")); + searchTimerModes->push_back(tr("Announce by mail")); + searchTimerModes->push_back(tr("Inactive record")); +} + +void cTVGuideSearchTimer::GetDelModes(std::vector *delModes) { + delModes->push_back(tr("no")); + delModes->push_back(tr("count recordings")); + delModes->push_back(tr("count days")); +} + +void cTVGuideSearchTimer::Dump(void) { + esyslog("tvguide searchtimer: strTimer: %s", strTimer.c_str()); + esyslog("tvguide searchtimer: ID: %d", ID); + esyslog("tvguide searchtimer: searchString: %s", searchString.c_str()); + esyslog("tvguide searchtimer: useTime: %d", useTime); + esyslog("tvguide searchtimer: startTime: %d", startTime); + esyslog("tvguide searchtimer: stopTime: %d", stopTime); + esyslog("tvguide searchtimer: useChannel: %d", useChannel); + if (channelMin) + esyslog("tvguide searchtimer: channelMin: %s", channelMin->Name()); + if (channelMax) + esyslog("tvguide searchtimer: channelMax: %s", channelMax->Name()); + esyslog("tvguide searchtimer: channelGroup: %s", channelGroup.c_str()); + esyslog("tvguide searchtimer: useCase: %d", useCase); + esyslog("tvguide searchtimer: mode: %d", mode); + esyslog("tvguide searchtimer: useTitle: %d", useTitle); + esyslog("tvguide searchtimer: useSubtitle: %d", useSubtitle); + esyslog("tvguide searchtimer: useDescription: %d", useDescription); +} diff --git a/searchtimer.h b/searchtimer.h index 65a04c9..da88b10 100644 --- a/searchtimer.h +++ b/searchtimer.h @@ -1,136 +1,136 @@ -#ifndef __TVGUIDE_SEARCHTIMER_H -#define __TVGUIDE_SEARCHTIMER_H - - -class cTVGuideSearchTimer { -friend class cRecMenuSearchTimerEdit; -protected: - std::string strTimer; - int ID; - std::string searchString; - int useTime; - int startTime; - int stopTime; - int useChannel; - const cChannel *channelMin; - const cChannel *channelMax; - std::string channelGroup; - int useCase; - int mode; - int useTitle; - int useSubtitle; - int useDescription; - int useDuration; - int minDuration; - int maxDuration; - int useAsSearchTimer; - int useDayOfWeek; - int dayOfWeek; - int useEpisode; - std::string directory; - int priority; - int lifetime; - int marginStart; - int marginStop; - int useVPS; - int action; - int useExtEPGInfo; - std::string extEPGInfoValues; - int avoidRepeats; - int allowedRepeats; - int compareTitle; - int compareSubtitle; - int compareSummary; - unsigned long catvaluesAvoidRepeat; - int repeatsWithinDays; - int delAfterDays; - int recordingsKeep; - int switchMinsBefore; - int pauseOnNrRecordings; - int blacklistMode; - std::string blacklists; - int fuzzyTolerance; - int useInFavorites; - int menuTemplate; - int delMode; - int delAfterCountRecs; - int delAfterDaysOfFirstRec; - int useAsSearchTimerFrom; - int useAsSearchTimerTil; - int ignoreMissingEPGCats; - int unmuteSoundOnSwitch; - int compareSummaryMatchInPercent; - std::string contentsFilter; - int compareDate; -public: - cTVGuideSearchTimer(void); - virtual ~cTVGuideSearchTimer(void); - bool operator < (const cTVGuideSearchTimer& other) const; - void SetEPGSearchString(std::string strTimer) { this->strTimer = strTimer; }; - void SetTemplate(std::string tmpl); - bool Parse(bool readTemplate = false); - std::string BuildSearchString(void); - int GetID(void) { return ID; }; - //GETTER - std::string GetSearchString(void) const { return searchString; }; - bool IsActive(void); - int DayOfWeek(void); - bool UseInFavorites(void) { return useInFavorites; }; - //SETTER - void SetSearchString(std::string searchString) { this->searchString = searchString; }; - void SetSearchMode(int mode) { this->mode = mode; }; - void SetFuzzyTolerance(int fuzzyTolerance) { this->fuzzyTolerance = fuzzyTolerance; }; - void SetUseCase(bool useCase) { this->useCase = useCase; }; - void SetUseTitle(bool useTitle) { this->useTitle = useTitle; }; - void SetUseSubtitle(bool useSubtitle) { this->useSubtitle = useSubtitle; }; - void SetUseDesription(bool useDescription) { this->useDescription = useDescription; }; - void SetUseChannel(int useChannel) { this->useChannel = useChannel; }; - void SetStartChannel(const cChannel *channelMin) { this->channelMin = channelMin; }; - void SetStopChannel(const cChannel *channelMax) { this->channelMax = channelMax; }; - void SetChannelGroup(std::string channelGroup) { this->channelGroup = channelGroup; }; - void SetUseTime(bool useTime) { this->useTime = useTime; }; - void SetStartTime(int startTime) { this->startTime = startTime; }; - void SetStopTime(int stopTime) { this->stopTime = stopTime; }; - void SetUseDayOfWeek(bool useDayOfWeek) { this->useDayOfWeek = useDayOfWeek; }; - void SetDayOfWeek(int VDRDayOfWeek); - void SetUseDuration(bool useDuration) { this->useDuration = useDuration; }; - void SetMinDuration(int minDuration) { this->minDuration = minDuration; }; - void SetMaxDuration(int maxDuration) { this->maxDuration = maxDuration; }; - void SetUseEpisode(int useEpisode) { this->useEpisode = useEpisode; }; - void SetDirectory(std::string directory) { this-> directory = directory; }; - void SetDelAfterDays(int delAfterDays) { this->delAfterDays = delAfterDays; }; - void SetRecordingsKeep(int recordingsKeep) { this->recordingsKeep = recordingsKeep; }; - void SetPauseOnNrRecordings(int pauseOnNrRecordings) { this-> pauseOnNrRecordings = pauseOnNrRecordings; }; - void SetPriority(int priority) { this->priority = priority; }; - void SetLifetime(int lifetime) { this->lifetime = lifetime; }; - void SetMarginStart(int marginStart) { this->marginStart = marginStart; }; - void SetMarginStop(int marginStop) { this->marginStop = marginStop; }; - void SetUseVPS(bool useVPS) { this->useVPS = useVPS; }; - void SetAvoidRepeats(bool avoidRepeats) { this->avoidRepeats = avoidRepeats; }; - void SetAllowedRepeats(int allowedRepeats) { this->allowedRepeats = allowedRepeats; }; - void SetRepeatsWithinDays(int repeatsWithinDays) { this-> repeatsWithinDays = repeatsWithinDays; }; - void SetCompareTitle(bool compareTitle) { this->compareTitle = compareTitle; }; - void SetCompareSubtitle(bool compareSubtitle) { this->compareSubtitle = compareSubtitle; }; - void SetCompareSummary(bool compareSummary) { this->compareSummary = compareSummary; }; - void SetCompareSummaryMatchInPercent(int compareSummaryMatchInPercent) { this->compareSummaryMatchInPercent = compareSummaryMatchInPercent; }; - void SetCompareDate(int compareDate) { this->compareDate = compareDate; }; - void SetUseInFavorites(bool useInFavorites) { this->useInFavorites = useInFavorites; }; - void SetUseAsSearchTimer(bool useAsSearchTimer) { this->useAsSearchTimer = useAsSearchTimer; }; - void SetAction(int action) { this->action = action; }; - void SetSwitchMinsBefore(int switchMinsBefore) { this->switchMinsBefore = switchMinsBefore; }; - void SetUnmuteSoundOnSwitch(bool unmuteSoundOnSwitch) { this->unmuteSoundOnSwitch = unmuteSoundOnSwitch; }; - void SetDelMode(bool delMode) { this->delMode = delMode; }; - void SetDelAfterCountRecs(bool delAfterCountRecs) { this->delAfterCountRecs = delAfterCountRecs; }; - void SetDelAfterDaysOfFirstRec(bool delAfterDaysOfFirstRec) { this->delAfterDaysOfFirstRec = delAfterDaysOfFirstRec; }; - //COMMON - int GetNumTimers(void); - int GetNumRecordings(void); - void GetSearchModes(std::vector *searchModes); - void GetUseChannelModes(std::vector *useChannelModes); - void GetSearchTimerModes(std::vector *searchTimerModes); - void GetCompareDateModes(std::vector *compareDateModes); - void GetDelModes(std::vector *delModes); - void Dump(void); -}; - -#endif //__TVGUIDE_SEARCHTIMER_H +#ifndef __TVGUIDE_SEARCHTIMER_H +#define __TVGUIDE_SEARCHTIMER_H + + +class cTVGuideSearchTimer { +friend class cRecMenuSearchTimerEdit; +protected: + std::string strTimer; + int ID; + std::string searchString; + int useTime; + int startTime; + int stopTime; + int useChannel; + const cChannel *channelMin; + const cChannel *channelMax; + std::string channelGroup; + int useCase; + int mode; + int useTitle; + int useSubtitle; + int useDescription; + int useDuration; + int minDuration; + int maxDuration; + int useAsSearchTimer; + int useDayOfWeek; + int dayOfWeek; + int useEpisode; + std::string directory; + int priority; + int lifetime; + int marginStart; + int marginStop; + int useVPS; + int action; + int useExtEPGInfo; + std::string extEPGInfoValues; + int avoidRepeats; + int allowedRepeats; + int compareTitle; + int compareSubtitle; + int compareSummary; + unsigned long catvaluesAvoidRepeat; + int repeatsWithinDays; + int delAfterDays; + int recordingsKeep; + int switchMinsBefore; + int pauseOnNrRecordings; + int blacklistMode; + std::string blacklists; + int fuzzyTolerance; + int useInFavorites; + int menuTemplate; + int delMode; + int delAfterCountRecs; + int delAfterDaysOfFirstRec; + int useAsSearchTimerFrom; + int useAsSearchTimerTil; + int ignoreMissingEPGCats; + int unmuteSoundOnSwitch; + int compareSummaryMatchInPercent; + std::string contentsFilter; + int compareDate; +public: + cTVGuideSearchTimer(void); + virtual ~cTVGuideSearchTimer(void); + bool operator < (const cTVGuideSearchTimer& other) const; + void SetEPGSearchString(std::string strTimer) { this->strTimer = strTimer; }; + void SetTemplate(std::string tmpl); + bool Parse(bool readTemplate = false); + std::string BuildSearchString(void); + int GetID(void) { return ID; }; + //GETTER + std::string GetSearchString(void) const { return searchString; }; + bool IsActive(void); + int DayOfWeek(void); + bool UseInFavorites(void) { return useInFavorites; }; + //SETTER + void SetSearchString(std::string searchString) { this->searchString = searchString; }; + void SetSearchMode(int mode) { this->mode = mode; }; + void SetFuzzyTolerance(int fuzzyTolerance) { this->fuzzyTolerance = fuzzyTolerance; }; + void SetUseCase(bool useCase) { this->useCase = useCase; }; + void SetUseTitle(bool useTitle) { this->useTitle = useTitle; }; + void SetUseSubtitle(bool useSubtitle) { this->useSubtitle = useSubtitle; }; + void SetUseDesription(bool useDescription) { this->useDescription = useDescription; }; + void SetUseChannel(int useChannel) { this->useChannel = useChannel; }; + void SetStartChannel(const cChannel *channelMin) { this->channelMin = channelMin; }; + void SetStopChannel(const cChannel *channelMax) { this->channelMax = channelMax; }; + void SetChannelGroup(std::string channelGroup) { this->channelGroup = channelGroup; }; + void SetUseTime(bool useTime) { this->useTime = useTime; }; + void SetStartTime(int startTime) { this->startTime = startTime; }; + void SetStopTime(int stopTime) { this->stopTime = stopTime; }; + void SetUseDayOfWeek(bool useDayOfWeek) { this->useDayOfWeek = useDayOfWeek; }; + void SetDayOfWeek(int VDRDayOfWeek); + void SetUseDuration(bool useDuration) { this->useDuration = useDuration; }; + void SetMinDuration(int minDuration) { this->minDuration = minDuration; }; + void SetMaxDuration(int maxDuration) { this->maxDuration = maxDuration; }; + void SetUseEpisode(int useEpisode) { this->useEpisode = useEpisode; }; + void SetDirectory(std::string directory) { this-> directory = directory; }; + void SetDelAfterDays(int delAfterDays) { this->delAfterDays = delAfterDays; }; + void SetRecordingsKeep(int recordingsKeep) { this->recordingsKeep = recordingsKeep; }; + void SetPauseOnNrRecordings(int pauseOnNrRecordings) { this-> pauseOnNrRecordings = pauseOnNrRecordings; }; + void SetPriority(int priority) { this->priority = priority; }; + void SetLifetime(int lifetime) { this->lifetime = lifetime; }; + void SetMarginStart(int marginStart) { this->marginStart = marginStart; }; + void SetMarginStop(int marginStop) { this->marginStop = marginStop; }; + void SetUseVPS(bool useVPS) { this->useVPS = useVPS; }; + void SetAvoidRepeats(bool avoidRepeats) { this->avoidRepeats = avoidRepeats; }; + void SetAllowedRepeats(int allowedRepeats) { this->allowedRepeats = allowedRepeats; }; + void SetRepeatsWithinDays(int repeatsWithinDays) { this-> repeatsWithinDays = repeatsWithinDays; }; + void SetCompareTitle(bool compareTitle) { this->compareTitle = compareTitle; }; + void SetCompareSubtitle(bool compareSubtitle) { this->compareSubtitle = compareSubtitle; }; + void SetCompareSummary(bool compareSummary) { this->compareSummary = compareSummary; }; + void SetCompareSummaryMatchInPercent(int compareSummaryMatchInPercent) { this->compareSummaryMatchInPercent = compareSummaryMatchInPercent; }; + void SetCompareDate(int compareDate) { this->compareDate = compareDate; }; + void SetUseInFavorites(bool useInFavorites) { this->useInFavorites = useInFavorites; }; + void SetUseAsSearchTimer(bool useAsSearchTimer) { this->useAsSearchTimer = useAsSearchTimer; }; + void SetAction(int action) { this->action = action; }; + void SetSwitchMinsBefore(int switchMinsBefore) { this->switchMinsBefore = switchMinsBefore; }; + void SetUnmuteSoundOnSwitch(bool unmuteSoundOnSwitch) { this->unmuteSoundOnSwitch = unmuteSoundOnSwitch; }; + void SetDelMode(bool delMode) { this->delMode = delMode; }; + void SetDelAfterCountRecs(bool delAfterCountRecs) { this->delAfterCountRecs = delAfterCountRecs; }; + void SetDelAfterDaysOfFirstRec(bool delAfterDaysOfFirstRec) { this->delAfterDaysOfFirstRec = delAfterDaysOfFirstRec; }; + //COMMON + int GetNumTimers(void); + int GetNumRecordings(void); + void GetSearchModes(std::vector *searchModes); + void GetUseChannelModes(std::vector *useChannelModes); + void GetSearchTimerModes(std::vector *searchTimerModes); + void GetCompareDateModes(std::vector *compareDateModes); + void GetDelModes(std::vector *delModes); + void Dump(void); +}; + +#endif //__TVGUIDE_SEARCHTIMER_H diff --git a/statusheader.c b/statusheader.c index f5db056..0ef5562 100644 --- a/statusheader.c +++ b/statusheader.c @@ -1,143 +1,143 @@ -#include "tools.h" -#include "services/scraper2vdr.h" -#include "imageloader.h" -#include "statusheader.h" - -cStatusHeader::cStatusHeader(void) { - color = theme.Color(clrStatusHeader); - colorBlending = theme.Color(clrStatusHeaderBlending); - height = geoManager.statusHeaderHeight; - width = geoManager.headerContentWidth; - tvFrameWidth = geoManager.tvFrameWidth; - pixmap = osdManager.requestPixmap(1, cRect(0, 0, width, height)); - pixmapText = osdManager.requestPixmap(2, cRect(0, 0, width, height)); - pixmapTVFrame = osdManager.requestPixmap(1, cRect(width, 0, tvFrameWidth, height)); -} - -cStatusHeader::~cStatusHeader(void) { - osdManager.releasePixmap(pixmapText); - osdManager.releasePixmap(pixmapTVFrame); - if (tvguideConfig.scaleVideo) { - cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null); - cDevice::PrimaryDevice()->ScaleVideo(vidWin); - } -} - -void cStatusHeader::Draw(void) { - pixmapText->Fill(clrTransparent); - pixmapTVFrame->Fill(clrTransparent); - if (tvguideConfig.style == eStyleGraphical) { - if (tvguideConfig.scaleVideo) { - drawBackgroundGraphical(bgStatusHeaderWindowed); - cImage *tvFrameBack = imgCache.GetOsdElement(oeStatusHeaderTVFrame); - if (tvFrameBack) - pixmapTVFrame->DrawImage(cPoint(0,0), *tvFrameBack); - } else { - drawBackgroundGraphical(bgStatusHeaderFull); - } - } else { - if (tvguideConfig.decorateVideo) { - DecorateVideoFrame(); - } - drawBackground(); - drawBorder(); - } -} - -void cStatusHeader::ScaleVideo(void) { - if (tvguideConfig.scaleVideo) { - int width = height * 16 / 9; - int x = osdManager.Left() + geoManager.osdWidth - width; - int y = osdManager.Top(); - cRect availableRect(x, y, width, height); - cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect); - cDevice::PrimaryDevice()->ScaleVideo(vidWin); - } -} - -void cStatusHeader::DrawInfoText(cGrid *grid) { - int border = 10; - int textWidth = 0; - textWidth = width - 2 * border; - tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; - pixmapText->Fill(clrTransparent); - int x = border; - int y = border; - if (!grid->isDummy()) { - const cEvent *event = grid->GetEvent(); - int newX = DrawPoster(event, x, y, height-2*border, border); - if (newX > 0) { - textWidth -= (newX - x); - x += newX; - } - cString time = grid->getTimeString(); - cString title(""); - title = cString::sprintf(": %s", event->Title()); - cString header = cString::sprintf("%s%s", *time, *title); - header = CutText(*header, textWidth, fontManager.FontStatusHeaderLarge).c_str(); - pixmapText->DrawText(cPoint(x,y), *header, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge); - y += fontManager.FontStatusHeaderLarge->Height() + border; - int heightText = pixmapText->ViewPort().Height() - y; - cTextWrapper description; - description.Set(event->Description(), fontManager.FontStatusHeader, textWidth); - int lineHeight = fontManager.FontStatusHeader->Height(); - int textLines = description.Lines(); - int maxLines = heightText / lineHeight; - int lines = std::min(textLines, maxLines); - for (int i = 0; i < lines-1; i++) { - pixmapText->DrawText(cPoint(x,y), description.GetLine(i), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader); - y += lineHeight; - } - cString lastLine = description.GetLine(lines-1); - if (textLines > maxLines) { - lastLine = cString::sprintf("%s...", *lastLine); - } - pixmapText->DrawText(cPoint(x,y), *lastLine, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader); - } else { - int heightText = pixmapText->ViewPort().Height() - y; - y += (heightText - fontManager.FontStatusHeaderLarge->Height() - 2*border)/2; - pixmapText->DrawText(cPoint(x,y), *grid->getText(), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge); - } -} - -int cStatusHeader::DrawPoster(const cEvent *event, int x, int y, int height, int border) { - bool hasPoster = false; - ScraperGetPoster posterScraper2Vdr; - int posterWidth = 0; - int posterHeight = 0; - static cPlugin *pScraper = GetScraperPlugin(); - if (pScraper) { - posterScraper2Vdr.event = event; - posterScraper2Vdr.recording = NULL; - if (pScraper->Service("GetPoster", &posterScraper2Vdr)) { - hasPoster = true; - int posterWidthOrig = posterScraper2Vdr.poster.width; - int posterHeightOrig = posterScraper2Vdr.poster.height; - posterHeight = height; - posterWidth = posterWidthOrig * ((double)posterHeight / (double)posterHeightOrig); - } else { - hasPoster = false; - } - } - if (hasPoster) { - cImageLoader imgLoader; - if (imgLoader.LoadPoster(posterScraper2Vdr.poster.path.c_str(), posterWidth, posterHeight)) { - pixmapText->DrawImage(cPoint(x, y), imgLoader.GetImage()); - return posterWidth + border; - } - } - return 0; -} - -void cStatusHeader::DecorateVideoFrame(void) { - int radius = 16; - int frame = 2; - pixmapTVFrame->DrawRectangle(cRect(0, 0, tvFrameWidth, frame), theme.Color(clrBackgroundOSD)); - pixmapTVFrame->DrawEllipse(cRect(frame,frame,radius,radius), theme.Color(clrBackgroundOSD), -2); - pixmapTVFrame->DrawRectangle(cRect(tvFrameWidth - frame, frame, frame, height - 2*frame), theme.Color(clrBackgroundOSD)); - pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, frame, radius, radius), theme.Color(clrBackgroundOSD), -1); - pixmapTVFrame->DrawRectangle(cRect(0, frame, frame, height - 2*frame), theme.Color(clrBackgroundOSD)); - pixmapTVFrame->DrawEllipse(cRect(frame, height - radius - frame, radius, radius), theme.Color(clrBackgroundOSD), -3); - pixmapTVFrame->DrawRectangle(cRect(0, height - frame, tvFrameWidth, frame), theme.Color(clrBackgroundOSD)); - pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, height - radius - frame, radius, radius), theme.Color(clrBackgroundOSD), -4); -} +#include "tools.h" +#include "services/scraper2vdr.h" +#include "imageloader.h" +#include "statusheader.h" + +cStatusHeader::cStatusHeader(void) { + color = theme.Color(clrStatusHeader); + colorBlending = theme.Color(clrStatusHeaderBlending); + height = geoManager.statusHeaderHeight; + width = geoManager.headerContentWidth; + tvFrameWidth = geoManager.tvFrameWidth; + pixmap = osdManager.requestPixmap(1, cRect(0, 0, width, height)); + pixmapText = osdManager.requestPixmap(2, cRect(0, 0, width, height)); + pixmapTVFrame = osdManager.requestPixmap(1, cRect(width, 0, tvFrameWidth, height)); +} + +cStatusHeader::~cStatusHeader(void) { + osdManager.releasePixmap(pixmapText); + osdManager.releasePixmap(pixmapTVFrame); + if (tvguideConfig.scaleVideo) { + cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null); + cDevice::PrimaryDevice()->ScaleVideo(vidWin); + } +} + +void cStatusHeader::Draw(void) { + pixmapText->Fill(clrTransparent); + pixmapTVFrame->Fill(clrTransparent); + if (tvguideConfig.style == eStyleGraphical) { + if (tvguideConfig.scaleVideo) { + drawBackgroundGraphical(bgStatusHeaderWindowed); + cImage *tvFrameBack = imgCache.GetOsdElement(oeStatusHeaderTVFrame); + if (tvFrameBack) + pixmapTVFrame->DrawImage(cPoint(0,0), *tvFrameBack); + } else { + drawBackgroundGraphical(bgStatusHeaderFull); + } + } else { + if (tvguideConfig.decorateVideo) { + DecorateVideoFrame(); + } + drawBackground(); + drawBorder(); + } +} + +void cStatusHeader::ScaleVideo(void) { + if (tvguideConfig.scaleVideo) { + int width = height * 16 / 9; + int x = osdManager.Left() + geoManager.osdWidth - width; + int y = osdManager.Top(); + cRect availableRect(x, y, width, height); + cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect); + cDevice::PrimaryDevice()->ScaleVideo(vidWin); + } +} + +void cStatusHeader::DrawInfoText(cGrid *grid) { + int border = 10; + int textWidth = 0; + textWidth = width - 2 * border; + tColor colorTextBack = (tvguideConfig.style == eStyleFlat)?color:clrTransparent; + pixmapText->Fill(clrTransparent); + int x = border; + int y = border; + if (!grid->isDummy()) { + const cEvent *event = grid->GetEvent(); + int newX = DrawPoster(event, x, y, height-2*border, border); + if (newX > 0) { + textWidth -= (newX - x); + x += newX; + } + cString time = grid->getTimeString(); + cString title(""); + title = cString::sprintf(": %s", event->Title()); + cString header = cString::sprintf("%s%s", *time, *title); + header = CutText(*header, textWidth, fontManager.FontStatusHeaderLarge).c_str(); + pixmapText->DrawText(cPoint(x,y), *header, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge); + y += fontManager.FontStatusHeaderLarge->Height() + border; + int heightText = pixmapText->ViewPort().Height() - y; + cTextWrapper description; + description.Set(event->Description(), fontManager.FontStatusHeader, textWidth); + int lineHeight = fontManager.FontStatusHeader->Height(); + int textLines = description.Lines(); + int maxLines = heightText / lineHeight; + int lines = std::min(textLines, maxLines); + for (int i = 0; i < lines-1; i++) { + pixmapText->DrawText(cPoint(x,y), description.GetLine(i), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader); + y += lineHeight; + } + cString lastLine = description.GetLine(lines-1); + if (textLines > maxLines) { + lastLine = cString::sprintf("%s...", *lastLine); + } + pixmapText->DrawText(cPoint(x,y), *lastLine, theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeader); + } else { + int heightText = pixmapText->ViewPort().Height() - y; + y += (heightText - fontManager.FontStatusHeaderLarge->Height() - 2*border)/2; + pixmapText->DrawText(cPoint(x,y), *grid->getText(), theme.Color(clrFont), colorTextBack, fontManager.FontStatusHeaderLarge); + } +} + +int cStatusHeader::DrawPoster(const cEvent *event, int x, int y, int height, int border) { + bool hasPoster = false; + ScraperGetPoster posterScraper2Vdr; + int posterWidth = 0; + int posterHeight = 0; + static cPlugin *pScraper = GetScraperPlugin(); + if (pScraper) { + posterScraper2Vdr.event = event; + posterScraper2Vdr.recording = NULL; + if (pScraper->Service("GetPoster", &posterScraper2Vdr)) { + hasPoster = true; + int posterWidthOrig = posterScraper2Vdr.poster.width; + int posterHeightOrig = posterScraper2Vdr.poster.height; + posterHeight = height; + posterWidth = posterWidthOrig * ((double)posterHeight / (double)posterHeightOrig); + } else { + hasPoster = false; + } + } + if (hasPoster) { + cImageLoader imgLoader; + if (imgLoader.LoadPoster(posterScraper2Vdr.poster.path.c_str(), posterWidth, posterHeight)) { + pixmapText->DrawImage(cPoint(x, y), imgLoader.GetImage()); + return posterWidth + border; + } + } + return 0; +} + +void cStatusHeader::DecorateVideoFrame(void) { + int radius = 16; + int frame = 2; + pixmapTVFrame->DrawRectangle(cRect(0, 0, tvFrameWidth, frame), theme.Color(clrBackgroundOSD)); + pixmapTVFrame->DrawEllipse(cRect(frame,frame,radius,radius), theme.Color(clrBackgroundOSD), -2); + pixmapTVFrame->DrawRectangle(cRect(tvFrameWidth - frame, frame, frame, height - 2*frame), theme.Color(clrBackgroundOSD)); + pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, frame, radius, radius), theme.Color(clrBackgroundOSD), -1); + pixmapTVFrame->DrawRectangle(cRect(0, frame, frame, height - 2*frame), theme.Color(clrBackgroundOSD)); + pixmapTVFrame->DrawEllipse(cRect(frame, height - radius - frame, radius, radius), theme.Color(clrBackgroundOSD), -3); + pixmapTVFrame->DrawRectangle(cRect(0, height - frame, tvFrameWidth, frame), theme.Color(clrBackgroundOSD)); + pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius - frame, height - radius - frame, radius, radius), theme.Color(clrBackgroundOSD), -4); +} diff --git a/statusheader.h b/statusheader.h index 3096803..61f59bb 100644 --- a/statusheader.h +++ b/statusheader.h @@ -1,25 +1,25 @@ -#ifndef __TVGUIDE_STATUSHEADER_H -#define __TVGUIDE_STATUSHEADER_H - -#include "styledpixmap.h" -#include "grid.h" - -// --- cStatusHeader ------------------------------------------------------------- - -class cStatusHeader : public cStyledPixmap { -private: - int width, height; - int tvFrameWidth; - cPixmap *pixmapText; - cPixmap *pixmapTVFrame; - int DrawPoster(const cEvent *event, int x, int y, int height, int border); - void DecorateVideoFrame(void); -public: - cStatusHeader(void); - virtual ~cStatusHeader(void); - void Draw(void); - void ScaleVideo(void); - void DrawInfoText(cGrid *grid); -}; - -#endif //__TVGUIDE_STATUSHEADER_H \ No newline at end of file +#ifndef __TVGUIDE_STATUSHEADER_H +#define __TVGUIDE_STATUSHEADER_H + +#include "styledpixmap.h" +#include "grid.h" + +// --- cStatusHeader ------------------------------------------------------------- + +class cStatusHeader : public cStyledPixmap { +private: + int width, height; + int tvFrameWidth; + cPixmap *pixmapText; + cPixmap *pixmapTVFrame; + int DrawPoster(const cEvent *event, int x, int y, int height, int border); + void DecorateVideoFrame(void); +public: + cStatusHeader(void); + virtual ~cStatusHeader(void); + void Draw(void); + void ScaleVideo(void); + void DrawInfoText(cGrid *grid); +}; + +#endif //__TVGUIDE_STATUSHEADER_H diff --git a/styledpixmap.c b/styledpixmap.c index 73c9256..0cd4646 100644 --- a/styledpixmap.c +++ b/styledpixmap.c @@ -1,205 +1,205 @@ -#include "imageloader.h" -#include "geometrymanager.h" -#include "styledpixmap.h" - -cStyledPixmap::cStyledPixmap(void) { - pixmap = NULL; -} - -cStyledPixmap::cStyledPixmap(cPixmap *pixmap) { - this->pixmap = pixmap; -} - -cStyledPixmap::~cStyledPixmap(void) { - if (pixmap) - osdManager.releasePixmap(pixmap); -} - -void cStyledPixmap::setPixmap(cPixmap *pixmap) { - if (pixmap) { - this->pixmap = pixmap; - } -} - -void cStyledPixmap::drawBackground() { - if (tvguideConfig.style == eStyleBlendingDefault){ - drawBlendedBackground(); - } else if (tvguideConfig.style == eStyleBlendingMagick){ - drawSparsedBackground(); - } else { - pixmap->Fill(color); - } -} - -void cStyledPixmap::drawBackgroundGraphical(eBackgroundType type, bool active) { - cImage *back = NULL; - if (type == bgGrid) { - back = imgCache.GetGrid(pixmap->ViewPort().Width(), pixmap->ViewPort().Height(), active); - } else if (type == bgChannelHeader) { - back = imgCache.GetOsdElement(oeLogoBack); - } else if (type == bgChannelGroup) { - back = imgCache.GetChannelGroup(pixmap->ViewPort().Width(), pixmap->ViewPort().Height()); - } else if (type == bgStatusHeaderWindowed) { - back = imgCache.GetOsdElement(oeStatusHeaderContentWindowed); - } else if (type == bgStatusHeaderFull) { - back = imgCache.GetOsdElement(oeStatusHeaderContentFull); - } else if (type == bgClock) { - back = imgCache.GetOsdElement(oeClock); - } else if (type == bgButton) { - drawBackgroundButton(active); - return; - } else if (type == bgRecMenuBack) { - cImageLoader imgLoader; - if (imgLoader.LoadOsdElement("recmenu_background", pixmap->ViewPort().Width(), pixmap->ViewPort().Height())) { - cImage background = imgLoader.GetImage(); - pixmap->DrawImage(cPoint(0, 0), background); - } else { - pixmap->Fill(clrTransparent); - } - return; - } else if (type == bgChannelJump) { - back = imgCache.GetOsdElement(oeChannelJump); - } - if (back) { - pixmap->DrawImage(cPoint(0,0), *back); - } else { - pixmap->Fill(clrTransparent); - } -} - -void cStyledPixmap::drawBackgroundButton(bool active) { - std::string buttonName = ""; - int buttonWidth = pixmap->ViewPort().Width(); - int buttonHeight = pixmap->ViewPort().Height(); - if (buttonWidth > geoManager.osdWidth * 50 / 100) { - if (active) - buttonName = "button_active_70percent"; - else - buttonName = "button_70percent"; - } else { - if (active) - buttonName = "button_active_30percent"; - else - buttonName = "button_30percent"; - } - cImageLoader imgLoader; - if (imgLoader.LoadOsdElement(buttonName.c_str(), buttonWidth, buttonHeight)) { - cImage button = imgLoader.GetImage(); - pixmap->DrawImage(cPoint(0, 0), button); - } else { - pixmap->Fill(clrTransparent); - } -} - - -void cStyledPixmap::drawBlendedBackground() { - int width = pixmap->ViewPort().Width(); - int height = pixmap->ViewPort().Height(); - pixmap->Fill(color); - int numSteps = 64; - int alphaStep = 0x04; - if (height < 30) - return; - else if (height < 100) { - numSteps = 32; - alphaStep = 0x08; - } - int stepY = 0.5*height / numSteps; - if (stepY == 0) stepY = 1; - int alpha = 0x00; - tColor clr; - for (int i = 0; iDrawRectangle(cRect(0,i*stepY,width,stepY), clr); - alpha += alphaStep; - } -} - -void cStyledPixmap::drawSparsedBackground() { - int width = pixmap->ViewPort().Width(); - int height = pixmap->ViewPort().Height(); - cImageLoader imgLoader; - if (imgLoader.DrawBackground(colorBlending, color, width, height)) - pixmap->DrawImage(cPoint(0,0), imgLoader.GetImage()); - -} - -void cStyledPixmap::drawBorder() { - int width = pixmap->ViewPort().Width(); - int height = pixmap->ViewPort().Height(); - - drawDefaultBorder(width, height); - if (tvguideConfig.roundedCorners) { - int borderRadius = 12; - drawRoundedCorners(width, height, borderRadius); - } -} - -void cStyledPixmap::drawDefaultBorder(int width, int height) { - pixmap->DrawRectangle(cRect(0,0,width,2), clrTransparent); //top - pixmap->DrawRectangle(cRect(0,0,2,height), clrTransparent); //left - pixmap->DrawRectangle(cRect(0,height-2,width,2), clrTransparent); //bottom - pixmap->DrawRectangle(cRect(width-2,0,2,height), clrTransparent); //right - - pixmap->DrawRectangle(cRect(2,2,width-4,1), theme.Color(clrBorder)); //top - pixmap->DrawRectangle(cRect(2,2,1,height-4), theme.Color(clrBorder)); //left - pixmap->DrawRectangle(cRect(2,height-3,width-4,1), theme.Color(clrBorder)); //bottom - pixmap->DrawRectangle(cRect(width-3,2,1,height-4), theme.Color(clrBorder)); //right -} - -void cStyledPixmap::drawBoldBorder() { - int width = pixmap->ViewPort().Width(); - int height = pixmap->ViewPort().Height(); - pixmap->DrawRectangle(cRect(0,0,width,2), theme.Color(clrBorder)); //top - pixmap->DrawRectangle(cRect(0,0,2,height), theme.Color(clrBorder)); //left - pixmap->DrawRectangle(cRect(0,height-2,width,2), theme.Color(clrBorder)); //bottom - pixmap->DrawRectangle(cRect(width-2,0,2,height), theme.Color(clrBorder)); //right -} - -void cStyledPixmap::drawRoundedCorners(int width, int height, int radius) { - pixmap->DrawEllipse(cRect(2,2,radius,radius), theme.Color(clrBorder), -2); - pixmap->DrawEllipse(cRect(1,1,radius,radius), clrTransparent, -2); - - pixmap->DrawEllipse(cRect(width-radius - 2,2,radius,radius), theme.Color(clrBorder), -1); - pixmap->DrawEllipse(cRect(width-radius - 1,1,radius,radius), clrTransparent, -1); - - if( height > 2*radius) { - pixmap->DrawEllipse(cRect(2,height-radius - 2,radius,radius), theme.Color(clrBorder), -3); - pixmap->DrawEllipse(cRect(1,height-radius - 1,radius,radius), clrTransparent, -3); - - pixmap->DrawEllipse(cRect(width-radius - 2,height-radius - 2,radius,radius), theme.Color(clrBorder), -4); - pixmap->DrawEllipse(cRect(width-radius - 1,height-radius - 1,radius,radius), clrTransparent, -4); - } -} - -void cStyledPixmap::drawVerticalLine(int x, int yStart, int yStop, tColor col) { - for (int y = yStart; y <= yStop; y++) { - pixmap->DrawPixel(cPoint(x,y), col); - } -} - -void cStyledPixmap::drawHorizontalLine(int y, int xStart, int xStop, tColor col) { - for (int x = xStart; x <= xStop; x++) { - pixmap->DrawPixel(cPoint(x,y), col); - } -} - -void cStyledPixmap::DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font) { - pixmap->DrawText(Point, s, ColorFg, ColorBg, Font); -} - -void cStyledPixmap::DrawImage(const cPoint &Point, const cImage &Image) { - pixmap->DrawImage(Point, Image); -} - -void cStyledPixmap::DrawRectangle(const cRect &Rect, tColor Color) { - pixmap->DrawRectangle(Rect,Color); -} - -void cStyledPixmap::DrawEllipse(const cRect &Rect, tColor Color, int Quadrant) { - pixmap->DrawEllipse(Rect,Color,Quadrant); -} - -void cStyledPixmap::SetViewPort(const cRect &Rect) { - pixmap->SetViewPort(Rect); -} \ No newline at end of file +#include "imageloader.h" +#include "geometrymanager.h" +#include "styledpixmap.h" + +cStyledPixmap::cStyledPixmap(void) { + pixmap = NULL; +} + +cStyledPixmap::cStyledPixmap(cPixmap *pixmap) { + this->pixmap = pixmap; +} + +cStyledPixmap::~cStyledPixmap(void) { + if (pixmap) + osdManager.releasePixmap(pixmap); +} + +void cStyledPixmap::setPixmap(cPixmap *pixmap) { + if (pixmap) { + this->pixmap = pixmap; + } +} + +void cStyledPixmap::drawBackground() { + if (tvguideConfig.style == eStyleBlendingDefault){ + drawBlendedBackground(); + } else if (tvguideConfig.style == eStyleBlendingMagick){ + drawSparsedBackground(); + } else { + pixmap->Fill(color); + } +} + +void cStyledPixmap::drawBackgroundGraphical(eBackgroundType type, bool active) { + cImage *back = NULL; + if (type == bgGrid) { + back = imgCache.GetGrid(pixmap->ViewPort().Width(), pixmap->ViewPort().Height(), active); + } else if (type == bgChannelHeader) { + back = imgCache.GetOsdElement(oeLogoBack); + } else if (type == bgChannelGroup) { + back = imgCache.GetChannelGroup(pixmap->ViewPort().Width(), pixmap->ViewPort().Height()); + } else if (type == bgStatusHeaderWindowed) { + back = imgCache.GetOsdElement(oeStatusHeaderContentWindowed); + } else if (type == bgStatusHeaderFull) { + back = imgCache.GetOsdElement(oeStatusHeaderContentFull); + } else if (type == bgClock) { + back = imgCache.GetOsdElement(oeClock); + } else if (type == bgButton) { + drawBackgroundButton(active); + return; + } else if (type == bgRecMenuBack) { + cImageLoader imgLoader; + if (imgLoader.LoadOsdElement("recmenu_background", pixmap->ViewPort().Width(), pixmap->ViewPort().Height())) { + cImage background = imgLoader.GetImage(); + pixmap->DrawImage(cPoint(0, 0), background); + } else { + pixmap->Fill(clrTransparent); + } + return; + } else if (type == bgChannelJump) { + back = imgCache.GetOsdElement(oeChannelJump); + } + if (back) { + pixmap->DrawImage(cPoint(0,0), *back); + } else { + pixmap->Fill(clrTransparent); + } +} + +void cStyledPixmap::drawBackgroundButton(bool active) { + std::string buttonName = ""; + int buttonWidth = pixmap->ViewPort().Width(); + int buttonHeight = pixmap->ViewPort().Height(); + if (buttonWidth > geoManager.osdWidth * 50 / 100) { + if (active) + buttonName = "button_active_70percent"; + else + buttonName = "button_70percent"; + } else { + if (active) + buttonName = "button_active_30percent"; + else + buttonName = "button_30percent"; + } + cImageLoader imgLoader; + if (imgLoader.LoadOsdElement(buttonName.c_str(), buttonWidth, buttonHeight)) { + cImage button = imgLoader.GetImage(); + pixmap->DrawImage(cPoint(0, 0), button); + } else { + pixmap->Fill(clrTransparent); + } +} + + +void cStyledPixmap::drawBlendedBackground() { + int width = pixmap->ViewPort().Width(); + int height = pixmap->ViewPort().Height(); + pixmap->Fill(color); + int numSteps = 64; + int alphaStep = 0x04; + if (height < 30) + return; + else if (height < 100) { + numSteps = 32; + alphaStep = 0x08; + } + int stepY = 0.5*height / numSteps; + if (stepY == 0) stepY = 1; + int alpha = 0x00; + tColor clr; + for (int i = 0; iDrawRectangle(cRect(0,i*stepY,width,stepY), clr); + alpha += alphaStep; + } +} + +void cStyledPixmap::drawSparsedBackground() { + int width = pixmap->ViewPort().Width(); + int height = pixmap->ViewPort().Height(); + cImageLoader imgLoader; + if (imgLoader.DrawBackground(colorBlending, color, width, height)) + pixmap->DrawImage(cPoint(0,0), imgLoader.GetImage()); + +} + +void cStyledPixmap::drawBorder() { + int width = pixmap->ViewPort().Width(); + int height = pixmap->ViewPort().Height(); + + drawDefaultBorder(width, height); + if (tvguideConfig.roundedCorners) { + int borderRadius = 12; + drawRoundedCorners(width, height, borderRadius); + } +} + +void cStyledPixmap::drawDefaultBorder(int width, int height) { + pixmap->DrawRectangle(cRect(0,0,width,2), clrTransparent); //top + pixmap->DrawRectangle(cRect(0,0,2,height), clrTransparent); //left + pixmap->DrawRectangle(cRect(0,height-2,width,2), clrTransparent); //bottom + pixmap->DrawRectangle(cRect(width-2,0,2,height), clrTransparent); //right + + pixmap->DrawRectangle(cRect(2,2,width-4,1), theme.Color(clrBorder)); //top + pixmap->DrawRectangle(cRect(2,2,1,height-4), theme.Color(clrBorder)); //left + pixmap->DrawRectangle(cRect(2,height-3,width-4,1), theme.Color(clrBorder)); //bottom + pixmap->DrawRectangle(cRect(width-3,2,1,height-4), theme.Color(clrBorder)); //right +} + +void cStyledPixmap::drawBoldBorder() { + int width = pixmap->ViewPort().Width(); + int height = pixmap->ViewPort().Height(); + pixmap->DrawRectangle(cRect(0,0,width,2), theme.Color(clrBorder)); //top + pixmap->DrawRectangle(cRect(0,0,2,height), theme.Color(clrBorder)); //left + pixmap->DrawRectangle(cRect(0,height-2,width,2), theme.Color(clrBorder)); //bottom + pixmap->DrawRectangle(cRect(width-2,0,2,height), theme.Color(clrBorder)); //right +} + +void cStyledPixmap::drawRoundedCorners(int width, int height, int radius) { + pixmap->DrawEllipse(cRect(2,2,radius,radius), theme.Color(clrBorder), -2); + pixmap->DrawEllipse(cRect(1,1,radius,radius), clrTransparent, -2); + + pixmap->DrawEllipse(cRect(width-radius - 2,2,radius,radius), theme.Color(clrBorder), -1); + pixmap->DrawEllipse(cRect(width-radius - 1,1,radius,radius), clrTransparent, -1); + + if( height > 2*radius) { + pixmap->DrawEllipse(cRect(2,height-radius - 2,radius,radius), theme.Color(clrBorder), -3); + pixmap->DrawEllipse(cRect(1,height-radius - 1,radius,radius), clrTransparent, -3); + + pixmap->DrawEllipse(cRect(width-radius - 2,height-radius - 2,radius,radius), theme.Color(clrBorder), -4); + pixmap->DrawEllipse(cRect(width-radius - 1,height-radius - 1,radius,radius), clrTransparent, -4); + } +} + +void cStyledPixmap::drawVerticalLine(int x, int yStart, int yStop, tColor col) { + for (int y = yStart; y <= yStop; y++) { + pixmap->DrawPixel(cPoint(x,y), col); + } +} + +void cStyledPixmap::drawHorizontalLine(int y, int xStart, int xStop, tColor col) { + for (int x = xStart; x <= xStop; x++) { + pixmap->DrawPixel(cPoint(x,y), col); + } +} + +void cStyledPixmap::DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font) { + pixmap->DrawText(Point, s, ColorFg, ColorBg, Font); +} + +void cStyledPixmap::DrawImage(const cPoint &Point, const cImage &Image) { + pixmap->DrawImage(Point, Image); +} + +void cStyledPixmap::DrawRectangle(const cRect &Rect, tColor Color) { + pixmap->DrawRectangle(Rect,Color); +} + +void cStyledPixmap::DrawEllipse(const cRect &Rect, tColor Color, int Quadrant) { + pixmap->DrawEllipse(Rect,Color,Quadrant); +} + +void cStyledPixmap::SetViewPort(const cRect &Rect) { + pixmap->SetViewPort(Rect); +} diff --git a/styledpixmap.h b/styledpixmap.h index 82af25c..af463fe 100644 --- a/styledpixmap.h +++ b/styledpixmap.h @@ -1,58 +1,58 @@ -#ifndef __TVGUIDE_STYLEDPIXMAP_H -#define __TVGUIDE_STYLEDPIXMAP_H - -#include -#include -#include "timer.h" -#include "config.h" - -enum eBackgroundType { - bgGrid, - bgStatusHeaderFull, - bgStatusHeaderWindowed, - bgChannelHeader, - bgChannelGroup, - bgClock, - bgButton, - bgRecMenuBack, - bgChannelJump, -}; - -// --- cStyledPixmap ------------------------------------------------------------- - -class cStyledPixmap { -private: - void drawVerticalLine(int x, int yStart, int yStop, tColor col); - void drawHorizontalLine(int y, int xStart, int xStop, tColor col); - void drawBackgroundButton(bool active); -protected: - cPixmap *pixmap; - tColor color; - tColor colorBlending; - void setPixmap(cPixmap *pixmap); -public: - cStyledPixmap(void); - cStyledPixmap(cPixmap *pixmap); - virtual ~cStyledPixmap(void); - void drawBackground(); - void drawBackgroundGraphical(eBackgroundType type, bool active = false); - void drawBlendedBackground(); - void drawSparsedBackground(); - void drawBorder(); - void drawBoldBorder(); - void drawDefaultBorder(int width, int height); - void drawRoundedCorners(int width, int height, int radius); - void setColor(tColor color, tColor colorBlending) {this->color = color; this->colorBlending = colorBlending;}; - void SetAlpha(int alpha) {pixmap->SetAlpha(alpha);}; - void SetLayer(int layer) {pixmap->SetLayer(layer);}; - void Fill(tColor clr) {pixmap->Fill(clr);}; - void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font); - void DrawImage(const cPoint &Point, const cImage &Image); - void DrawRectangle(const cRect &Rect, tColor Color); - void DrawEllipse(const cRect &Rect, tColor Color, int Quadrant); - void SetViewPort(const cRect &Rect); - int Width() {return pixmap->ViewPort().Width();}; - int Height() {return pixmap->ViewPort().Height();}; -}; - -#endif //__TVGUIDE_STYLEDPIXMAP_H \ No newline at end of file +#ifndef __TVGUIDE_STYLEDPIXMAP_H +#define __TVGUIDE_STYLEDPIXMAP_H + +#include +#include +#include "timer.h" +#include "config.h" + +enum eBackgroundType { + bgGrid, + bgStatusHeaderFull, + bgStatusHeaderWindowed, + bgChannelHeader, + bgChannelGroup, + bgClock, + bgButton, + bgRecMenuBack, + bgChannelJump, +}; + +// --- cStyledPixmap ------------------------------------------------------------- + +class cStyledPixmap { +private: + void drawVerticalLine(int x, int yStart, int yStop, tColor col); + void drawHorizontalLine(int y, int xStart, int xStop, tColor col); + void drawBackgroundButton(bool active); +protected: + cPixmap *pixmap; + tColor color; + tColor colorBlending; + void setPixmap(cPixmap *pixmap); +public: + cStyledPixmap(void); + cStyledPixmap(cPixmap *pixmap); + virtual ~cStyledPixmap(void); + void drawBackground(); + void drawBackgroundGraphical(eBackgroundType type, bool active = false); + void drawBlendedBackground(); + void drawSparsedBackground(); + void drawBorder(); + void drawBoldBorder(); + void drawDefaultBorder(int width, int height); + void drawRoundedCorners(int width, int height, int radius); + void setColor(tColor color, tColor colorBlending) {this->color = color; this->colorBlending = colorBlending;}; + void SetAlpha(int alpha) {pixmap->SetAlpha(alpha);}; + void SetLayer(int layer) {pixmap->SetLayer(layer);}; + void Fill(tColor clr) {pixmap->Fill(clr);}; + void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font); + void DrawImage(const cPoint &Point, const cImage &Image); + void DrawRectangle(const cRect &Rect, tColor Color); + void DrawEllipse(const cRect &Rect, tColor Color, int Quadrant); + void SetViewPort(const cRect &Rect); + int Width() {return pixmap->ViewPort().Width();}; + int Height() {return pixmap->ViewPort().Height();}; +}; + +#endif //__TVGUIDE_STYLEDPIXMAP_H diff --git a/timeline.c b/timeline.c index cb30177..fd016bc 100644 --- a/timeline.c +++ b/timeline.c @@ -1,282 +1,282 @@ -#include "imageloader.h" -#include "timeline.h" - -cTimeLine::cTimeLine(cMyTime *myTime) { - this->myTime = myTime; - if (tvguideConfig.displayMode == eVertical) { - dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(0, - geoManager.statusHeaderHeight + geoManager.clockHeight, - geoManager.dateVieverWidth, - geoManager.dateVieverHeight))); - timeline = osdManager.requestPixmap(2, cRect(0, - geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight, - geoManager.timeLineWidth, - geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight) - , cRect(0, - 0, - geoManager.timeLineWidth, - 1440*geoManager.minutePixel)); - timeBase = osdManager.requestPixmap(3, cRect(0, - geoManager.statusHeaderHeight + geoManager.channelGroupsHeight + geoManager.channelHeaderHeight, - geoManager.osdWidth, - geoManager.timeLineGridHeight)); - } else if (tvguideConfig.displayMode == eHorizontal) { - dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(geoManager.clockWidth, - geoManager.statusHeaderHeight, - geoManager.dateVieverWidth, - geoManager.dateVieverHeight))); - timeline = osdManager.requestPixmap(2, cRect(geoManager.channelHeaderWidth + geoManager.channelGroupsWidth, - geoManager.statusHeaderHeight, - geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth, - geoManager.timeLineHeight) - , cRect(0, - 0, - 1440*geoManager.minutePixel, - geoManager.timeLineHeight)); - timeBase = osdManager.requestPixmap(3, cRect(geoManager.channelGroupsWidth + geoManager.channelHeaderWidth, - geoManager.statusHeaderHeight, - geoManager.timeLineGridWidth, - geoManager.timeLineHeight + tvguideConfig.channelRows * geoManager.rowHeight)); - } - timeBase->Fill(clrTransparent); - int clockY; - int clockX; - if (tvguideConfig.displayMode == eVertical) { - clockY = geoManager.statusHeaderHeight; - clockX = 0; - } - else { - clockY = geoManager.statusHeaderHeight; - clockX = 0; - } - clock = new cStyledPixmap(osdManager.requestPixmap(3, cRect(clockX, - clockY, - geoManager.clockWidth, - geoManager.clockHeight))); -} - -cTimeLine::~cTimeLine(void) { - delete dateViewer; - osdManager.releasePixmap(timeline); - if (clock) - delete clock; -} - -void cTimeLine::drawDateViewer() { - cString weekDay = myTime->GetWeekday(); - cString date = myTime->GetDate(); - if (tvguideConfig.style != eStyleGraphical) { - dateViewer->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); - dateViewer->drawBackground(); - dateViewer->drawBorder(); - - } else { - cImage *imgBack = imgCache.GetOsdElement(oeDateViewer); - if (imgBack) - dateViewer->DrawImage(cPoint(0,0), *imgBack); - else - dateViewer->Fill(clrTransparent); - } - tColor colorFont = theme.Color(clrButtonYellow); - tColor colorFontBack = (tvguideConfig.style == eStyleFlat) ? theme.Color(clrHeader) : clrTransparent; - - if (tvguideConfig.displayMode == eVertical) { - int textHeightWeekday = fontManager.FontTimeLineWeekday->Height(); - int textHeightDate = fontManager.FontTimeLineDate->Height(); - int weekdayWidth = fontManager.FontTimeLineWeekday->Width(*weekDay); - int dateWidth = fontManager.FontTimeLineDate->Width(*date); - int y = ((geoManager.dateVieverHeight - textHeightWeekday - textHeightDate) / 2); - dateViewer->DrawText(cPoint((geoManager.timeLineWidth - weekdayWidth) / 2, y), *weekDay, colorFont, colorFontBack, fontManager.FontTimeLineWeekday); - dateViewer->DrawText(cPoint((geoManager.timeLineWidth - dateWidth) / 2, y + textHeightWeekday), *date, colorFont, colorFontBack, fontManager.FontTimeLineDate); - } else if (tvguideConfig.displayMode == eHorizontal) { - cString strDate = cString::sprintf("%s %s", *weekDay, *date); - int x = ((dateViewer->Width() - fontManager.FontTimeLineDateHorizontal->Width(*strDate)) / 2); - int y = ((dateViewer->Height() - fontManager.FontTimeLineDateHorizontal->Height()) / 2); - dateViewer->DrawText(cPoint(x, y), *strDate, colorFont, colorFontBack, fontManager.FontTimeLineDateHorizontal); - } -} - -void cTimeLine::drawTimeline() { - timeline->SetTile(true); - timeline->Fill(clrTransparent); - tColor colorFont, colorBackground; - - int imgWidth = geoManager.timeLineGridWidth; - int imgHeight = geoManager.timeLineGridHeight; - const cImage *img1 = NULL; - const cImage *img2 = NULL; - if (tvguideConfig.style == eStyleGraphical) { - img1 = imgCache.GetOsdElement(oeTimeline1); - img2 = imgCache.GetOsdElement(oeTimeline2); - } else { - img1 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending)); - img2 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending)); - } - const cImage *img = NULL; - if (!img1 || !img2) - return; - int textWidth, posX, posY; - char timetext[10]; - - for (int i=0; i<48; i++) { - if (i%2==0) { - img = img1; - colorFont = theme.Color(clrTimeline2); - colorBackground = (tvguideConfig.style == eStyleFlat)?theme.Color(clrTimeline1):clrTransparent; - if (tvguideConfig.timeFormat == e12Hours) { - if (i == 0) - sprintf(timetext, "12:00 PM"); - else if (i/2 < 13) - sprintf(timetext, "%d:00 AM", i/2); - else - sprintf(timetext, "%d:00 PM", i/2-12); - } else { - sprintf(timetext, "%d:00", i/2); - } - } else { - img = img2; - colorFont = theme.Color(clrTimeline1); - colorBackground = (tvguideConfig.style == eStyleFlat)?theme.Color(clrTimeline2):clrTransparent; - if (tvguideConfig.timeFormat == e12Hours) { - if (i == 1) - sprintf(timetext, "12:30 PM"); - else if (i/2 < 13) - sprintf(timetext, "%d:30 AM", i/2); - else - sprintf(timetext, "%d:30 PM", i/2-12); - } else { - sprintf(timetext, "%d:30", i/2); - } - } - if (tvguideConfig.displayMode == eVertical) { - posY = i*geoManager.minutePixel*30; - timeline->DrawImage(cPoint(0, posY), *img); - if (tvguideConfig.style != eStyleGraphical) { - decorateTile(0, posY, imgWidth+2, imgHeight); - } - textWidth = fontManager.FontTimeLineTime->Width(timetext); - timeline->DrawText(cPoint((geoManager.timeLineWidth-textWidth)/2, posY + 5), timetext, colorFont, colorBackground, fontManager.FontTimeLineTime); - } else if (tvguideConfig.displayMode == eHorizontal) { - posX = i*geoManager.minutePixel*30; - timeline->DrawImage(cPoint(posX, 0), *img); - if (tvguideConfig.style != eStyleGraphical) { - decorateTile(posX, 0, imgWidth, imgHeight+2); - } - timeline->DrawText(cPoint(posX + 15, (dateViewer->Height() - fontManager.FontTimeLineTimeHorizontal->Height())/2), timetext, colorFont, colorBackground, fontManager.FontTimeLineTimeHorizontal); - } - } - setTimeline(); - if (tvguideConfig.style != eStyleGraphical) { - delete img1; - delete img2; - } -} - -void cTimeLine::decorateTile(int posX, int posY, int tileWidth, int tileHeight) { - timeline->DrawRectangle(cRect(posX,posY,tileWidth,2), clrTransparent); //top - timeline->DrawRectangle(cRect(posX,posY,2,tileHeight), clrTransparent); //left - timeline->DrawRectangle(cRect(posX,posY + tileHeight-2,tileWidth,2), clrTransparent); //bottom - timeline->DrawRectangle(cRect(posX + tileWidth-2,posY,2,tileHeight), clrTransparent); //right - - timeline->DrawRectangle(cRect(2+posX,posY+2,tileWidth-4,1), theme.Color(clrBorder)); //top - timeline->DrawRectangle(cRect(2+posX,posY+2,1,tileHeight-4), theme.Color(clrBorder)); //left - timeline->DrawRectangle(cRect(2+posX,posY+tileHeight-3,tileWidth-4,1), theme.Color(clrBorder)); //bottom - timeline->DrawRectangle(cRect(posX+tileWidth-3,posY+2,1,tileHeight-4), theme.Color(clrBorder)); //right - - if (tvguideConfig.roundedCorners) { - int borderRadius = 12; - drawRoundedCorners(posX, posY, tileWidth, tileHeight, borderRadius); - } -} - -void cTimeLine::drawRoundedCorners(int posX, int posY, int width, int height, int radius) { - timeline->DrawEllipse(cRect(posX+2,posY+2,radius,radius), theme.Color(clrBorder), -2); - timeline->DrawEllipse(cRect(posX+1,posY+1,radius,radius), clrTransparent, -2); - - timeline->DrawEllipse(cRect(posX+width-radius - 2,posY+2,radius,radius), theme.Color(clrBorder), -1); - timeline->DrawEllipse(cRect(posX+width-radius - 1,posY+1,radius,radius), clrTransparent, -1); - - if( height > 2*radius) { - timeline->DrawEllipse(cRect(posX+2,posY+height-radius - 2,radius,radius), theme.Color(clrBorder), -3); - timeline->DrawEllipse(cRect(posX+1,posY+height-radius - 1,radius,radius), clrTransparent, -3); - - timeline->DrawEllipse(cRect(posX+width-radius - 2,posY+height-radius - 2,radius,radius), theme.Color(clrBorder), -4); - timeline->DrawEllipse(cRect(posX+width-radius - 1,posY+height-radius - 1,radius,radius), clrTransparent, -4); - } -} - -void cTimeLine::drawCurrentTimeBase(void) { - timeBase->Fill(clrTransparent); - bool nowVisible = myTime->NowVisible(); - if (!nowVisible) - return; - int deltaTime = (myTime->GetNow() - myTime->GetStart()) / 60 * geoManager.minutePixel; - if (tvguideConfig.displayMode == eVertical) { - timeBase->DrawRectangle(cRect(0, deltaTime - 2, timeBase->ViewPort().Width(), 4), theme.Color(clrTimeBase)); - } else { - timeBase->DrawRectangle(cRect(deltaTime-2, 0, 4, timeBase->ViewPort().Height()), theme.Color(clrTimeBase)); - } -} - - -cImage *cTimeLine::createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend) { - cImage *image = NULL; - if (tvguideConfig.style == eStyleBlendingDefault) { - image = new cImage(cSize(width, height)); - image->Fill(clrBgr); - int stepY = 0.5*height / 64; - int alpha = 0x00; - tColor clr; - for (int i = 0; i<64; i++) { - clr = AlphaBlend(clrBgr, clrBlend, alpha); - for (int y = i*stepY; y < (i+1)*stepY; y++) { - for (int x=0; xSetPixel(cPoint(x,y), clr); - } - } - alpha += 0x04; - } - } else if (tvguideConfig.style == eStyleBlendingMagick) { - cImageLoader imgLoader; - if (imgLoader.DrawBackground(clrBgr, clrBlend, width, height)) { - image = new cImage(imgLoader.GetImage()); - } - } else { - image = new cImage(cSize(width, height)); - image->Fill(clrBgr); - } - return image; -} - -void cTimeLine::setTimeline() { - int offset = myTime->GetTimelineOffset(); - int xNew, yNew; - if (tvguideConfig.displayMode == eVertical) { - xNew = 0; - yNew = -offset*geoManager.minutePixel; - } else if (tvguideConfig.displayMode == eHorizontal) { - xNew = -offset*geoManager.minutePixel; - yNew = 0; - } - timeline->SetDrawPortPoint(cPoint(xNew, yNew)); - if (tvguideConfig.displayTimeBase) - drawCurrentTimeBase(); -} - -void cTimeLine::drawClock() { - if (tvguideConfig.displayMode == eVertical) - clock->Fill(clrTransparent); - cString currentTime = myTime->GetCurrentTime(); - const cFont *font = (tvguideConfig.displayMode == eVertical)?fontManager.FontTimeLineTime:fontManager.FontTimeLineTimeHorizontal; - int textHeight = font->Height(); - int clockTextWidth = font->Width(*currentTime); - tColor colorFontBack = (tvguideConfig.style == eStyleFlat)?theme.Color(clrHeader):clrTransparent; - if (tvguideConfig.style == eStyleGraphical) { - clock->drawBackgroundGraphical(bgClock); - } else { - clock->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); - clock->drawBackground(); - clock->drawBorder(); - } - clock->DrawText(cPoint((geoManager.clockWidth-clockTextWidth)/2, (geoManager.clockHeight-textHeight)/2), *currentTime, theme.Color(clrFont), colorFontBack, font); -} +#include "imageloader.h" +#include "timeline.h" + +cTimeLine::cTimeLine(cMyTime *myTime) { + this->myTime = myTime; + if (tvguideConfig.displayMode == eVertical) { + dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(0, + geoManager.statusHeaderHeight + geoManager.clockHeight, + geoManager.dateVieverWidth, + geoManager.dateVieverHeight))); + timeline = osdManager.requestPixmap(2, cRect(0, + geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight, + geoManager.timeLineWidth, + geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight) + , cRect(0, + 0, + geoManager.timeLineWidth, + 1440*geoManager.minutePixel)); + timeBase = osdManager.requestPixmap(3, cRect(0, + geoManager.statusHeaderHeight + geoManager.channelGroupsHeight + geoManager.channelHeaderHeight, + geoManager.osdWidth, + geoManager.timeLineGridHeight)); + } else if (tvguideConfig.displayMode == eHorizontal) { + dateViewer = new cStyledPixmap(osdManager.requestPixmap(1, cRect(geoManager.clockWidth, + geoManager.statusHeaderHeight, + geoManager.dateVieverWidth, + geoManager.dateVieverHeight))); + timeline = osdManager.requestPixmap(2, cRect(geoManager.channelHeaderWidth + geoManager.channelGroupsWidth, + geoManager.statusHeaderHeight, + geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth, + geoManager.timeLineHeight) + , cRect(0, + 0, + 1440*geoManager.minutePixel, + geoManager.timeLineHeight)); + timeBase = osdManager.requestPixmap(3, cRect(geoManager.channelGroupsWidth + geoManager.channelHeaderWidth, + geoManager.statusHeaderHeight, + geoManager.timeLineGridWidth, + geoManager.timeLineHeight + tvguideConfig.channelRows * geoManager.rowHeight)); + } + timeBase->Fill(clrTransparent); + int clockY; + int clockX; + if (tvguideConfig.displayMode == eVertical) { + clockY = geoManager.statusHeaderHeight; + clockX = 0; + } + else { + clockY = geoManager.statusHeaderHeight; + clockX = 0; + } + clock = new cStyledPixmap(osdManager.requestPixmap(3, cRect(clockX, + clockY, + geoManager.clockWidth, + geoManager.clockHeight))); +} + +cTimeLine::~cTimeLine(void) { + delete dateViewer; + osdManager.releasePixmap(timeline); + if (clock) + delete clock; +} + +void cTimeLine::drawDateViewer() { + cString weekDay = myTime->GetWeekday(); + cString date = myTime->GetDate(); + if (tvguideConfig.style != eStyleGraphical) { + dateViewer->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); + dateViewer->drawBackground(); + dateViewer->drawBorder(); + + } else { + cImage *imgBack = imgCache.GetOsdElement(oeDateViewer); + if (imgBack) + dateViewer->DrawImage(cPoint(0,0), *imgBack); + else + dateViewer->Fill(clrTransparent); + } + tColor colorFont = theme.Color(clrButtonYellow); + tColor colorFontBack = (tvguideConfig.style == eStyleFlat) ? theme.Color(clrHeader) : clrTransparent; + + if (tvguideConfig.displayMode == eVertical) { + int textHeightWeekday = fontManager.FontTimeLineWeekday->Height(); + int textHeightDate = fontManager.FontTimeLineDate->Height(); + int weekdayWidth = fontManager.FontTimeLineWeekday->Width(*weekDay); + int dateWidth = fontManager.FontTimeLineDate->Width(*date); + int y = ((geoManager.dateVieverHeight - textHeightWeekday - textHeightDate) / 2); + dateViewer->DrawText(cPoint((geoManager.timeLineWidth - weekdayWidth) / 2, y), *weekDay, colorFont, colorFontBack, fontManager.FontTimeLineWeekday); + dateViewer->DrawText(cPoint((geoManager.timeLineWidth - dateWidth) / 2, y + textHeightWeekday), *date, colorFont, colorFontBack, fontManager.FontTimeLineDate); + } else if (tvguideConfig.displayMode == eHorizontal) { + cString strDate = cString::sprintf("%s %s", *weekDay, *date); + int x = ((dateViewer->Width() - fontManager.FontTimeLineDateHorizontal->Width(*strDate)) / 2); + int y = ((dateViewer->Height() - fontManager.FontTimeLineDateHorizontal->Height()) / 2); + dateViewer->DrawText(cPoint(x, y), *strDate, colorFont, colorFontBack, fontManager.FontTimeLineDateHorizontal); + } +} + +void cTimeLine::drawTimeline() { + timeline->SetTile(true); + timeline->Fill(clrTransparent); + tColor colorFont, colorBackground; + + int imgWidth = geoManager.timeLineGridWidth; + int imgHeight = geoManager.timeLineGridHeight; + const cImage *img1 = NULL; + const cImage *img2 = NULL; + if (tvguideConfig.style == eStyleGraphical) { + img1 = imgCache.GetOsdElement(oeTimeline1); + img2 = imgCache.GetOsdElement(oeTimeline2); + } else { + img1 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline1), theme.Color(clrTimeline1Blending)); + img2 = createBackgroundImage(imgWidth, imgHeight, theme.Color(clrTimeline2), theme.Color(clrTimeline2Blending)); + } + const cImage *img = NULL; + if (!img1 || !img2) + return; + int textWidth, posX, posY; + char timetext[10]; + + for (int i=0; i<48; i++) { + if (i%2==0) { + img = img1; + colorFont = theme.Color(clrTimeline2); + colorBackground = (tvguideConfig.style == eStyleFlat)?theme.Color(clrTimeline1):clrTransparent; + if (tvguideConfig.timeFormat == e12Hours) { + if (i == 0) + sprintf(timetext, "12:00 PM"); + else if (i/2 < 13) + sprintf(timetext, "%d:00 AM", i/2); + else + sprintf(timetext, "%d:00 PM", i/2-12); + } else { + sprintf(timetext, "%d:00", i/2); + } + } else { + img = img2; + colorFont = theme.Color(clrTimeline1); + colorBackground = (tvguideConfig.style == eStyleFlat)?theme.Color(clrTimeline2):clrTransparent; + if (tvguideConfig.timeFormat == e12Hours) { + if (i == 1) + sprintf(timetext, "12:30 PM"); + else if (i/2 < 13) + sprintf(timetext, "%d:30 AM", i/2); + else + sprintf(timetext, "%d:30 PM", i/2-12); + } else { + sprintf(timetext, "%d:30", i/2); + } + } + if (tvguideConfig.displayMode == eVertical) { + posY = i*geoManager.minutePixel*30; + timeline->DrawImage(cPoint(0, posY), *img); + if (tvguideConfig.style != eStyleGraphical) { + decorateTile(0, posY, imgWidth+2, imgHeight); + } + textWidth = fontManager.FontTimeLineTime->Width(timetext); + timeline->DrawText(cPoint((geoManager.timeLineWidth-textWidth)/2, posY + 5), timetext, colorFont, colorBackground, fontManager.FontTimeLineTime); + } else if (tvguideConfig.displayMode == eHorizontal) { + posX = i*geoManager.minutePixel*30; + timeline->DrawImage(cPoint(posX, 0), *img); + if (tvguideConfig.style != eStyleGraphical) { + decorateTile(posX, 0, imgWidth, imgHeight+2); + } + timeline->DrawText(cPoint(posX + 15, (dateViewer->Height() - fontManager.FontTimeLineTimeHorizontal->Height())/2), timetext, colorFont, colorBackground, fontManager.FontTimeLineTimeHorizontal); + } + } + setTimeline(); + if (tvguideConfig.style != eStyleGraphical) { + delete img1; + delete img2; + } +} + +void cTimeLine::decorateTile(int posX, int posY, int tileWidth, int tileHeight) { + timeline->DrawRectangle(cRect(posX,posY,tileWidth,2), clrTransparent); //top + timeline->DrawRectangle(cRect(posX,posY,2,tileHeight), clrTransparent); //left + timeline->DrawRectangle(cRect(posX,posY + tileHeight-2,tileWidth,2), clrTransparent); //bottom + timeline->DrawRectangle(cRect(posX + tileWidth-2,posY,2,tileHeight), clrTransparent); //right + + timeline->DrawRectangle(cRect(2+posX,posY+2,tileWidth-4,1), theme.Color(clrBorder)); //top + timeline->DrawRectangle(cRect(2+posX,posY+2,1,tileHeight-4), theme.Color(clrBorder)); //left + timeline->DrawRectangle(cRect(2+posX,posY+tileHeight-3,tileWidth-4,1), theme.Color(clrBorder)); //bottom + timeline->DrawRectangle(cRect(posX+tileWidth-3,posY+2,1,tileHeight-4), theme.Color(clrBorder)); //right + + if (tvguideConfig.roundedCorners) { + int borderRadius = 12; + drawRoundedCorners(posX, posY, tileWidth, tileHeight, borderRadius); + } +} + +void cTimeLine::drawRoundedCorners(int posX, int posY, int width, int height, int radius) { + timeline->DrawEllipse(cRect(posX+2,posY+2,radius,radius), theme.Color(clrBorder), -2); + timeline->DrawEllipse(cRect(posX+1,posY+1,radius,radius), clrTransparent, -2); + + timeline->DrawEllipse(cRect(posX+width-radius - 2,posY+2,radius,radius), theme.Color(clrBorder), -1); + timeline->DrawEllipse(cRect(posX+width-radius - 1,posY+1,radius,radius), clrTransparent, -1); + + if( height > 2*radius) { + timeline->DrawEllipse(cRect(posX+2,posY+height-radius - 2,radius,radius), theme.Color(clrBorder), -3); + timeline->DrawEllipse(cRect(posX+1,posY+height-radius - 1,radius,radius), clrTransparent, -3); + + timeline->DrawEllipse(cRect(posX+width-radius - 2,posY+height-radius - 2,radius,radius), theme.Color(clrBorder), -4); + timeline->DrawEllipse(cRect(posX+width-radius - 1,posY+height-radius - 1,radius,radius), clrTransparent, -4); + } +} + +void cTimeLine::drawCurrentTimeBase(void) { + timeBase->Fill(clrTransparent); + bool nowVisible = myTime->NowVisible(); + if (!nowVisible) + return; + int deltaTime = (myTime->GetNow() - myTime->GetStart()) / 60 * geoManager.minutePixel; + if (tvguideConfig.displayMode == eVertical) { + timeBase->DrawRectangle(cRect(0, deltaTime - 2, timeBase->ViewPort().Width(), 4), theme.Color(clrTimeBase)); + } else { + timeBase->DrawRectangle(cRect(deltaTime-2, 0, 4, timeBase->ViewPort().Height()), theme.Color(clrTimeBase)); + } +} + + +cImage *cTimeLine::createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend) { + cImage *image = NULL; + if (tvguideConfig.style == eStyleBlendingDefault) { + image = new cImage(cSize(width, height)); + image->Fill(clrBgr); + int stepY = 0.5*height / 64; + int alpha = 0x00; + tColor clr; + for (int i = 0; i<64; i++) { + clr = AlphaBlend(clrBgr, clrBlend, alpha); + for (int y = i*stepY; y < (i+1)*stepY; y++) { + for (int x=0; xSetPixel(cPoint(x,y), clr); + } + } + alpha += 0x04; + } + } else if (tvguideConfig.style == eStyleBlendingMagick) { + cImageLoader imgLoader; + if (imgLoader.DrawBackground(clrBgr, clrBlend, width, height)) { + image = new cImage(imgLoader.GetImage()); + } + } else { + image = new cImage(cSize(width, height)); + image->Fill(clrBgr); + } + return image; +} + +void cTimeLine::setTimeline() { + int offset = myTime->GetTimelineOffset(); + int xNew, yNew; + if (tvguideConfig.displayMode == eVertical) { + xNew = 0; + yNew = -offset*geoManager.minutePixel; + } else if (tvguideConfig.displayMode == eHorizontal) { + xNew = -offset*geoManager.minutePixel; + yNew = 0; + } + timeline->SetDrawPortPoint(cPoint(xNew, yNew)); + if (tvguideConfig.displayTimeBase) + drawCurrentTimeBase(); +} + +void cTimeLine::drawClock() { + if (tvguideConfig.displayMode == eVertical) + clock->Fill(clrTransparent); + cString currentTime = myTime->GetCurrentTime(); + const cFont *font = (tvguideConfig.displayMode == eVertical)?fontManager.FontTimeLineTime:fontManager.FontTimeLineTimeHorizontal; + int textHeight = font->Height(); + int clockTextWidth = font->Width(*currentTime); + tColor colorFontBack = (tvguideConfig.style == eStyleFlat)?theme.Color(clrHeader):clrTransparent; + if (tvguideConfig.style == eStyleGraphical) { + clock->drawBackgroundGraphical(bgClock); + } else { + clock->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); + clock->drawBackground(); + clock->drawBorder(); + } + clock->DrawText(cPoint((geoManager.clockWidth-clockTextWidth)/2, (geoManager.clockHeight-textHeight)/2), *currentTime, theme.Color(clrFont), colorFontBack, font); +} diff --git a/timeline.h b/timeline.h index 127b7be..2cc7b26 100644 --- a/timeline.h +++ b/timeline.h @@ -1,29 +1,29 @@ -#ifndef __TVGUIDE_TIMELINE_H -#define __TVGUIDE_TIMELINE_H - -#include "timer.h" -#include "styledpixmap.h" - -// --- cTimeLine ------------------------------------------------------------- - -class cTimeLine { -private: - cMyTime *myTime; - cStyledPixmap *dateViewer; - cPixmap *timeline; - cStyledPixmap *clock; - cPixmap *timeBase; - void decorateTile(int posX, int posY, int tileWidth, int tileHeight); - void drawRoundedCorners(int posX, int posY, int width, int height, int radius); - cImage *createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend); - void drawCurrentTimeBase(void); -public: - cTimeLine(cMyTime *myTime); - virtual ~cTimeLine(void); - void setTimeline(); - void drawDateViewer(); - void drawTimeline(); - void drawClock(); -}; - -#endif //__TVGUIDE_TIMELINE_H \ No newline at end of file +#ifndef __TVGUIDE_TIMELINE_H +#define __TVGUIDE_TIMELINE_H + +#include "timer.h" +#include "styledpixmap.h" + +// --- cTimeLine ------------------------------------------------------------- + +class cTimeLine { +private: + cMyTime *myTime; + cStyledPixmap *dateViewer; + cPixmap *timeline; + cStyledPixmap *clock; + cPixmap *timeBase; + void decorateTile(int posX, int posY, int tileWidth, int tileHeight); + void drawRoundedCorners(int posX, int posY, int width, int height, int radius); + cImage *createBackgroundImage(int width, int height, tColor clrBgr, tColor clrBlend); + void drawCurrentTimeBase(void); +public: + cTimeLine(cMyTime *myTime); + virtual ~cTimeLine(void); + void setTimeline(); + void drawDateViewer(); + void drawTimeline(); + void drawClock(); +}; + +#endif //__TVGUIDE_TIMELINE_H diff --git a/timer.c b/timer.c index 59c21ec..6a082a4 100644 --- a/timer.c +++ b/timer.c @@ -1,178 +1,178 @@ -#include -#include -#include "config.h" -#include "timer.h" - -cMyTime::~cMyTime(void) { -} - -cString cMyTime::printTime(time_t displayTime) { - struct tm *ts; - ts = localtime(&displayTime); - cString strTime = cString::sprintf("%d.%d-%d:%d.%d", ts->tm_mday, ts->tm_mon+1, ts->tm_hour, ts->tm_min, ts->tm_sec); - return strTime; -} - - -void cMyTime::Now() { - t = time(0); - tStart = t; - tStart = GetRounded(); - if (tvguideConfig.displayMode == eVertical) { - tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60; - } else if (tvguideConfig.displayMode == eHorizontal) { - tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60; - } -} - -void cMyTime::AddStep(int step) { - tStart += step*60; - tEnd += step*60; -} - -bool cMyTime::DelStep(int step) { - if ((tStart - step*60)+30*60 < t) { - return true; - } - tStart -= step*60; - tEnd -= step*60; - return false; -} - -void cMyTime::SetTime(time_t newTime) { - tStart = newTime; - if (tvguideConfig.displayMode == eVertical) { - tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60; - } else if (tvguideConfig.displayMode == eHorizontal) { - tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60; - } -} - -time_t cMyTime::getPrevPrimetime(time_t current) { - tm *st = localtime(¤t); - if (st->tm_hour < 21) { - current -= 24 * 60* 60; - st = localtime(¤t); - } - st->tm_hour = 20; - st->tm_min = 0; - time_t primeTime = mktime(st); - return primeTime; -} - -time_t cMyTime::getNextPrimetime(time_t current){ - tm *st = localtime(¤t); - if (st->tm_hour > 19) { - current += 24 * 60* 60; - st = localtime(¤t); - } - st->tm_hour = 20; - st->tm_min = 0; - time_t primeTime = mktime(st); - return primeTime; -} - -bool cMyTime::tooFarInPast(time_t current) { - if (current < t) { - return true; - } - return false; -} - -cString cMyTime::GetCurrentTime() { - char buf[25]; - t = time(0); - tm *st = localtime(&t); - //snprintf(text, sizeof(text), "%d:%02d", st->tm_hour, st->tm_min); - if (tvguideConfig.timeFormat == e12Hours) { - strftime(buf, sizeof(buf), "%I:%M %p", st); - } else if (tvguideConfig.timeFormat == e24Hours) - strftime(buf, sizeof(buf), "%H:%M", st); - return buf; - -} - -cString cMyTime::GetDate() { - char text[6]; - tm *st = localtime(&tStart); - snprintf(text, sizeof(text), "%d.%d", st->tm_mday, st->tm_mon+1); - return text; -} - -cString cMyTime::GetWeekday() { - return WeekDayName(tStart); -} - -int cMyTime::GetTimelineOffset() { - tm *st = localtime(&tStart); - int offset = st->tm_hour*60; - offset += st->tm_min; - return offset; -} - -time_t cMyTime::GetRounded() { - tm *rounded = localtime ( &tStart ); - rounded->tm_sec = 0; - if (rounded->tm_min > 29) - rounded->tm_min = 30; - else - rounded->tm_min = 0; - return mktime(rounded); -} - -bool cMyTime::NowVisible(void) { - if (t > tStart) - return true; - return false; -} - - -void cMyTime::debug() { - esyslog("t: %s, tStart: %s, tEnd: %s", *TimeString(t), *TimeString(tStart), *TimeString(tEnd)); -} - -// --- cTimeInterval ------------------------------------------------------------- - -cTimeInterval::cTimeInterval(time_t start, time_t stop) { - this->start = start; - this->stop = stop; -} - -cTimeInterval::~cTimeInterval(void) { -} - -cTimeInterval *cTimeInterval::Intersect(cTimeInterval *interval) { - time_t startIntersect, stopIntersect; - - if ((stop <= interval->Start()) || (interval->Stop() <= start)) { - return NULL; - } - - if (start <= interval->Start()) { - startIntersect = interval->Start(); - } else { - startIntersect = start; - } - if (stop <= interval->Stop()) { - stopIntersect = stop; - } else { - stopIntersect = interval->Stop(); - } - return new cTimeInterval(startIntersect, stopIntersect); -} - -cTimeInterval *cTimeInterval::Union(cTimeInterval *interval) { - time_t startUnion, stopUnion; - - if (start <= interval->Start()) { - startUnion = start; - } else { - startUnion = interval->Start(); - } - if (stop <= interval->Stop()) { - stopUnion = interval->Stop(); - } else { - stopUnion = stop; - } - return new cTimeInterval(startUnion, stopUnion); -} \ No newline at end of file +#include +#include +#include "config.h" +#include "timer.h" + +cMyTime::~cMyTime(void) { +} + +cString cMyTime::printTime(time_t displayTime) { + struct tm *ts; + ts = localtime(&displayTime); + cString strTime = cString::sprintf("%d.%d-%d:%d.%d", ts->tm_mday, ts->tm_mon+1, ts->tm_hour, ts->tm_min, ts->tm_sec); + return strTime; +} + + +void cMyTime::Now() { + t = time(0); + tStart = t; + tStart = GetRounded(); + if (tvguideConfig.displayMode == eVertical) { + tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60; + } else if (tvguideConfig.displayMode == eHorizontal) { + tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60; + } +} + +void cMyTime::AddStep(int step) { + tStart += step*60; + tEnd += step*60; +} + +bool cMyTime::DelStep(int step) { + if ((tStart - step*60)+30*60 < t) { + return true; + } + tStart -= step*60; + tEnd -= step*60; + return false; +} + +void cMyTime::SetTime(time_t newTime) { + tStart = newTime; + if (tvguideConfig.displayMode == eVertical) { + tEnd = tStart + (geoManager.osdHeight - geoManager.statusHeaderHeight - geoManager.channelHeaderHeight - geoManager.channelGroupsHeight - geoManager.footerHeight)/geoManager.minutePixel*60; + } else if (tvguideConfig.displayMode == eHorizontal) { + tEnd = tStart + (geoManager.osdWidth - geoManager.channelHeaderWidth - geoManager.channelGroupsWidth)/geoManager.minutePixel*60; + } +} + +time_t cMyTime::getPrevPrimetime(time_t current) { + tm *st = localtime(¤t); + if (st->tm_hour < 21) { + current -= 24 * 60* 60; + st = localtime(¤t); + } + st->tm_hour = 20; + st->tm_min = 0; + time_t primeTime = mktime(st); + return primeTime; +} + +time_t cMyTime::getNextPrimetime(time_t current){ + tm *st = localtime(¤t); + if (st->tm_hour > 19) { + current += 24 * 60* 60; + st = localtime(¤t); + } + st->tm_hour = 20; + st->tm_min = 0; + time_t primeTime = mktime(st); + return primeTime; +} + +bool cMyTime::tooFarInPast(time_t current) { + if (current < t) { + return true; + } + return false; +} + +cString cMyTime::GetCurrentTime() { + char buf[25]; + t = time(0); + tm *st = localtime(&t); + //snprintf(text, sizeof(text), "%d:%02d", st->tm_hour, st->tm_min); + if (tvguideConfig.timeFormat == e12Hours) { + strftime(buf, sizeof(buf), "%I:%M %p", st); + } else if (tvguideConfig.timeFormat == e24Hours) + strftime(buf, sizeof(buf), "%H:%M", st); + return buf; + +} + +cString cMyTime::GetDate() { + char text[6]; + tm *st = localtime(&tStart); + snprintf(text, sizeof(text), "%d.%d", st->tm_mday, st->tm_mon+1); + return text; +} + +cString cMyTime::GetWeekday() { + return WeekDayName(tStart); +} + +int cMyTime::GetTimelineOffset() { + tm *st = localtime(&tStart); + int offset = st->tm_hour*60; + offset += st->tm_min; + return offset; +} + +time_t cMyTime::GetRounded() { + tm *rounded = localtime ( &tStart ); + rounded->tm_sec = 0; + if (rounded->tm_min > 29) + rounded->tm_min = 30; + else + rounded->tm_min = 0; + return mktime(rounded); +} + +bool cMyTime::NowVisible(void) { + if (t > tStart) + return true; + return false; +} + + +void cMyTime::debug() { + esyslog("t: %s, tStart: %s, tEnd: %s", *TimeString(t), *TimeString(tStart), *TimeString(tEnd)); +} + +// --- cTimeInterval ------------------------------------------------------------- + +cTimeInterval::cTimeInterval(time_t start, time_t stop) { + this->start = start; + this->stop = stop; +} + +cTimeInterval::~cTimeInterval(void) { +} + +cTimeInterval *cTimeInterval::Intersect(cTimeInterval *interval) { + time_t startIntersect, stopIntersect; + + if ((stop <= interval->Start()) || (interval->Stop() <= start)) { + return NULL; + } + + if (start <= interval->Start()) { + startIntersect = interval->Start(); + } else { + startIntersect = start; + } + if (stop <= interval->Stop()) { + stopIntersect = stop; + } else { + stopIntersect = interval->Stop(); + } + return new cTimeInterval(startIntersect, stopIntersect); +} + +cTimeInterval *cTimeInterval::Union(cTimeInterval *interval) { + time_t startUnion, stopUnion; + + if (start <= interval->Start()) { + startUnion = start; + } else { + startUnion = interval->Start(); + } + if (stop <= interval->Stop()) { + stopUnion = interval->Stop(); + } else { + stopUnion = stop; + } + return new cTimeInterval(startUnion, stopUnion); +} diff --git a/timer.h b/timer.h index 6491458..af7f1a3 100644 --- a/timer.h +++ b/timer.h @@ -1,52 +1,52 @@ -#ifndef __TVGUIDE_TIMER_H -#define __TVGUIDE_TIMER_H - -#include - -// --- cMyTime ------------------------------------------------------------- - -class cMyTime { - private: - time_t t; - time_t tStart; - time_t tEnd; - public: - cMyTime(){}; - virtual ~cMyTime(void); - static cString printTime(time_t displayTime); - void Now(); - time_t GetNow() { return t; }; - void AddStep(int step); - bool DelStep(int step); - void SetTime(time_t newTime); - time_t Get() {return t;}; - time_t GetStart() {return tStart;}; - time_t GetEnd() {return tEnd;}; - cString GetCurrentTime(); - cString GetDate(); - cString GetWeekday(); - time_t getPrevPrimetime(time_t current); - time_t getNextPrimetime(time_t current); - bool tooFarInPast(time_t current); - int GetTimelineOffset(); - time_t GetRounded(); - bool NowVisible(void); - void debug(); -}; - -// --- cTimeInterval ------------------------------------------------------------- - -class cTimeInterval { - private: - time_t start; - time_t stop; - public: - cTimeInterval(time_t start, time_t stop); - virtual ~cTimeInterval(void); - time_t Start(void) { return start; }; - time_t Stop(void) { return stop; }; - cTimeInterval *Intersect(cTimeInterval *interval); - cTimeInterval *Union(cTimeInterval *interval); -}; - -#endif //__TVGUIDE_TIMER_H \ No newline at end of file +#ifndef __TVGUIDE_TIMER_H +#define __TVGUIDE_TIMER_H + +#include + +// --- cMyTime ------------------------------------------------------------- + +class cMyTime { + private: + time_t t; + time_t tStart; + time_t tEnd; + public: + cMyTime(){}; + virtual ~cMyTime(void); + static cString printTime(time_t displayTime); + void Now(); + time_t GetNow() { return t; }; + void AddStep(int step); + bool DelStep(int step); + void SetTime(time_t newTime); + time_t Get() {return t;}; + time_t GetStart() {return tStart;}; + time_t GetEnd() {return tEnd;}; + cString GetCurrentTime(); + cString GetDate(); + cString GetWeekday(); + time_t getPrevPrimetime(time_t current); + time_t getNextPrimetime(time_t current); + bool tooFarInPast(time_t current); + int GetTimelineOffset(); + time_t GetRounded(); + bool NowVisible(void); + void debug(); +}; + +// --- cTimeInterval ------------------------------------------------------------- + +class cTimeInterval { + private: + time_t start; + time_t stop; + public: + cTimeInterval(time_t start, time_t stop); + virtual ~cTimeInterval(void); + time_t Start(void) { return start; }; + time_t Stop(void) { return stop; }; + cTimeInterval *Intersect(cTimeInterval *interval); + cTimeInterval *Union(cTimeInterval *interval); +}; + +#endif //__TVGUIDE_TIMER_H diff --git a/tvguideosd.c b/tvguideosd.c index 3a4ca73..dc70b3b 100644 --- a/tvguideosd.c +++ b/tvguideosd.c @@ -1,788 +1,788 @@ -#include -#include - -#include "config.h" -#include "services/epgsearch.h" -#include "services/remotetimers.h" - -#include "tools.h" -#include "setup.h" - -#include "tvguideosd.h" - -cTvGuideOsd::cTvGuideOsd(void) { - detailView = NULL; - detailViewActive = false; - activeGrid = NULL; - timeLine = NULL; - recMenuView = NULL; - channelJumper = NULL; -} - -cTvGuideOsd::~cTvGuideOsd() { - delete myTime; - columns.Clear(); - if (tvguideConfig.displayStatusHeader) { - delete statusHeader; - } - if (detailView) - delete detailView; - delete timeLine; - delete channelGroups; - delete footer; - delete recMenuView; - if (channelJumper) - delete channelJumper; - osdManager.deleteOsd(); -} - -void cTvGuideOsd::Show(void) { - int start = cTimeMs::Now(); - bool ok = false; - ok = osdManager.setOsd(); - if (ok) { - bool themeChanged = tvguideConfig.LoadTheme(); - tvguideConfig.SetStyle(); - tvguideConfig.setDynamicValues(); - bool geoChanged = geoManager.SetGeometry(cOsd::OsdWidth(), cOsd::OsdHeight()); - if (themeChanged || geoChanged) { - fontManager.DeleteFonts(); - fontManager.SetFonts(); - imgCache.Clear(); - imgCache.CreateCache(); - } - osdManager.setBackground(); - myTime = new cMyTime(); - myTime->Now(); - SwitchTimers.Load(AddDirectory(cPlugin::ConfigDirectory("epgsearch"), "epgsearchswitchtimers.conf")); - recMenuView = new cRecMenuView(); - pRemoteTimers = cPluginManager::CallFirstService("RemoteTimers::RefreshTimers-v1.0", NULL); - if (pRemoteTimers) { - isyslog("tvguide: remotetimers-plugin is available"); - } - if (tvguideConfig.useRemoteTimers && pRemoteTimers) { - cString errorMsg; - if (!pRemoteTimers->Service("RemoteTimers::RefreshTimers-v1.0", &errorMsg)) { - esyslog("tvguide: %s", *errorMsg); - } - } - drawOsd(); - } - esyslog("tvguide: Rendering took %d ms", int(cTimeMs::Now()-start)); -} - -void cTvGuideOsd::drawOsd() { - cPixmap::Lock(); - int numBack = tvguideConfig.numGrids / 2; - int offset = 0; - const cChannel *newStartChannel; -#if VDRVERSNUM >= 20301 - { - LOCK_CHANNELS_READ; - const cChannel *startChannel = Channels->GetByNumber(cDevice::CurrentChannel()); -#else - cChannel *startChannel = Channels.GetByNumber(cDevice::CurrentChannel()); -#endif - newStartChannel = startChannel; -#if VDRVERSNUM >= 20301 - for (; newStartChannel ; newStartChannel = Channels->Prev(newStartChannel)) { -#else - for (; newStartChannel ; newStartChannel = Channels.Prev(newStartChannel)) { -#endif - if (newStartChannel && !newStartChannel->GroupSep()) { - offset++; - } - if (offset == numBack) - break; - } - if (!newStartChannel) -#if VDRVERSNUM >= 20301 - newStartChannel = Channels->First(); - } //LOCK_CHANNELS_READ -#else - newStartChannel = Channels.First(); -#endif - offset--; - if (offset < 0) - offset = 0; - - if (tvguideConfig.displayStatusHeader) { - statusHeader = new cStatusHeader(); - statusHeader->Draw(); - statusHeader->ScaleVideo(); - } - timeLine = new cTimeLine(myTime); - timeLine->drawDateViewer(); - timeLine->drawTimeline(); - timeLine->drawClock(); - channelGroups = new cChannelGroups(); - channelGroups->ReadChannelGroups(); - footer = new cFooter(channelGroups); - recMenuView->SetFooter(footer); - footer->drawRedButton(); - if (tvguideConfig.channelJumpMode == eNumJump) { - footer->drawGreenButton(); - footer->drawYellowButton(); - } - footer->drawBlueButton(false); - osdManager.flush(); - readChannels(newStartChannel); - drawGridsChannelJump(offset); - osdManager.flush(); - cPixmap::Unlock(); -} - -void cTvGuideOsd::readChannels(const cChannel *channelStart) { - int i=0; - bool foundEnough = false; - columns.Clear(); - if (!channelStart) - return; -#if VDRVERSNUM >= 20301 - const cChannels *channels; - { - LOCK_CHANNELS_READ; - channels = Channels; - } -#else - cChannels *channels = &Channels; -#endif - for (const cChannel *channel = channelStart; channel; channel = channels->Next(channel)) { - if (!channel->GroupSep()) { - if (channelGroups->IsInLastGroup(channel)) { - break; - } - cChannelColumn *column = new cChannelColumn(i, channel, myTime); - if (column->readGrids()) { - columns.Add(column); - i++; - } else { - delete column; - } - } - if (i == tvguideConfig.numGrids) { - foundEnough = true; - break; - } - } - if (!foundEnough) { - int numCurrent = columns.Count(); - int numBack = tvguideConfig.numGrids - numCurrent; - int newChannelNumber = columns.First()->getChannel()->Number() - numBack; - const cChannel *newStart = channels->GetByNumber(newChannelNumber); - readChannels(newStart); - } -} - -void cTvGuideOsd::drawGridsChannelJump(int offset) { - if (columns.Count() == 0) - return; - activeGrid = columns.Get(offset)->getActive(); - if (activeGrid) - activeGrid->SetActive(); - if (tvguideConfig.displayStatusHeader) { - statusHeader->DrawInfoText(activeGrid); - } - if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { - footer->UpdateGroupButtons(activeGrid->column->getChannel()); - } - if (tvguideConfig.displayChannelGroups) { - channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); - } - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->createHeader(); - column->drawGrids(); - } -} - -void cTvGuideOsd::drawGridsTimeJump() { - if (columns.Count() == 0) - return; - cChannelColumn *colActive = NULL; - if (activeGrid) { - colActive = activeGrid->column; - } else { - colActive = columns.First(); - } - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->clearGrids(); - column->readGrids(); - column->drawGrids(); - } - activeGrid = colActive->getActive(); - if (activeGrid) { - activeGrid->SetActive(); - activeGrid->Draw(); - if (tvguideConfig.displayStatusHeader) { - statusHeader->DrawInfoText(activeGrid); - } - } -} - -void cTvGuideOsd::setNextActiveGrid(cGrid *next) { - if (!next || !activeGrid) { - return; - } - activeGrid->SetInActive(); - activeGrid->Draw(); - activeGrid = next; - activeGrid->SetActive(); - activeGrid->Draw(); - if (tvguideConfig.displayStatusHeader) { - statusHeader->DrawInfoText(activeGrid); - } -} - -void cTvGuideOsd::channelForward() { - cChannelColumn *colRight = columns.Next(activeGrid->column); - bool colAdded = false; - if (!colRight) { - const cChannel *channelRight = activeGrid->column->getChannel(); - const cChannels *channels; -#if VDRVERSNUM >= 20301 - { - LOCK_CHANNELS_READ; - channels = Channels; - } -#else - channels = &Channels; -#endif - while (channelRight = channels->Next(channelRight)) { - if (!channelRight->GroupSep()) { - if (channelGroups->IsInLastGroup(channelRight)) { - break; - } - colRight = new cChannelColumn(tvguideConfig.numGrids - 1, channelRight, myTime); - if (colRight->readGrids()) { - break; - } else { - delete colRight; - colRight = NULL; - } - } - } - if (colRight) { - colAdded = true; - if (columns.Count() == tvguideConfig.numGrids) { - cChannelColumn *cFirst = columns.First(); - columns.Del(cFirst); - } - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->SetNum(column->GetNum() - 1); - column->drawHeader(); - column->drawGrids(); - } - columns.Add(colRight); - colRight->createHeader(); - colRight->drawGrids(); - } - } - if (colRight) { - cGrid *right = colRight->getNeighbor(activeGrid); - if (right) { - setNextActiveGrid(right); - } - } - if (tvguideConfig.displayChannelGroups && colAdded) { - channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); - } - if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { - footer->UpdateGroupButtons(activeGrid->column->getChannel()); - } - osdManager.flush(); -} - -void cTvGuideOsd::channelBack() { - cChannelColumn *colLeft = columns.Prev(activeGrid->column); - bool colAdded = false; - if (!colLeft) { - const cChannel *channelLeft = activeGrid->column->getChannel(); - const cChannels *channels; -#if VDRVERSNUM >= 20301 - { - LOCK_CHANNELS_READ; - channels = Channels; - } -#else - channels = &Channels; -#endif - while (channelLeft = channels->Prev(channelLeft)) { - if (!channelLeft->GroupSep()) { - colLeft = new cChannelColumn(0, channelLeft, myTime); - if (colLeft->readGrids()) { - break; - } else { - delete colLeft; - colLeft = NULL; - } - } - } - if (colLeft) { - colAdded = true; - if (columns.Count() == tvguideConfig.numGrids) { - cChannelColumn *cLast = columns.Last(); - columns.Del(cLast); - } - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->SetNum(column->GetNum() + 1); - column->drawHeader(); - column->drawGrids(); - } - columns.Ins(colLeft, columns.First()); - colLeft->createHeader(); - colLeft->drawGrids(); - } - } - - if (colLeft) { - cGrid *left = colLeft->getNeighbor(activeGrid); - if (left) { - setNextActiveGrid(left); - } - } - if (tvguideConfig.displayChannelGroups && colAdded) { - channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); - } - - if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { - footer->UpdateGroupButtons(activeGrid->column->getChannel()); - } - osdManager.flush(); -} - -void cTvGuideOsd::timeForward() { - bool actionDone = false; - if ( (myTime->GetEnd() - activeGrid->EndTime())/60 < 30 ) { - ScrollForward(); - actionDone = true; - } - cGrid *next = activeGrid->column->getNext(activeGrid); - if (next) { - if ( (next->EndTime() < myTime->GetEnd()) - || ( (myTime->GetEnd() - next->StartTime())/60 > 30 ) ) { - setNextActiveGrid(next); - actionDone = true; - } - } - if (!actionDone) { - ScrollForward(); - } - osdManager.flush(); -} - -void cTvGuideOsd::ScrollForward() { - myTime->AddStep(tvguideConfig.stepMinutes); - timeLine->drawDateViewer(); - timeLine->drawClock(); - timeLine->setTimeline(); - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->AddNewGridsAtEnd(); - column->ClearOutdatedStart(); - column->drawGrids(); - } -} - -void cTvGuideOsd::timeBack() { - bool actionDone = false; - if ( (activeGrid->StartTime() - myTime->GetStart())/60 < 30 ) { - ScrollBack(); - actionDone = true; - } - cGrid *prev = activeGrid->column->getPrev(activeGrid); - if (prev) { - if ( (prev->StartTime() > myTime->GetStart()) - || ( (prev->EndTime() - myTime->GetStart())/60 > 30 ) - || ( prev->isFirst()) ) { - setNextActiveGrid(prev); - actionDone = true; - } - } - if (!actionDone) { - ScrollBack(); - } - osdManager.flush(); -} - -void cTvGuideOsd::ScrollBack() { - bool tooFarInPast = myTime->DelStep(tvguideConfig.stepMinutes); - if (tooFarInPast) - return; - timeLine->drawDateViewer(); - timeLine->drawClock(); - timeLine->setTimeline(); - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->AddNewGridsAtStart(); - column->ClearOutdatedEnd(); - column->drawGrids(); - } -} - -void cTvGuideOsd::processKeyUp() { - if (!activeGrid) { - return; - } - if (tvguideConfig.displayMode == eVertical) { - timeBack(); - } else if (tvguideConfig.displayMode == eHorizontal) { - channelBack(); - } -} - -void cTvGuideOsd::processKeyDown() { - if (!activeGrid) { - return; - } - if (tvguideConfig.displayMode == eVertical) { - timeForward(); - } else if (tvguideConfig.displayMode == eHorizontal) { - channelForward(); - } -} - -void cTvGuideOsd::processKeyLeft() { - if (activeGrid == NULL) - return; - if (tvguideConfig.displayMode == eVertical) { - channelBack(); - } else if (tvguideConfig.displayMode == eHorizontal) { - timeBack(); - } -} - -void cTvGuideOsd::processKeyRight() { - if (activeGrid == NULL) - return; - if (tvguideConfig.displayMode == eVertical) { - channelForward(); - } else if (tvguideConfig.displayMode == eHorizontal) { - timeForward(); - } -} - -void cTvGuideOsd::processKeyRed() { - if ((activeGrid == NULL) || activeGrid->isDummy()) - return; - recMenuView->Start(activeGrid->GetEvent()); -} - -void cTvGuideOsd::processKeyGreen() { - if (activeGrid == NULL) - return; - - const cChannel *currentChannel = activeGrid->column->getChannel(); - const cChannel *firstChannel = columns.First()->getChannel(); - int currentCol = activeGrid->column->GetNum(); - const cChannel *prev = NULL; - - if (tvguideConfig.channelJumpMode == eGroupJump) { - int prevNum = channelGroups->GetPrevGroupChannelNumber(currentChannel); - if (prevNum) { -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - prev = Channels->GetByNumber(prevNum); -#else - prev = Channels.GetByNumber(prevNum); -#endif - } - } else if (tvguideConfig.channelJumpMode == eNumJump) { - int i = tvguideConfig.jumpChannels + 1; -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - for (const cChannel *channel = firstChannel; channel; channel = Channels->Prev(channel)) { -#else - for (const cChannel *channel = firstChannel; channel; channel = Channels.Prev(channel)) { -#endif - if (!channel->GroupSep()) { - prev = channel; - i--; - } - if (i == 0) - break; - } - } - if (prev) { - readChannels(prev); - if (columns.Count() > 0) { - if (tvguideConfig.channelJumpMode == eGroupJump) - drawGridsChannelJump(); - else - drawGridsChannelJump(currentCol); - } - osdManager.flush(); - } -} - -void cTvGuideOsd::processKeyYellow() { - if (activeGrid == NULL) - return; - const cChannel *currentChannel = activeGrid->column->getChannel(); - int currentCol = activeGrid->column->GetNum(); - const cChannel *firstChannel = columns.First()->getChannel(); - const cChannel *next = NULL; - - if (tvguideConfig.channelJumpMode == eGroupJump) { - int nextNum = channelGroups->GetNextGroupChannelNumber(currentChannel); - if (nextNum) { -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - next = Channels->GetByNumber(nextNum); -#else - next = Channels.GetByNumber(nextNum); -#endif - } - } else if (tvguideConfig.channelJumpMode == eNumJump) { - int i=0; -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - for (const cChannel *channel = firstChannel; channel; channel = Channels->Next(channel)) { -#else - for (const cChannel *channel = firstChannel; channel; channel = Channels.Next(channel)) { -#endif - if (channelGroups->IsInLastGroup(channel)) { - break; - } - if (!channel->GroupSep()) { - next = channel; - i++; - } - if (i == (tvguideConfig.jumpChannels+1)) { - break; - } - } - } - if (next) { - readChannels(next); - if (columns.Count() > 0) { - if (tvguideConfig.channelJumpMode == eGroupJump) - drawGridsChannelJump(); - else - drawGridsChannelJump(currentCol); - } - osdManager.flush(); - } -} - -eOSState cTvGuideOsd::processKeyBlue(bool *alreadyUnlocked) { - if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { - return ChannelSwitch(alreadyUnlocked); - } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { - DetailedEPG(); - } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { - recMenuView->StartFavorites(); - } - return osContinue; -} - -eOSState cTvGuideOsd::processKeyOk(bool *alreadyUnlocked) { - if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { - DetailedEPG(); - } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { - return ChannelSwitch(alreadyUnlocked); - } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { - DetailedEPG(); - } - return osContinue; -} - -eOSState cTvGuideOsd::ChannelSwitch(bool *alreadyUnlocked) { - if (activeGrid == NULL) - return osContinue; - const cChannel *currentChannel = activeGrid->column->getChannel(); - if (currentChannel) { - cPixmap::Unlock(); - *alreadyUnlocked = true; - cDevice::PrimaryDevice()->SwitchChannel(currentChannel, true); - if (tvguideConfig.closeOnSwitch) { - if (detailView) { - delete detailView; - detailView = NULL; - detailViewActive = false; - } - return osEnd; - } - } - return osContinue; -} - -void cTvGuideOsd::DetailedEPG() { - if (!activeGrid->isDummy()) { - detailViewActive = true; - detailView = new cDetailView(activeGrid->GetEvent(), footer); - footer->SetDetailedViewMode(); - osdManager.flush(); - detailView->Start(); - osdManager.flush(); - } -} - -void cTvGuideOsd::processNumKey(int numKey) { - if (tvguideConfig.numkeyMode == 0) { - //timely jumps with 1,3,4,6,7,9 - TimeJump(numKey); - } else { - //jump to specific channel - ChannelJump(numKey); - } -} - -void cTvGuideOsd::TimeJump(int mode) { - switch (mode) { - case 1: { - bool tooFarInPast = myTime->DelStep(tvguideConfig.bigStepHours*60); - if (tooFarInPast) - return; - } - break; - case 3: { - myTime->AddStep(tvguideConfig.bigStepHours*60); - } - break; - case 4: { - bool tooFarInPast = myTime->DelStep(tvguideConfig.hugeStepHours*60); - if (tooFarInPast) - return; - } - break; - case 6: { - myTime->AddStep(tvguideConfig.hugeStepHours*60); - } - break; - case 7: { - cMyTime primeChecker; - primeChecker.Now(); - time_t prevPrime = primeChecker.getPrevPrimetime(myTime->GetStart()); - if (primeChecker.tooFarInPast(prevPrime)) - return; - myTime->SetTime(prevPrime); - } - break; - case 9: { - cMyTime primeChecker; - time_t nextPrime = primeChecker.getNextPrimetime(myTime->GetStart()); - myTime->SetTime(nextPrime); - } - break; - default: - return; - } - drawGridsTimeJump(); - timeLine->drawDateViewer(); - timeLine->drawClock(); - timeLine->setTimeline(); - osdManager.flush(); -} - -void cTvGuideOsd::ChannelJump(int num) { - if (!channelJumper) { - channelJumper = new cChannelJump(channelGroups); - } - channelJumper->Set(num); - channelJumper->DrawText(); - osdManager.flush(); -} - -void cTvGuideOsd::CheckTimeout(void) { - if (!channelJumper) - return; - if (channelJumper->TimeOut()) { - int newChannelNum = channelJumper->GetChannel(); - delete channelJumper; - channelJumper = NULL; - const cChannel *newChannel; -#if VDRVERSNUM >= 20301 - { - LOCK_CHANNELS_READ; - newChannel = Channels->GetByNumber(newChannelNum); - } -#else - newChannel = Channels.GetByNumber(newChannelNum); -#endif - if (newChannel) { - readChannels(newChannel); - if (columns.Count() > 0) { - drawGridsChannelJump(); - } - } - osdManager.flush(); - } -} - -void cTvGuideOsd::SetTimers() { - for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { - column->SetTimers(); - } -} - -eOSState cTvGuideOsd::ProcessKey(eKeys Key) { - eOSState state = osContinue; - cPixmap::Lock(); - bool alreadyUnlocked = false; - if (recMenuView->isActive()) { - state = recMenuView->ProcessKey(Key); - if (state == osEnd) { - SetTimers(); - osdManager.flush(); - } - state = osContinue; - } else if (detailViewActive) { - if ((Key & ~k_Repeat) == kRed) { - delete detailView; - detailView = NULL; - detailViewActive = false; - processKeyRed(); - } else if ((Key & ~k_Repeat) == kBlue) { - delete detailView; - detailView = NULL; - detailViewActive = false; - if ((tvguideConfig.blueKeyMode == eBlueKeySwitch) || (tvguideConfig.blueKeyMode == eBlueKeyFavorites)) { - state = ChannelSwitch(&alreadyUnlocked); - } else { - osdManager.flush(); - state = osContinue; - } - } else if ((Key & ~k_Repeat) == kOk && (tvguideConfig.blueKeyMode == eBlueKeyEPG)) { - delete detailView; - detailView = NULL; - detailViewActive = false; - state = ChannelSwitch(&alreadyUnlocked); - } else { - state = detailView->ProcessKey(Key); - if (state == osEnd) { - delete detailView; - detailView = NULL; - detailViewActive = false; - osdManager.flush(); - state = osContinue; - } - } - } else { - switch (Key & ~k_Repeat) { - case kUp: processKeyUp(); break; - case kDown: processKeyDown(); break; - case kLeft: processKeyLeft(); break; - case kRight: processKeyRight(); break; - case kRed: processKeyRed(); break; - case kGreen: processKeyGreen(); break; - case kYellow: processKeyYellow(); break; - case kBlue: state = processKeyBlue(&alreadyUnlocked); break; - case kOk: state = processKeyOk(&alreadyUnlocked); break; - case kBack: state=osEnd; break; - case k0 ... k9: processNumKey(Key - k0); break; - case kNone: if (channelJumper) CheckTimeout(); break; - default: break; - } - } - if (!alreadyUnlocked) { - cPixmap::Unlock(); - } - return state; -} - -void cTvGuideOsd::dump() { - esyslog("tvguide: ------Dumping Content---------"); - activeGrid->debug(); -// int i=1; - for (cChannelColumn *col = columns.First(); col; col = columns.Next(col)) { - col->dumpGrids(); - } -} +#include +#include + +#include "config.h" +#include "services/epgsearch.h" +#include "services/remotetimers.h" + +#include "tools.h" +#include "setup.h" + +#include "tvguideosd.h" + +cTvGuideOsd::cTvGuideOsd(void) { + detailView = NULL; + detailViewActive = false; + activeGrid = NULL; + timeLine = NULL; + recMenuView = NULL; + channelJumper = NULL; +} + +cTvGuideOsd::~cTvGuideOsd() { + delete myTime; + columns.Clear(); + if (tvguideConfig.displayStatusHeader) { + delete statusHeader; + } + if (detailView) + delete detailView; + delete timeLine; + delete channelGroups; + delete footer; + delete recMenuView; + if (channelJumper) + delete channelJumper; + osdManager.deleteOsd(); +} + +void cTvGuideOsd::Show(void) { + int start = cTimeMs::Now(); + bool ok = false; + ok = osdManager.setOsd(); + if (ok) { + bool themeChanged = tvguideConfig.LoadTheme(); + tvguideConfig.SetStyle(); + tvguideConfig.setDynamicValues(); + bool geoChanged = geoManager.SetGeometry(cOsd::OsdWidth(), cOsd::OsdHeight()); + if (themeChanged || geoChanged) { + fontManager.DeleteFonts(); + fontManager.SetFonts(); + imgCache.Clear(); + imgCache.CreateCache(); + } + osdManager.setBackground(); + myTime = new cMyTime(); + myTime->Now(); + SwitchTimers.Load(AddDirectory(cPlugin::ConfigDirectory("epgsearch"), "epgsearchswitchtimers.conf")); + recMenuView = new cRecMenuView(); + pRemoteTimers = cPluginManager::CallFirstService("RemoteTimers::RefreshTimers-v1.0", NULL); + if (pRemoteTimers) { + isyslog("tvguide: remotetimers-plugin is available"); + } + if (tvguideConfig.useRemoteTimers && pRemoteTimers) { + cString errorMsg; + if (!pRemoteTimers->Service("RemoteTimers::RefreshTimers-v1.0", &errorMsg)) { + esyslog("tvguide: %s", *errorMsg); + } + } + drawOsd(); + } + esyslog("tvguide: Rendering took %d ms", int(cTimeMs::Now()-start)); +} + +void cTvGuideOsd::drawOsd() { + cPixmap::Lock(); + int numBack = tvguideConfig.numGrids / 2; + int offset = 0; + const cChannel *newStartChannel; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + const cChannel *startChannel = Channels->GetByNumber(cDevice::CurrentChannel()); +#else + cChannel *startChannel = Channels.GetByNumber(cDevice::CurrentChannel()); +#endif + newStartChannel = startChannel; +#if VDRVERSNUM >= 20301 + for (; newStartChannel ; newStartChannel = Channels->Prev(newStartChannel)) { +#else + for (; newStartChannel ; newStartChannel = Channels.Prev(newStartChannel)) { +#endif + if (newStartChannel && !newStartChannel->GroupSep()) { + offset++; + } + if (offset == numBack) + break; + } + if (!newStartChannel) +#if VDRVERSNUM >= 20301 + newStartChannel = Channels->First(); + } //LOCK_CHANNELS_READ +#else + newStartChannel = Channels.First(); +#endif + offset--; + if (offset < 0) + offset = 0; + + if (tvguideConfig.displayStatusHeader) { + statusHeader = new cStatusHeader(); + statusHeader->Draw(); + statusHeader->ScaleVideo(); + } + timeLine = new cTimeLine(myTime); + timeLine->drawDateViewer(); + timeLine->drawTimeline(); + timeLine->drawClock(); + channelGroups = new cChannelGroups(); + channelGroups->ReadChannelGroups(); + footer = new cFooter(channelGroups); + recMenuView->SetFooter(footer); + footer->drawRedButton(); + if (tvguideConfig.channelJumpMode == eNumJump) { + footer->drawGreenButton(); + footer->drawYellowButton(); + } + footer->drawBlueButton(false); + osdManager.flush(); + readChannels(newStartChannel); + drawGridsChannelJump(offset); + osdManager.flush(); + cPixmap::Unlock(); +} + +void cTvGuideOsd::readChannels(const cChannel *channelStart) { + int i=0; + bool foundEnough = false; + columns.Clear(); + if (!channelStart) + return; +#if VDRVERSNUM >= 20301 + const cChannels *channels; + { + LOCK_CHANNELS_READ; + channels = Channels; + } +#else + cChannels *channels = &Channels; +#endif + for (const cChannel *channel = channelStart; channel; channel = channels->Next(channel)) { + if (!channel->GroupSep()) { + if (channelGroups->IsInLastGroup(channel)) { + break; + } + cChannelColumn *column = new cChannelColumn(i, channel, myTime); + if (column->readGrids()) { + columns.Add(column); + i++; + } else { + delete column; + } + } + if (i == tvguideConfig.numGrids) { + foundEnough = true; + break; + } + } + if (!foundEnough) { + int numCurrent = columns.Count(); + int numBack = tvguideConfig.numGrids - numCurrent; + int newChannelNumber = columns.First()->getChannel()->Number() - numBack; + const cChannel *newStart = channels->GetByNumber(newChannelNumber); + readChannels(newStart); + } +} + +void cTvGuideOsd::drawGridsChannelJump(int offset) { + if (columns.Count() == 0) + return; + activeGrid = columns.Get(offset)->getActive(); + if (activeGrid) + activeGrid->SetActive(); + if (tvguideConfig.displayStatusHeader) { + statusHeader->DrawInfoText(activeGrid); + } + if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { + footer->UpdateGroupButtons(activeGrid->column->getChannel()); + } + if (tvguideConfig.displayChannelGroups) { + channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); + } + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->createHeader(); + column->drawGrids(); + } +} + +void cTvGuideOsd::drawGridsTimeJump() { + if (columns.Count() == 0) + return; + cChannelColumn *colActive = NULL; + if (activeGrid) { + colActive = activeGrid->column; + } else { + colActive = columns.First(); + } + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->clearGrids(); + column->readGrids(); + column->drawGrids(); + } + activeGrid = colActive->getActive(); + if (activeGrid) { + activeGrid->SetActive(); + activeGrid->Draw(); + if (tvguideConfig.displayStatusHeader) { + statusHeader->DrawInfoText(activeGrid); + } + } +} + +void cTvGuideOsd::setNextActiveGrid(cGrid *next) { + if (!next || !activeGrid) { + return; + } + activeGrid->SetInActive(); + activeGrid->Draw(); + activeGrid = next; + activeGrid->SetActive(); + activeGrid->Draw(); + if (tvguideConfig.displayStatusHeader) { + statusHeader->DrawInfoText(activeGrid); + } +} + +void cTvGuideOsd::channelForward() { + cChannelColumn *colRight = columns.Next(activeGrid->column); + bool colAdded = false; + if (!colRight) { + const cChannel *channelRight = activeGrid->column->getChannel(); + const cChannels *channels; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + channels = Channels; + } +#else + channels = &Channels; +#endif + while (channelRight = channels->Next(channelRight)) { + if (!channelRight->GroupSep()) { + if (channelGroups->IsInLastGroup(channelRight)) { + break; + } + colRight = new cChannelColumn(tvguideConfig.numGrids - 1, channelRight, myTime); + if (colRight->readGrids()) { + break; + } else { + delete colRight; + colRight = NULL; + } + } + } + if (colRight) { + colAdded = true; + if (columns.Count() == tvguideConfig.numGrids) { + cChannelColumn *cFirst = columns.First(); + columns.Del(cFirst); + } + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->SetNum(column->GetNum() - 1); + column->drawHeader(); + column->drawGrids(); + } + columns.Add(colRight); + colRight->createHeader(); + colRight->drawGrids(); + } + } + if (colRight) { + cGrid *right = colRight->getNeighbor(activeGrid); + if (right) { + setNextActiveGrid(right); + } + } + if (tvguideConfig.displayChannelGroups && colAdded) { + channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); + } + if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { + footer->UpdateGroupButtons(activeGrid->column->getChannel()); + } + osdManager.flush(); +} + +void cTvGuideOsd::channelBack() { + cChannelColumn *colLeft = columns.Prev(activeGrid->column); + bool colAdded = false; + if (!colLeft) { + const cChannel *channelLeft = activeGrid->column->getChannel(); + const cChannels *channels; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + channels = Channels; + } +#else + channels = &Channels; +#endif + while (channelLeft = channels->Prev(channelLeft)) { + if (!channelLeft->GroupSep()) { + colLeft = new cChannelColumn(0, channelLeft, myTime); + if (colLeft->readGrids()) { + break; + } else { + delete colLeft; + colLeft = NULL; + } + } + } + if (colLeft) { + colAdded = true; + if (columns.Count() == tvguideConfig.numGrids) { + cChannelColumn *cLast = columns.Last(); + columns.Del(cLast); + } + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->SetNum(column->GetNum() + 1); + column->drawHeader(); + column->drawGrids(); + } + columns.Ins(colLeft, columns.First()); + colLeft->createHeader(); + colLeft->drawGrids(); + } + } + + if (colLeft) { + cGrid *left = colLeft->getNeighbor(activeGrid); + if (left) { + setNextActiveGrid(left); + } + } + if (tvguideConfig.displayChannelGroups && colAdded) { + channelGroups->DrawChannelGroups(columns.First()->getChannel(), columns.Last()->getChannel()); + } + + if (activeGrid && (tvguideConfig.channelJumpMode == eGroupJump)) { + footer->UpdateGroupButtons(activeGrid->column->getChannel()); + } + osdManager.flush(); +} + +void cTvGuideOsd::timeForward() { + bool actionDone = false; + if ( (myTime->GetEnd() - activeGrid->EndTime())/60 < 30 ) { + ScrollForward(); + actionDone = true; + } + cGrid *next = activeGrid->column->getNext(activeGrid); + if (next) { + if ( (next->EndTime() < myTime->GetEnd()) + || ( (myTime->GetEnd() - next->StartTime())/60 > 30 ) ) { + setNextActiveGrid(next); + actionDone = true; + } + } + if (!actionDone) { + ScrollForward(); + } + osdManager.flush(); +} + +void cTvGuideOsd::ScrollForward() { + myTime->AddStep(tvguideConfig.stepMinutes); + timeLine->drawDateViewer(); + timeLine->drawClock(); + timeLine->setTimeline(); + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->AddNewGridsAtEnd(); + column->ClearOutdatedStart(); + column->drawGrids(); + } +} + +void cTvGuideOsd::timeBack() { + bool actionDone = false; + if ( (activeGrid->StartTime() - myTime->GetStart())/60 < 30 ) { + ScrollBack(); + actionDone = true; + } + cGrid *prev = activeGrid->column->getPrev(activeGrid); + if (prev) { + if ( (prev->StartTime() > myTime->GetStart()) + || ( (prev->EndTime() - myTime->GetStart())/60 > 30 ) + || ( prev->isFirst()) ) { + setNextActiveGrid(prev); + actionDone = true; + } + } + if (!actionDone) { + ScrollBack(); + } + osdManager.flush(); +} + +void cTvGuideOsd::ScrollBack() { + bool tooFarInPast = myTime->DelStep(tvguideConfig.stepMinutes); + if (tooFarInPast) + return; + timeLine->drawDateViewer(); + timeLine->drawClock(); + timeLine->setTimeline(); + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->AddNewGridsAtStart(); + column->ClearOutdatedEnd(); + column->drawGrids(); + } +} + +void cTvGuideOsd::processKeyUp() { + if (!activeGrid) { + return; + } + if (tvguideConfig.displayMode == eVertical) { + timeBack(); + } else if (tvguideConfig.displayMode == eHorizontal) { + channelBack(); + } +} + +void cTvGuideOsd::processKeyDown() { + if (!activeGrid) { + return; + } + if (tvguideConfig.displayMode == eVertical) { + timeForward(); + } else if (tvguideConfig.displayMode == eHorizontal) { + channelForward(); + } +} + +void cTvGuideOsd::processKeyLeft() { + if (activeGrid == NULL) + return; + if (tvguideConfig.displayMode == eVertical) { + channelBack(); + } else if (tvguideConfig.displayMode == eHorizontal) { + timeBack(); + } +} + +void cTvGuideOsd::processKeyRight() { + if (activeGrid == NULL) + return; + if (tvguideConfig.displayMode == eVertical) { + channelForward(); + } else if (tvguideConfig.displayMode == eHorizontal) { + timeForward(); + } +} + +void cTvGuideOsd::processKeyRed() { + if ((activeGrid == NULL) || activeGrid->isDummy()) + return; + recMenuView->Start(activeGrid->GetEvent()); +} + +void cTvGuideOsd::processKeyGreen() { + if (activeGrid == NULL) + return; + + const cChannel *currentChannel = activeGrid->column->getChannel(); + const cChannel *firstChannel = columns.First()->getChannel(); + int currentCol = activeGrid->column->GetNum(); + const cChannel *prev = NULL; + + if (tvguideConfig.channelJumpMode == eGroupJump) { + int prevNum = channelGroups->GetPrevGroupChannelNumber(currentChannel); + if (prevNum) { +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + prev = Channels->GetByNumber(prevNum); +#else + prev = Channels.GetByNumber(prevNum); +#endif + } + } else if (tvguideConfig.channelJumpMode == eNumJump) { + int i = tvguideConfig.jumpChannels + 1; +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + for (const cChannel *channel = firstChannel; channel; channel = Channels->Prev(channel)) { +#else + for (const cChannel *channel = firstChannel; channel; channel = Channels.Prev(channel)) { +#endif + if (!channel->GroupSep()) { + prev = channel; + i--; + } + if (i == 0) + break; + } + } + if (prev) { + readChannels(prev); + if (columns.Count() > 0) { + if (tvguideConfig.channelJumpMode == eGroupJump) + drawGridsChannelJump(); + else + drawGridsChannelJump(currentCol); + } + osdManager.flush(); + } +} + +void cTvGuideOsd::processKeyYellow() { + if (activeGrid == NULL) + return; + const cChannel *currentChannel = activeGrid->column->getChannel(); + int currentCol = activeGrid->column->GetNum(); + const cChannel *firstChannel = columns.First()->getChannel(); + const cChannel *next = NULL; + + if (tvguideConfig.channelJumpMode == eGroupJump) { + int nextNum = channelGroups->GetNextGroupChannelNumber(currentChannel); + if (nextNum) { +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + next = Channels->GetByNumber(nextNum); +#else + next = Channels.GetByNumber(nextNum); +#endif + } + } else if (tvguideConfig.channelJumpMode == eNumJump) { + int i=0; +#if VDRVERSNUM >= 20301 + LOCK_CHANNELS_READ; + for (const cChannel *channel = firstChannel; channel; channel = Channels->Next(channel)) { +#else + for (const cChannel *channel = firstChannel; channel; channel = Channels.Next(channel)) { +#endif + if (channelGroups->IsInLastGroup(channel)) { + break; + } + if (!channel->GroupSep()) { + next = channel; + i++; + } + if (i == (tvguideConfig.jumpChannels+1)) { + break; + } + } + } + if (next) { + readChannels(next); + if (columns.Count() > 0) { + if (tvguideConfig.channelJumpMode == eGroupJump) + drawGridsChannelJump(); + else + drawGridsChannelJump(currentCol); + } + osdManager.flush(); + } +} + +eOSState cTvGuideOsd::processKeyBlue(bool *alreadyUnlocked) { + if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { + return ChannelSwitch(alreadyUnlocked); + } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { + DetailedEPG(); + } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { + recMenuView->StartFavorites(); + } + return osContinue; +} + +eOSState cTvGuideOsd::processKeyOk(bool *alreadyUnlocked) { + if (tvguideConfig.blueKeyMode == eBlueKeySwitch) { + DetailedEPG(); + } else if (tvguideConfig.blueKeyMode == eBlueKeyEPG) { + return ChannelSwitch(alreadyUnlocked); + } else if (tvguideConfig.blueKeyMode == eBlueKeyFavorites) { + DetailedEPG(); + } + return osContinue; +} + +eOSState cTvGuideOsd::ChannelSwitch(bool *alreadyUnlocked) { + if (activeGrid == NULL) + return osContinue; + const cChannel *currentChannel = activeGrid->column->getChannel(); + if (currentChannel) { + cPixmap::Unlock(); + *alreadyUnlocked = true; + cDevice::PrimaryDevice()->SwitchChannel(currentChannel, true); + if (tvguideConfig.closeOnSwitch) { + if (detailView) { + delete detailView; + detailView = NULL; + detailViewActive = false; + } + return osEnd; + } + } + return osContinue; +} + +void cTvGuideOsd::DetailedEPG() { + if (!activeGrid->isDummy()) { + detailViewActive = true; + detailView = new cDetailView(activeGrid->GetEvent(), footer); + footer->SetDetailedViewMode(); + osdManager.flush(); + detailView->Start(); + osdManager.flush(); + } +} + +void cTvGuideOsd::processNumKey(int numKey) { + if (tvguideConfig.numkeyMode == 0) { + //timely jumps with 1,3,4,6,7,9 + TimeJump(numKey); + } else { + //jump to specific channel + ChannelJump(numKey); + } +} + +void cTvGuideOsd::TimeJump(int mode) { + switch (mode) { + case 1: { + bool tooFarInPast = myTime->DelStep(tvguideConfig.bigStepHours*60); + if (tooFarInPast) + return; + } + break; + case 3: { + myTime->AddStep(tvguideConfig.bigStepHours*60); + } + break; + case 4: { + bool tooFarInPast = myTime->DelStep(tvguideConfig.hugeStepHours*60); + if (tooFarInPast) + return; + } + break; + case 6: { + myTime->AddStep(tvguideConfig.hugeStepHours*60); + } + break; + case 7: { + cMyTime primeChecker; + primeChecker.Now(); + time_t prevPrime = primeChecker.getPrevPrimetime(myTime->GetStart()); + if (primeChecker.tooFarInPast(prevPrime)) + return; + myTime->SetTime(prevPrime); + } + break; + case 9: { + cMyTime primeChecker; + time_t nextPrime = primeChecker.getNextPrimetime(myTime->GetStart()); + myTime->SetTime(nextPrime); + } + break; + default: + return; + } + drawGridsTimeJump(); + timeLine->drawDateViewer(); + timeLine->drawClock(); + timeLine->setTimeline(); + osdManager.flush(); +} + +void cTvGuideOsd::ChannelJump(int num) { + if (!channelJumper) { + channelJumper = new cChannelJump(channelGroups); + } + channelJumper->Set(num); + channelJumper->DrawText(); + osdManager.flush(); +} + +void cTvGuideOsd::CheckTimeout(void) { + if (!channelJumper) + return; + if (channelJumper->TimeOut()) { + int newChannelNum = channelJumper->GetChannel(); + delete channelJumper; + channelJumper = NULL; + const cChannel *newChannel; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + newChannel = Channels->GetByNumber(newChannelNum); + } +#else + newChannel = Channels.GetByNumber(newChannelNum); +#endif + if (newChannel) { + readChannels(newChannel); + if (columns.Count() > 0) { + drawGridsChannelJump(); + } + } + osdManager.flush(); + } +} + +void cTvGuideOsd::SetTimers() { + for (cChannelColumn *column = columns.First(); column; column = columns.Next(column)) { + column->SetTimers(); + } +} + +eOSState cTvGuideOsd::ProcessKey(eKeys Key) { + eOSState state = osContinue; + cPixmap::Lock(); + bool alreadyUnlocked = false; + if (recMenuView->isActive()) { + state = recMenuView->ProcessKey(Key); + if (state == osEnd) { + SetTimers(); + osdManager.flush(); + } + state = osContinue; + } else if (detailViewActive) { + if ((Key & ~k_Repeat) == kRed) { + delete detailView; + detailView = NULL; + detailViewActive = false; + processKeyRed(); + } else if ((Key & ~k_Repeat) == kBlue) { + delete detailView; + detailView = NULL; + detailViewActive = false; + if ((tvguideConfig.blueKeyMode == eBlueKeySwitch) || (tvguideConfig.blueKeyMode == eBlueKeyFavorites)) { + state = ChannelSwitch(&alreadyUnlocked); + } else { + osdManager.flush(); + state = osContinue; + } + } else if ((Key & ~k_Repeat) == kOk && (tvguideConfig.blueKeyMode == eBlueKeyEPG)) { + delete detailView; + detailView = NULL; + detailViewActive = false; + state = ChannelSwitch(&alreadyUnlocked); + } else { + state = detailView->ProcessKey(Key); + if (state == osEnd) { + delete detailView; + detailView = NULL; + detailViewActive = false; + osdManager.flush(); + state = osContinue; + } + } + } else { + switch (Key & ~k_Repeat) { + case kUp: processKeyUp(); break; + case kDown: processKeyDown(); break; + case kLeft: processKeyLeft(); break; + case kRight: processKeyRight(); break; + case kRed: processKeyRed(); break; + case kGreen: processKeyGreen(); break; + case kYellow: processKeyYellow(); break; + case kBlue: state = processKeyBlue(&alreadyUnlocked); break; + case kOk: state = processKeyOk(&alreadyUnlocked); break; + case kBack: state=osEnd; break; + case k0 ... k9: processNumKey(Key - k0); break; + case kNone: if (channelJumper) CheckTimeout(); break; + default: break; + } + } + if (!alreadyUnlocked) { + cPixmap::Unlock(); + } + return state; +} + +void cTvGuideOsd::dump() { + esyslog("tvguide: ------Dumping Content---------"); + activeGrid->debug(); +// int i=1; + for (cChannelColumn *col = columns.First(); col; col = columns.Next(col)) { + col->dumpGrids(); + } +} diff --git a/tvguideosd.h b/tvguideosd.h index 7db4046..a643318 100644 --- a/tvguideosd.h +++ b/tvguideosd.h @@ -1,65 +1,65 @@ -#ifndef __TVGUIDE_TVGUIDEOSD_H -#define __TVGUIDE_TVGUIDEOSD_H - -#include "timer.h" -#include "grid.h" -#include "channelcolumn.h" -#include "statusheader.h" -#include "detailview.h" -#include "timeline.h" -#include "channelgroups.h" -#include "footer.h" -#include "recmenuview.h" -#include "channeljump.h" - -// --- cTvGuideOsd ------------------------------------------------------------- - -class cTvGuideOsd : public cOsdObject { -private: - cMyTime *myTime; - cList columns; - cGrid *activeGrid; - cStatusHeader *statusHeader; - cDetailView *detailView; - cTimeLine *timeLine; - cChannelGroups *channelGroups; - cFooter *footer; - cRecMenuView *recMenuView; - cChannelJump *channelJumper; - bool detailViewActive; - void drawOsd(); - void readChannels(const cChannel *channelStart); - void drawGridsChannelJump(int offset = 0); - void drawGridsTimeJump(); - void processKeyUp(); - void processKeyDown(); - void processKeyLeft(); - void processKeyRight(); - void processKeyRed(); - void processKeyGreen(); - void processKeyYellow(); - eOSState processKeyBlue(bool *alreadyUnlocked); - eOSState processKeyOk(bool *alreadyUnlocked); - void processNumKey(int numKey); - void TimeJump(int mode); - void ChannelJump(int num); - void CheckTimeout(void); - void setNextActiveGrid(cGrid *next); - void channelForward(); - void channelBack(); - void timeForward(); - void timeBack(); - void ScrollForward(); - void ScrollBack(); - eOSState ChannelSwitch(bool *alreadyUnlocked); - void DetailedEPG(); - void SetTimers(); - void dump(); -public: - cTvGuideOsd(void); - virtual ~cTvGuideOsd(void); - virtual void Show(void); - virtual eOSState ProcessKey(eKeys Key); -}; - -#endif //__TVGUIDE_TVGUIDEOSD_H +#ifndef __TVGUIDE_TVGUIDEOSD_H +#define __TVGUIDE_TVGUIDEOSD_H + +#include "timer.h" +#include "grid.h" +#include "channelcolumn.h" +#include "statusheader.h" +#include "detailview.h" +#include "timeline.h" +#include "channelgroups.h" +#include "footer.h" +#include "recmenuview.h" +#include "channeljump.h" + +// --- cTvGuideOsd ------------------------------------------------------------- + +class cTvGuideOsd : public cOsdObject { +private: + cMyTime *myTime; + cList columns; + cGrid *activeGrid; + cStatusHeader *statusHeader; + cDetailView *detailView; + cTimeLine *timeLine; + cChannelGroups *channelGroups; + cFooter *footer; + cRecMenuView *recMenuView; + cChannelJump *channelJumper; + bool detailViewActive; + void drawOsd(); + void readChannels(const cChannel *channelStart); + void drawGridsChannelJump(int offset = 0); + void drawGridsTimeJump(); + void processKeyUp(); + void processKeyDown(); + void processKeyLeft(); + void processKeyRight(); + void processKeyRed(); + void processKeyGreen(); + void processKeyYellow(); + eOSState processKeyBlue(bool *alreadyUnlocked); + eOSState processKeyOk(bool *alreadyUnlocked); + void processNumKey(int numKey); + void TimeJump(int mode); + void ChannelJump(int num); + void CheckTimeout(void); + void setNextActiveGrid(cGrid *next); + void channelForward(); + void channelBack(); + void timeForward(); + void timeBack(); + void ScrollForward(); + void ScrollBack(); + eOSState ChannelSwitch(bool *alreadyUnlocked); + void DetailedEPG(); + void SetTimers(); + void dump(); +public: + cTvGuideOsd(void); + virtual ~cTvGuideOsd(void); + virtual void Show(void); + virtual eOSState ProcessKey(eKeys Key); +}; + +#endif //__TVGUIDE_TVGUIDEOSD_H diff --git a/view.c b/view.c index d0dd604..e0a607b 100644 --- a/view.c +++ b/view.c @@ -1,1062 +1,1062 @@ -#include "detailview.h" -#include "switchtimer.h" - -/******************************************************************************************** -* cView -********************************************************************************************/ - -cView::cView(void) { - activeView = 0; - scrollable = false; - tabbed = false; - font = NULL; - fontSmall = NULL; - fontHeader = NULL; - fontHeaderLarge = NULL; - pixmapBackground = NULL; - pixmapHeader = NULL; - pixmapHeaderLogo = NULL; - pixmapContent = NULL; - pixmapTabs = NULL; - pixmapScrollbar = NULL; - pixmapScrollbarBack = NULL; - imgScrollBar = NULL; - title = ""; - subTitle = ""; - dateTime = ""; - infoText = ""; - channel = NULL; - eventID = 0; - event = NULL; - x = 0; - y = 0; - width = 0; - height = 0; - border = 0; - headerHeight = 0; - contentHeight = 0; - tabHeight = 0; - headerDrawn = false; -} - -cView::~cView(void) { - if (pixmapBackground) - osdManager.releasePixmap(pixmapBackground); - if (pixmapHeader) - delete pixmapHeader; - if (pixmapHeaderLogo) - osdManager.releasePixmap(pixmapHeaderLogo); - if (pixmapContent) - osdManager.releasePixmap(pixmapContent); - if (pixmapTabs) - osdManager.releasePixmap(pixmapTabs); - if (pixmapScrollbar) - osdManager.releasePixmap(pixmapScrollbar); - if (pixmapScrollbarBack) - osdManager.releasePixmap(pixmapScrollbarBack); - if (imgScrollBar) - delete imgScrollBar; -} - -void cView::SetFonts(void) { - font = fontManager.FontDetailView; - fontSmall = fontManager.FontDetailViewSmall; - fontHeaderLarge = fontManager.FontDetailHeaderLarge; - fontHeader = fontManager.FontDetailHeader; -} - -void cView::SetGeometry(void) { - x = 0; - y = 0; - scrollbarWidth = 40; - width = geoManager.osdWidth - scrollbarWidth; - height = geoManager.osdHeight; - border = tvguideConfig.epgViewBorder; - headerWidth = geoManager.headerContentWidth; - headerHeight = geoManager.epgViewHeaderHeight; - if (tabbed) - tabHeight = font->Height() * 3 / 2; - contentHeight = height - headerHeight - tabHeight - geoManager.footerHeight; -} - -void cView::DrawHeader(void) { - if (!pixmapHeader) { - pixmapHeader = new cStyledPixmap(osdManager.requestPixmap(5, cRect(0, 0, headerWidth, headerHeight))); - pixmapHeader->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); - } - if (!pixmapHeaderLogo) { - pixmapHeaderLogo = osdManager.requestPixmap(6, cRect(0, 0, width, headerHeight)); - } - pixmapHeader->Fill(clrTransparent); - pixmapHeaderLogo->Fill(clrTransparent); - if (tvguideConfig.style == eStyleGraphical) { - if (tvguideConfig.scaleVideo) { - pixmapHeader->drawBackgroundGraphical(bgStatusHeaderWindowed); - } else { - pixmapHeader->drawBackgroundGraphical(bgStatusHeaderFull); - } - } else { - pixmapHeader->drawBackground(); - pixmapHeader->drawBoldBorder(); - } - //Channel Logo - int logoHeight = 2 * headerHeight / 3; - int logoWidth = logoHeight * tvguideConfig.logoWidthRatio / tvguideConfig.logoHeightRatio; - int xText = border / 2; - if (channel && !tvguideConfig.hideChannelLogos) { - cImageLoader imgLoader; - if (imgLoader.LoadLogo(channel, logoWidth, logoHeight)) { - cImage logo = imgLoader.GetImage(); - const int logoheight = logo.Height(); - pixmapHeaderLogo->DrawImage(cPoint(border / 2, ((headerHeight - logoHeight) / 2 + (logoHeight - logoheight) / 2)), logo); - xText += logoWidth + border / 2; - } - } - //Date and Time, Title, Subtitle - int yDateTime = border / 2; - int yTitle = (headerHeight - fontHeaderLarge->Height()) / 2; - int ySubtitle = headerHeight - fontHeader->Height() - border / 3; - int textWidthMax = headerWidth - xText; - pixmapHeader->DrawText(cPoint(xText, yDateTime), CutText(dateTime, textWidthMax, fontHeader).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeader); - pixmapHeader->DrawText(cPoint(xText, yTitle), CutText(title, textWidthMax, fontHeaderLarge).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeaderLarge); - pixmapHeader->DrawText(cPoint(xText, ySubtitle), CutText(subTitle, textWidthMax, fontHeader).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeader); - //REC Icon - eTimerMatch timerMatch = tmNone; - if (!event) - return; - const cTimer *ti; - if (tvguideConfig.useRemoteTimers && pRemoteTimers) { - RemoteTimers_GetMatch_v1_0 rtMatch; - rtMatch.event = event; - pRemoteTimers->Service("RemoteTimers::GetMatch-v1.0", &rtMatch); - timerMatch = (eTimerMatch)rtMatch.timerMatch; - ti = rtMatch.timer; - } else { -#if VDRVERSNUM >= 20301 - LOCK_TIMERS_READ; - ti = Timers->GetMatch(event, &timerMatch); -#else - ti = Timers.GetMatch(event, &timerMatch); -#endif - } - bool hasSwitchTimer = SwitchTimers.EventInSwitchList(event); - if (hasSwitchTimer || (ti && timerMatch == tmFull)) { - tColor iconColor; - bool switchOnly = false; - bool timerActive = ti && ti->HasFlags(tfActive); - cString recIconText; -#ifdef SWITCHONLYPATCH - switchOnly = ti && ti->HasFlags(tfSwitchOnly); -#endif - (hasSwitchTimer || switchOnly) ? recIconText = "Switch" : recIconText = " REC "; - iconColor = (hasSwitchTimer || switchOnly) ? theme.Color(clrButtonYellow) : timerActive ? theme.Color(clrButtonRed) : theme.Color(clrButtonGreen); - int widthIcon = fontManager.FontDetailHeader->Width(*recIconText) + 10; - int height = fontManager.FontDetailHeader->Height() + 10; - int posX = headerWidth - widthIcon - 25; - int posY = ySubtitle - 5; - pixmapHeader->DrawRectangle( cRect(posX, posY, widthIcon, height), iconColor); - pixmapHeader->DrawText(cPoint(posX + 5, posY + 5), *recIconText, theme.Color(clrFont), iconColor, fontManager.FontDetailHeader); - } -} - -void cView::DrawTabs(void) { - if (!pixmapTabs) { - pixmapTabs = osdManager.requestPixmap(4, cRect(0, y + headerHeight + contentHeight, width + scrollbarWidth, tabHeight)); - } - tColor bgColor = theme.Color(clrTabInactive); - pixmapTabs->Fill(clrTransparent); - pixmapTabs->DrawRectangle(cRect(0, 0, width, 2), bgColor); - int numTabs = tabs.size(); - int xCurrent = 0; - for (int tab = 0; tab < numTabs; tab++) { - std::string tabText = tabs[tab]; - int textWidth = font->Width(tabText.c_str()); - int tabWidth = textWidth + border; - pixmapTabs->DrawRectangle(cRect(xCurrent, (tab == activeView) ? 0 : 2, tabWidth - 2, tabHeight), bgColor); - pixmapTabs->DrawEllipse(cRect(xCurrent, tabHeight - border/2, border/2, border/2), clrTransparent, -3); - pixmapTabs->DrawEllipse(cRect(xCurrent + tabWidth - border / 2 - 2, tabHeight - border/2, border/2, border/2), clrTransparent, -4); - if (tab == activeView) { - pixmapTabs->DrawRectangle(cRect(xCurrent + 2, 0, tabWidth - 6, tabHeight - border/2 - 1), clrTransparent); - pixmapTabs->DrawRectangle(cRect(xCurrent + border / 2, tabHeight - border/2 - 1, tabWidth - border, border/2 - 1), clrTransparent); - pixmapTabs->DrawEllipse(cRect(xCurrent + 2, tabHeight - border/2 - 2, border/2, border/2), clrTransparent, 3); - pixmapTabs->DrawEllipse(cRect(xCurrent + tabWidth - border / 2 - 4, tabHeight - border/2 - 2, border/2, border/2), clrTransparent, 4); - } - pixmapTabs->DrawText(cPoint(xCurrent + (tabWidth - textWidth) / 2, 2 + (tabHeight - font->Height())/2), tabText.c_str(), theme.Color(clrFont), (tab == activeView) ? clrTransparent : bgColor, font); - xCurrent += tabWidth; - } -} - -void cView::ClearContent(void) { - if (pixmapContent && Running()) { - osdManager.releasePixmap(pixmapContent); - pixmapContent = NULL; - } - if (pixmapBackground && Running()) { - osdManager.releasePixmap(pixmapBackground); - pixmapBackground = NULL; - } -} - -void cView::CreateContent(int fullHeight) { - scrollable = false; - pixmapBackground = osdManager.requestPixmap(3, cRect(x, y + headerHeight, width + scrollbarWidth, contentHeight + tabHeight)); - pixmapBackground->Fill(theme.Color(clrBackground)); - - int drawPortHeight = contentHeight; - if (fullHeight > contentHeight) { - drawPortHeight = fullHeight; - scrollable = true; - } - pixmapContent = osdManager.requestPixmap(4, cRect(x, y + headerHeight, width, contentHeight), cRect(0, 0, width, drawPortHeight)); - pixmapContent->Fill(clrTransparent); -} - -void cView::DrawContent(std::string *text) { - cTextWrapper wText; - wText.Set(text->c_str(), font, width - 2 * border); - int lineHeight = font->Height(); - int textLines = wText.Lines(); - int textHeight = lineHeight * textLines + 2*border; - int yText = border; - CreateContent(textHeight); - for (int i=0; i < textLines; i++) { - pixmapContent->DrawText(cPoint(border, yText), wText.GetLine(i), theme.Color(clrFont), clrTransparent, font); - yText += lineHeight; - } -} - -void cView::DrawFloatingContent(std::string *infoText, cTvMedia *img, cTvMedia *img2) { - cTextWrapper wTextTall; - cTextWrapper wTextFull; - int imgWidth = img->width; - int imgHeight = img->height; - int imgWidth2 = 0; - int imgHeight2 = 0; - if (imgHeight > (contentHeight - 2 * border)) { - imgHeight = contentHeight - 2 * border; - imgWidth = imgWidth * ((double)imgHeight / (double)img->height); - } - int imgHeightTotal = imgHeight; - if (img2) { - imgWidth2 = imgWidth; - imgHeight2 = img2->height * ((double)img2->width / (double)imgWidth2); - imgHeightTotal += img2->height + border; - } - CreateFloatingTextWrapper(&wTextTall, &wTextFull, infoText, imgWidth, imgHeightTotal); - int lineHeight = font->Height(); - int textLinesTall = wTextTall.Lines(); - int textLinesFull = wTextFull.Lines(); - int textHeight = lineHeight * (textLinesTall + textLinesFull) + 2*border; - int yText = border; - CreateContent(max(textHeight, imgHeight + 2*border)); - for (int i=0; i < textLinesTall; i++) { - pixmapContent->DrawText(cPoint(border, yText), wTextTall.GetLine(i), theme.Color(clrFont), clrTransparent, font); - yText += lineHeight; - } - for (int i=0; i < textLinesFull; i++) { - pixmapContent->DrawText(cPoint(border, yText), wTextFull.GetLine(i), theme.Color(clrFont), clrTransparent, font); - yText += lineHeight; - } - osdManager.flush(); - cImageLoader imgLoader; - if (imgLoader.LoadPoster(img->path.c_str(), imgWidth, imgHeight)) { - if (Running() && pixmapContent) - pixmapContent->DrawImage(cPoint(width - imgWidth - border, border), imgLoader.GetImage()); - } - if (!img2) - return; - osdManager.flush(); - if (imgLoader.LoadPoster(img2->path.c_str(), imgWidth2, imgHeight2)) { - if (Running() && pixmapContent) - pixmapContent->DrawImage(cPoint(width - imgWidth2 - border, imgHeight + 2*border), imgLoader.GetImage()); - } -} - -void cView::CreateFloatingTextWrapper(cTextWrapper *twNarrow, cTextWrapper *twFull, std::string *text, int widthImg, int heightImg) { - int lineHeight = font->Height(); - int linesNarrow = (heightImg + 2*border)/ lineHeight; - int linesDrawn = 0; - int y = 0; - int widthNarrow = width - 3 * border - widthImg; - bool drawNarrow = true; - - splitstring s(text->c_str()); - std::vector flds = s.split('\n', 1); - - if (flds.size() < 1) - return; - - std::stringstream sstrTextTall; - std::stringstream sstrTextFull; - - for (int i = 0; i < (int)flds.size(); i++) { - if (!flds[i].size()) { - //empty line - linesDrawn++; - y += lineHeight; - if (drawNarrow) - sstrTextTall << "\n"; - else - sstrTextFull << "\n"; - } else { - cTextWrapper wrapper; - if (drawNarrow) { - wrapper.Set((flds[i].c_str()), font, widthNarrow); - int newLines = wrapper.Lines(); - //check if wrapper fits completely into narrow area - if (linesDrawn + newLines < linesNarrow) { - for (int line = 0; line < wrapper.Lines(); line++) { - sstrTextTall << wrapper.GetLine(line) << " "; - } - sstrTextTall << "\n"; - linesDrawn += newLines; - } else { - //this wrapper has to be splitted - for (int line = 0; line < wrapper.Lines(); line++) { - if (line + linesDrawn < linesNarrow) { - sstrTextTall << wrapper.GetLine(line) << " "; - } else { - sstrTextFull << wrapper.GetLine(line) << " "; - } - } - sstrTextFull << "\n"; - drawNarrow = false; - } - } else { - wrapper.Set((flds[i].c_str()), font, width - 2*border); - for (int line = 0; line < wrapper.Lines(); line++) { - sstrTextFull << wrapper.GetLine(line) << " "; - } - sstrTextFull << "\n"; - } - } - } - twNarrow->Set(sstrTextTall.str().c_str(), font, widthNarrow); - twFull->Set(sstrTextFull.str().c_str(), font, width - 2 * border); -} - -void cView::DrawActors(std::vector *actors) { - int numActors = actors->size(); - if (numActors < 1) { - CreateContent(100); - pixmapContent->DrawText(cPoint(border, border), tr("No Cast available"), theme.Color(clrFont), clrTransparent, fontHeaderLarge); - return; - } - int thumbWidth = actors->at(0).actorThumb.width; - int thumbHeight = actors->at(0).actorThumb.height; - - int picsPerLine = width / (thumbWidth + 2 * border); - if (picsPerLine < 1) - return; - - int picLines = numActors / picsPerLine; - if (numActors%picsPerLine != 0) - picLines++; - - int totalHeight = picLines * (thumbHeight + 2*fontSmall->Height() + border + border/2) + 2*border + fontHeaderLarge->Height(); - - CreateContent(totalHeight); - cString header = cString::sprintf("%s:", tr("Cast")); - pixmapContent->DrawText(cPoint(border, border), *header, theme.Color(clrFont), clrTransparent, fontHeaderLarge); - - int x = 0; - int y = 2 * border + fontHeaderLarge->Height(); - if (!Running()) - return; - cImageLoader imgLoader; - int actor = 0; - for (int row = 0; row < picLines; row++) { - for (int col = 0; col < picsPerLine; col++) { - if (!Running()) - return; - if (actor == numActors) - break; - std::string path = actors->at(actor).actorThumb.path; - std::string name = actors->at(actor).name; - std::stringstream sstrRole; - sstrRole << "\"" << actors->at(actor).role << "\""; - std::string role = sstrRole.str(); - if (imgLoader.LoadPoster(path.c_str(), thumbWidth, thumbHeight)) { - if (Running() && pixmapContent) - pixmapContent->DrawImage(cPoint(x + border, y), imgLoader.GetImage()); - } - - if (fontSmall->Width(name.c_str()) > thumbWidth + 2*border) - name = CutText(name, thumbWidth + 2*border, fontSmall); - if (fontSmall->Width(role.c_str()) > thumbWidth + 2*border) - role = CutText(role, thumbWidth + 2*border, fontSmall); - int xName = x + ((thumbWidth+2*border) - fontSmall->Width(name.c_str()))/2; - int xRole = x + ((thumbWidth+2*border) - fontSmall->Width(role.c_str()))/2; - if (Running() && pixmapContent) { - pixmapContent->DrawText(cPoint(xName, y + thumbHeight + border/2), name.c_str(), theme.Color(clrFont), clrTransparent, fontSmall); - pixmapContent->DrawText(cPoint(xRole, y + thumbHeight + border/2 + fontSmall->Height()), role.c_str(), theme.Color(clrFont), clrTransparent, fontSmall); - x += thumbWidth + 2*border; - } - actor++; - } - osdManager.flush(); - x = 0; - y += thumbHeight + 2 * fontSmall->Height() + border + border/2; - } -} - -void cView::ClearScrollbar(void) { - if (pixmapScrollbar) - pixmapScrollbar->Fill(clrTransparent); - if (pixmapScrollbarBack) - pixmapScrollbarBack->Fill(clrTransparent); -} - -void cView::ClearScrollbarImage(void) { - if (imgScrollBar) { - delete imgScrollBar; - imgScrollBar = NULL; - } -} - -void cView::DrawScrollbar(void) { - ClearScrollbar(); - if (!scrollable || !pixmapContent) - return; - - if (!pixmapScrollbar) { - pixmapScrollbar = osdManager.requestPixmap(6, cRect(width, y + headerHeight, scrollbarWidth, contentHeight)); - pixmapScrollbar->Fill(clrTransparent); - } - if (!pixmapScrollbarBack) { - pixmapScrollbarBack = osdManager.requestPixmap(5, cRect(width, y + headerHeight, scrollbarWidth, contentHeight)); - pixmapScrollbarBack->Fill(clrTransparent); - } - - int totalBarHeight = pixmapScrollbar->ViewPort().Height() - 6; - - int aktHeight = (-1)*pixmapContent->DrawPort().Point().Y(); - int totalHeight = pixmapContent->DrawPort().Height(); - int screenHeight = pixmapContent->ViewPort().Height(); - - int barHeight = (double)(screenHeight * totalBarHeight) / (double)totalHeight ; - int barTop = (double)(aktHeight * totalBarHeight) / (double)totalHeight ; - - if (!imgScrollBar) { - imgScrollBar = CreateScrollbarImage(pixmapScrollbar->ViewPort().Width()-10, barHeight, theme.Color(clrHighlight), theme.Color(clrHighlightBlending)); - } - - pixmapScrollbarBack->Fill(theme.Color(clrHighlightBlending)); - pixmapScrollbarBack->DrawRectangle(cRect(2, 2, pixmapScrollbar->ViewPort().Width() - 4, pixmapScrollbar->ViewPort().Height() - 4), theme.Color(clrHighlightBlending)); - - pixmapScrollbar->DrawImage(cPoint(3, 3 + barTop), *imgScrollBar); -} - -cImage *cView::CreateScrollbarImage(int width, int height, tColor clrBgr, tColor clrBlend) { - cImage *image = new cImage(cSize(width, height)); - image->Fill(clrBgr); - if (tvguideConfig.style != eStyleFlat) { - int numSteps = 64; - int alphaStep = 0x03; - if (height < 30) - return image; - else if (height < 100) { - numSteps = 32; - alphaStep = 0x06; - } - int stepY = 0.5*height / numSteps; - if (stepY == 0) - stepY = 1; - int alpha = 0x40; - tColor clr; - for (int i = 0; iSetPixel(cPoint(x,y), clr); - } - } - alpha += alphaStep; - } - } - return image; -} - -bool cView::KeyUp(void) { - if (!scrollable) - return false; - int aktHeight = pixmapContent->DrawPort().Point().Y(); -// int lineHeight = font->Height(); - if (aktHeight >= 0) { - return false; - } - int step = tvguideConfig.detailedViewScrollStep * font->Height(); - int newY = aktHeight + step; - if (newY > 0) - newY = 0; - pixmapContent->SetDrawPortPoint(cPoint(0, newY)); - return true; -} - -bool cView::KeyDown(void) { - if (!scrollable) - return false; - int aktHeight = pixmapContent->DrawPort().Point().Y(); - int totalHeight = pixmapContent->DrawPort().Height(); - int screenHeight = pixmapContent->ViewPort().Height(); - - if (totalHeight - ((-1)*aktHeight) == screenHeight) { - return false; - } - int step = tvguideConfig.detailedViewScrollStep * font->Height(); - int newY = aktHeight - step; - if ((-1)*newY > totalHeight - screenHeight) - newY = (-1)*(totalHeight - screenHeight); - pixmapContent->SetDrawPortPoint(cPoint(0, newY)); - return true; -} - -/******************************************************************************************** -* cEPGView : cView -********************************************************************************************/ - -cEPGView::cEPGView(void) : cView() { - tabbed = true; - numEPGPics = -1; - numTabs = 0; -} - -cEPGView::~cEPGView(void) { - Cancel(-1); - while (Active()) - cCondWait::SleepMs(10); -} - -void cEPGView::SetTabs(void) { - tabs.push_back(tr("EPG Info")); - if (eventID > 0) - tabs.push_back(tr("Reruns")); - else - tabs.push_back(tr("Recording Information")); - if (numEPGPics > 0) - tabs.push_back(tr("Image Galery")); - numTabs = tabs.size(); -} - -void cEPGView::CheckEPGImages(void) { - if (eventID > 0) { - for (int i=1; i <= tvguideConfig.numAdditionalEPGPictures; i++) { - cString epgimage; - epgimage = cString::sprintf("%s%d_%d.jpg", *tvguideConfig.epgImagePath, eventID, i); - FILE *fp = fopen(*epgimage, "r"); - if (fp) { - std::stringstream ss; - ss << i; - epgPics.push_back(ss.str()); - fclose(fp); - } else { - break; - } - } - } else { - return; - } - numEPGPics = epgPics.size(); -} - -void cEPGView::DrawImages(void) { - int imgWidth = tvguideConfig.epgImageWidthLarge; - int imgHeight = tvguideConfig.epgImageHeightLarge; - - int totalHeight = numEPGPics * (imgHeight + border); - - CreateContent(totalHeight); - - cImageLoader imgLoader; - int yPic = border; - for (int pic = 0; pic < numEPGPics; pic++) { - bool drawPic = false; - if (eventID > 0) { - cString epgimage = cString::sprintf("%d_%d", eventID, atoi(epgPics[pic].c_str())); - if (imgLoader.LoadAdditionalEPGImage(epgimage)) { - drawPic = true; - } - - } - if (drawPic) { - pixmapContent->DrawImage(cPoint((width - imgWidth) / 2, yPic), imgLoader.GetImage()); - yPic += imgHeight + border; - osdManager.flush(); - } - } -} - -void cEPGView::KeyLeft(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView--; - if (activeView < 0) - activeView = numTabs - 1; -} - -void cEPGView::KeyRight(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView = (activeView + 1) % numTabs; -} - -void cEPGView::Action(void) { - ClearContent(); - if (!headerDrawn) { - DrawHeader(); - osdManager.flush(); - headerDrawn = true; - } - if (tabs.size() == 0) { - CheckEPGImages(); - SetTabs(); - } - DrawTabs(); - switch (activeView) { - case evtInfo: - DrawContent(&infoText); - break; - case evtAddInfo: - DrawContent(&addInfoText); - break; - case evtImages: - DrawImages(); - break; - } - DrawScrollbar(); - osdManager.flush(); -} - -/******************************************************************************************** -* cSeriesView : cView -********************************************************************************************/ - -cSeriesView::cSeriesView(int seriesId, int episodeId) : cView() { - this->seriesId = seriesId; - this->episodeId = episodeId; - tvdbInfo = ""; - tabbed = true; -} - -cSeriesView::~cSeriesView(void) { - Cancel(-1); - while (Active()) - cCondWait::SleepMs(10); -} - -void cSeriesView::LoadMedia(void) { - static cPlugin *pScraper = GetScraperPlugin(); - if (!pScraper || seriesId < 1) - return; - series.seriesId = seriesId; - series.episodeId = episodeId; - pScraper->Service("GetSeries", &series); -} - -void cSeriesView::SetTabs(void) { - tabs.push_back(tr("EPG Info")); - if (eventID > 0) - tabs.push_back(tr("Reruns")); - else - tabs.push_back(tr("Recording Information")); - tabs.push_back(tr("Cast")); - tabs.push_back(tr("TheTVDB Info")); - tabs.push_back(tr("Image Galery")); -} - -void cSeriesView::CreateTVDBInfo(void) { - if (tvdbInfo.size() > 0) - return; - std::stringstream info; - info << tr("TheTVDB Information") << ":\n\n"; - - if (series.episode.name.size() > 0) { - info << tr("Episode") << ": " << series.episode.name << " (" << tr("Season") << " " << series.episode.season << ", " << tr("Episode") << " " << series.episode.number << ")\n\n"; - } - if (series.episode.overview.size() > 0) { - info << tr("Episode Overview") << ": " << series.episode.overview << "\n\n"; - } - if (series.episode.firstAired.size() > 0) { - info << tr("First aired") << ": " << series.episode.firstAired << "\n\n"; - } - if (series.episode.guestStars.size() > 0) { - info << tr("Guest Stars") << ": " << series.episode.guestStars << "\n\n"; - } - if (series.episode.rating > 0) { - info << tr("TheMovieDB Rating") << ": " << series.episode.rating << "\n\n"; - } - if (series.overview.size() > 0) { - info << tr("Series Overview") << ": " << series.overview << "\n\n"; - } - if (series.firstAired.size() > 0) { - info << tr("First aired") << ": " << series.firstAired << "\n\n"; - } - if (series.genre.size() > 0) { - info << tr("Genre") << ": " << series.genre << "\n\n"; - } - if (series.network.size() > 0) { - info << tr("Network") << ": " << series.network << "\n\n"; - } - if (series.rating > 0) { - info << tr("TheMovieDB Rating") << ": " << series.rating << "\n\n"; - } - if (series.status.size() > 0) { - info << tr("Status") << ": " << series.status << "\n\n"; - } - tvdbInfo = info.str(); -} - -void cSeriesView::DrawImages(void) { - int numPosters = series.posters.size(); - int numFanarts = series.fanarts.size(); - int numBanners = series.banners.size(); - - int totalHeight = border; - //Fanart Height - int fanartWidth = width - 2 * border; - int fanartHeight = 0; - if (numFanarts > 0 && series.fanarts[0].width > 0) { - fanartHeight = series.fanarts[0].height * ((double)fanartWidth / (double)series.fanarts[0].width); - if (fanartHeight > contentHeight - 2 * border) { - int fanartHeightOrig = fanartHeight; - fanartHeight = contentHeight - 2 * border; - fanartWidth = fanartWidth * ((double)fanartHeight / (double)fanartHeightOrig); - } - totalHeight += series.fanarts.size() * (fanartHeight + border); - } - //Poster Height - int posterWidth = (width - 4 * border) / 2; - int posterHeight = 0; - if (numPosters > 0 && series.posters[0].width > 0) { - posterHeight = series.posters[0].height * ((double)posterWidth / (double)series.posters[0].width); - } - if (numPosters > 0) - totalHeight += posterHeight + border; - if (numPosters == 3) - totalHeight += posterHeight + border; - //Banners Height - if (numBanners > 0) - totalHeight += (series.banners[0].height + border) * numBanners; - - CreateContent(totalHeight); - - cImageLoader imgLoader; - int yPic = border; - for (int i=0; i < numFanarts; i++) { - if (numBanners > i) { - if (imgLoader.LoadPoster(series.banners[i].path.c_str(), series.banners[i].width, series.banners[i].height) && Running()) { - pixmapContent->DrawImage(cPoint((width - series.banners[i].width) / 2, yPic), imgLoader.GetImage()); - yPic += series.banners[i].height + border; - osdManager.flush(); - } - } - if (imgLoader.LoadPoster(series.fanarts[i].path.c_str(), fanartWidth, fanartHeight) && Running()) { - pixmapContent->DrawImage(cPoint((width - fanartWidth)/2, yPic), imgLoader.GetImage()); - yPic += fanartHeight + border; - osdManager.flush(); - } - } - if (numPosters >= 1) { - if (imgLoader.LoadPoster(series.posters[0].path.c_str(), posterWidth, posterHeight) && Running()) { - pixmapContent->DrawImage(cPoint(border, yPic), imgLoader.GetImage()); - osdManager.flush(); - yPic += posterHeight + border; - } - } - if (numPosters >= 2) { - if (imgLoader.LoadPoster(series.posters[1].path.c_str(), posterWidth, posterHeight) && Running()) { - pixmapContent->DrawImage(cPoint(2 * border + posterWidth, yPic - posterHeight - border), imgLoader.GetImage()); - osdManager.flush(); - } - } - if (numPosters == 3) { - if (imgLoader.LoadPoster(series.posters[2].path.c_str(), posterWidth, posterHeight) && Running()) { - pixmapContent->DrawImage(cPoint((width - posterWidth) / 2, yPic), imgLoader.GetImage()); - osdManager.flush(); - } - } -} - -int cSeriesView::GetRandomPoster(void) { - int numPosters = series.posters.size(); - if (numPosters == 0) - return -1; - srand((unsigned)time(NULL)); - int randPoster = rand()%numPosters; - return randPoster; -} - -void cSeriesView::KeyLeft(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView--; - if (activeView < 0) - activeView = mvtCount - 1; -} - -void cSeriesView::KeyRight(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView = (activeView + 1) % mvtCount; -} - -void cSeriesView::Action(void) { - ClearContent(); - if (!headerDrawn) { - DrawHeader(); - osdManager.flush(); - headerDrawn = true; - } - if (tabs.size() == 0) { - SetTabs(); - } - DrawTabs(); - int randomPoster = GetRandomPoster(); - switch (activeView) { - case mvtInfo: - if (randomPoster >= 0) { - DrawFloatingContent(&infoText, &series.posters[randomPoster]); - } else - DrawContent(&infoText); - break; - case mvtAddInfo: - if (randomPoster >= 0) - DrawFloatingContent(&addInfoText, &series.posters[randomPoster]); - else - DrawContent(&addInfoText); - break; - case mvtCast: - DrawActors(&series.actors); - break; - case mvtOnlineInfo: - CreateTVDBInfo(); - if ((series.seasonPoster.path.size() > 0) && series.episode.episodeImage.path.size() > 0) - DrawFloatingContent(&tvdbInfo, &series.episode.episodeImage, &series.seasonPoster); - else if (series.seasonPoster.path.size() > 0) - DrawFloatingContent(&tvdbInfo, &series.seasonPoster); - else if (series.episode.episodeImage.path.size() > 0) - DrawFloatingContent(&tvdbInfo, &series.episode.episodeImage); - else if (randomPoster >= 0) - DrawFloatingContent(&tvdbInfo, &series.posters[randomPoster]); - else - DrawContent(&tvdbInfo); - break; - case mvtImages: - DrawImages(); - break; - } - DrawScrollbar(); - osdManager.flush(); -} - -/******************************************************************************************** -* cMovieView : cView -********************************************************************************************/ - -cMovieView::cMovieView(int movieId) : cView() { - this->movieId = movieId; - tabbed = true; -} - -cMovieView::~cMovieView(void) { - Cancel(-1); - while (Active()) - cCondWait::SleepMs(10); -} - -void cMovieView::LoadMedia(void) { - static cPlugin *pScraper = GetScraperPlugin(); - if (!pScraper || movieId < 1) - return; - movie.movieId = movieId; - pScraper->Service("GetMovie", &movie); -} - -void cMovieView::SetTabs(void) { - tabs.push_back(tr("EPG Info")); - if (eventID > 0) - tabs.push_back(tr("Reruns")); - else - tabs.push_back(tr("Recording Information")); - tabs.push_back(tr("Cast")); - tabs.push_back(tr("TheTVDB Info")); - tabs.push_back(tr("Image Galery")); -} - -void cMovieView::CreateMovieDBInfo(void) { - if (movieDBInfo.size() > 0) - return; - std::stringstream info; - info << tr("TheMovieDB Information") << ":\n\n"; - if (movie.originalTitle.size() > 0) { - info << tr("Original Title") << ": " << movie.originalTitle << "\n\n"; - } - if (movie.tagline.size() > 0) { - info << tr("Tagline") << ": " << movie.tagline << "\n\n"; - } - if (movie.overview.size() > 0) { - info << tr("Overview") << ": " << movie.overview << "\n\n"; - } - std::string strAdult = (movie.adult)?(tr("yes")):(tr("no")); - info << tr("Adult") << ": " << strAdult << "\n\n"; - if (movie.collectionName.size() > 0) { - info << tr("Collection") << ": " << movie.collectionName << "\n\n"; - } - if (movie.budget > 0) { - info << tr("Budget") << ": " << movie.budget << "$\n\n"; - } - if (movie.revenue > 0) { - info << tr("Revenue") << ": " << movie.revenue << "$\n\n"; - } - if (movie.genres.size() > 0) { - info << tr("Genre") << ": " << movie.genres << "\n\n"; - } - if (movie.homepage.size() > 0) { - info << tr("Homepage") << ": " << movie.homepage << "\n\n"; - } - if (movie.releaseDate.size() > 0) { - info << tr("Release Date") << ": " << movie.releaseDate << "\n\n"; - } - if (movie.runtime > 0) { - info << tr("Runtime") << ": " << movie.runtime << " " << tr("minutes") << "\n\n"; - } - if (movie.popularity > 0) { - info << tr("TheMovieDB Popularity") << ": " << movie.popularity << "\n\n"; - } - if (movie.voteAverage > 0) { - info << tr("TheMovieDB Vote Average") << ": " << movie.voteAverage << "\n\n"; - } - movieDBInfo = info.str(); -} - -void cMovieView::DrawImages(void) { - int totalHeight = border; - //Fanart Height - int fanartWidth = width - 2 * border; - int fanartHeight = 0; - if (movie.fanart.width > 0 && movie.fanart.height > 0 && movie.fanart.path.size() > 0) { - fanartHeight = movie.fanart.height * ((double)fanartWidth / (double)movie.fanart.width); - if (fanartHeight > contentHeight - 2 * border) { - int fanartHeightOrig = fanartHeight; - fanartHeight = contentHeight - 2 * border; - fanartWidth = fanartWidth * ((double)fanartHeight / (double)fanartHeightOrig); - } - totalHeight += fanartHeight + border; - } - //Collection Fanart Height - int collectionFanartWidth = width - 2 * border; - int collectionFanartHeight = 0; - if (movie.collectionFanart.width > 0 && movie.collectionFanart.height > 0 && movie.collectionFanart.path.size() > 0) { - collectionFanartHeight = movie.collectionFanart.height * ((double)collectionFanartWidth / (double)movie.collectionFanart.width); - if (collectionFanartHeight > contentHeight - 2 * border) { - int fanartHeightOrig = collectionFanartHeight; - collectionFanartHeight = contentHeight - 2 * border; - collectionFanartWidth = collectionFanartWidth * ((double)collectionFanartHeight / (double)fanartHeightOrig); - } - totalHeight += collectionFanartHeight + border; - } - //Poster Height - if (movie.poster.width > 0 && movie.poster.height > 0 && movie.poster.path.size() > 0) { - totalHeight += movie.poster.height + border; - } - //Collection Popster Height - if (movie.collectionPoster.width > 0 && movie.collectionPoster.height > 0 && movie.collectionPoster.path.size() > 0) { - totalHeight += movie.collectionPoster.height + border; - } - - CreateContent(totalHeight); - - cImageLoader imgLoader; - int yPic = border; - if (movie.fanart.width > 0 && movie.fanart.height > 0 && movie.fanart.path.size() > 0) { - if (imgLoader.LoadPoster(movie.fanart.path.c_str(), fanartWidth, fanartHeight) && Running()) { - pixmapContent->DrawImage(cPoint((width - fanartWidth)/2, yPic), imgLoader.GetImage()); - yPic += fanartHeight + border; - osdManager.flush(); - } - } - if (movie.collectionFanart.width > 0 && movie.collectionFanart.height > 0 && movie.collectionFanart.path.size() > 0) { - if (imgLoader.LoadPoster(movie.collectionFanart.path.c_str(), collectionFanartWidth, collectionFanartHeight) && Running()) { - pixmapContent->DrawImage(cPoint((width - collectionFanartWidth)/2, yPic), imgLoader.GetImage()); - yPic += collectionFanartHeight + border; - osdManager.flush(); - } - } - if (movie.poster.width > 0 && movie.poster.height > 0 && movie.poster.path.size() > 0) { - if (imgLoader.LoadPoster(movie.poster.path.c_str(), movie.poster.width, movie.poster.height) && Running()) { - pixmapContent->DrawImage(cPoint((width - movie.poster.width) / 2, yPic), imgLoader.GetImage()); - yPic += movie.poster.height + border; - osdManager.flush(); - } - } - if (movie.collectionPoster.width > 0 && movie.collectionPoster.height > 0 && movie.collectionPoster.path.size() > 0) { - if (imgLoader.LoadPoster(movie.collectionPoster.path.c_str(), movie.collectionPoster.width, movie.collectionPoster.height) && Running()) { - pixmapContent->DrawImage(cPoint((width - movie.collectionPoster.width) / 2, yPic), imgLoader.GetImage()); - yPic += movie.collectionPoster.height + border; - osdManager.flush(); - } - } -} - -void cMovieView::KeyLeft(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView--; - if (activeView < 0) - activeView = mvtCount - 1; -} - -void cMovieView::KeyRight(void) { - if (Running()) - return; - ClearScrollbarImage(); - activeView = (activeView + 1) % mvtCount; -} - -void cMovieView::Action(void) { - ClearContent(); - if (!headerDrawn) { - DrawHeader(); - osdManager.flush(); - headerDrawn = true; - } - if (tabs.size() == 0) { - SetTabs(); - } - DrawTabs(); - bool posterAvailable = (movie.poster.path.size() > 0 && movie.poster.width > 0 && movie.poster.height > 0) ? true : false; - switch (activeView) { - case mvtInfo: - if (posterAvailable) - DrawFloatingContent(&infoText, &movie.poster); - else - DrawContent(&infoText); - break; - case mvtAddInfo: - if (posterAvailable) - DrawFloatingContent(&addInfoText, &movie.poster); - else - DrawContent(&addInfoText); - break; - case mvtCast: - DrawActors(&movie.actors); - break; - case mvtOnlineInfo: - CreateMovieDBInfo(); - if (posterAvailable) - DrawFloatingContent(&movieDBInfo, &movie.poster); - else - DrawContent(&movieDBInfo); - break; - case mvtImages: - DrawImages(); - break; - } - DrawScrollbar(); - osdManager.flush(); -} +#include "detailview.h" +#include "switchtimer.h" + +/******************************************************************************************** +* cView +********************************************************************************************/ + +cView::cView(void) { + activeView = 0; + scrollable = false; + tabbed = false; + font = NULL; + fontSmall = NULL; + fontHeader = NULL; + fontHeaderLarge = NULL; + pixmapBackground = NULL; + pixmapHeader = NULL; + pixmapHeaderLogo = NULL; + pixmapContent = NULL; + pixmapTabs = NULL; + pixmapScrollbar = NULL; + pixmapScrollbarBack = NULL; + imgScrollBar = NULL; + title = ""; + subTitle = ""; + dateTime = ""; + infoText = ""; + channel = NULL; + eventID = 0; + event = NULL; + x = 0; + y = 0; + width = 0; + height = 0; + border = 0; + headerHeight = 0; + contentHeight = 0; + tabHeight = 0; + headerDrawn = false; +} + +cView::~cView(void) { + if (pixmapBackground) + osdManager.releasePixmap(pixmapBackground); + if (pixmapHeader) + delete pixmapHeader; + if (pixmapHeaderLogo) + osdManager.releasePixmap(pixmapHeaderLogo); + if (pixmapContent) + osdManager.releasePixmap(pixmapContent); + if (pixmapTabs) + osdManager.releasePixmap(pixmapTabs); + if (pixmapScrollbar) + osdManager.releasePixmap(pixmapScrollbar); + if (pixmapScrollbarBack) + osdManager.releasePixmap(pixmapScrollbarBack); + if (imgScrollBar) + delete imgScrollBar; +} + +void cView::SetFonts(void) { + font = fontManager.FontDetailView; + fontSmall = fontManager.FontDetailViewSmall; + fontHeaderLarge = fontManager.FontDetailHeaderLarge; + fontHeader = fontManager.FontDetailHeader; +} + +void cView::SetGeometry(void) { + x = 0; + y = 0; + scrollbarWidth = 40; + width = geoManager.osdWidth - scrollbarWidth; + height = geoManager.osdHeight; + border = tvguideConfig.epgViewBorder; + headerWidth = geoManager.headerContentWidth; + headerHeight = geoManager.epgViewHeaderHeight; + if (tabbed) + tabHeight = font->Height() * 3 / 2; + contentHeight = height - headerHeight - tabHeight - geoManager.footerHeight; +} + +void cView::DrawHeader(void) { + if (!pixmapHeader) { + pixmapHeader = new cStyledPixmap(osdManager.requestPixmap(5, cRect(0, 0, headerWidth, headerHeight))); + pixmapHeader->setColor(theme.Color(clrHeader), theme.Color(clrHeaderBlending)); + } + if (!pixmapHeaderLogo) { + pixmapHeaderLogo = osdManager.requestPixmap(6, cRect(0, 0, width, headerHeight)); + } + pixmapHeader->Fill(clrTransparent); + pixmapHeaderLogo->Fill(clrTransparent); + if (tvguideConfig.style == eStyleGraphical) { + if (tvguideConfig.scaleVideo) { + pixmapHeader->drawBackgroundGraphical(bgStatusHeaderWindowed); + } else { + pixmapHeader->drawBackgroundGraphical(bgStatusHeaderFull); + } + } else { + pixmapHeader->drawBackground(); + pixmapHeader->drawBoldBorder(); + } + //Channel Logo + int logoHeight = 2 * headerHeight / 3; + int logoWidth = logoHeight * tvguideConfig.logoWidthRatio / tvguideConfig.logoHeightRatio; + int xText = border / 2; + if (channel && !tvguideConfig.hideChannelLogos) { + cImageLoader imgLoader; + if (imgLoader.LoadLogo(channel, logoWidth, logoHeight)) { + cImage logo = imgLoader.GetImage(); + const int logoheight = logo.Height(); + pixmapHeaderLogo->DrawImage(cPoint(border / 2, ((headerHeight - logoHeight) / 2 + (logoHeight - logoheight) / 2)), logo); + xText += logoWidth + border / 2; + } + } + //Date and Time, Title, Subtitle + int yDateTime = border / 2; + int yTitle = (headerHeight - fontHeaderLarge->Height()) / 2; + int ySubtitle = headerHeight - fontHeader->Height() - border / 3; + int textWidthMax = headerWidth - xText; + pixmapHeader->DrawText(cPoint(xText, yDateTime), CutText(dateTime, textWidthMax, fontHeader).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeader); + pixmapHeader->DrawText(cPoint(xText, yTitle), CutText(title, textWidthMax, fontHeaderLarge).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeaderLarge); + pixmapHeader->DrawText(cPoint(xText, ySubtitle), CutText(subTitle, textWidthMax, fontHeader).c_str(), theme.Color(clrFont), theme.Color(clrStatusHeader), fontHeader); + //REC Icon + eTimerMatch timerMatch = tmNone; + if (!event) + return; + const cTimer *ti; + if (tvguideConfig.useRemoteTimers && pRemoteTimers) { + RemoteTimers_GetMatch_v1_0 rtMatch; + rtMatch.event = event; + pRemoteTimers->Service("RemoteTimers::GetMatch-v1.0", &rtMatch); + timerMatch = (eTimerMatch)rtMatch.timerMatch; + ti = rtMatch.timer; + } else { +#if VDRVERSNUM >= 20301 + LOCK_TIMERS_READ; + ti = Timers->GetMatch(event, &timerMatch); +#else + ti = Timers.GetMatch(event, &timerMatch); +#endif + } + bool hasSwitchTimer = SwitchTimers.EventInSwitchList(event); + if (hasSwitchTimer || (ti && timerMatch == tmFull)) { + tColor iconColor; + bool switchOnly = false; + bool timerActive = ti && ti->HasFlags(tfActive); + cString recIconText; +#ifdef SWITCHONLYPATCH + switchOnly = ti && ti->HasFlags(tfSwitchOnly); +#endif + (hasSwitchTimer || switchOnly) ? recIconText = "Switch" : recIconText = " REC "; + iconColor = (hasSwitchTimer || switchOnly) ? theme.Color(clrButtonYellow) : timerActive ? theme.Color(clrButtonRed) : theme.Color(clrButtonGreen); + int widthIcon = fontManager.FontDetailHeader->Width(*recIconText) + 10; + int height = fontManager.FontDetailHeader->Height() + 10; + int posX = headerWidth - widthIcon - 25; + int posY = ySubtitle - 5; + pixmapHeader->DrawRectangle( cRect(posX, posY, widthIcon, height), iconColor); + pixmapHeader->DrawText(cPoint(posX + 5, posY + 5), *recIconText, theme.Color(clrFont), iconColor, fontManager.FontDetailHeader); + } +} + +void cView::DrawTabs(void) { + if (!pixmapTabs) { + pixmapTabs = osdManager.requestPixmap(4, cRect(0, y + headerHeight + contentHeight, width + scrollbarWidth, tabHeight)); + } + tColor bgColor = theme.Color(clrTabInactive); + pixmapTabs->Fill(clrTransparent); + pixmapTabs->DrawRectangle(cRect(0, 0, width, 2), bgColor); + int numTabs = tabs.size(); + int xCurrent = 0; + for (int tab = 0; tab < numTabs; tab++) { + std::string tabText = tabs[tab]; + int textWidth = font->Width(tabText.c_str()); + int tabWidth = textWidth + border; + pixmapTabs->DrawRectangle(cRect(xCurrent, (tab == activeView) ? 0 : 2, tabWidth - 2, tabHeight), bgColor); + pixmapTabs->DrawEllipse(cRect(xCurrent, tabHeight - border/2, border/2, border/2), clrTransparent, -3); + pixmapTabs->DrawEllipse(cRect(xCurrent + tabWidth - border / 2 - 2, tabHeight - border/2, border/2, border/2), clrTransparent, -4); + if (tab == activeView) { + pixmapTabs->DrawRectangle(cRect(xCurrent + 2, 0, tabWidth - 6, tabHeight - border/2 - 1), clrTransparent); + pixmapTabs->DrawRectangle(cRect(xCurrent + border / 2, tabHeight - border/2 - 1, tabWidth - border, border/2 - 1), clrTransparent); + pixmapTabs->DrawEllipse(cRect(xCurrent + 2, tabHeight - border/2 - 2, border/2, border/2), clrTransparent, 3); + pixmapTabs->DrawEllipse(cRect(xCurrent + tabWidth - border / 2 - 4, tabHeight - border/2 - 2, border/2, border/2), clrTransparent, 4); + } + pixmapTabs->DrawText(cPoint(xCurrent + (tabWidth - textWidth) / 2, 2 + (tabHeight - font->Height())/2), tabText.c_str(), theme.Color(clrFont), (tab == activeView) ? clrTransparent : bgColor, font); + xCurrent += tabWidth; + } +} + +void cView::ClearContent(void) { + if (pixmapContent && Running()) { + osdManager.releasePixmap(pixmapContent); + pixmapContent = NULL; + } + if (pixmapBackground && Running()) { + osdManager.releasePixmap(pixmapBackground); + pixmapBackground = NULL; + } +} + +void cView::CreateContent(int fullHeight) { + scrollable = false; + pixmapBackground = osdManager.requestPixmap(3, cRect(x, y + headerHeight, width + scrollbarWidth, contentHeight + tabHeight)); + pixmapBackground->Fill(theme.Color(clrBackground)); + + int drawPortHeight = contentHeight; + if (fullHeight > contentHeight) { + drawPortHeight = fullHeight; + scrollable = true; + } + pixmapContent = osdManager.requestPixmap(4, cRect(x, y + headerHeight, width, contentHeight), cRect(0, 0, width, drawPortHeight)); + pixmapContent->Fill(clrTransparent); +} + +void cView::DrawContent(std::string *text) { + cTextWrapper wText; + wText.Set(text->c_str(), font, width - 2 * border); + int lineHeight = font->Height(); + int textLines = wText.Lines(); + int textHeight = lineHeight * textLines + 2*border; + int yText = border; + CreateContent(textHeight); + for (int i=0; i < textLines; i++) { + pixmapContent->DrawText(cPoint(border, yText), wText.GetLine(i), theme.Color(clrFont), clrTransparent, font); + yText += lineHeight; + } +} + +void cView::DrawFloatingContent(std::string *infoText, cTvMedia *img, cTvMedia *img2) { + cTextWrapper wTextTall; + cTextWrapper wTextFull; + int imgWidth = img->width; + int imgHeight = img->height; + int imgWidth2 = 0; + int imgHeight2 = 0; + if (imgHeight > (contentHeight - 2 * border)) { + imgHeight = contentHeight - 2 * border; + imgWidth = imgWidth * ((double)imgHeight / (double)img->height); + } + int imgHeightTotal = imgHeight; + if (img2) { + imgWidth2 = imgWidth; + imgHeight2 = img2->height * ((double)img2->width / (double)imgWidth2); + imgHeightTotal += img2->height + border; + } + CreateFloatingTextWrapper(&wTextTall, &wTextFull, infoText, imgWidth, imgHeightTotal); + int lineHeight = font->Height(); + int textLinesTall = wTextTall.Lines(); + int textLinesFull = wTextFull.Lines(); + int textHeight = lineHeight * (textLinesTall + textLinesFull) + 2*border; + int yText = border; + CreateContent(max(textHeight, imgHeight + 2*border)); + for (int i=0; i < textLinesTall; i++) { + pixmapContent->DrawText(cPoint(border, yText), wTextTall.GetLine(i), theme.Color(clrFont), clrTransparent, font); + yText += lineHeight; + } + for (int i=0; i < textLinesFull; i++) { + pixmapContent->DrawText(cPoint(border, yText), wTextFull.GetLine(i), theme.Color(clrFont), clrTransparent, font); + yText += lineHeight; + } + osdManager.flush(); + cImageLoader imgLoader; + if (imgLoader.LoadPoster(img->path.c_str(), imgWidth, imgHeight)) { + if (Running() && pixmapContent) + pixmapContent->DrawImage(cPoint(width - imgWidth - border, border), imgLoader.GetImage()); + } + if (!img2) + return; + osdManager.flush(); + if (imgLoader.LoadPoster(img2->path.c_str(), imgWidth2, imgHeight2)) { + if (Running() && pixmapContent) + pixmapContent->DrawImage(cPoint(width - imgWidth2 - border, imgHeight + 2*border), imgLoader.GetImage()); + } +} + +void cView::CreateFloatingTextWrapper(cTextWrapper *twNarrow, cTextWrapper *twFull, std::string *text, int widthImg, int heightImg) { + int lineHeight = font->Height(); + int linesNarrow = (heightImg + 2*border)/ lineHeight; + int linesDrawn = 0; + int y = 0; + int widthNarrow = width - 3 * border - widthImg; + bool drawNarrow = true; + + splitstring s(text->c_str()); + std::vector flds = s.split('\n', 1); + + if (flds.size() < 1) + return; + + std::stringstream sstrTextTall; + std::stringstream sstrTextFull; + + for (int i = 0; i < (int)flds.size(); i++) { + if (!flds[i].size()) { + //empty line + linesDrawn++; + y += lineHeight; + if (drawNarrow) + sstrTextTall << "\n"; + else + sstrTextFull << "\n"; + } else { + cTextWrapper wrapper; + if (drawNarrow) { + wrapper.Set((flds[i].c_str()), font, widthNarrow); + int newLines = wrapper.Lines(); + //check if wrapper fits completely into narrow area + if (linesDrawn + newLines < linesNarrow) { + for (int line = 0; line < wrapper.Lines(); line++) { + sstrTextTall << wrapper.GetLine(line) << " "; + } + sstrTextTall << "\n"; + linesDrawn += newLines; + } else { + //this wrapper has to be splitted + for (int line = 0; line < wrapper.Lines(); line++) { + if (line + linesDrawn < linesNarrow) { + sstrTextTall << wrapper.GetLine(line) << " "; + } else { + sstrTextFull << wrapper.GetLine(line) << " "; + } + } + sstrTextFull << "\n"; + drawNarrow = false; + } + } else { + wrapper.Set((flds[i].c_str()), font, width - 2*border); + for (int line = 0; line < wrapper.Lines(); line++) { + sstrTextFull << wrapper.GetLine(line) << " "; + } + sstrTextFull << "\n"; + } + } + } + twNarrow->Set(sstrTextTall.str().c_str(), font, widthNarrow); + twFull->Set(sstrTextFull.str().c_str(), font, width - 2 * border); +} + +void cView::DrawActors(std::vector *actors) { + int numActors = actors->size(); + if (numActors < 1) { + CreateContent(100); + pixmapContent->DrawText(cPoint(border, border), tr("No Cast available"), theme.Color(clrFont), clrTransparent, fontHeaderLarge); + return; + } + int thumbWidth = actors->at(0).actorThumb.width; + int thumbHeight = actors->at(0).actorThumb.height; + + int picsPerLine = width / (thumbWidth + 2 * border); + if (picsPerLine < 1) + return; + + int picLines = numActors / picsPerLine; + if (numActors%picsPerLine != 0) + picLines++; + + int totalHeight = picLines * (thumbHeight + 2*fontSmall->Height() + border + border/2) + 2*border + fontHeaderLarge->Height(); + + CreateContent(totalHeight); + cString header = cString::sprintf("%s:", tr("Cast")); + pixmapContent->DrawText(cPoint(border, border), *header, theme.Color(clrFont), clrTransparent, fontHeaderLarge); + + int x = 0; + int y = 2 * border + fontHeaderLarge->Height(); + if (!Running()) + return; + cImageLoader imgLoader; + int actor = 0; + for (int row = 0; row < picLines; row++) { + for (int col = 0; col < picsPerLine; col++) { + if (!Running()) + return; + if (actor == numActors) + break; + std::string path = actors->at(actor).actorThumb.path; + std::string name = actors->at(actor).name; + std::stringstream sstrRole; + sstrRole << "\"" << actors->at(actor).role << "\""; + std::string role = sstrRole.str(); + if (imgLoader.LoadPoster(path.c_str(), thumbWidth, thumbHeight)) { + if (Running() && pixmapContent) + pixmapContent->DrawImage(cPoint(x + border, y), imgLoader.GetImage()); + } + + if (fontSmall->Width(name.c_str()) > thumbWidth + 2*border) + name = CutText(name, thumbWidth + 2*border, fontSmall); + if (fontSmall->Width(role.c_str()) > thumbWidth + 2*border) + role = CutText(role, thumbWidth + 2*border, fontSmall); + int xName = x + ((thumbWidth+2*border) - fontSmall->Width(name.c_str()))/2; + int xRole = x + ((thumbWidth+2*border) - fontSmall->Width(role.c_str()))/2; + if (Running() && pixmapContent) { + pixmapContent->DrawText(cPoint(xName, y + thumbHeight + border/2), name.c_str(), theme.Color(clrFont), clrTransparent, fontSmall); + pixmapContent->DrawText(cPoint(xRole, y + thumbHeight + border/2 + fontSmall->Height()), role.c_str(), theme.Color(clrFont), clrTransparent, fontSmall); + x += thumbWidth + 2*border; + } + actor++; + } + osdManager.flush(); + x = 0; + y += thumbHeight + 2 * fontSmall->Height() + border + border/2; + } +} + +void cView::ClearScrollbar(void) { + if (pixmapScrollbar) + pixmapScrollbar->Fill(clrTransparent); + if (pixmapScrollbarBack) + pixmapScrollbarBack->Fill(clrTransparent); +} + +void cView::ClearScrollbarImage(void) { + if (imgScrollBar) { + delete imgScrollBar; + imgScrollBar = NULL; + } +} + +void cView::DrawScrollbar(void) { + ClearScrollbar(); + if (!scrollable || !pixmapContent) + return; + + if (!pixmapScrollbar) { + pixmapScrollbar = osdManager.requestPixmap(6, cRect(width, y + headerHeight, scrollbarWidth, contentHeight)); + pixmapScrollbar->Fill(clrTransparent); + } + if (!pixmapScrollbarBack) { + pixmapScrollbarBack = osdManager.requestPixmap(5, cRect(width, y + headerHeight, scrollbarWidth, contentHeight)); + pixmapScrollbarBack->Fill(clrTransparent); + } + + int totalBarHeight = pixmapScrollbar->ViewPort().Height() - 6; + + int aktHeight = (-1)*pixmapContent->DrawPort().Point().Y(); + int totalHeight = pixmapContent->DrawPort().Height(); + int screenHeight = pixmapContent->ViewPort().Height(); + + int barHeight = (double)(screenHeight * totalBarHeight) / (double)totalHeight ; + int barTop = (double)(aktHeight * totalBarHeight) / (double)totalHeight ; + + if (!imgScrollBar) { + imgScrollBar = CreateScrollbarImage(pixmapScrollbar->ViewPort().Width()-10, barHeight, theme.Color(clrHighlight), theme.Color(clrHighlightBlending)); + } + + pixmapScrollbarBack->Fill(theme.Color(clrHighlightBlending)); + pixmapScrollbarBack->DrawRectangle(cRect(2, 2, pixmapScrollbar->ViewPort().Width() - 4, pixmapScrollbar->ViewPort().Height() - 4), theme.Color(clrHighlightBlending)); + + pixmapScrollbar->DrawImage(cPoint(3, 3 + barTop), *imgScrollBar); +} + +cImage *cView::CreateScrollbarImage(int width, int height, tColor clrBgr, tColor clrBlend) { + cImage *image = new cImage(cSize(width, height)); + image->Fill(clrBgr); + if (tvguideConfig.style != eStyleFlat) { + int numSteps = 64; + int alphaStep = 0x03; + if (height < 30) + return image; + else if (height < 100) { + numSteps = 32; + alphaStep = 0x06; + } + int stepY = 0.5*height / numSteps; + if (stepY == 0) + stepY = 1; + int alpha = 0x40; + tColor clr; + for (int i = 0; iSetPixel(cPoint(x,y), clr); + } + } + alpha += alphaStep; + } + } + return image; +} + +bool cView::KeyUp(void) { + if (!scrollable) + return false; + int aktHeight = pixmapContent->DrawPort().Point().Y(); +// int lineHeight = font->Height(); + if (aktHeight >= 0) { + return false; + } + int step = tvguideConfig.detailedViewScrollStep * font->Height(); + int newY = aktHeight + step; + if (newY > 0) + newY = 0; + pixmapContent->SetDrawPortPoint(cPoint(0, newY)); + return true; +} + +bool cView::KeyDown(void) { + if (!scrollable) + return false; + int aktHeight = pixmapContent->DrawPort().Point().Y(); + int totalHeight = pixmapContent->DrawPort().Height(); + int screenHeight = pixmapContent->ViewPort().Height(); + + if (totalHeight - ((-1)*aktHeight) == screenHeight) { + return false; + } + int step = tvguideConfig.detailedViewScrollStep * font->Height(); + int newY = aktHeight - step; + if ((-1)*newY > totalHeight - screenHeight) + newY = (-1)*(totalHeight - screenHeight); + pixmapContent->SetDrawPortPoint(cPoint(0, newY)); + return true; +} + +/******************************************************************************************** +* cEPGView : cView +********************************************************************************************/ + +cEPGView::cEPGView(void) : cView() { + tabbed = true; + numEPGPics = -1; + numTabs = 0; +} + +cEPGView::~cEPGView(void) { + Cancel(-1); + while (Active()) + cCondWait::SleepMs(10); +} + +void cEPGView::SetTabs(void) { + tabs.push_back(tr("EPG Info")); + if (eventID > 0) + tabs.push_back(tr("Reruns")); + else + tabs.push_back(tr("Recording Information")); + if (numEPGPics > 0) + tabs.push_back(tr("Image Galery")); + numTabs = tabs.size(); +} + +void cEPGView::CheckEPGImages(void) { + if (eventID > 0) { + for (int i=1; i <= tvguideConfig.numAdditionalEPGPictures; i++) { + cString epgimage; + epgimage = cString::sprintf("%s%d_%d.jpg", *tvguideConfig.epgImagePath, eventID, i); + FILE *fp = fopen(*epgimage, "r"); + if (fp) { + std::stringstream ss; + ss << i; + epgPics.push_back(ss.str()); + fclose(fp); + } else { + break; + } + } + } else { + return; + } + numEPGPics = epgPics.size(); +} + +void cEPGView::DrawImages(void) { + int imgWidth = tvguideConfig.epgImageWidthLarge; + int imgHeight = tvguideConfig.epgImageHeightLarge; + + int totalHeight = numEPGPics * (imgHeight + border); + + CreateContent(totalHeight); + + cImageLoader imgLoader; + int yPic = border; + for (int pic = 0; pic < numEPGPics; pic++) { + bool drawPic = false; + if (eventID > 0) { + cString epgimage = cString::sprintf("%d_%d", eventID, atoi(epgPics[pic].c_str())); + if (imgLoader.LoadAdditionalEPGImage(epgimage)) { + drawPic = true; + } + + } + if (drawPic) { + pixmapContent->DrawImage(cPoint((width - imgWidth) / 2, yPic), imgLoader.GetImage()); + yPic += imgHeight + border; + osdManager.flush(); + } + } +} + +void cEPGView::KeyLeft(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView--; + if (activeView < 0) + activeView = numTabs - 1; +} + +void cEPGView::KeyRight(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView = (activeView + 1) % numTabs; +} + +void cEPGView::Action(void) { + ClearContent(); + if (!headerDrawn) { + DrawHeader(); + osdManager.flush(); + headerDrawn = true; + } + if (tabs.size() == 0) { + CheckEPGImages(); + SetTabs(); + } + DrawTabs(); + switch (activeView) { + case evtInfo: + DrawContent(&infoText); + break; + case evtAddInfo: + DrawContent(&addInfoText); + break; + case evtImages: + DrawImages(); + break; + } + DrawScrollbar(); + osdManager.flush(); +} + +/******************************************************************************************** +* cSeriesView : cView +********************************************************************************************/ + +cSeriesView::cSeriesView(int seriesId, int episodeId) : cView() { + this->seriesId = seriesId; + this->episodeId = episodeId; + tvdbInfo = ""; + tabbed = true; +} + +cSeriesView::~cSeriesView(void) { + Cancel(-1); + while (Active()) + cCondWait::SleepMs(10); +} + +void cSeriesView::LoadMedia(void) { + static cPlugin *pScraper = GetScraperPlugin(); + if (!pScraper || seriesId < 1) + return; + series.seriesId = seriesId; + series.episodeId = episodeId; + pScraper->Service("GetSeries", &series); +} + +void cSeriesView::SetTabs(void) { + tabs.push_back(tr("EPG Info")); + if (eventID > 0) + tabs.push_back(tr("Reruns")); + else + tabs.push_back(tr("Recording Information")); + tabs.push_back(tr("Cast")); + tabs.push_back(tr("TheTVDB Info")); + tabs.push_back(tr("Image Galery")); +} + +void cSeriesView::CreateTVDBInfo(void) { + if (tvdbInfo.size() > 0) + return; + std::stringstream info; + info << tr("TheTVDB Information") << ":\n\n"; + + if (series.episode.name.size() > 0) { + info << tr("Episode") << ": " << series.episode.name << " (" << tr("Season") << " " << series.episode.season << ", " << tr("Episode") << " " << series.episode.number << ")\n\n"; + } + if (series.episode.overview.size() > 0) { + info << tr("Episode Overview") << ": " << series.episode.overview << "\n\n"; + } + if (series.episode.firstAired.size() > 0) { + info << tr("First aired") << ": " << series.episode.firstAired << "\n\n"; + } + if (series.episode.guestStars.size() > 0) { + info << tr("Guest Stars") << ": " << series.episode.guestStars << "\n\n"; + } + if (series.episode.rating > 0) { + info << tr("TheMovieDB Rating") << ": " << series.episode.rating << "\n\n"; + } + if (series.overview.size() > 0) { + info << tr("Series Overview") << ": " << series.overview << "\n\n"; + } + if (series.firstAired.size() > 0) { + info << tr("First aired") << ": " << series.firstAired << "\n\n"; + } + if (series.genre.size() > 0) { + info << tr("Genre") << ": " << series.genre << "\n\n"; + } + if (series.network.size() > 0) { + info << tr("Network") << ": " << series.network << "\n\n"; + } + if (series.rating > 0) { + info << tr("TheMovieDB Rating") << ": " << series.rating << "\n\n"; + } + if (series.status.size() > 0) { + info << tr("Status") << ": " << series.status << "\n\n"; + } + tvdbInfo = info.str(); +} + +void cSeriesView::DrawImages(void) { + int numPosters = series.posters.size(); + int numFanarts = series.fanarts.size(); + int numBanners = series.banners.size(); + + int totalHeight = border; + //Fanart Height + int fanartWidth = width - 2 * border; + int fanartHeight = 0; + if (numFanarts > 0 && series.fanarts[0].width > 0) { + fanartHeight = series.fanarts[0].height * ((double)fanartWidth / (double)series.fanarts[0].width); + if (fanartHeight > contentHeight - 2 * border) { + int fanartHeightOrig = fanartHeight; + fanartHeight = contentHeight - 2 * border; + fanartWidth = fanartWidth * ((double)fanartHeight / (double)fanartHeightOrig); + } + totalHeight += series.fanarts.size() * (fanartHeight + border); + } + //Poster Height + int posterWidth = (width - 4 * border) / 2; + int posterHeight = 0; + if (numPosters > 0 && series.posters[0].width > 0) { + posterHeight = series.posters[0].height * ((double)posterWidth / (double)series.posters[0].width); + } + if (numPosters > 0) + totalHeight += posterHeight + border; + if (numPosters == 3) + totalHeight += posterHeight + border; + //Banners Height + if (numBanners > 0) + totalHeight += (series.banners[0].height + border) * numBanners; + + CreateContent(totalHeight); + + cImageLoader imgLoader; + int yPic = border; + for (int i=0; i < numFanarts; i++) { + if (numBanners > i) { + if (imgLoader.LoadPoster(series.banners[i].path.c_str(), series.banners[i].width, series.banners[i].height) && Running()) { + pixmapContent->DrawImage(cPoint((width - series.banners[i].width) / 2, yPic), imgLoader.GetImage()); + yPic += series.banners[i].height + border; + osdManager.flush(); + } + } + if (imgLoader.LoadPoster(series.fanarts[i].path.c_str(), fanartWidth, fanartHeight) && Running()) { + pixmapContent->DrawImage(cPoint((width - fanartWidth)/2, yPic), imgLoader.GetImage()); + yPic += fanartHeight + border; + osdManager.flush(); + } + } + if (numPosters >= 1) { + if (imgLoader.LoadPoster(series.posters[0].path.c_str(), posterWidth, posterHeight) && Running()) { + pixmapContent->DrawImage(cPoint(border, yPic), imgLoader.GetImage()); + osdManager.flush(); + yPic += posterHeight + border; + } + } + if (numPosters >= 2) { + if (imgLoader.LoadPoster(series.posters[1].path.c_str(), posterWidth, posterHeight) && Running()) { + pixmapContent->DrawImage(cPoint(2 * border + posterWidth, yPic - posterHeight - border), imgLoader.GetImage()); + osdManager.flush(); + } + } + if (numPosters == 3) { + if (imgLoader.LoadPoster(series.posters[2].path.c_str(), posterWidth, posterHeight) && Running()) { + pixmapContent->DrawImage(cPoint((width - posterWidth) / 2, yPic), imgLoader.GetImage()); + osdManager.flush(); + } + } +} + +int cSeriesView::GetRandomPoster(void) { + int numPosters = series.posters.size(); + if (numPosters == 0) + return -1; + srand((unsigned)time(NULL)); + int randPoster = rand()%numPosters; + return randPoster; +} + +void cSeriesView::KeyLeft(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView--; + if (activeView < 0) + activeView = mvtCount - 1; +} + +void cSeriesView::KeyRight(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView = (activeView + 1) % mvtCount; +} + +void cSeriesView::Action(void) { + ClearContent(); + if (!headerDrawn) { + DrawHeader(); + osdManager.flush(); + headerDrawn = true; + } + if (tabs.size() == 0) { + SetTabs(); + } + DrawTabs(); + int randomPoster = GetRandomPoster(); + switch (activeView) { + case mvtInfo: + if (randomPoster >= 0) { + DrawFloatingContent(&infoText, &series.posters[randomPoster]); + } else + DrawContent(&infoText); + break; + case mvtAddInfo: + if (randomPoster >= 0) + DrawFloatingContent(&addInfoText, &series.posters[randomPoster]); + else + DrawContent(&addInfoText); + break; + case mvtCast: + DrawActors(&series.actors); + break; + case mvtOnlineInfo: + CreateTVDBInfo(); + if ((series.seasonPoster.path.size() > 0) && series.episode.episodeImage.path.size() > 0) + DrawFloatingContent(&tvdbInfo, &series.episode.episodeImage, &series.seasonPoster); + else if (series.seasonPoster.path.size() > 0) + DrawFloatingContent(&tvdbInfo, &series.seasonPoster); + else if (series.episode.episodeImage.path.size() > 0) + DrawFloatingContent(&tvdbInfo, &series.episode.episodeImage); + else if (randomPoster >= 0) + DrawFloatingContent(&tvdbInfo, &series.posters[randomPoster]); + else + DrawContent(&tvdbInfo); + break; + case mvtImages: + DrawImages(); + break; + } + DrawScrollbar(); + osdManager.flush(); +} + +/******************************************************************************************** +* cMovieView : cView +********************************************************************************************/ + +cMovieView::cMovieView(int movieId) : cView() { + this->movieId = movieId; + tabbed = true; +} + +cMovieView::~cMovieView(void) { + Cancel(-1); + while (Active()) + cCondWait::SleepMs(10); +} + +void cMovieView::LoadMedia(void) { + static cPlugin *pScraper = GetScraperPlugin(); + if (!pScraper || movieId < 1) + return; + movie.movieId = movieId; + pScraper->Service("GetMovie", &movie); +} + +void cMovieView::SetTabs(void) { + tabs.push_back(tr("EPG Info")); + if (eventID > 0) + tabs.push_back(tr("Reruns")); + else + tabs.push_back(tr("Recording Information")); + tabs.push_back(tr("Cast")); + tabs.push_back(tr("TheTVDB Info")); + tabs.push_back(tr("Image Galery")); +} + +void cMovieView::CreateMovieDBInfo(void) { + if (movieDBInfo.size() > 0) + return; + std::stringstream info; + info << tr("TheMovieDB Information") << ":\n\n"; + if (movie.originalTitle.size() > 0) { + info << tr("Original Title") << ": " << movie.originalTitle << "\n\n"; + } + if (movie.tagline.size() > 0) { + info << tr("Tagline") << ": " << movie.tagline << "\n\n"; + } + if (movie.overview.size() > 0) { + info << tr("Overview") << ": " << movie.overview << "\n\n"; + } + std::string strAdult = (movie.adult)?(tr("yes")):(tr("no")); + info << tr("Adult") << ": " << strAdult << "\n\n"; + if (movie.collectionName.size() > 0) { + info << tr("Collection") << ": " << movie.collectionName << "\n\n"; + } + if (movie.budget > 0) { + info << tr("Budget") << ": " << movie.budget << "$\n\n"; + } + if (movie.revenue > 0) { + info << tr("Revenue") << ": " << movie.revenue << "$\n\n"; + } + if (movie.genres.size() > 0) { + info << tr("Genre") << ": " << movie.genres << "\n\n"; + } + if (movie.homepage.size() > 0) { + info << tr("Homepage") << ": " << movie.homepage << "\n\n"; + } + if (movie.releaseDate.size() > 0) { + info << tr("Release Date") << ": " << movie.releaseDate << "\n\n"; + } + if (movie.runtime > 0) { + info << tr("Runtime") << ": " << movie.runtime << " " << tr("minutes") << "\n\n"; + } + if (movie.popularity > 0) { + info << tr("TheMovieDB Popularity") << ": " << movie.popularity << "\n\n"; + } + if (movie.voteAverage > 0) { + info << tr("TheMovieDB Vote Average") << ": " << movie.voteAverage << "\n\n"; + } + movieDBInfo = info.str(); +} + +void cMovieView::DrawImages(void) { + int totalHeight = border; + //Fanart Height + int fanartWidth = width - 2 * border; + int fanartHeight = 0; + if (movie.fanart.width > 0 && movie.fanart.height > 0 && movie.fanart.path.size() > 0) { + fanartHeight = movie.fanart.height * ((double)fanartWidth / (double)movie.fanart.width); + if (fanartHeight > contentHeight - 2 * border) { + int fanartHeightOrig = fanartHeight; + fanartHeight = contentHeight - 2 * border; + fanartWidth = fanartWidth * ((double)fanartHeight / (double)fanartHeightOrig); + } + totalHeight += fanartHeight + border; + } + //Collection Fanart Height + int collectionFanartWidth = width - 2 * border; + int collectionFanartHeight = 0; + if (movie.collectionFanart.width > 0 && movie.collectionFanart.height > 0 && movie.collectionFanart.path.size() > 0) { + collectionFanartHeight = movie.collectionFanart.height * ((double)collectionFanartWidth / (double)movie.collectionFanart.width); + if (collectionFanartHeight > contentHeight - 2 * border) { + int fanartHeightOrig = collectionFanartHeight; + collectionFanartHeight = contentHeight - 2 * border; + collectionFanartWidth = collectionFanartWidth * ((double)collectionFanartHeight / (double)fanartHeightOrig); + } + totalHeight += collectionFanartHeight + border; + } + //Poster Height + if (movie.poster.width > 0 && movie.poster.height > 0 && movie.poster.path.size() > 0) { + totalHeight += movie.poster.height + border; + } + //Collection Popster Height + if (movie.collectionPoster.width > 0 && movie.collectionPoster.height > 0 && movie.collectionPoster.path.size() > 0) { + totalHeight += movie.collectionPoster.height + border; + } + + CreateContent(totalHeight); + + cImageLoader imgLoader; + int yPic = border; + if (movie.fanart.width > 0 && movie.fanart.height > 0 && movie.fanart.path.size() > 0) { + if (imgLoader.LoadPoster(movie.fanart.path.c_str(), fanartWidth, fanartHeight) && Running()) { + pixmapContent->DrawImage(cPoint((width - fanartWidth)/2, yPic), imgLoader.GetImage()); + yPic += fanartHeight + border; + osdManager.flush(); + } + } + if (movie.collectionFanart.width > 0 && movie.collectionFanart.height > 0 && movie.collectionFanart.path.size() > 0) { + if (imgLoader.LoadPoster(movie.collectionFanart.path.c_str(), collectionFanartWidth, collectionFanartHeight) && Running()) { + pixmapContent->DrawImage(cPoint((width - collectionFanartWidth)/2, yPic), imgLoader.GetImage()); + yPic += collectionFanartHeight + border; + osdManager.flush(); + } + } + if (movie.poster.width > 0 && movie.poster.height > 0 && movie.poster.path.size() > 0) { + if (imgLoader.LoadPoster(movie.poster.path.c_str(), movie.poster.width, movie.poster.height) && Running()) { + pixmapContent->DrawImage(cPoint((width - movie.poster.width) / 2, yPic), imgLoader.GetImage()); + yPic += movie.poster.height + border; + osdManager.flush(); + } + } + if (movie.collectionPoster.width > 0 && movie.collectionPoster.height > 0 && movie.collectionPoster.path.size() > 0) { + if (imgLoader.LoadPoster(movie.collectionPoster.path.c_str(), movie.collectionPoster.width, movie.collectionPoster.height) && Running()) { + pixmapContent->DrawImage(cPoint((width - movie.collectionPoster.width) / 2, yPic), imgLoader.GetImage()); + yPic += movie.collectionPoster.height + border; + osdManager.flush(); + } + } +} + +void cMovieView::KeyLeft(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView--; + if (activeView < 0) + activeView = mvtCount - 1; +} + +void cMovieView::KeyRight(void) { + if (Running()) + return; + ClearScrollbarImage(); + activeView = (activeView + 1) % mvtCount; +} + +void cMovieView::Action(void) { + ClearContent(); + if (!headerDrawn) { + DrawHeader(); + osdManager.flush(); + headerDrawn = true; + } + if (tabs.size() == 0) { + SetTabs(); + } + DrawTabs(); + bool posterAvailable = (movie.poster.path.size() > 0 && movie.poster.width > 0 && movie.poster.height > 0) ? true : false; + switch (activeView) { + case mvtInfo: + if (posterAvailable) + DrawFloatingContent(&infoText, &movie.poster); + else + DrawContent(&infoText); + break; + case mvtAddInfo: + if (posterAvailable) + DrawFloatingContent(&addInfoText, &movie.poster); + else + DrawContent(&addInfoText); + break; + case mvtCast: + DrawActors(&movie.actors); + break; + case mvtOnlineInfo: + CreateMovieDBInfo(); + if (posterAvailable) + DrawFloatingContent(&movieDBInfo, &movie.poster); + else + DrawContent(&movieDBInfo); + break; + case mvtImages: + DrawImages(); + break; + } + DrawScrollbar(); + osdManager.flush(); +} diff --git a/view.h b/view.h index 17292bd..e3f2fe7 100644 --- a/view.h +++ b/view.h @@ -1,149 +1,149 @@ -#ifndef __TVGUIDE_VIEW_H -#define __TVGUIDE_VIEW_H - -#include -#include -#include -#include -#include "services/scraper2vdr.h" -#include "services/epgsearch.h" -#include "services/remotetimers.h" -#include "config.h" -#include "imagecache.h" -#include "imageloader.h" -#include "tools.h" - -enum eEPGViewTabs { - evtInfo = 0, - evtAddInfo, - evtImages, - evtCount -}; - -enum eMediaViewTabs { - mvtInfo = 0, - mvtAddInfo, - mvtCast, - mvtOnlineInfo, - mvtImages, - mvtCount -}; - -class cView : public cThread { -protected: - const cEvent *event; - cPixmap *pixmapBackground; - cStyledPixmap *pixmapHeader; - cPixmap *pixmapHeaderLogo; - cPixmap *pixmapContent; - cPixmap *pixmapScrollbar; - cPixmap *pixmapScrollbarBack; - cPixmap *pixmapTabs; - cFont *font, *fontSmall, *fontHeader, *fontHeaderLarge; - cImage *imgScrollBar; - int activeView; - bool scrollable; - bool tabbed; - int x, y; - int width, height; - int border; - int headerWidth, headerHeight; - int contentHeight; - int tabHeight; - int scrollbarWidth; - std::vector tabs; - std::string title; - std::string subTitle; - std::string dateTime; - std::string infoText; - std::string addInfoText; - const cChannel *channel; - int eventID; - bool headerDrawn; - void DrawHeader(void); - void ClearContent(void); - void CreateContent(int fullHeight); - void DrawContent(std::string *text); - void DrawFloatingContent(std::string *infoText, cTvMedia *img, cTvMedia *img2 = NULL); - void CreateFloatingTextWrapper(cTextWrapper *twNarrow, cTextWrapper *twFull, std::string *text, int widthImg, int heightImg); - void DrawActors(std::vector *actors); - void ClearScrollbar(void); - void ClearScrollbarImage(void); - cImage *CreateScrollbarImage(int width, int height, tColor clrBgr, tColor clrBlend); - virtual void SetTabs(void) {}; - void DrawTabs(void); -public: - cView(void); - virtual ~cView(void); - void SetTitle(const char *t) { title = t ? t : ""; }; - void SetSubTitle(const char *s) { subTitle = s ? s : ""; }; - void SetDateTime(const char *dt) { dateTime = dt; }; - void SetInfoText(const char *i) { infoText = i ? i : ""; }; - void SetAdditionalInfoText(std::string addInfo) { addInfoText = addInfo; }; - void SetChannel(const cChannel *c) { channel = c; }; - void SetEventID(int id) { eventID = id; }; - void SetEvent(const cEvent *event) { this->event = event; }; - virtual void LoadMedia(void) {}; - void SetGeometry(void); - void SetFonts(void); - virtual bool KeyUp(void); - virtual bool KeyDown(void); - virtual void KeyLeft(void) {}; - virtual void KeyRight(void) {}; - void DrawScrollbar(void); - virtual void Action(void) {}; -}; - -class cEPGView : public cView { -protected: - std::vector epgPics; - int numEPGPics; - int numTabs; - void SetTabs(void); - void CheckEPGImages(void); - void DrawImages(void); -public: - cEPGView(void); - virtual ~cEPGView(void); - void KeyLeft(void); - void KeyRight(void); - void Action(void); -}; - -class cSeriesView : public cView { -protected: - int seriesId; - int episodeId; - cSeries series; - std::string tvdbInfo; - void SetTabs(void); - void CreateTVDBInfo(void); - void DrawImages(void); - int GetRandomPoster(void); -public: - cSeriesView(int seriesId, int episodeId); - virtual ~cSeriesView(void); - void LoadMedia(void); - void KeyLeft(void); - void KeyRight(void); - void Action(void); -}; - -class cMovieView : public cView { -protected: - int movieId; - cMovie movie; - std::string movieDBInfo; - void SetTabs(void); - void CreateMovieDBInfo(void); - void DrawImages(void); -public: - cMovieView(int movieId); - virtual ~cMovieView(void); - void LoadMedia(void); - void KeyLeft(void); - void KeyRight(void); - void Action(void); -}; - -#endif //__TVGUIDE_VIEW_H +#ifndef __TVGUIDE_VIEW_H +#define __TVGUIDE_VIEW_H + +#include +#include +#include +#include +#include "services/scraper2vdr.h" +#include "services/epgsearch.h" +#include "services/remotetimers.h" +#include "config.h" +#include "imagecache.h" +#include "imageloader.h" +#include "tools.h" + +enum eEPGViewTabs { + evtInfo = 0, + evtAddInfo, + evtImages, + evtCount +}; + +enum eMediaViewTabs { + mvtInfo = 0, + mvtAddInfo, + mvtCast, + mvtOnlineInfo, + mvtImages, + mvtCount +}; + +class cView : public cThread { +protected: + const cEvent *event; + cPixmap *pixmapBackground; + cStyledPixmap *pixmapHeader; + cPixmap *pixmapHeaderLogo; + cPixmap *pixmapContent; + cPixmap *pixmapScrollbar; + cPixmap *pixmapScrollbarBack; + cPixmap *pixmapTabs; + cFont *font, *fontSmall, *fontHeader, *fontHeaderLarge; + cImage *imgScrollBar; + int activeView; + bool scrollable; + bool tabbed; + int x, y; + int width, height; + int border; + int headerWidth, headerHeight; + int contentHeight; + int tabHeight; + int scrollbarWidth; + std::vector tabs; + std::string title; + std::string subTitle; + std::string dateTime; + std::string infoText; + std::string addInfoText; + const cChannel *channel; + int eventID; + bool headerDrawn; + void DrawHeader(void); + void ClearContent(void); + void CreateContent(int fullHeight); + void DrawContent(std::string *text); + void DrawFloatingContent(std::string *infoText, cTvMedia *img, cTvMedia *img2 = NULL); + void CreateFloatingTextWrapper(cTextWrapper *twNarrow, cTextWrapper *twFull, std::string *text, int widthImg, int heightImg); + void DrawActors(std::vector *actors); + void ClearScrollbar(void); + void ClearScrollbarImage(void); + cImage *CreateScrollbarImage(int width, int height, tColor clrBgr, tColor clrBlend); + virtual void SetTabs(void) {}; + void DrawTabs(void); +public: + cView(void); + virtual ~cView(void); + void SetTitle(const char *t) { title = t ? t : ""; }; + void SetSubTitle(const char *s) { subTitle = s ? s : ""; }; + void SetDateTime(const char *dt) { dateTime = dt; }; + void SetInfoText(const char *i) { infoText = i ? i : ""; }; + void SetAdditionalInfoText(std::string addInfo) { addInfoText = addInfo; }; + void SetChannel(const cChannel *c) { channel = c; }; + void SetEventID(int id) { eventID = id; }; + void SetEvent(const cEvent *event) { this->event = event; }; + virtual void LoadMedia(void) {}; + void SetGeometry(void); + void SetFonts(void); + virtual bool KeyUp(void); + virtual bool KeyDown(void); + virtual void KeyLeft(void) {}; + virtual void KeyRight(void) {}; + void DrawScrollbar(void); + virtual void Action(void) {}; +}; + +class cEPGView : public cView { +protected: + std::vector epgPics; + int numEPGPics; + int numTabs; + void SetTabs(void); + void CheckEPGImages(void); + void DrawImages(void); +public: + cEPGView(void); + virtual ~cEPGView(void); + void KeyLeft(void); + void KeyRight(void); + void Action(void); +}; + +class cSeriesView : public cView { +protected: + int seriesId; + int episodeId; + cSeries series; + std::string tvdbInfo; + void SetTabs(void); + void CreateTVDBInfo(void); + void DrawImages(void); + int GetRandomPoster(void); +public: + cSeriesView(int seriesId, int episodeId); + virtual ~cSeriesView(void); + void LoadMedia(void); + void KeyLeft(void); + void KeyRight(void); + void Action(void); +}; + +class cMovieView : public cView { +protected: + int movieId; + cMovie movie; + std::string movieDBInfo; + void SetTabs(void); + void CreateMovieDBInfo(void); + void DrawImages(void); +public: + cMovieView(int movieId); + virtual ~cMovieView(void); + void LoadMedia(void); + void KeyLeft(void); + void KeyRight(void); + void Action(void); +}; + +#endif //__TVGUIDE_VIEW_H