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 type)
37 boxstack = BoxStack::getInstance();
40 if (Video::getInstance()->getFormat() == Video::PAL)
51 if (type == VDR::VIDEO)
53 setTitleText(tr("Channels"));
54 TVMediaInfo *info= new TVMediaInfo();
55 info->setStaticArtwork(sa_tv);
56 setTitleBarIcon(info);
58 else if (type == VDR::RADIO)
60 setTitleText(tr("Radio Stations"));
61 TVMediaInfo *info= new TVMediaInfo();
62 info->setStaticArtwork(sa_radio);
63 setTitleBarIcon(info);
65 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
67 sl.setPosition(10, 30 + 5);
68 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
72 VChannelList::~VChannelList()
77 for (UINT i = 0; i < chanList->size(); i++)
79 delete (*chanList)[i];
87 void VChannelList::setList(ChannelList* tlist)
90 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
93 if (osdv) sl.addColumn(20);
103 for (UINT i = 0; i < chanList->size(); i++)
105 chan = (*chanList)[i];
106 sprintf(str, "%lu\t%s", chan->number, chan->name);
107 TVMediaInfo *info=NULL;
109 info= new TVMediaInfo();
110 info->setChannelLogo((*chanList)[i]->number);
112 chan->index = sl.addOption(str, (ULONG)chan, first, info);
118 void VChannelList::highlightChannel(Channel* chan)
120 sl.hintSetCurrent(chan->index);
123 boxstack->update(this);
126 void VChannelList::draw()
131 // Put the status stuff at the bottom
136 w.nextSymbol = WSymbol::UP;
137 w.setPosition(20, 385);
140 w.nextSymbol = WSymbol::DOWN;
141 w.setPosition(50, 385);
144 w.nextSymbol = WSymbol::SKIPBACK;
145 w.setPosition(85, 385);
148 w.nextSymbol = WSymbol::SKIPFORWARD;
149 w.setPosition(115, 385);
152 w.nextSymbol = WSymbol::PLAY;
153 w.setPosition(150, 385);
159 void VChannelList::doShowingBar()
161 int topOption = sl.getTopOption() + 1;
162 if (sl.getNumOptions() == 0) topOption = 0;
165 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
166 #ifndef GRADIENT_DRAWING
167 rectangle(220, 385,160, 25, DrawStyle::VIEWBACKGROUND);
169 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
172 void VChannelList::quickUpdate() { //only quick for plattform that need it!
173 #ifdef GRADIENT_DRAWING
181 int VChannelList::handleCommand(int command)
191 boxstack->update(this);
194 case Remote::DF_DOWN:
200 boxstack->update(this);
203 case Remote::SKIPBACK:
208 boxstack->update(this);
211 case Remote::SKIPFORWARD:
216 boxstack->update(this);
230 VChannelSelect* v = new VChannelSelect(this);
234 v->handleCommand(command);
240 Channel* chan = NULL;
241 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
242 if (chan == NULL) return 2;
244 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
255 // stop command getting to any more views
259 void VChannelList::processMessage(Message* m)
261 /* if (m->message == Message::MOUSE_MOVE) {
262 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
263 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
266 boxstack->update(this);
269 else */if (m->message == Message::MOUSE_MOVE)
271 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
274 boxstack->update(this);
277 else if (m->message == Message::MOUSE_LBDOWN)
279 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
281 boxstack->handleCommand(Remote::OK); //simulate OK press
284 { //check if press is outside this view! then simulate cancel
285 int x=(m->parameter>>16)-getScreenX();
286 int y=(m->parameter&0xFFFF)-getScreenY();
287 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
289 boxstack->handleCommand(Remote::BACK); //simulate cancel press
293 else if (m->message == Message::CHANNEL_CHANGE)
295 Channel* chan = NULL;
296 for (UINT i = 0; i < chanList->size(); i++)
298 if ((*chanList)[i]->number == m->parameter)
300 chan = (*chanList)[i];
306 /* if (chan->type == VDR::VIDEO)
308 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
315 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
319 v->channelChange(VVideoLive::NUMBER, chan->number);