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 viewman = ViewMan::getInstance();
27 if (Video::getInstance()->getFormat() == Video::PAL)
37 setBackgroundColour(Colour::VIEWBACKGROUND);
40 if (type == VDR::VIDEO)
42 setTitleText(tr("Channels"));
44 else if (type == VDR::RADIO)
46 setTitleText(tr("Radio Stations"));
48 setTitleBarColour(Colour::TITLEBARBACKGROUND);
50 sl.setSurface(surface);
51 sl.setSurfaceOffset(10, 30 + 5);
52 sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
55 VChannelList::~VChannelList()
59 for (UINT i = 0; i < chanList->size(); i++)
61 delete (*chanList)[i];
69 void VChannelList::setList(ChannelList* tlist)
82 for (UINT i = 0; i < chanList->size(); i++)
84 chan = (*chanList)[i];
85 sprintf(str, "%lu\t%s", chan->number, chan->name);
86 chan->index = sl.addOption(str, (ULONG)chan, first);
92 void VChannelList::highlightChannel(Channel* chan)
94 sl.hintSetCurrent(chan->index);
97 viewman->updateView(this);
100 void VChannelList::draw()
105 // Put the status stuff at the bottom
108 w.setSurface(surface);
110 w.nextSymbol = WSymbol::UP;
111 w.setSurfaceOffset(20, 385);
114 w.nextSymbol = WSymbol::DOWN;
115 w.setSurfaceOffset(50, 385);
118 w.nextSymbol = WSymbol::SKIPBACK;
119 w.setSurfaceOffset(85, 385);
122 w.nextSymbol = WSymbol::SKIPFORWARD;
123 w.setSurfaceOffset(115, 385);
126 w.nextSymbol = WSymbol::PLAY;
127 w.setSurfaceOffset(150, 385);
133 void VChannelList::doShowingBar()
135 int topOption = sl.getTopOption() + 1;
136 if (sl.getNumOptions() == 0) topOption = 0;
139 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
142 // b.setSurfaceOffset(220, 385);
143 // b.setDimensions(160, 25);
144 // b.fillColour(Colour::VIEWBACKGROUND);
145 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
147 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
148 drawText(showing, 220, 385, Colour::LIGHTTEXT);
151 int VChannelList::handleCommand(int command)
162 viewman->updateView(this);
165 case Remote::DF_DOWN:
172 viewman->updateView(this);
175 case Remote::SKIPBACK:
181 viewman->updateView(this);
184 case Remote::SKIPFORWARD:
190 viewman->updateView(this);
204 VChannelSelect* v = new VChannelSelect(this);
207 viewman->updateView(v);
208 v->handleCommand(command);
214 Channel* chan = NULL;
215 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
216 if (chan == NULL) return 2;
218 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
222 viewman->updateView(v);
224 v->channelChange(VVideoLive::NUMBER, chan->number);
233 // stop command getting to any more views
237 void VChannelList::processMessage(Message* m)
239 if (m->message == Message::MOUSE_MOVE)
241 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
245 viewman->updateView(this);
248 else if (m->message == Message::MOUSE_LBDOWN)
250 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
252 viewman->handleCommand(Remote::OK); //simulate OK press
255 { //check if press is outside this view! then simulate cancel
256 int x=(m->parameter>>16)-getScreenX();
257 int y=(m->parameter&0xFFFF)-getScreenY();
258 if (x<0 || y <0 || x>getWidth() || y>getHeight())
260 viewman->handleCommand(Remote::BACK); //simulate cancel press
264 else if (m->message == Message::CHANNEL_CHANGE)
266 bool isinlist = false;
268 for (UINT i = 0; i < chanList->size(); i++)
270 if ((*chanList)[i]->number == m->parameter)
276 if (!isinlist) return;
278 VVideoLive* v = new VVideoLive(chanList, VDR::VIDEO, this); // FIXME - what's wrong with it?
282 viewman->updateView(v);
283 v->channelChange(VVideoLive::NUMBER, m->parameter);