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, (ULONG)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)
195 boxstack->update(this);
198 case Remote::DF_DOWN:
204 boxstack->update(this);
207 case Remote::SKIPBACK:
212 boxstack->update(this);
215 case Remote::SKIPFORWARD:
220 boxstack->update(this);
234 VChannelSelect* v = new VChannelSelect(this);
238 v->handleCommand(command);
244 Channel* chan = NULL;
245 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
246 if (chan == NULL) return 2;
248 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
259 // stop command getting to any more views
263 void VChannelList::processMessage(Message* m)
265 /* if (m->message == Message::MOUSE_MOVE) {
266 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
267 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
270 boxstack->update(this);
273 else */if (m->message == Message::MOUSE_MOVE)
275 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
278 boxstack->update(this);
281 else if (m->message == Message::MOUSE_LBDOWN)
283 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
285 boxstack->handleCommand(Remote::OK); //simulate OK press
288 { //check if press is outside this view! then simulate cancel
289 int x=(m->parameter>>16)-getScreenX();
290 int y=(m->parameter&0xFFFF)-getScreenY();
291 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
293 boxstack->handleCommand(Remote::BACK); //simulate cancel press
297 else if (m->message == Message::CHANNEL_CHANGE)
299 Channel* chan = NULL;
300 for (UINT i = 0; i < chanList->size(); i++)
302 if ((*chanList)[i]->number == m->parameter)
304 chan = (*chanList)[i];
310 /* if (chan->type == VDR::VIDEO)
312 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
319 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
323 v->channelChange(VVideoLive::NUMBER, chan->number);