2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
20 #include "vchannelselect.h"
29 #include "messagequeue.h"
31 // this class only works as it does because the remote command
32 // values for the numbers are the numbers themselves !
34 VChannelSelect::VChannelSelect(Boxx* v)
40 numWidth = (int)VDR::getInstance()->getChannelNumberWidth();
41 if (numWidth > 10) numWidth = 10;
42 for (int i = 0; i < numWidth; i++) input[i] = -1;
44 setSize((numWidth*10) + 22, 30); // 10 px = width of number chars in font
47 setBackgroundColour(DrawStyle::VIEWBACKGROUND);
50 VChannelSelect::~VChannelSelect()
52 Timers::getInstance()->cancelTimer(this, 1);
55 void VChannelSelect::timercall(int clientReference)
57 Log::getInstance()->log("VChannelSelect", Log::DEBUG, "Timer call");
58 if (ignoreTimer) return;
62 void VChannelSelect::doInput(int number)
64 for (int i = numGot - 1; i >= 0; i--)
66 input[i+1] = input[i];
73 void VChannelSelect::draw()
80 for (int i = 0; i < numWidth; i++)
84 drawText("_", 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
88 sprintf(text, "%i", input[i]);
89 drawText(text, 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
94 void VChannelSelect::changeChannel()
97 Timers::getInstance()->cancelTimer(this, 1);
101 // Is there valid data? (is any number not-zero)
103 for(i = 0; i < numWidth; i++) if (input[i]) break;
105 if (i < numWidth) // There is data
110 m->message = Message::CHANNEL_CHANGE;
113 for(i = numGot - 1; i >= 0; i--)
115 m->parameter += input[i] * (ULONG)pow(10., i);
118 MessageQueue::getInstance()->postMessage(m);
122 m = new Message(); // Delete self
124 m->to = BoxStack::getInstance();
125 m->message = Message::CLOSE_ME;
126 MessageQueue::getInstance()->postMessage(m);
129 int VChannelSelect::handleCommand(int command)
146 BoxStack::getInstance()->update(this);
147 if (numGot == numWidth) changeChannel();
148 else Timers::getInstance()->setTimerD(this, 1, 3);
158 // allow command to drop through to other views