2013-05-20 11:37:37 +02:00
|
|
|
#include "channelcolumn.h"
|
|
|
|
#include "grid.h"
|
|
|
|
|
|
|
|
cGrid::cGrid(cChannelColumn *c) {
|
|
|
|
this->column = c;
|
2013-05-26 11:38:05 +02:00
|
|
|
text = new cTextWrapper();
|
|
|
|
dirty = true;
|
|
|
|
active = false;
|
|
|
|
viewportHeight = 0;
|
|
|
|
borderWidth = 10;
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cGrid::~cGrid(void) {
|
2013-05-26 11:38:05 +02:00
|
|
|
delete text;
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cGrid::setBackground() {
|
2013-05-26 11:38:05 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cGrid::Draw() {
|
2013-05-26 11:38:05 +02:00
|
|
|
if (!pixmap) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dirty) {
|
|
|
|
setBackground();
|
|
|
|
drawBackground();
|
|
|
|
drawText();
|
|
|
|
drawBorder();
|
|
|
|
pixmap->SetLayer(1);
|
|
|
|
dirty = false;
|
|
|
|
}
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cGrid::isFirst(void) {
|
|
|
|
if (column->isFirst(this))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cGrid::Match(time_t t) {
|
2013-05-26 11:38:05 +02:00
|
|
|
if ((StartTime() < t) && (EndTime() > t))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int cGrid::calcOverlap(cGrid *neighbor) {
|
2013-05-26 11:38:05 +02:00
|
|
|
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;
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cGrid::intersects(cGrid *neighbor) {
|
2013-05-26 11:38:05 +02:00
|
|
|
return ! ( (neighbor->EndTime() <= StartTime()) || (neighbor->StartTime() >= EndTime()) );
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|