2019-07-11 11:07:13 +02:00
|
|
|
#include <vdr/channels.h>
|
|
|
|
#include "config.h"
|
|
|
|
#include "geometrymanager.h"
|
|
|
|
#include "osdmanager.h"
|
|
|
|
#include "fontmanager.h"
|
|
|
|
#include "channelgroups.h"
|
|
|
|
#include "channeljump.h"
|
|
|
|
|
2019-07-11 14:14:51 +02:00
|
|
|
cChannelJump::cChannelJump(cChannelGroups *channelGroups, int lastValidChannel) {
|
2019-07-11 11:07:13 +02:00
|
|
|
this->channelGroups = channelGroups;
|
|
|
|
pixmapText = NULL;
|
|
|
|
channel = 0;
|
2019-07-11 14:14:51 +02:00
|
|
|
maxChannels = lastValidChannel;
|
2019-07-11 11:07:13 +02:00
|
|
|
timeout = Setup.ChannelEntryTimeout;
|
2019-07-11 14:14:51 +02:00
|
|
|
startTime = 0;
|
2019-07-11 11:07:13 +02:00
|
|
|
SetPixmaps();
|
|
|
|
Draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
cChannelJump::~cChannelJump(void) {
|
2019-11-10 15:37:28 +01:00
|
|
|
osdManager.DestroyPixmap(pixmapBack);
|
|
|
|
osdManager.DestroyPixmap(pixmapText);
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelJump::SetPixmaps(void) {
|
|
|
|
int x = (geoManager.osdWidth - geoManager.channelJumpWidth)/2;
|
|
|
|
int y = (geoManager.osdHeight - geoManager.channelJumpHeight)/2;
|
|
|
|
|
2019-11-10 15:37:28 +01:00
|
|
|
pixmapBack = osdManager.CreatePixmap(4, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight));
|
|
|
|
pixmap = osdManager.CreatePixmap(5, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight));
|
|
|
|
pixmapText = osdManager.CreatePixmap(6, cRect(x, y, geoManager.channelJumpWidth, geoManager.channelJumpHeight));
|
2019-07-11 11:07:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelJump::Draw(void) {
|
2019-07-11 11:28:11 +02:00
|
|
|
if (config.style == eStyleGraphical) {
|
2019-07-11 11:07:13 +02:00
|
|
|
drawBackgroundGraphical(bgChannelJump);
|
|
|
|
} else {
|
|
|
|
pixmap->Fill(theme.Color(clrBackground));
|
|
|
|
drawBorder();
|
|
|
|
}
|
|
|
|
pixmapBack->Fill(clrTransparent);
|
|
|
|
pixmapBack->DrawRectangle(cRect(5, Height()/2, Width()-10, Height()-3), theme.Color(clrBackground));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelJump::DrawText(void) {
|
|
|
|
pixmapText->Fill(clrTransparent);
|
|
|
|
|
|
|
|
cString header = cString::sprintf("%s:", tr("Channel"));
|
|
|
|
|
|
|
|
const cFont *font = fontManager.FontMessageBox;
|
|
|
|
const cFont *fontHeader = fontManager.FontMessageBoxLarge;
|
|
|
|
|
|
|
|
int xHeader = (Width() - fontHeader->Width(*header)) / 2;
|
|
|
|
int yHeader = (Height()/2 - fontHeader->Height()) / 2;
|
|
|
|
pixmapText->DrawText(cPoint(xHeader, yHeader), *header, theme.Color(clrFont), clrTransparent, fontHeader);
|
|
|
|
|
|
|
|
cString strChannel = BuildChannelString();
|
|
|
|
int xChannel = (Width() - font->Width(*strChannel)) / 2;
|
|
|
|
int yChannel = Height()/2 + (Height()/2 - font->Height()) / 2;
|
|
|
|
pixmapText->DrawText(cPoint(xChannel, yChannel), *strChannel, theme.Color(clrFont), clrTransparent, font);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void cChannelJump::Set(int num) {
|
|
|
|
startTime = cTimeMs::Now();
|
|
|
|
if (channel == 0) {
|
|
|
|
channel = num;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int newChannel = channel * 10 + num;
|
|
|
|
if (newChannel <= maxChannels)
|
|
|
|
channel = newChannel;
|
|
|
|
}
|
|
|
|
|
|
|
|
cString cChannelJump::BuildChannelString(void) {
|
|
|
|
if (channel*10 <= maxChannels)
|
|
|
|
return cString::sprintf("%d-", channel);
|
|
|
|
else
|
|
|
|
return cString::sprintf("%d", channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cChannelJump::TimeOut(void) {
|
|
|
|
if ((cTimeMs::Now() - startTime) > timeout)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|