diff options
Diffstat (limited to 'epggrid.c')
-rw-r--r-- | epggrid.c | 125 |
1 files changed, 36 insertions, 89 deletions
@@ -1,93 +1,48 @@ #include "channelcolumn.h"
#include "epggrid.h"
-cEpgGrid::cEpgGrid(cChannelColumn *c, const cEvent *event) {
+cEpgGrid::cEpgGrid(cChannelColumn *c, const cEvent *event) : cGrid(c) {
this->event = event;
- this->column = c;
- text = new cTextWrapper();
extText = new cTextWrapper();
- dirty = true;
- active = false;
- viewportHeight = 0;
- borderWidth = 10;
hasTimer = false;
- if (column->hasTimer)
- hasTimer = event->HasTimer();
+ if (column->HasTimer())
+ hasTimer = event->HasTimer();
+ dummy = false;
}
cEpgGrid::~cEpgGrid(void) {
- delete text;
delete extText;
}
void cEpgGrid::SetViewportHeight() {
int viewportHeightOld = viewportHeight;
- if ( column->myTime->GetStart() > event->StartTime() ) {
- viewportHeight = (min(event->EndTime(), column->myTime->GetStop()) - column->myTime->GetStart()) /60;
- } else if ( column->myTime->GetStop() < event->EndTime() ) {
- viewportHeight = (column->myTime->GetStop() - event->StartTime()) /60;
+ 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 = event->Duration() / 60;
+ viewportHeight = Duration() / 60;
}
+ viewportHeight *= tvguideConfig.minuteHeight;
if (viewportHeight != viewportHeightOld)
dirty = true;
}
void cEpgGrid::PositionPixmap() {
int x0 = column->getX();
- int y0 = tvguideConfig.headerHeight;
- if ( column->myTime->GetStart() < event->StartTime() ) {
- y0 += (event->StartTime() - column->myTime->GetStart())/60*tvguideConfig.minuteHeight;
+ int y0 = tvguideConfig.statusHeaderHeight + tvguideConfig.headerHeight;
+ if ( column->Start() < StartTime() ) {
+ y0 += (StartTime() - column->Start())/60*tvguideConfig.minuteHeight;
}
-
if (!pixmap) {
- caller = cString::sprintf("epggrid %s %s", column->channel->Name(), event->Title());
- pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, tvguideConfig.colWidth, viewportHeight * tvguideConfig.minuteHeight),
- cRect(0, 0, tvguideConfig.colWidth, event->Duration()/60*tvguideConfig.minuteHeight), *caller);
- } else {
- pixmap->SetViewPort(cRect(x0, y0, tvguideConfig.colWidth, viewportHeight * tvguideConfig.minuteHeight));
- }
-}
-
-void cEpgGrid::setBackground() {
- if (active) {
- color = theme.Color(clrHighlight);
- colorBlending = theme.Color(clrHighlightBlending);
+ pixmap = osdManager.requestPixmap(-1, cRect(x0, y0, tvguideConfig.colWidth, viewportHeight),
+ cRect(0, 0, tvguideConfig.colWidth, Duration()/60*tvguideConfig.minuteHeight));
} else {
- if (isColor1) {
- color = theme.Color(clrGrid1);
- colorBlending = theme.Color(clrGrid1Blending);
- } else {
- color = theme.Color(clrGrid2);
- colorBlending = theme.Color(clrGrid2Blending);
- }
- }
-}
-
-void cEpgGrid::Draw() {
- if (!pixmap) {
- return;
- }
- if (dirty) {
- setBackground();
- drawBackground();
- drawText();
- if (hasTimer)
- DrawRecIcon();
- drawBorder();
- pixmap->SetLayer(1);
- dirty = false;
+ pixmap->SetViewPort(cRect(x0, y0, tvguideConfig.colWidth, viewportHeight));
}
}
-void cEpgGrid::DrawRecIcon() {
- cString recIconText("REC");
- int width = tvguideConfig.FontGrid->Width(*recIconText)+2*borderWidth;
- int height = tvguideConfig.FontGrid->Height()+10;
- pixmap->DrawRectangle( cRect(pixmap->ViewPort().Width() - width - borderWidth, pixmap->ViewPort().Height() - height - borderWidth, width, height), theme.Color(clrButtonRed));
- pixmap->DrawText(cPoint(pixmap->ViewPort().Width() - width, pixmap->ViewPort().Height() - height - borderWidth/2), *recIconText, theme.Color(clrFont), clrTransparent, tvguideConfig.FontGrid);
-}
-
void cEpgGrid::setText() {
cString strText;
strText = cString::sprintf("%s - %s:\n%s", *(event->GetTimeString()), *(event->GetEndTimeString()), event->Title());
@@ -96,8 +51,7 @@ void cEpgGrid::setText() { }
void cEpgGrid::drawText() {
- int gridHeight = pixmap->ViewPort().Height();
- if (gridHeight/tvguideConfig.minuteHeight < 6)
+ if (Height()/tvguideConfig.minuteHeight < 6)
return;
int textHeight = tvguideConfig.FontGrid->Height();
int textLines = text->Lines();
@@ -107,40 +61,33 @@ void cEpgGrid::drawText() { int extTextLines = extText->Lines();
int offset = (textLines+1)*textHeight - 0.5*textHeight;
textHeight = tvguideConfig.FontGridSmall->Height();
- if ((pixmap->ViewPort().Height()-textHeight-10) > offset) {
+ if ((Height()-textHeight-10) > offset) {
for (int i=0; i<extTextLines; i++) {
pixmap->DrawText(cPoint(borderWidth, borderWidth + offset + i*textHeight), extText->GetLine(i), theme.Color(clrFont), clrTransparent, tvguideConfig.FontGridSmall);
}
}
+ if (hasTimer)
+ drawRecIcon();
}
-int cEpgGrid::calcOverlap(cEpgGrid *neighbor) {
- int overlap = 0;
- if (intersects(neighbor)) {
- if ((event->StartTime() <= neighbor->StartTime()) && (event->EndTime() <= neighbor->EndTime())) {
- overlap = event->EndTime() - neighbor->StartTime();
- } else if ((event->StartTime() >= neighbor->StartTime()) && (event->EndTime() >= neighbor->EndTime())) {
- overlap = neighbor->EndTime() - event->StartTime();
- } else if ((event->StartTime() >= neighbor->StartTime()) && (event->EndTime() <= neighbor->EndTime())) {
- overlap = event->Duration();
- } else if ((event->StartTime() <= neighbor->StartTime()) && (event->EndTime() >= neighbor->EndTime())) {
- overlap = neighbor->EndTime() - neighbor->StartTime();
- }
- }
- return overlap;
-}
-
-bool cEpgGrid::intersects(cEpgGrid *neighbor) {
- return ! ( (neighbor->EndTime() <= event->StartTime()) || (neighbor->StartTime() >= event->EndTime()) );
+void cEpgGrid::drawRecIcon() {
+ 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));
+ pixmap->DrawText(cPoint(Width() - width, Height() - height - borderWidth/2), *recIconText, theme.Color(clrFont), clrTransparent, tvguideConfig.FontGrid);
}
-bool cEpgGrid::isActiveInitial(time_t t) {
- if ((event->StartTime() < t) && (event->EndTime() > t))
- return true;
- else
- return false;
+cString cEpgGrid::getTimeString(void) {
+ return cString::sprintf("%s - %s", *(event->GetTimeString()), *(event->GetEndTimeString()));
}
void cEpgGrid::debug() {
- esyslog("tvguide Grid: %s, %s, viewportHeight: %d, Duration: %d", *(event->GetTimeString()), event->Title(), viewportHeight, event->Duration()/60);
+ 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);
}
\ No newline at end of file |