]> git.vomp.tv Git - vompclient.git/blob - vchannellist.cc
Channel schedules in live banner
[vompclient.git] / vchannellist.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #include "vchannellist.h"
22
23 VChannelList::VChannelList(ULONG type)
24 {
25   if (Video::getInstance()->getFormat() == Video::PAL)
26   {
27     setScreenPos(80, 70);
28   }
29   else
30   {
31     setScreenPos(70, 35);
32   }
33
34   setDimensions(570, 420);
35
36   setBackgroundColour(Colour::VIEWBACKGROUND);
37   setTitleBarOn(1);
38
39   if (type == VDR::VIDEO)
40   {
41     setTitleText("Channels");
42   }
43   else if (type == VDR::RADIO)
44   {
45     setTitleText("Radio Stations");
46   }
47   setTitleBarColour(Colour::TITLEBARBACKGROUND);
48
49   sl.setScreenPos(screenX + 10, screenY + 30 + 5);
50   sl.setDimensions(width - 20, height - 30 - 15 - 30);
51 }
52
53 VChannelList::~VChannelList()
54 {
55   if (chanList)
56   {
57     for (UINT i = 0; i < chanList->size(); i++)
58     {
59       delete (*chanList)[i];
60     }
61
62     chanList->clear();
63     delete chanList;
64   }
65 }
66
67 void VChannelList::setList(ChannelList* tlist)
68 {
69   char str[500];
70
71   sl.addColumn(0);
72   sl.addColumn(60);
73
74   chanList = tlist;
75
76   Channel* chan;
77   int first = 1;
78   if (chanList)
79   {
80     for (UINT i = 0; i < chanList->size(); i++)
81     {
82       chan = (*chanList)[i];
83       sprintf(str, "%lu\t%s", chan->number, chan->name);
84       chan->index = sl.addOption(str, first);
85       first = 0;
86     }
87   }
88 }
89
90 void VChannelList::draw()
91 {
92   View::draw();
93   sl.draw();
94
95   // Put the status stuff at the bottom
96
97   WSymbol w;
98
99   w.nextSymbol = WSymbol::UP;
100   w.setScreenPos(screenX + 20, screenY + 385);
101   w.draw();
102
103   w.nextSymbol = WSymbol::DOWN;
104   w.setScreenPos(screenX + 50, screenY + 385);
105   w.draw();
106
107   w.nextSymbol = WSymbol::SKIPBACK;
108   w.setScreenPos(screenX + 85, screenY + 385);
109   w.draw();
110
111   w.nextSymbol = WSymbol::SKIPFORWARD;
112   w.setScreenPos(screenX + 115, screenY + 385);
113   w.draw();
114
115   w.nextSymbol = WSymbol::PLAY;
116   w.setScreenPos(screenX + 150, screenY + 385);
117   w.draw();
118
119   doShowingBar();
120 }
121
122 void VChannelList::doShowingBar()
123 {
124   int topOption = sl.getTopOption() + 1;
125   if (sl.getNumOptions() == 0) topOption = 0;
126
127   char showing[200];
128   sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
129   Box b;
130   b.setScreenPos(screenX + 220, screenY + 385);
131   b.setDimensions(160, 25);
132   b.fillColour(Colour::VIEWBACKGROUND);
133   b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
134 }
135
136 int VChannelList::handleCommand(int command)
137 {
138   switch(command)
139   {
140     case Remote::DF_UP:
141     case Remote::UP:
142     {
143       sl.up();
144       sl.draw();
145
146       doShowingBar();
147       show();
148       return 2;
149     }
150     case Remote::DF_DOWN:
151     case Remote::DOWN:
152     {
153       sl.down();
154       sl.draw();
155
156       doShowingBar();
157       show();
158       return 2;
159     }
160     case Remote::SKIPBACK:
161     {
162       sl.pageUp();
163       sl.draw();
164
165       doShowingBar();
166       show();
167       return 2;
168     }
169     case Remote::SKIPFORWARD:
170     {
171       sl.pageDown();
172       sl.draw();
173
174       doShowingBar();
175       show();
176       return 2;
177     }
178     case Remote::OK:
179     case Remote::PLAY:
180     {
181       Channel* chan = NULL;
182       if (chanList)
183       {
184         int currentOption = sl.getCurrentOption();
185
186         for (UINT i = 0; i < chanList->size(); i++)
187         {
188           chan = (*chanList)[i];
189           if (currentOption == chan->index) break;
190         }
191       }
192
193       if (chan == NULL) return 2;
194
195       if (chan->type == VDR::RADIO) return 2;
196
197       VVideoLive* v = new VVideoLive(chanList, chan->type);
198       v->setChannel(chan->number);
199
200       ViewMan::getInstance()->addNoLock(v);
201       v->draw();
202       v->show();
203
204       return 2;
205     }
206     case Remote::BACK:
207     {
208       return 4;
209     }
210   }
211   // stop command getting to any more views
212   return 1;
213 }