2 Copyright 2004-2005 Chris Tallon
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
21 #include "vwelcome.h"
\r
25 #include "vchannellist.h"
\r
26 #include "vrecordinglist.h"
\r
27 #include "vtimerlist.h"
\r
28 #include "command.h"
\r
29 #include "message.h"
\r
34 #include "vscreensaver.h"
\r
35 #include "vmedialist.h"
\r
36 #include "boxstack.h"
\r
41 VWelcome::VWelcome()
\r
43 boxstack = BoxStack::getInstance();
\r
45 clockRegion.x = 400;
\r
52 if (Video::getInstance()->getFormat() == Video::PAL)
\r
54 setPosition(140, 170);
\r
58 setPosition(130, 140);
\r
62 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
\r
64 sl.setPosition(20, 40);
\r
65 sl.setSize(200, 160);
\r
68 setTitleText(tr("Welcome"));
\r
69 sl.addOption(tr("1. Live TV"), 1, 1);
\r
70 sl.addOption(tr("2. Radio"), 2, 0);
\r
71 sl.addOption(tr("3. Recordings"), 3, 0);
\r
72 sl.addOption(tr("4. Timers"), 4, 0);
\r
73 #ifdef VOMP_PLATTFORM_MVP
\r
74 sl.addOption(tr("5. MediaPlayer"), 5, 0);
\r
77 sl.addOption(tr("6. Options"), 6, 0);
\r
78 #ifndef VOMP_HAS_EXIT
\r
79 sl.addOption(tr("7. Reboot"), 7, 0);
\r
81 sl.addOption(tr("7. Exit"), 7, 0);
\r
84 jpeg.setPosition(240, 60);
\r
86 jpeg.init("/vdr.jpg");
\r
88 jpeg.init("vdr.jpg");
\r
93 void VWelcome::preDelete()
\r
95 Timers::getInstance()->cancelTimer(this, 1);
\r
98 VWelcome::~VWelcome()
\r
102 void VWelcome::draw()
\r
108 void VWelcome::drawClock()
\r
110 // Blank the area first
\r
111 rectangle(area.w - 60, 0, 60, 30, titleBarColour);
\r
113 char timeString[20];
\r
116 struct tm* tms = localtime(&t);
\r
117 strftime(timeString, 19, "%H:%M", tms);
\r
118 drawTextRJ(timeString, 450, 5, DrawStyle::LIGHTTEXT);
\r
120 time_t dt = 60 - (t % 60); // seconds to the next minute
\r
121 if (dt == 0) dt = 60; // advance a whole minute if necessary
\r
122 dt += t; // get a time_t value for it rather than using duration
\r
123 // (so it will occur at the actual second and not second and a half)
\r
125 Timers::getInstance()->setTimerT(this, 1, dt);
\r
128 void VWelcome::timercall(int clientReference)
\r
131 boxstack->update(this, &clockRegion);
\r
134 int VWelcome::handleCommand(int command)
\r
138 case Remote::DF_UP:
\r
143 boxstack->update(this);
\r
146 case Remote::DF_DOWN:
\r
151 boxstack->update(this);
\r
164 case Remote::THREE:
\r
166 doRecordingsList();
\r
176 #ifdef VOMP_PLATTFORM_MVP
\r
186 case Remote::SEVEN:
\r
188 Command::getInstance()->doReboot();
\r
193 ULONG option = sl.getCurrentOptionData();
\r
199 else if (option == 2)
\r
204 else if (option == 3)
\r
206 doRecordingsList();
\r
209 else if (option == 4)
\r
214 else if (option == 5)
\r
219 else if (option == 6)
\r
224 else if (option == 7)
\r
226 Command::getInstance()->doReboot();
\r
229 return 2; // never gets here
\r
234 VScreensaver* vscreensaver = new VScreensaver();
\r
235 boxstack->add(vscreensaver);
\r
236 vscreensaver->draw();
\r
237 // boxstack->update(vscreensaver);
\r
244 // case Remote::BACK:
\r
253 void VWelcome::doChannelsList()
\r
255 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
\r
259 VChannelList* vchan = new VChannelList(VDR::VIDEO);
\r
260 vchan->setList(chanList);
\r
263 boxstack->add(vchan);
\r
264 boxstack->update(vchan);
\r
268 Command::getInstance()->connectionLost();
\r
272 void VWelcome::doRadioList()
\r
274 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
\r
278 VChannelList* vchan = new VChannelList(VDR::RADIO);
\r
279 vchan->setList(chanList);
\r
282 boxstack->add(vchan);
\r
283 boxstack->update(vchan);
\r
287 Command::getInstance()->connectionLost();
\r
291 void VWelcome::doRecordingsList()
\r
293 VRecordingList* vrec = new VRecordingList();
\r
295 boxstack->add(vrec);
\r
296 boxstack->update(vrec);
\r
300 Command::getInstance()->connectionLost();
\r
304 void VWelcome::doMediaList()
\r
306 #ifdef VOMP_MEDIAPLAYER
\r
307 VMediaList::createList();
\r
311 void VWelcome::doTimersList()
\r
313 VTimerList* vtl = new VTimerList();
\r
317 Command::getInstance()->connectionLost();
\r
322 boxstack->add(vtl);
\r
323 boxstack->update(vtl);
\r
326 void VWelcome::doOptions()
\r
328 // VOptionsMenu* voptionsmenu = new VOptionsMenu();
\r
329 // voptionsmenu->draw();
\r
330 // boxstack->add(voptionsmenu);
\r
331 // boxstack->updateView(voptionsmenu);
\r
333 VOpts* vopts = new VOpts();
\r
335 boxstack->add(vopts);
\r
336 boxstack->update(vopts);
\r
339 void VWelcome::processMessage(Message* m)
\r
341 if (m->message == Message::MOUSE_MOVE)
\r
343 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
346 boxstack->update(this);
\r
349 else if (m->message == Message::MOUSE_LBDOWN)
\r
351 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
353 boxstack->handleCommand(Remote::OK); //simulate OK press
\r