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"
23 VChannelList::VChannelList(ULONG type)
26 if (Video::getInstance()->getFormat() == Video::PAL)
36 setBackgroundColour(Colour::VIEWBACKGROUND);
39 if (type == VDR::VIDEO)
41 setTitleText(tr("Channels"));
43 else if (type == VDR::RADIO)
45 setTitleText(tr("Radio Stations"));
47 setTitleBarColour(Colour::TITLEBARBACKGROUND);
49 sl.setSurface(surface);
50 sl.setSurfaceOffset(10, 30 + 5);
51 sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
54 VChannelList::~VChannelList()
58 for (UINT i = 0; i < chanList->size(); i++)
60 delete (*chanList)[i];
68 void VChannelList::setList(ChannelList* tlist)
81 for (UINT i = 0; i < chanList->size(); i++)
83 chan = (*chanList)[i];
84 sprintf(str, "%lu\t%s", chan->number, chan->name);
85 chan->index = sl.addOption(str, (ULONG)chan, first);
91 void VChannelList::highlightChannel(Channel* chan)
93 sl.hintSetCurrent(chan->index);
96 ViewMan::getInstance()->updateView(this);
99 void VChannelList::draw()
104 // Put the status stuff at the bottom
107 w.setSurface(surface);
109 w.nextSymbol = WSymbol::UP;
110 w.setSurfaceOffset(20, 385);
113 w.nextSymbol = WSymbol::DOWN;
114 w.setSurfaceOffset(50, 385);
117 w.nextSymbol = WSymbol::SKIPBACK;
118 w.setSurfaceOffset(85, 385);
121 w.nextSymbol = WSymbol::SKIPFORWARD;
122 w.setSurfaceOffset(115, 385);
125 w.nextSymbol = WSymbol::PLAY;
126 w.setSurfaceOffset(150, 385);
132 void VChannelList::doShowingBar()
134 int topOption = sl.getTopOption() + 1;
135 if (sl.getNumOptions() == 0) topOption = 0;
138 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
141 // b.setSurfaceOffset(220, 385);
142 // b.setDimensions(160, 25);
143 // b.fillColour(Colour::VIEWBACKGROUND);
144 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
146 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
147 drawText(showing, 220, 385, Colour::LIGHTTEXT);
150 int VChannelList::handleCommand(int command)
161 ViewMan::getInstance()->updateView(this);
164 case Remote::DF_DOWN:
171 ViewMan::getInstance()->updateView(this);
174 case Remote::SKIPBACK:
180 ViewMan::getInstance()->updateView(this);
183 case Remote::SKIPFORWARD:
189 ViewMan::getInstance()->updateView(this);
195 Channel* chan = NULL;
196 if (chanList) chan = (Channel*)sl.getCurrentOptionData();
197 if (chan == NULL) return 2;
199 VVideoLive* v = new VVideoLive(chanList, chan->type, this);
202 ViewMan::getInstance()->add(v);
203 ViewMan::getInstance()->updateView(v);
205 v->channelChange(VVideoLive::NUMBER, chan->number);
214 // stop command getting to any more views
218 void VChannelList::processMessage(Message* m)
220 if (m->message == Message::MOUSE_MOVE)
222 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
226 ViewMan::getInstance()->updateView(this);
229 else if (m->message == Message::MOUSE_LBDOWN)
231 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
233 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
236 { //check if press is outside this view! then simulate cancel
237 int x=(m->parameter>>16)-getScreenX();
238 int y=(m->parameter&0xFFFF)-getScreenY();
239 if (x<0 || y <0 || x>getWidth() || y>getHeight())
241 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press