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"
25 #include "vvideolive.h"
32 #include "vchannelselect.h"
34 VChannelList::VChannelList(ULONG type)
36 boxstack = BoxStack::getInstance();
39 if (Video::getInstance()->getFormat() == Video::PAL)
50 if (type == VDR::VIDEO)
52 setTitleText(tr("Channels"));
54 else if (type == VDR::RADIO)
56 setTitleText(tr("Radio Stations"));
58 setTitleBarColour(Colour::TITLEBARBACKGROUND);
60 sl.setPosition(10, 30 + 5);
61 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
65 VChannelList::~VChannelList()
69 for (UINT i = 0; i < chanList->size(); i++)
71 delete (*chanList)[i];
79 void VChannelList::setList(ChannelList* tlist)
92 for (UINT i = 0; i < chanList->size(); i++)
94 chan = (*chanList)[i];
95 sprintf(str, "%lu\t%s", chan->number, chan->name);
96 chan->index = sl.addOption(str, (ULONG)chan, first);
102 void VChannelList::highlightChannel(Channel* chan)
104 sl.hintSetCurrent(chan->index);
107 boxstack->update(this);
110 void VChannelList::draw()
115 // Put the status stuff at the bottom
120 w.nextSymbol = WSymbol::UP;
121 w.setPosition(20, 385);
124 w.nextSymbol = WSymbol::DOWN;
125 w.setPosition(50, 385);
128 w.nextSymbol = WSymbol::SKIPBACK;
129 w.setPosition(85, 385);
132 w.nextSymbol = WSymbol::SKIPFORWARD;
133 w.setPosition(115, 385);
136 w.nextSymbol = WSymbol::PLAY;
137 w.setPosition(150, 385);
143 void VChannelList::doShowingBar()
145 int topOption = sl.getTopOption() + 1;
146 if (sl.getNumOptions() == 0) topOption = 0;
149 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
151 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
152 drawText(showing, 220, 385, Colour::LIGHTTEXT);
155 int VChannelList::handleCommand(int command)
166 boxstack->update(this);
169 case Remote::DF_DOWN:
176 boxstack->update(this);
179 case Remote::SKIPBACK:
185 boxstack->update(this);
188 case Remote::SKIPFORWARD:
194 boxstack->update(this);
208 VChannelSelect* v = new VChannelSelect(this);
212 v->handleCommand(command);
218 Channel* chan = NULL;
219 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
220 if (chan == NULL) return 2;
222 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
228 v->channelChange(VVideoLive::NUMBER, chan->number);
237 // stop command getting to any more views
241 void VChannelList::processMessage(Message* m)
243 if (m->message == Message::MOUSE_MOVE)
245 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
249 boxstack->update(this);
252 else if (m->message == Message::MOUSE_LBDOWN)
254 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
256 boxstack->handleCommand(Remote::OK); //simulate OK press
259 { //check if press is outside this view! then simulate cancel
260 int x=(m->parameter>>16)-getScreenX();
261 int y=(m->parameter&0xFFFF)-getScreenY();
262 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
264 boxstack->handleCommand(Remote::BACK); //simulate cancel press
268 else if (m->message == Message::CHANNEL_CHANGE)
270 bool isinlist = false;
272 for (UINT i = 0; i < chanList->size(); i++)
274 if ((*chanList)[i]->number == m->parameter)
280 if (!isinlist) return;
282 VVideoLive* v = new VVideoLive(chanList, VDR::VIDEO, this); // FIXME - what's wrong with it?
287 v->channelChange(VVideoLive::NUMBER, m->parameter);