summaryrefslogtreecommitdiff
path: root/channeljump.c
blob: b149dcf445255548a7a6fd8c95c237dddcf5c246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <vdr/channels.h>
#include "channeljump.h"

cChannelJump::cChannelJump(skindesignerapi::cViewElement *channelJump, int lastValidChannel) {
    this->channelJump = channelJump;
    channel = 0;
    maxChannels = lastValidChannel;
    startTime = 0;
    timeout = Setup.ChannelEntryTimeout;
}

cChannelJump::~cChannelJump(void) {
    channelJump->Clear();
    delete channelJump;
}

void cChannelJump::Draw(void) {
    channelJump->Clear();
    channelJump->ClearTokens();
    channelJump->AddStringToken((int)eChannelJumpST::channel, *BuildChannelString());
    channelJump->Display();
}

void cChannelJump::Set(int key) {
    startTime = cTimeMs::Now();
    if (channel == 0) {
	    channel = key;
	    return;
    }
    int newChannel = channel * 10 + key;
    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 ((int)(cTimeMs::Now() - startTime) > timeout)
	 	return true;
	return false;
 }