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"
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(DrawStyle::TITLEBARBACKGROUND);
60 sl.setPosition(10, 30 + 5);
61 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
65 VChannelList::~VChannelList()
70 for (UINT i = 0; i < chanList->size(); i++)
72 delete (*chanList)[i];
80 void VChannelList::setList(ChannelList* tlist)
83 OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
86 if (osdv) sl.addColumn(20);
96 for (UINT i = 0; i < chanList->size(); i++)
98 chan = (*chanList)[i];
99 sprintf(str, "%lu\t%s", chan->number, chan->name);
100 TVMediaInfo *info=NULL;
102 info= new TVMediaInfo();
103 info->setChannelLogo((*chanList)[i]->number);
105 chan->index = sl.addOption(str, (ULONG)chan, first, info);
111 void VChannelList::highlightChannel(Channel* chan)
113 sl.hintSetCurrent(chan->index);
116 boxstack->update(this);
119 void VChannelList::draw()
124 // Put the status stuff at the bottom
129 w.nextSymbol = WSymbol::UP;
130 w.setPosition(20, 385);
133 w.nextSymbol = WSymbol::DOWN;
134 w.setPosition(50, 385);
137 w.nextSymbol = WSymbol::SKIPBACK;
138 w.setPosition(85, 385);
141 w.nextSymbol = WSymbol::SKIPFORWARD;
142 w.setPosition(115, 385);
145 w.nextSymbol = WSymbol::PLAY;
146 w.setPosition(150, 385);
152 void VChannelList::doShowingBar()
154 int topOption = sl.getTopOption() + 1;
155 if (sl.getNumOptions() == 0) topOption = 0;
158 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
159 #ifndef GRADIENT_DRAWING
160 rectangle(220, 385,160, 25, DrawStyle::VIEWBACKGROUND);
162 drawText(showing, 220, 385, DrawStyle::LIGHTTEXT);
165 void VChannelList::quickUpdate() { //only quick for plattform that need it!
166 #ifdef GRADIENT_DRAWING
174 int VChannelList::handleCommand(int command)
184 boxstack->update(this);
187 case Remote::DF_DOWN:
193 boxstack->update(this);
196 case Remote::SKIPBACK:
201 boxstack->update(this);
204 case Remote::SKIPFORWARD:
209 boxstack->update(this);
223 VChannelSelect* v = new VChannelSelect(this);
227 v->handleCommand(command);
233 Channel* chan = NULL;
234 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
235 if (chan == NULL) return 2;
237 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
248 // stop command getting to any more views
252 void VChannelList::processMessage(Message* m)
254 /* if (m->message == Message::MOUSE_MOVE) {
255 if (sl.mouseAndroidScroll((m->tag >> 16),(m->tag & 0xFFFF),
256 (m->parameter >> 16),(m->parameter & 0xFFFF))) {
259 boxstack->update(this);
262 else */if (m->message == Message::MOUSE_MOVE)
264 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
267 boxstack->update(this);
270 else if (m->message == Message::MOUSE_LBDOWN)
272 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
274 boxstack->handleCommand(Remote::OK); //simulate OK press
277 { //check if press is outside this view! then simulate cancel
278 int x=(m->parameter>>16)-getScreenX();
279 int y=(m->parameter&0xFFFF)-getScreenY();
280 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
282 boxstack->handleCommand(Remote::BACK); //simulate cancel press
286 else if (m->message == Message::CHANNEL_CHANGE)
288 Channel* chan = NULL;
289 for (UINT i = 0; i < chanList->size(); i++)
291 if ((*chanList)[i]->number == m->parameter)
293 chan = (*chanList)[i];
299 /* if (chan->type == VDR::VIDEO)
301 VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
308 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
312 v->channelChange(VVideoLive::NUMBER, chan->number);