2019-07-11 11:07:13 +02:00
|
|
|
#include "services/remotetimers.h"
|
2019-07-11 12:06:18 +02:00
|
|
|
#include "channelepg.h"
|
2019-07-11 11:07:13 +02:00
|
|
|
#include "tools.h"
|
|
|
|
#include "epggrid.h"
|
|
|
|
|
2019-07-11 15:06:07 +02:00
|
|
|
cEpgGrid::cEpgGrid(cChannelEpg *c, const cEvent *event) : cGridElement(c) {
|
2019-07-11 11:07:13 +02:00
|
|
|
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() ) {
|
2021-01-11 11:32:34 +01:00
|
|
|
viewportHeight = (std::min((int)EndTime(), column->Stop()) - column->Start()) / 60;
|
2019-07-11 11:07:13 +02:00
|
|
|
} else if ( column->Stop() < EndTime() ) {
|
2021-01-11 11:32:34 +01:00
|
|
|
viewportHeight = (column->Stop() - StartTime()) / 60;
|
2019-07-11 11:07:13 +02:00
|
|
|
if (viewportHeight < 0) viewportHeight = 0;
|
|
|
|
} else {
|
|
|
|
viewportHeight = Duration() / 60;
|
|
|
|
}
|
|
|
|
viewportHeight *= geoManager.minutePixel;
|
|
|
|
if (viewportHeight != viewportHeightOld)
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::PositionPixmap() {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int x0 = column->getX();
|
|
|
|
int y0 = geoManager.statusHeaderHeight + geoManager.channelHeaderHeight + geoManager.channelGroupsHeight;
|
|
|
|
if ( column->Start() < StartTime() ) {
|
2021-01-11 11:32:34 +01:00
|
|
|
y0 += (StartTime() - column->Start()) / 60 * geoManager.minutePixel;
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
if (!pixmap) {
|
2019-11-10 15:37:28 +01:00
|
|
|
pixmap = osdManager.CreatePixmap(-1, cRect(x0, y0, geoManager.colWidth, viewportHeight),
|
2021-01-11 11:32:34 +01:00
|
|
|
cRect(0, 0, geoManager.colWidth, Duration() / 60 * geoManager.minutePixel));
|
2019-07-11 11:07:13 +02:00
|
|
|
} else {
|
|
|
|
pixmap->SetViewPort(cRect(x0, y0, geoManager.colWidth, viewportHeight));
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int x0 = geoManager.channelHeaderWidth + geoManager.channelGroupsWidth;
|
|
|
|
int y0 = column->getY();
|
|
|
|
if ( column->Start() < StartTime() ) {
|
2021-01-11 11:32:34 +01:00
|
|
|
x0 += (StartTime() - column->Start()) / 60 * geoManager.minutePixel;
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
if (!pixmap) {
|
2019-11-10 15:37:28 +01:00
|
|
|
pixmap = osdManager.CreatePixmap(-1, cRect(x0, y0, viewportHeight, geoManager.rowHeight),
|
2021-01-11 11:32:34 +01:00
|
|
|
cRect(0, 0, Duration() / 60 * geoManager.minutePixel, geoManager.rowHeight));
|
2019-07-11 11:07:13 +02:00
|
|
|
} else {
|
|
|
|
pixmap->SetViewPort(cRect(x0, y0, viewportHeight, geoManager.rowHeight ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::SetTimer() {
|
|
|
|
hasTimer = false;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.useRemoteTimers && pRemoteTimers) {
|
2019-07-11 11:07:13 +02:00
|
|
|
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() {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-10-17 13:46:03 +02:00
|
|
|
text->Set(event->Title(), fontManager.FontGrid, geoManager.colWidth - 2 * borderWidth);
|
|
|
|
extText->Set(event->ShortText(), fontManager.FontGridSmall, geoManager.colWidth - 2 * borderWidth);
|
|
|
|
}
|
|
|
|
if (config.showTimeInGrid) {
|
|
|
|
timeString = cString::sprintf("%s - %s:", *(event->GetTimeString()), *(event->GetEndTimeString()));
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::drawText() {
|
2019-10-17 13:46:03 +02:00
|
|
|
tColor colorText = (active) ? theme.Color(clrFontActive) : theme.Color(clrFont);
|
2019-07-11 11:07:13 +02:00
|
|
|
tColor colorTextBack;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.style == eStyleFlat)
|
2019-07-11 11:07:13 +02:00
|
|
|
colorTextBack = color;
|
2019-07-11 11:28:11 +02:00
|
|
|
else if (config.style == eStyleGraphical)
|
2019-10-17 13:46:03 +02:00
|
|
|
colorTextBack = (active) ? theme.Color(clrGridActiveFontBack) : theme.Color(clrGridFontBack);
|
2019-07-11 11:07:13 +02:00
|
|
|
else
|
|
|
|
colorTextBack = clrTransparent;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-10-17 13:46:03 +02:00
|
|
|
if (Height() / geoManager.minutePixel < 6)
|
2019-07-11 11:07:13 +02:00
|
|
|
return;
|
|
|
|
int textHeight = fontManager.FontGrid->Height();
|
2019-10-17 13:46:03 +02:00
|
|
|
int textHeightSmall = fontManager.FontGridSmall->Height();
|
2019-07-11 11:07:13 +02:00
|
|
|
int textLines = text->Lines();
|
2019-10-17 13:46:03 +02:00
|
|
|
int titleY = borderWidth;
|
|
|
|
if (config.showTimeInGrid) { // mit Zeitangabe im Grid
|
|
|
|
pixmap->DrawText(cPoint(borderWidth, borderWidth), *timeString, colorText, colorTextBack, fontManager.FontGridSmall);
|
|
|
|
titleY += textHeightSmall;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < textLines; i++) {
|
|
|
|
pixmap->DrawText(cPoint(borderWidth, titleY + i * textHeight), text->GetLine(i), colorText, colorTextBack, fontManager.FontGrid);
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
int extTextLines = extText->Lines();
|
2019-10-17 13:46:03 +02:00
|
|
|
int offset = titleY + (textLines + 0.5) * textHeight;
|
|
|
|
if ((Height() - textHeightSmall - 10) > offset) {
|
|
|
|
for (int i = 0; i < extTextLines; i++) {
|
|
|
|
pixmap->DrawText(cPoint(borderWidth, offset + i * textHeightSmall), extText->GetLine(i), colorText, colorTextBack, fontManager.FontGridSmall);
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2020-01-08 16:17:08 +01:00
|
|
|
cString strTitle = CutText(event->Title(), viewportHeight - borderWidth, fontManager.FontGridHorizontal).c_str();
|
2019-07-11 11:07:13 +02:00
|
|
|
int titleY = 0;
|
2019-10-17 13:46:03 +02:00
|
|
|
if (config.showTimeInGrid) { // mit Zeitangabe im Grid
|
2019-07-11 11:07:13 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth, borderWidth), *timeString, colorText, colorTextBack, fontManager.FontGridHorizontalSmall);
|
2019-10-17 13:46:03 +02:00
|
|
|
titleY = fontManager.FontGridHorizontalSmall->Height() + (geoManager.rowHeight - fontManager.FontGridHorizontalSmall->Height() - fontManager.FontGridHorizontal->Height()) / 2;
|
2019-07-11 11:07:13 +02:00
|
|
|
} else {
|
2019-10-17 13:46:03 +02:00
|
|
|
titleY = (geoManager.rowHeight - fontManager.FontGridHorizontal->Height()) / 2;
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
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) {
|
|
|
|
|
2020-01-09 13:20:02 +01:00
|
|
|
const cFont *font = (config.displayMode == eVertical) ? fontManager.FontGrid : fontManager.FontGridHorizontalSmall;
|
|
|
|
int textWidth = font->Width(*iconText) + 2 * borderWidth;
|
|
|
|
int textHeight = font->Height() + 10;
|
|
|
|
if ((config.displayMode == eHorizontal) && ((Width() - 2 * textWidth) < 0))
|
|
|
|
pixmap->DrawEllipse( cRect(Width() - textHeight / 2 - borderWidth, Height() - textHeight - borderWidth, textHeight / 2, textHeight / 2), color);
|
|
|
|
else if ((config.displayMode == eVertical) && ((Height() - 2 * textHeight) < 0))
|
|
|
|
pixmap->DrawEllipse( cRect(Width() - textHeight / 2 - borderWidth, borderWidth, textHeight / 2, textHeight / 2), color);
|
|
|
|
else {
|
|
|
|
pixmap->DrawEllipse( cRect(Width() - textWidth - borderWidth, Height() - textHeight - borderWidth, textWidth, textHeight), color);
|
|
|
|
pixmap->DrawText(cPoint(Width() - textWidth, Height() - textHeight - borderWidth / 2), *iconText, theme.Color(clrFont), clrTransparent, font);
|
|
|
|
}
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|