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, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vchannelselect.h"
32 // this class only works as it does because the remote command
33 // values for the numbers are the numbers themselves !
35 VChannelSelect::VChannelSelect(Boxx* v)
41 numWidth = (int)VDR::getInstance()->getChannelNumberWidth();
42 if (numWidth > 10) numWidth = 10;
43 for (int i = 0; i < numWidth; i++) input[i] = -1;
45 setSize((numWidth*10) + 22, 30); // 10 px = width of number chars in font
48 setBackgroundColour(DrawStyle::VIEWBACKGROUND);
51 VChannelSelect::~VChannelSelect()
53 Timers::getInstance()->cancelTimer(this, 1);
56 void VChannelSelect::timercall(int clientReference)
58 Log::getInstance()->log("VChannelSelect", Log::DEBUG, "Timer call");
59 if (ignoreTimer) return;
63 void VChannelSelect::doInput(int number)
65 for (int i = numGot - 1; i >= 0; i--)
67 input[i+1] = input[i];
74 void VChannelSelect::draw()
81 for (int i = 0; i < numWidth; i++)
85 drawText("_", 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
89 sprintf(text, "%i", input[i]);
90 drawText(text, 7 + ((numWidth - 1 - i) * 10), 5, DrawStyle::LIGHTTEXT);
95 void VChannelSelect::changeChannel(bool which)
98 Timers::getInstance()->cancelTimer(this, 1);
102 // Is there valid data? (is any number not-zero)
104 for(i = 0; i < numWidth; i++) if (input[i]) break;
106 if (i < numWidth) // There is data
111 m->message = Message::CHANNEL_CHANGE;
114 for(i = numGot - 1; i >= 0; i--)
116 m->parameter += input[i] * (ULONG)pow(10., i);
120 Command::getInstance()->postMessageNoLock(m);
122 Command::getInstance()->postMessageFromOuterSpace(m);
126 m = new Message(); // Delete self
128 m->to = BoxStack::getInstance();
129 m->message = Message::CLOSE_ME;
131 Command::getInstance()->postMessageNoLock(m);
133 Command::getInstance()->postMessageFromOuterSpace(m);
136 int VChannelSelect::handleCommand(int command)
153 BoxStack::getInstance()->update(this);
154 if (numGot == numWidth) changeChannel(true);
155 else Timers::getInstance()->setTimerD(this, 1, 3);
165 // allow command to drop through to other views