diff --git a/recmenu.c b/recmenu.c index 3f2916f..fead471 100644 --- a/recmenu.c +++ b/recmenu.c @@ -94,6 +94,18 @@ void cRecMenu::CreatePixmap(void) { pixmapScrollBar = NULL; } +void cRecMenu::AddHeader(cRecMenuItem *header) { + this->header = header; + headerHeight = header->GetHeight(); + height += headerHeight; +} + +void cRecMenu::AddFooter(cRecMenuItem *footer) { + this->footer = footer; + footerHeight = footer->GetHeight(); + height += footerHeight; +} + void cRecMenu::SetHeader(cRecMenuItem *header) { this->header = header; headerHeight = header->GetHeight(); diff --git a/recmenu.h b/recmenu.h index eb819ee..ea29561 100644 --- a/recmenu.h +++ b/recmenu.h @@ -37,6 +37,8 @@ protected: int CalculateOptimalWidth(void); bool CalculateHeight(bool reDraw = false); void CreatePixmap(void); + void AddHeader(cRecMenuItem *header); + void AddFooter(cRecMenuItem *footer); void SetHeader(cRecMenuItem *header); void SetFooter(cRecMenuItem *footer); void ClearMenuItems(bool destructor = false); @@ -63,4 +65,4 @@ public: void UpdateActiveMenuItem(void); virtual eRecMenuState ProcessKey(eKeys Key); }; -#endif //__TVGUIDE_RECMENU_H \ No newline at end of file +#endif //__TVGUIDE_RECMENU_H diff --git a/recmenuitem.c b/recmenuitem.c index b52526e..4a79e1b 100644 --- a/recmenuitem.c +++ b/recmenuitem.c @@ -266,15 +266,41 @@ cRecMenuItemInfo::cRecMenuItemInfo(const char *text, bool largeFont) { selectable = false; active = false; this->text = text; + this->line1 = ""; + this->line2 = ""; + this->line3 = ""; + this->line4 = ""; + this->numLines = 1; fontInfo = (largeFont) ? fontLarge : font; border = 10; } +cRecMenuItemInfo::cRecMenuItemInfo(std::string line1, int numLines, std::string line2, std::string line3, std::string line4, int width, bool largeFont) { + selectable = false; + fontInfo = (largeFont) ? fontLarge : font; + border = 10; + this->numLines = numLines; + this->line2 = line2; + this->line3 = line3; + this->line4 = line4; + if (numLines == 1) { + this->line1 = line1; + } else if (numLines == 2) { + this->line1 = cString::sprintf("%s\n%s", line1.c_str(), line2.c_str()); + } else if (numLines == 3) { + this->line1 = cString::sprintf("%s\n%s\n%s", line1.c_str(), line2.c_str(), line3.c_str()); + } else if (numLines == 4) { + this->line1 = cString::sprintf("%s\n%s\n%s\n%s", line1.c_str(), line2.c_str(), line3.c_str(), line4.c_str()); + } + this->active = false; + CalculateHeight(width); +} + cRecMenuItemInfo::~cRecMenuItemInfo(void) { } void cRecMenuItemInfo::CalculateHeight(int textWidth) { - wrapper.Set(*text, fontInfo, textWidth); + wrapper.Set((line1 == "") ? *text : line1.c_str(), fontInfo, textWidth); height = fontInfo->Height() * wrapper.Lines() + 2 * border; } diff --git a/recmenuitem.h b/recmenuitem.h index a98e21d..4af307a 100644 --- a/recmenuitem.h +++ b/recmenuitem.h @@ -175,12 +175,18 @@ public: // --- cRecMenuItemInfo ------------------------------------------------------- class cRecMenuItemInfo : public cRecMenuItem { private: + int numLines; cString text; + std::string line1; + std::string line2; + std::string line3; + std::string line4; cTextWrapper wrapper; int border; const cFont *fontInfo; public: cRecMenuItemInfo(const char *text, bool largeFont = false); + cRecMenuItemInfo(std::string line1, int numLines = 1, std::string line2 = "", std::string line3 = "", std::string line4 = "", int width = 80, bool largeFont = false); virtual ~cRecMenuItemInfo(void); void setBackground(void); void CalculateHeight(int textWidth); diff --git a/recmenus.c b/recmenus.c index 987a20c..48a2ed8 100644 --- a/recmenus.c +++ b/recmenus.c @@ -104,40 +104,40 @@ std::string cRecMenuAskFolder::GetFolder(void) { } // --- cRecMenuConfirmTimer --------------------------------------------------------- -cRecMenuConfirmTimer::cRecMenuConfirmTimer(const cEvent *event, bool timerChanged) { +cRecMenuConfirmTimer::cRecMenuConfirmTimer(const cEvent *event, bool timerChanged) { // OK SetWidthPercent(50); -#if VDRVERSNUM >= 20301 - LOCK_CHANNELS_READ; - const cString channelName = Channels->GetByChannelID(event->ChannelID())->Name(); -#else - const cString channelName = Channels.GetByChannelID(event->ChannelID())->Name(); -#endif + bool eventHasTimer = false; if (config.useRemoteTimers && pRemoteTimers) { RemoteTimers_GetMatch_v1_0 rtMatch; rtMatch.event = event; pRemoteTimers->Service("RemoteTimers::GetMatch-v1.0", &rtMatch); if (rtMatch.timerMatch == tmFull) { - eventHasTimer = true; + eventHasTimer = true; } } else { eventHasTimer = event->HasTimer(); } - const cString message = (eventHasTimer) ? (timerChanged) ? tr("Timer changed") - : tr("Timer created") - : tr("Timer NOT created"); - cString text = cString::sprintf("%s\n%s\n%s %s - %s\n%s", - *message, - *channelName, - *event->GetDateString(), - *event->GetTimeString(), - *event->GetEndTimeString(), - event->Title() - ); - cRecMenuItemInfo *infoItem = new cRecMenuItemInfo(*text); - infoItem->CalculateHeight(width - 2 * border); - AddMenuItem(infoItem); - AddMenuItem(new cRecMenuItemButton(tr("OK"), rmsClose, true, true)); + + const cChannels *channels = NULL; +#if VDRVERSNUM >= 20301 + { + LOCK_CHANNELS_READ; + channels = Channels; + } +#else + channels = &Channels; +#endif + const cString channelName = channels->GetByChannelID(event->ChannelID())->Name(); + const cString line1 = (eventHasTimer) ? (timerChanged) ? tr("Timer changed") + : tr("Timer created") + : tr("Timer NOT created"); + const cString line3 = cString::sprintf("%s %s - %s", *event->GetDateString(), *event->GetTimeString(), *event->GetEndTimeString()); + const cString line4 = (event && event->Title()) ? cString::sprintf("\"%s\"", event->Title()) : ""; + + AddHeader(new cRecMenuItemInfo(*line1, 4, *channelName, *line3, *line4, width - 2 * border)); + AddFooter(new cRecMenuItemButton(tr("OK"), rmsClose, true, true)); + CalculateHeight(); CreatePixmap(); Arrange();