2 Copyright 2004-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vchannellist.h"
25 #include "vvideolivetv.h"
32 #include "vchannelselect.h"
33 #include "staticartwork.h"
35 VChannelList::VChannelList(ULONG ttype)
37 boxstack = BoxStack::getInstance();
40 if (Video::getInstance()->getFormat() == Video::PAL)
52 if (type == VDR::VIDEO)
54 setTitleText(tr("Channels"));
55 TVMediaInfo *info= new TVMediaInfo();
56 info->setStaticArtwork(sa_tv);
57 setTitleBarIcon(info);
59 else if (type == VDR::RADIO)
61 setTitleText(tr("Radio Stations"));
62 TVMediaInfo *info= new TVMediaInfo();
63 info->setStaticArtwork(sa_radio);
64 setTitleBarIcon(info);
67 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
69 sl.setPosition(10, 30 + 5);
70 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
74 VChannelList::~VChannelList()
79 for (UINT i = 0; i < chanList->size(); i++)
81 delete (*chanList)[i];
89 void VChannelList::setList(ChannelList* tlist)
92 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
95 if (osdv) sl.addColumn(20);
105 for (UINT i = 0; i < chanList->size(); i++)
107 chan = (*chanList)[i];
108 sprintf(str, "%lu\t%s", chan->number, chan->name);
109 TVMediaInfo *info=NULL;
111 info= new TVMediaInfo();
112 info->setChannelLogo((*chanList)[i]->number);
113 if (type == VDR::VIDEO) info->setStaticFallback(sa_tv);
114 else info->setStaticFallback(sa_radio);
116 chan->index = sl.addOption(str, chan, first, info);
122 void VChannelList::highlightChannel(Channel* chan)
124 sl.hintSetCurrent(chan->index);
127 boxstack->update(this);
130 void VChannelList::draw()
135 // Put the status stuff at the bottom
140 w.nextSymbol = WSymbol::UP;
141 w.setPosition(20, 385);
144 w.nextSymbol = WSymbol::DOWN;
145 w.setPosition(50, 385);
148 w.nextSymbol = WSymbol::SKIPBACK;
149 w.setPosition(85, 385);
152 w.nextSymbol = WSymbol::SKIPFORWARD;
153 w.setPosition(115, 385);
156 w.nextSymbol = WSymbol::PLAY;
157 w.setPosition(150, 385);
163 void VChannelList::doShowingBar()
165 int topOption = sl.getTopOption() + 1;
166 if (sl.getNumOptions() == 0) topOption = 0;
169 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
170 #ifndef GRADIENT_DRAWING
171 rectangle(220, 385,160, 25, DrawStyle::VIEWBACKGROUND);
173 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
176 void VChannelList::quickUpdate() { //only quick for plattform that need it!
177 #ifdef GRADIENT_DRAWING
185 int VChannelList::handleCommand(int command)
194 boxstack->update(this);
202 boxstack->update(this);
205 case Input::SKIPBACK:
210 boxstack->update(this);
213 case Input::SKIPFORWARD:
218 boxstack->update(this);
232 VChannelSelect* v = new VChannelSelect(this);
236 v->handleCommand(command);
242 Channel* chan = NULL;
243 if (chanList) chan = reinterpret_cast<Channel*>(sl.getCurrentOptionData());
244 if (chan == NULL) return 2;
246 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
257 // stop command getting to any more views
261 void VChannelList::processMessage(Message* m)
263 /* if (m->message == Message::MOUSE_MOVE) {
264 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
265 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
268 boxstack->update(this);
271 else */if (m->message == Message::MOUSE_MOVE)
273 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
276 boxstack->update(this);
279 else if (m->message == Message::MOUSE_LBDOWN)
281 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
283 boxstack->handleCommand(Input::OK); //simulate OK press
285 else if (coordsOutsideBox(m))
287 boxstack->handleCommand(Input::BACK); //simulate cancel press
290 else if (m->message == Message::CHANNEL_CHANGE)
292 Channel* chan = NULL;
293 for (UINT i = 0; i < chanList->size(); i++)
295 if ((*chanList)[i]->number == m->parameter)
297 chan = (*chanList)[i];
303 /* if (chan->type == VDR::VIDEO)
305 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
312 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
316 v->channelChange(VVideoLive::NUMBER, chan->number);