]> git.vomp.tv Git - vompclient.git/blob - vchannellist.cc
NTSC support, needs testing
[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 (Osd::getInstance()->getScreenSize() == Osd::PAL)
26   {
27     setScreenPos(80, 70);
28   }
29   else
30   {
31     setScreenPos(70, 35);
32   }
33
34   setDimensions(420, 570);
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(height - 30 - 15 - 30, width - 20);
51 }
52
53 VChannelList::~VChannelList()
54 {
55   if (chanList)
56   {
57     while (!chanList->isEmpty())
58     {
59       chanList->reset();
60       delete (Channel*)chanList->remove();
61     }
62
63     delete chanList;
64   }
65 }
66
67 void VChannelList::setList(List* tlist)
68 {
69   char str[500];
70
71   chanList = tlist;
72
73   Channel* chan;
74   int first = 1;
75   if (chanList)
76   {
77     chanList->reset();
78
79     while((chan = (Channel*)chanList->getCurrent()))
80     {
81       sprintf(str, "%lu. %s", chan->number, chan->name);
82       chan->index = sl.addOption(str, first);
83       first = 0;
84       chanList->next();
85     }
86   }
87 }
88
89 void VChannelList::draw()
90 {
91   View::draw();
92   sl.draw();
93
94   // Put the status stuff at the bottom
95
96   WSymbol w;
97
98   w.nextSymbol = WSymbol::UP;
99   w.setScreenPos(screenX + 20, screenY + 385);
100   w.draw();
101
102   w.nextSymbol = WSymbol::DOWN;
103   w.setScreenPos(screenX + 50, screenY + 385);
104   w.draw();
105
106   w.nextSymbol = WSymbol::SKIPBACK;
107   w.setScreenPos(screenX + 85, screenY + 385);
108   w.draw();
109
110   w.nextSymbol = WSymbol::SKIPFORWARD;
111   w.setScreenPos(screenX + 115, screenY + 385);
112   w.draw();
113
114   w.nextSymbol = WSymbol::PLAY;
115   w.setScreenPos(screenX + 150, screenY + 385);
116   w.draw();
117
118   doShowingBar();
119 }
120
121 void VChannelList::doShowingBar()
122 {
123   int topOption = sl.getTopOption() + 1;
124   if (sl.getNumOptions() == 0) topOption = 0;
125
126   char showing[200];
127   sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
128   Box b;
129   b.setScreenPos(screenX + 220, screenY + 385);
130   b.setDimensions(25, 160);
131   b.fillColour(Colour::VIEWBACKGROUND);
132   b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
133 }
134
135 int VChannelList::handleCommand(int command)
136 {
137   if (command == Remote::UP)
138   {
139     sl.up();
140     sl.draw();
141
142     doShowingBar();
143     show();
144     return 2;
145   }
146   else if (command == Remote::DOWN)
147   {
148     sl.down();
149     sl.draw();
150
151     doShowingBar();
152     show();
153     return 2;
154   }
155   else if (command == Remote::SKIPBACK)
156   {
157     sl.pageUp();
158     sl.draw();
159
160     doShowingBar();
161     show();
162     return 2;
163   }
164   else if (command == Remote::SKIPFORWARD)
165   {
166     sl.pageDown();
167     sl.draw();
168
169     doShowingBar();
170     show();
171     return 2;
172   }
173   else if (command == Remote::OK)
174   {
175     Channel* chan = NULL;
176     if (chanList)
177     {
178       int currentOption = sl.getCurrentOption();
179       chanList->reset();
180
181       while((chan = (Channel*)chanList->getCurrent()))
182       {
183         if (currentOption == chan->index) break;
184         chanList->next();
185       }
186     }
187
188     if (chan == NULL) return 2;
189
190     View* v = NULL;
191
192 // stop radio
193 //    if (chan->type == VDR::RADIO) return 2;
194
195     if (chan->type == VDR::VIDEO)
196     {
197       v = new VVideoLive(chanList);
198       ((VVideoLive*)v)->setChannel(chan->number);
199     }
200     else if (chan->type == VDR::RADIO)
201     {
202       v = new VRadioLive(chanList);
203       ((VRadioLive*)v)->setChannel(chan->number);
204     }
205
206     ViewMan::getInstance()->addNoLock(v);
207     v->draw();
208     v->show();
209
210     return 2;
211   }
212   else if (command == Remote::BACK)
213   {
214     return 4;
215   }
216   // stop command getting to any more views
217   return 1;
218 }