2013-05-20 11:37:37 +02:00
|
|
|
#include "statusheader.h"
|
|
|
|
|
|
|
|
cStatusHeader::cStatusHeader(void) {
|
|
|
|
color = theme.Color(clrStatusHeader);
|
|
|
|
colorBlending = theme.Color(clrStatusHeaderBlending);
|
|
|
|
int height = tvguideConfig.statusHeaderHeight;
|
|
|
|
int width;
|
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
width = tvguideConfig.osdWidth - height * 16 / 9;
|
|
|
|
} else {
|
|
|
|
width = tvguideConfig.osdWidth;
|
|
|
|
}
|
2013-05-24 16:23:23 +02:00
|
|
|
int tvFrameWidth = tvguideConfig.osdWidth - width;
|
|
|
|
int radius = tvguideConfig.statusHeaderHeight / 8;
|
2013-05-20 11:37:37 +02:00
|
|
|
pixmap = osdManager.requestPixmap(1, cRect(0, 0, width, height));
|
|
|
|
pixmapText = osdManager.requestPixmap(2, cRect(0, 0, width, height));
|
|
|
|
pixmapText->Fill(clrTransparent);
|
2013-05-24 16:23:23 +02:00
|
|
|
|
|
|
|
pixmapTVFrame = osdManager.requestPixmap(1, cRect(width, 0, tvFrameWidth, height));
|
|
|
|
pixmapTVFrame->Fill(clrTransparent);
|
|
|
|
if (tvguideConfig.decorateVideo) {
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(0,0,radius,radius), theme.Color(clrBackground), -2);
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius, 0, radius, radius), theme.Color(clrBackground), -1);
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(0, height - radius, radius, radius), theme.Color(clrBackground), -3);
|
|
|
|
pixmapTVFrame->DrawEllipse(cRect(tvFrameWidth - radius, height - radius, radius, radius), theme.Color(clrBackground), -4);
|
|
|
|
}
|
2013-05-20 11:37:37 +02:00
|
|
|
drawBackground();
|
|
|
|
drawBorder();
|
|
|
|
}
|
|
|
|
|
|
|
|
cStatusHeader::~cStatusHeader(void) {
|
2013-05-24 16:23:23 +02:00
|
|
|
osdManager.releasePixmap(pixmapText);
|
|
|
|
osdManager.releasePixmap(pixmapTVFrame);
|
2013-05-20 11:37:37 +02:00
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null);
|
|
|
|
cDevice::PrimaryDevice()->ScaleVideo(vidWin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStatusHeader::ScaleVideo(void) {
|
|
|
|
if (tvguideConfig.scaleVideo) {
|
|
|
|
int height = tvguideConfig.statusHeaderHeight;
|
|
|
|
int width = height * 16 / 9;
|
2013-05-26 11:58:11 +02:00
|
|
|
int x = osdManager.Left() + tvguideConfig.osdWidth - width;
|
|
|
|
int y = osdManager.Top();
|
2013-05-20 11:37:37 +02:00
|
|
|
cRect availableRect(x, y, width, height);
|
|
|
|
cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect);
|
|
|
|
cDevice::PrimaryDevice()->ScaleVideo(vidWin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cStatusHeader::DrawInfoText(cGrid *grid) {
|
|
|
|
int border = 5;
|
2013-05-28 17:23:33 +02:00
|
|
|
tColor colorTextBack = (tvguideConfig.useBlending==0)?color:clrTransparent;
|
2013-05-20 11:37:37 +02:00
|
|
|
pixmapText->Fill(clrTransparent);
|
|
|
|
int x = border;
|
|
|
|
int y = border;
|
|
|
|
if (!grid->isDummy()) {
|
|
|
|
cString time = grid->getTimeString();
|
|
|
|
cString title("");
|
|
|
|
const cEvent *event = grid->GetEvent();
|
|
|
|
title = cString::sprintf(": %s", event->Title());
|
|
|
|
cString header = cString::sprintf("%s%s", *time, *title);
|
|
|
|
header = CutText(*header, pixmapText->ViewPort().Width() - 2 * border, tvguideConfig.FontStatusHeaderLarge).c_str();
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmapText->DrawText(cPoint(x,y), *header, theme.Color(clrFont), colorTextBack, tvguideConfig.FontStatusHeaderLarge);
|
2013-05-20 11:37:37 +02:00
|
|
|
y += tvguideConfig.FontStatusHeaderLarge->Height() + border;
|
|
|
|
int heightText = pixmapText->ViewPort().Height() - y;
|
|
|
|
cTextWrapper description;
|
|
|
|
description.Set(event->Description(), tvguideConfig.FontStatusHeader, pixmapText->ViewPort().Width() - 2 * border);
|
|
|
|
int lineHeight = tvguideConfig.FontStatusHeader->Height();
|
|
|
|
int textLines = description.Lines();
|
|
|
|
int maxLines = heightText / lineHeight;
|
|
|
|
int lines = min(textLines, maxLines);
|
|
|
|
for (int i = 0; i < lines-1; i++) {
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmapText->DrawText(cPoint(x,y), description.GetLine(i), theme.Color(clrFont), colorTextBack, tvguideConfig.FontStatusHeader);
|
2013-05-20 11:37:37 +02:00
|
|
|
y += lineHeight;
|
|
|
|
}
|
|
|
|
cString lastLine = description.GetLine(lines-1);
|
|
|
|
if (textLines > maxLines) {
|
|
|
|
lastLine = cString::sprintf("%s...", *lastLine);
|
|
|
|
}
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmapText->DrawText(cPoint(x,y), *lastLine, theme.Color(clrFont), colorTextBack, tvguideConfig.FontStatusHeader);
|
2013-05-20 11:37:37 +02:00
|
|
|
} else {
|
|
|
|
int heightText = pixmapText->ViewPort().Height() - y;
|
|
|
|
y += (heightText - tvguideConfig.FontStatusHeaderLarge->Height() - 2*border)/2;
|
2013-05-28 17:23:33 +02:00
|
|
|
pixmapText->DrawText(cPoint(x,y), *grid->getText(), theme.Color(clrFont), colorTextBack, tvguideConfig.FontStatusHeaderLarge);
|
2013-05-20 11:37:37 +02:00
|
|
|
}
|
2013-05-24 16:23:23 +02:00
|
|
|
}
|