From c611e004582067640111ef2f023410025201157d Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 20 May 2013 11:37:37 +0200 Subject: rewrote epg grid handling and scrolling, added status header --- statusheader.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 statusheader.c (limited to 'statusheader.c') diff --git a/statusheader.c b/statusheader.c new file mode 100644 index 0000000..ecb2363 --- /dev/null +++ b/statusheader.c @@ -0,0 +1,74 @@ +#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; + } + pixmap = osdManager.requestPixmap(1, cRect(0, 0, width, height)); + pixmapText = osdManager.requestPixmap(2, cRect(0, 0, width, height)); + pixmapText->Fill(clrTransparent); + drawBackground(); + drawBorder(); +} + +cStatusHeader::~cStatusHeader(void) { + 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; + int x = tvguideConfig.osdWidth - width; + int y = 0; + cRect availableRect(x, y, width, height); + cRect vidWin = cDevice::PrimaryDevice()->CanScaleVideo(availableRect); + cDevice::PrimaryDevice()->ScaleVideo(vidWin); + } +} + +void cStatusHeader::DrawInfoText(cGrid *grid) { + int border = 5; + 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(); + pixmapText->DrawText(cPoint(x,y), *header, theme.Color(clrFont), clrTransparent, tvguideConfig.FontStatusHeaderLarge); + 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++) { + pixmapText->DrawText(cPoint(x,y), description.GetLine(i), theme.Color(clrFont), clrTransparent, tvguideConfig.FontStatusHeader); + y += lineHeight; + } + cString lastLine = description.GetLine(lines-1); + if (textLines > maxLines) { + lastLine = cString::sprintf("%s...", *lastLine); + } + pixmapText->DrawText(cPoint(x,y), *lastLine, theme.Color(clrFont), clrTransparent, tvguideConfig.FontStatusHeader); + } else { + int heightText = pixmapText->ViewPort().Height() - y; + y += (heightText - tvguideConfig.FontStatusHeaderLarge->Height() - 2*border)/2; + pixmapText->DrawText(cPoint(x,y), *grid->getText(), theme.Color(clrFont), clrTransparent, tvguideConfig.FontStatusHeaderLarge); + } +} \ No newline at end of file -- cgit v1.2.3