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)
26 if (Video::getInstance()->getFormat() == Video::PAL)
36 setBackgroundColour(Colour::VIEWBACKGROUND);
39 if (type == VDR::VIDEO)
41 setTitleText(tr("Channels"));
43 else if (type == VDR::RADIO)
45 setTitleText(tr("Radio Stations"));
47 setTitleBarColour(Colour::TITLEBARBACKGROUND);
49 sl.setSurface(surface);
50 sl.setSurfaceOffset(10, 30 + 5);
51 sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
54 VChannelList::~VChannelList()
58 for (UINT i = 0; i < chanList->size(); i++)
60 delete (*chanList)[i];
68 void VChannelList::setList(ChannelList* tlist)
81 for (UINT i = 0; i < chanList->size(); i++)
83 chan = (*chanList)[i];
84 sprintf(str, "%lu\t%s", chan->number, chan->name);
85 chan->index = sl.addOption(str, first);
91 void VChannelList::highlightChannel(Channel* chan)
93 sl.hintSetCurrent(chan->index);
96 ViewMan::getInstance()->updateView(this);
99 void VChannelList::draw()
104 // Put the status stuff at the bottom
107 w.setSurface(surface);
109 w.nextSymbol = WSymbol::UP;
110 w.setSurfaceOffset(20, 385);
113 w.nextSymbol = WSymbol::DOWN;
114 w.setSurfaceOffset(50, 385);
117 w.nextSymbol = WSymbol::SKIPBACK;
118 w.setSurfaceOffset(85, 385);
121 w.nextSymbol = WSymbol::SKIPFORWARD;
122 w.setSurfaceOffset(115, 385);
125 w.nextSymbol = WSymbol::PLAY;
126 w.setSurfaceOffset(150, 385);
132 void VChannelList::doShowingBar()
134 int topOption = sl.getTopOption() + 1;
135 if (sl.getNumOptions() == 0) topOption = 0;
138 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
141 // b.setSurfaceOffset(220, 385);
142 // b.setDimensions(160, 25);
143 // b.fillColour(Colour::VIEWBACKGROUND);
144 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
146 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
147 drawText(showing, 220, 385, Colour::LIGHTTEXT);
150 int VChannelList::handleCommand(int command)
161 ViewMan::getInstance()->updateView(this);
164 case Remote::DF_DOWN:
171 ViewMan::getInstance()->updateView(this);
174 case Remote::SKIPBACK:
180 ViewMan::getInstance()->updateView(this);
183 case Remote::SKIPFORWARD:
189 ViewMan::getInstance()->updateView(this);
195 Channel* chan = NULL;
198 int currentOption = sl.getCurrentOption();
200 for (UINT i = 0; i < chanList->size(); i++)
202 chan = (*chanList)[i];
203 if (currentOption == chan->index) break;
207 if (chan == NULL) return 2;
209 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
212 ViewMan::getInstance()->add(v);
213 ViewMan::getInstance()->updateView(v);
215 v->channelChange(VVideoLive::NUMBER, chan->number);
224 // stop command getting to any more views