2013-05-20 11:37:37 +02:00
|
|
|
#include "headergrid.h"
|
|
|
|
|
|
|
|
cHeaderGrid::cHeaderGrid(void) : cGrid(NULL) {
|
|
|
|
pixmap = NULL;
|
|
|
|
pixmapLogo = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cHeaderGrid::~cHeaderGrid(void) {
|
|
|
|
osdManager.releasePixmap(pixmapLogo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cHeaderGrid::createBackground(int num) {
|
|
|
|
color = theme.Color(clrHeader);
|
|
|
|
colorBlending = theme.Color(clrHeaderBlending);
|
2013-05-24 16:23:23 +02:00
|
|
|
int x, y, width, height;
|
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
x = tvguideConfig.timeLineWidth + num*tvguideConfig.colWidth;
|
|
|
|
y = tvguideConfig.statusHeaderHeight;
|
|
|
|
width = tvguideConfig.colWidth;
|
|
|
|
height = tvguideConfig.channelHeaderHeight;
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
|
|
|
x = 0;
|
|
|
|
y = tvguideConfig.statusHeaderHeight + tvguideConfig.timeLineHeight + num*tvguideConfig.rowHeight;
|
|
|
|
width = tvguideConfig.channelHeaderWidth;
|
|
|
|
height = tvguideConfig.rowHeight;
|
|
|
|
}
|
|
|
|
pixmap = osdManager.requestPixmap(2, cRect(x, y, width, height));
|
|
|
|
pixmapLogo = osdManager.requestPixmap(3, cRect(x, y, width, height));
|
|
|
|
if ((!pixmap) || (!pixmapLogo)){
|
2013-05-20 11:37:37 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pixmapLogo->Fill(clrTransparent);
|
|
|
|
drawBackground();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cHeaderGrid::drawChannel(const cChannel *channel) {
|
2013-05-24 16:23:23 +02:00
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
drawChannelVertical(channel);
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
|
|
|
drawChannelHorizontal(channel);
|
|
|
|
}
|
|
|
|
drawBorder();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cHeaderGrid::drawChannelHorizontal(const cChannel *channel) {
|
|
|
|
int logoWidth = Height() * tvguideConfig.logoWidthRatio / tvguideConfig.logoHeightRatio;
|
|
|
|
int logoX = tvguideConfig.displayChannelName?2:(Width()-logoWidth)/2;
|
|
|
|
int textX = 5;
|
|
|
|
int textY = (Height() - tvguideConfig.FontChannelHeaderHorizontal->Height())/2;
|
|
|
|
bool logoFound = false;
|
|
|
|
if (!tvguideConfig.hideChannelLogos) {
|
|
|
|
cImageLoader imgLoader;
|
|
|
|
if (imgLoader.LoadLogo(channel->Name(), logoWidth, Height())) {
|
|
|
|
cImage logo = imgLoader.GetImage();
|
|
|
|
pixmapLogo->DrawImage(cPoint(logoX, 0), logo);
|
|
|
|
logoFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool drawText = false;
|
|
|
|
int textWidthMax = Width() - 10;
|
|
|
|
if (!logoFound) {
|
|
|
|
drawText = true;
|
|
|
|
} else if (tvguideConfig.displayChannelName) {
|
|
|
|
drawText = true;
|
|
|
|
textX += logoWidth;
|
|
|
|
textWidthMax -= logoWidth;
|
|
|
|
}
|
|
|
|
if (drawText) {
|
|
|
|
cString strChannel = cString::sprintf("%d %s", channel->Number(), channel->Name());
|
|
|
|
strChannel = CutText(*strChannel, textWidthMax, tvguideConfig.FontChannelHeaderHorizontal).c_str();
|
|
|
|
pixmap->DrawText(cPoint(textX, textY), *strChannel, theme.Color(clrFontHeader), clrTransparent, tvguideConfig.FontChannelHeaderHorizontal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cHeaderGrid::drawChannelVertical(const cChannel *channel) {
|
|
|
|
int logoWidth = Width()/2 - 15;
|
|
|
|
int logoHeight = logoWidth * tvguideConfig.logoHeightRatio / tvguideConfig.logoWidthRatio;
|
2013-05-20 11:37:37 +02:00
|
|
|
cTextWrapper tw;
|
|
|
|
cString headerText = cString::sprintf("%d - %s", channel->Number(), channel->Name());
|
2013-05-24 16:23:23 +02:00
|
|
|
tw.Set(*headerText, tvguideConfig.FontChannelHeader, tvguideConfig.colWidth - 8);
|
2013-05-20 11:37:37 +02:00
|
|
|
int lines = tw.Lines();
|
2013-05-24 16:23:23 +02:00
|
|
|
int lineHeight = tvguideConfig.FontChannelHeader->Height();
|
|
|
|
int yStart = (tvguideConfig.channelHeaderHeight - lines*lineHeight)/2 + 8;
|
|
|
|
bool logoFound = false;
|
|
|
|
if (!tvguideConfig.hideChannelLogos) {
|
2013-05-20 11:37:37 +02:00
|
|
|
cImageLoader imgLoader;
|
2013-05-24 16:23:23 +02:00
|
|
|
if (imgLoader.LoadLogo(channel->Name(), logoWidth, logoHeight)) {
|
2013-05-20 11:37:37 +02:00
|
|
|
cImage logo = imgLoader.GetImage();
|
2013-05-24 16:23:23 +02:00
|
|
|
pixmapLogo->DrawImage(cPoint((Width() - logoWidth)/2, 4), logo);
|
|
|
|
logoFound = true;
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
}
|
2013-05-24 16:23:23 +02:00
|
|
|
bool drawText = false;
|
|
|
|
if (!logoFound) {
|
|
|
|
drawText = true;
|
|
|
|
} else if (tvguideConfig.displayChannelName) {
|
|
|
|
drawText = true;
|
|
|
|
yStart = logoHeight;
|
|
|
|
}
|
|
|
|
if (!drawText)
|
|
|
|
return;
|
2013-05-20 11:37:37 +02:00
|
|
|
for (int i=0; i<lines; i++) {
|
2013-05-24 16:23:23 +02:00
|
|
|
int textWidth = tvguideConfig.FontChannelHeader->Width(tw.GetLine(i));
|
2013-05-20 11:37:37 +02:00
|
|
|
int xText = (tvguideConfig.colWidth - textWidth) / 2;
|
|
|
|
if (xText < 0)
|
|
|
|
xText = 0;
|
2013-05-24 16:23:23 +02:00
|
|
|
pixmap->DrawText(cPoint(xText, yStart + i*lineHeight), tw.GetLine(i), theme.Color(clrFontHeader), clrTransparent, tvguideConfig.FontChannelHeader);
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cHeaderGrid::setPosition(int num) {
|
2013-05-24 16:23:23 +02:00
|
|
|
int x, y, width, height;
|
|
|
|
if (tvguideConfig.displayMode == eVertical) {
|
|
|
|
x = tvguideConfig.timeLineWidth + num*tvguideConfig.colWidth;
|
|
|
|
y = tvguideConfig.statusHeaderHeight;
|
|
|
|
width = tvguideConfig.colWidth;
|
|
|
|
height = tvguideConfig.channelHeaderHeight;
|
|
|
|
} else if (tvguideConfig.displayMode == eHorizontal) {
|
|
|
|
x = 0;
|
|
|
|
y = tvguideConfig.statusHeaderHeight + tvguideConfig.timeLineHeight + num*tvguideConfig.rowHeight;
|
|
|
|
width = tvguideConfig.channelHeaderWidth;
|
|
|
|
height = tvguideConfig.rowHeight;
|
|
|
|
}
|
|
|
|
pixmap->SetViewPort(cRect(x, y, width, height));
|
|
|
|
pixmapLogo->SetViewPort(cRect(x, y, width, height));
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|