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("Channels");
43 else if (type == VDR::RADIO)
45 setTitleText("Radio Stations");
47 setTitleBarColour(Colour::TITLEBARBACKGROUND);
49 sl.setSurface(surface);
50 sl.setSurfaceOffset(10, 30 + 5);
51 sl.setDimensions(width - 20, height - 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::draw()
96 // Put the status stuff at the bottom
99 w.setSurface(surface);
101 w.nextSymbol = WSymbol::UP;
102 w.setSurfaceOffset(20, 385);
105 w.nextSymbol = WSymbol::DOWN;
106 w.setSurfaceOffset(50, 385);
109 w.nextSymbol = WSymbol::SKIPBACK;
110 w.setSurfaceOffset(85, 385);
113 w.nextSymbol = WSymbol::SKIPFORWARD;
114 w.setSurfaceOffset(115, 385);
117 w.nextSymbol = WSymbol::PLAY;
118 w.setSurfaceOffset(150, 385);
124 void VChannelList::doShowingBar()
126 int topOption = sl.getTopOption() + 1;
127 if (sl.getNumOptions() == 0) topOption = 0;
130 sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
133 // b.setSurfaceOffset(220, 385);
134 // b.setDimensions(160, 25);
135 // b.fillColour(Colour::VIEWBACKGROUND);
136 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
138 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
139 drawText(showing, 220, 385, Colour::LIGHTTEXT);
142 int VChannelList::handleCommand(int command)
156 case Remote::DF_DOWN:
166 case Remote::SKIPBACK:
175 case Remote::SKIPFORWARD:
187 Channel* chan = NULL;
190 int currentOption = sl.getCurrentOption();
192 for (UINT i = 0; i < chanList->size(); i++)
194 chan = (*chanList)[i];
195 if (currentOption == chan->index) break;
199 if (chan == NULL) return 2;
201 // if (chan->type == VDR::RADIO) return 2;
203 VVideoLive* v = new VVideoLive(chanList, chan->type);
204 v->setChannel(chan->number);
206 ViewMan::getInstance()->addNoLock(v);
217 // stop command getting to any more views