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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vchannellist.h"
23 VChannelList::VChannelList(ULONG type)
25 if (Video::getInstance()->getFormat() == Video::PAL)
34 setDimensions(420, 570);
36 setBackgroundColour(Colour::VIEWBACKGROUND);
39 if (type == VDR::VIDEO)
41 setTitleText("Channels");
43 else if (type == VDR::RADIO)
45 setTitleText("Radio Stations");
47 setTitleBarColour(Colour::TITLEBARBACKGROUND);
49 sl.setScreenPos(screenX + 10, screenY + 30 + 5);
50 sl.setDimensions(height - 30 - 15 - 30, width - 20);
53 VChannelList::~VChannelList()
57 while (!chanList->isEmpty())
60 delete (Channel*)chanList->remove();
67 void VChannelList::setList(List* tlist)
79 while((chan = (Channel*)chanList->getCurrent()))
81 sprintf(str, "%lu. %s", chan->number, chan->name);
82 chan->index = sl.addOption(str, first);
89 void VChannelList::draw()
94 // Put the status stuff at the bottom
98 w.nextSymbol = WSymbol::UP;
99 w.setScreenPos(screenX + 20, screenY + 385);
102 w.nextSymbol = WSymbol::DOWN;
103 w.setScreenPos(screenX + 50, screenY + 385);
106 w.nextSymbol = WSymbol::SKIPBACK;
107 w.setScreenPos(screenX + 85, screenY + 385);
110 w.nextSymbol = WSymbol::SKIPFORWARD;
111 w.setScreenPos(screenX + 115, screenY + 385);
114 w.nextSymbol = WSymbol::PLAY;
115 w.setScreenPos(screenX + 150, screenY + 385);
121 void VChannelList::doShowingBar()
123 int topOption = sl.getTopOption() + 1;
124 if (sl.getNumOptions() == 0) topOption = 0;
127 sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
129 b.setScreenPos(screenX + 220, screenY + 385);
130 b.setDimensions(25, 160);
131 b.fillColour(Colour::VIEWBACKGROUND);
132 b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
135 int VChannelList::handleCommand(int command)
137 if (command == Remote::UP)
146 else if (command == Remote::DOWN)
155 else if (command == Remote::SKIPBACK)
164 else if (command == Remote::SKIPFORWARD)
173 else if (command == Remote::OK)
175 Channel* chan = NULL;
178 int currentOption = sl.getCurrentOption();
181 while((chan = (Channel*)chanList->getCurrent()))
183 if (currentOption == chan->index) break;
188 if (chan == NULL) return 2;
193 // if (chan->type == VDR::RADIO) return 2;
195 if (chan->type == VDR::VIDEO)
197 v = new VVideoLive(chanList);
198 ((VVideoLive*)v)->setChannel(chan->number);
200 else if (chan->type == VDR::RADIO)
202 v = new VRadioLive(chanList);
203 ((VRadioLive*)v)->setChannel(chan->number);
206 ViewMan::getInstance()->addNoLock(v);
212 else if (command == Remote::BACK)
216 // stop command getting to any more views