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(Colour::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 #ifdef VOMP_PLATTFORM_MVP
\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
104 Log::getInstance()->log("VWelcome", Log::DEBUG, "Mark1");
\r
106 Log::getInstance()->log("VWelcome", Log::DEBUG, "Mark2");
\r
108 Log::getInstance()->log("VWelcome", Log::DEBUG, "Mark3");
\r
111 void VWelcome::drawClock()
\r
113 // Blank the area first
\r
114 rectangle(area.w - 60, 0, 60, 30, titleBarColour);
\r
116 char timeString[20];
\r
119 struct tm* tms = localtime(&t);
\r
120 strftime(timeString, 19, "%H:%M", tms);
\r
121 drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
\r
123 time_t dt = 60 - (t % 60); // seconds to the next minute
\r
124 if (dt == 0) dt = 60; // advance a whole minute if necessary
\r
125 dt += t; // get a time_t value for it rather than using duration
\r
126 // (so it will occur at the actual second and not second and a half)
\r
128 Timers::getInstance()->setTimerT(this, 1, dt);
\r
131 void VWelcome::timercall(int clientReference)
\r
134 boxstack->update(this, &clockRegion);
\r
137 int VWelcome::handleCommand(int command)
\r
141 case Remote::DF_UP:
\r
146 boxstack->update(this);
\r
149 case Remote::DF_DOWN:
\r
154 boxstack->update(this);
\r
167 case Remote::THREE:
\r
169 doRecordingsList();
\r
179 #ifdef VOMP_PLATTFORM_MVP
\r
189 case Remote::SEVEN:
\r
191 Command::getInstance()->doReboot();
\r
195 ULONG option = sl.getCurrentOptionData();
\r
201 else if (option == 2)
\r
206 else if (option == 3)
\r
208 doRecordingsList();
\r
211 else if (option == 4)
\r
216 else if (option == 5)
\r
221 else if (option == 6)
\r
226 else if (option == 7)
\r
228 Command::getInstance()->doReboot();
\r
231 return 2; // never gets here
\r
236 VScreensaver* vscreensaver = new VScreensaver();
\r
237 boxstack->add(vscreensaver);
\r
238 vscreensaver->draw();
\r
239 // boxstack->update(vscreensaver);
\r
246 // case Remote::BACK:
\r
255 void VWelcome::doChannelsList()
\r
257 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
\r
261 VChannelList* vchan = new VChannelList(VDR::VIDEO);
\r
262 vchan->setList(chanList);
\r
265 boxstack->add(vchan);
\r
266 boxstack->update(vchan);
\r
270 Command::getInstance()->connectionLost();
\r
274 void VWelcome::doRadioList()
\r
276 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
\r
280 VChannelList* vchan = new VChannelList(VDR::RADIO);
\r
281 vchan->setList(chanList);
\r
284 boxstack->add(vchan);
\r
285 boxstack->update(vchan);
\r
289 Command::getInstance()->connectionLost();
\r
293 void VWelcome::doRecordingsList()
\r
295 VRecordingList* vrec = new VRecordingList();
\r
297 boxstack->add(vrec);
\r
298 boxstack->update(vrec);
\r
302 Command::getInstance()->connectionLost();
\r
306 void VWelcome::doMediaList()
\r
308 #ifdef VOMP_MEDIAPLAYER
\r
309 VMediaList::createList();
\r
313 void VWelcome::doTimersList()
\r
315 VTimerList* vtl = new VTimerList();
\r
319 Command::getInstance()->connectionLost();
\r
324 boxstack->add(vtl);
\r
325 boxstack->update(vtl);
\r
328 void VWelcome::doOptions()
\r
330 // VOptionsMenu* voptionsmenu = new VOptionsMenu();
\r
331 // voptionsmenu->draw();
\r
332 // boxstack->add(voptionsmenu);
\r
333 // boxstack->updateView(voptionsmenu);
\r
335 VOpts* vopts = new VOpts();
\r
337 boxstack->add(vopts);
\r
338 boxstack->update(vopts);
\r
341 void VWelcome::processMessage(Message* m)
\r
343 if (m->message == Message::MOUSE_MOVE)
\r
345 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
348 boxstack->update(this);
\r
351 else if (m->message == Message::MOUSE_LBDOWN)
\r
353 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
355 boxstack->handleCommand(Remote::OK); //simulate OK press
\r