2019-07-11 11:07:13 +02:00
|
|
|
#include <algorithm>
|
|
|
|
#include "channelgroup.h"
|
|
|
|
#include "tools.h"
|
|
|
|
|
|
|
|
cChannelGroup::cChannelGroup(const char *name) {
|
|
|
|
channelStart = 0;
|
|
|
|
channelStop = 0;
|
|
|
|
this->name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cChannelGroup::~cChannelGroup(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroup::Dump(void) {
|
|
|
|
esyslog("tvguide: Group %s, startChannel %d, stopChannel %d", name, channelStart, channelStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cChannelGroupGrid -------------------------------------------------------------
|
|
|
|
|
|
|
|
cChannelGroupGrid::cChannelGroupGrid(const char *name) {
|
|
|
|
this->name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cChannelGroupGrid::~cChannelGroupGrid(void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroupGrid::SetBackground() {
|
|
|
|
if (isColor1) {
|
|
|
|
color = theme.Color(clrGrid1);
|
|
|
|
colorBlending = theme.Color(clrGrid1Blending);
|
|
|
|
} else {
|
|
|
|
color = theme.Color(clrGrid2);
|
|
|
|
colorBlending = theme.Color(clrGrid2Blending);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroupGrid::SetGeometry(int start, int end) {
|
|
|
|
int x, y, width, height;
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
x = geoManager.timeLineWidth + start*geoManager.colWidth;
|
|
|
|
y = geoManager.statusHeaderHeight;
|
|
|
|
width = (end - start + 1) * geoManager.colWidth;
|
|
|
|
height = geoManager.channelGroupsHeight;
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
x = 0;
|
|
|
|
y = geoManager.statusHeaderHeight + geoManager.timeLineHeight + start*geoManager.rowHeight;
|
|
|
|
width = geoManager.channelGroupsWidth;
|
|
|
|
height = (end - start + 1) * geoManager.rowHeight;
|
|
|
|
}
|
2019-11-10 15:37:28 +01:00
|
|
|
pixmap = osdManager.CreatePixmap(1, cRect(x, y, width, height));
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroupGrid::Draw(void) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.style == eStyleGraphical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
drawBackgroundGraphical(bgChannelGroup);
|
|
|
|
} else {
|
|
|
|
drawBackground();
|
|
|
|
drawBorder();
|
|
|
|
}
|
|
|
|
tColor colorText = theme.Color(clrFont);
|
2019-07-11 11:28:11 +02:00
|
|
|
tColor colorTextBack = (config.style == eStyleFlat)?color:clrTransparent;
|
|
|
|
if (config.displayMode == eVertical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
DrawVertical(colorText, colorTextBack);
|
2019-07-11 11:28:11 +02:00
|
|
|
} else if (config.displayMode == eHorizontal) {
|
2019-07-11 11:07:13 +02:00
|
|
|
DrawHorizontal(colorText, colorTextBack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroupGrid::DrawVertical(tColor colorText, tColor colorTextBack) {
|
|
|
|
int textY = (Height() - fontManager.FontChannelGroups->Height()) / 2;
|
2020-07-25 13:35:03 +02:00
|
|
|
cString text = cString::sprintf("%s", CutText(name, Width() - 4, fontManager.FontChannelGroups).c_str());
|
2019-07-11 11:07:13 +02:00
|
|
|
int textWidth = fontManager.FontChannelGroups->Width(*text);
|
|
|
|
int x = (Width() - textWidth) / 2;
|
|
|
|
pixmap->DrawText(cPoint(x, textY), *text, colorText, colorTextBack, fontManager.FontChannelGroups);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelGroupGrid::DrawHorizontal(tColor colorText, tColor colorTextBack) {
|
2020-07-25 13:35:03 +02:00
|
|
|
std::string groupName = name;
|
|
|
|
int numChars = groupName.length();
|
2019-07-11 11:07:13 +02:00
|
|
|
int charHeight = fontManager.FontChannelGroupsHorizontal->Height();
|
|
|
|
int textHeight = numChars * charHeight;
|
|
|
|
int y = 5;
|
2020-07-25 13:35:03 +02:00
|
|
|
if ((textHeight + 5) < Height()) {
|
2019-07-11 11:07:13 +02:00
|
|
|
y = (Height() - textHeight) / 2;
|
|
|
|
}
|
2020-07-25 13:35:03 +02:00
|
|
|
for (int i = 0; i < numChars; i++) {
|
|
|
|
if (((y + 2 * charHeight) > Height()) && ((i + 1) < numChars)) {
|
2019-07-11 11:07:13 +02:00
|
|
|
int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width("...")) / 2;
|
|
|
|
pixmap->DrawText(cPoint(x, y), "...", colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal);
|
|
|
|
break;
|
|
|
|
}
|
2020-07-25 13:35:03 +02:00
|
|
|
cString currentChar = cString::sprintf("%s", utf8_substr(groupName.c_str(), i, 1).c_str());
|
2019-07-11 11:07:13 +02:00
|
|
|
int x = (Width() - fontManager.FontChannelGroupsHorizontal->Width(*currentChar)) / 2;
|
|
|
|
pixmap->DrawText(cPoint(x, y), *currentChar, colorText, colorTextBack, fontManager.FontChannelGroupsHorizontal);
|
|
|
|
y += fontManager.FontChannelGroupsHorizontal->Height();
|
|
|
|
}
|
|
|
|
}
|