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/>.
27 #include "messagequeue.h"
29 #include "vchannelselect.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 = static_cast<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 if (ignoreTimer) return;
61 void VChannelSelect::doInput(int number)
63 for (int i = numGot - 1; i >= 0; i--)
65 input[i+1] = input[i];
72 void VChannelSelect::draw()
79 for (int i = 0; i < numWidth; i++)
83 drawText("_", 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
87 sprintf(text, "%i", input[i]);
88 drawText(text, 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
93 void VChannelSelect::changeChannel()
96 Timers::getInstance()->cancelTimer(this, 1);
100 // Is there valid data? (is any number not-zero)
102 for(i = 0; i < numWidth; i++) if (input[i]) break;
104 if (i < numWidth) // There is data
109 m->message = Message::CHANNEL_CHANGE;
112 for(i = numGot - 1; i >= 0; i--)
114 m->parameter += input[i] * static_cast<ULONG>(pow(10., i));
117 MessageQueue::getInstance()->postMessage(m);
121 m = new Message(); // Delete self
123 m->to = BoxStack::getInstance();
124 m->message = Message::CLOSE_ME;
125 MessageQueue::getInstance()->postMessage(m);
128 int VChannelSelect::handleCommand(int command)
145 BoxStack::getInstance()->update(this);
146 if (numGot == numWidth) changeChannel();
147 else Timers::getInstance()->setTimerD(this, 1, 3);
157 // allow command to drop through to other views