2013-01-17 13:16:44 +01:00
|
|
|
#include "channelcolumn.h"
|
|
|
|
#include "epggrid.h"
|
|
|
|
|
2013-05-20 11:37:37 +02:00
|
|
|
cEpgGrid::cEpgGrid(cChannelColumn *c, const cEvent *event) : cGrid(c) {
|
2013-05-26 11:38:05 +02:00
|
|
|
this->event = event;
|
|
|
|
extText = new cTextWrapper();
|
|
|
|
hasTimer = false;
|
|
|
|
if (column->HasTimer())
|
|
|
|
hasTimer = event->HasTimer();
|
2013-05-20 11:37:37 +02:00
|
|
|
dummy = false;
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cEpgGrid::~cEpgGrid(void) {
|
2013-05-26 11:38:05 +02:00
|
|
|
delete extText;
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::SetViewportHeight() {
|
2013-05-26 11:38:05 +02:00
|
|
|
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;
|
2013-05-20 11:37:37 +02:00
|
|
|
if (viewportHeight < 0) viewportHeight = 0;
|
2013-05-26 11:38:05 +02:00
|
|
|
} else {
|
|
|
|
viewportHeight = Duration() / 60;
|
|
|
|
}
|
2013-05-24 16:23:23 +02:00
|
|
|
viewportHeight *= tvguideConfig.minutePixel;
|
2013-05-26 11:38:05 +02:00
|
|
|
if (viewportHeight != viewportHeightOld)
|
|
|
|
dirty = true;
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::PositionPixmap() {
|
2013-05-24 16:23:23 +02:00
|
|
|
int x0, y0;
|
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
int x0 = column->getX();
|
2013-05-31 13:58:22 +02:00
|
|
|
int y0 = tvguideConfig.statusHeaderHeight + tvguideConfig.channelHeaderHeight + tvguideConfig.channelGroupsHeight;
|
2013-05-24 16:23:23 +02:00
|
|
|
if ( column->Start() < StartTime() ) {
|
|
|
|
y0 += (StartTime() - column->Start())/60*tvguideConfig.minutePixel;
|
|
|
|
}
|
|
|
|
if (!pixmap) {
|
|
|
|
pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, tvguideConfig.colWidth, viewportHeight),
|
|
|
|
cRect(0, 0, tvguideConfig.colWidth, Duration()/60*tvguideConfig.minutePixel));
|
|
|
|
} else {
|
|
|
|
pixmap->SetViewPort(cRect(x0, y0, tvguideConfig.colWidth, viewportHeight));
|
|
|
|
}
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
2013-05-31 13:58:22 +02:00
|
|
|
int x0 = tvguideConfig.channelHeaderWidth + tvguideConfig.channelGroupsWidth;
|
2013-05-24 16:23:23 +02:00
|
|
|
int y0 = column->getY();
|
|
|
|
if ( column->Start() < StartTime() ) {
|
|
|
|
x0 += (StartTime() - column->Start())/60*tvguideConfig.minutePixel;
|
|
|
|
}
|
|
|
|
if (!pixmap) {
|
|
|
|
pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, viewportHeight, tvguideConfig.rowHeight),
|
|
|
|
cRect(0, 0, Duration()/60*tvguideConfig.minutePixel, tvguideConfig.rowHeight));
|
|
|
|
} else {
|
|
|
|
pixmap->SetViewPort(cRect(x0, y0, viewportHeight, tvguideConfig.rowHeight ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::setText() {
|
2013-05-24 16:23:23 +02:00
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
cString strText;
|
|
|
|
strText = cString::sprintf("%s - %s:\n%s", *(event->GetTimeString()), *(event->GetEndTimeString()), event->Title());
|
|
|
|
text->Set(*(strText), tvguideConfig.FontGrid, tvguideConfig.colWidth-2*borderWidth);
|
|
|
|
extText->Set(event->ShortText(), tvguideConfig.FontGridSmall, tvguideConfig.colWidth-2*borderWidth);
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
|
|
|
timeString = cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString()));
|
|
|
|
}
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::drawText() {
|
2013-05-28 17:06:53 +02:00
|
|
|
tColor colorText = (active)?theme.Color(clrFontActive):theme.Color(clrFont);
|
2013-05-28 17:23:33 +02:00
|
|
|
tColor colorTextBack = (tvguideConfig.useBlending==0)?color:clrTransparent;
|
2013-05-24 16:23:23 +02:00
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
if (Height()/tvguideConfig.minutePixel < 6)
|
|
|
|
return;
|
|
|
|
int textHeight = tvguideConfig.FontGrid->Height();
|
|
|
|
int textLines = text->Lines();
|
|
|
|
for (int i=0; i<textLines; i++) {
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth, borderWidth + i*textHeight), text->GetLine(i), colorText, colorTextBack, tvguideConfig.FontGrid);
|
2013-05-24 16:23:23 +02:00
|
|
|
}
|
|
|
|
int extTextLines = extText->Lines();
|
|
|
|
int offset = (textLines+1)*textHeight - 0.5*textHeight;
|
|
|
|
textHeight = tvguideConfig.FontGridSmall->Height();
|
|
|
|
if ((Height()-textHeight-10) > offset) {
|
|
|
|
for (int i=0; i<extTextLines; i++) {
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth, borderWidth + offset + i*textHeight), extText->GetLine(i), colorText, colorTextBack, tvguideConfig.FontGridSmall);
|
2013-05-24 16:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasTimer)
|
|
|
|
drawRecIcon();
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
|
|
|
if (Width()/tvguideConfig.minutePixel < 10) {
|
|
|
|
int titleY = (tvguideConfig.rowHeight - tvguideConfig.FontGridHorizontal->Height())/2;
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth - 2, titleY), "...", colorText, colorTextBack, tvguideConfig.FontGridHorizontal);
|
2013-05-24 16:23:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth, borderWidth), *timeString, colorText, colorTextBack, tvguideConfig.FontGridHorizontalSmall);
|
2013-05-24 16:23:23 +02:00
|
|
|
cString strTitle = CutText(event->Title(), viewportHeight, tvguideConfig.FontGridHorizontal).c_str();
|
|
|
|
int titleY = tvguideConfig.FontGridHorizontalSmall->Height() + (tvguideConfig.rowHeight - tvguideConfig.FontGridHorizontalSmall->Height() - tvguideConfig.FontGridHorizontal->Height())/2;
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(borderWidth, titleY), *strTitle, colorText, colorTextBack, tvguideConfig.FontGridHorizontal);
|
2013-05-24 16:23:23 +02:00
|
|
|
}
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
2013-05-20 11:37:37 +02:00
|
|
|
void cEpgGrid::drawRecIcon() {
|
2013-05-26 11:38:05 +02:00
|
|
|
cString recIconText("REC");
|
|
|
|
int width = tvguideConfig.FontGrid->Width(*recIconText)+2*borderWidth;
|
|
|
|
int height = tvguideConfig.FontGrid->Height()+10;
|
|
|
|
pixmap->DrawRectangle( cRect(Width() - width - borderWidth, Height() - height - borderWidth, width, height), theme.Color(clrButtonRed));
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmap->DrawText(cPoint(Width() - width, Height() - height - borderWidth/2), *recIconText, theme.Color(clrFont), theme.Color(clrButtonRed), tvguideConfig.FontGrid);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
2013-05-20 11:37:37 +02:00
|
|
|
cString cEpgGrid::getTimeString(void) {
|
|
|
|
return cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString()));
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cEpgGrid::debug() {
|
2013-05-26 11:38:05 +02:00
|
|
|
esyslog("tvguide epggrid: %s: %s, %s, viewportHeight: %d px, Duration: %d min, active: %d",
|
2013-05-20 11:37:37 +02:00
|
|
|
column->Name(),
|
|
|
|
*(event->GetTimeString()),
|
|
|
|
event->Title(),
|
|
|
|
viewportHeight,
|
|
|
|
event->Duration()/60,
|
|
|
|
active);
|
2013-01-17 13:16:44 +01:00
|
|
|
}
|