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
23 VWelcome* VWelcome::instance = NULL;
28 viewman = ViewMan::getInstance();
36 if (Video::getInstance()->getFormat() == Video::PAL)
38 setScreenPos(140, 170);
42 setScreenPos(130, 140);
45 setBackgroundColour(Colour::VIEWBACKGROUND);
47 setTitleBarColour(Colour::TITLEBARBACKGROUND);
49 sl.setSurface(surface);
50 sl.setSurfaceOffset(20, 40);
51 sl.setDimensions(170, 140);
53 jpeg.setSurface(surface);
54 jpeg.setSurfaceOffset(240, 60);
61 Timers::getInstance()->cancelTimer(this, 1);
65 VWelcome* VWelcome::getInstance()
70 void VWelcome::setup()
73 setTitleText(tr("Welcome"));
74 sl.addOption(tr("1. Live TV"), 1);
75 sl.addOption(tr("2. Radio"), 0);
76 sl.addOption(tr("3. Recordings"), 0);
77 sl.addOption(tr("4. Options"), 0);
78 sl.addOption(tr("5. Stand by"), 0);
79 sl.addOption(tr("6. Reboot"), 0);
86 jpeg.init("/vdr.jpg");
91 void VWelcome::drawClock()
93 // Blank the area first
94 rectangle(area.w - 60, 0, 60, 30, titleBarColour);
99 struct tm* tms = localtime(&t);
100 strftime(timeString, 19, "%H:%M", tms);
101 drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
103 time_t dt = 60 - (t % 60); // seconds to the next minute
104 if (dt == 0) dt = 60; // advance a whole minute if necessary
105 dt += t; // get a time_t value for it rather than using duration
106 // (so it will occur at the actual second and not second and a half)
108 Timers::getInstance()->setTimer(this, 1, dt);
111 void VWelcome::timercall(int clientReference)
114 viewman->updateView(this, &clockRegion);
117 int VWelcome::handleCommand(int command)
126 viewman->updateView(this);
129 case Remote::DF_DOWN:
134 viewman->updateView(this);
159 Message* m = new Message();
160 m->message = Message::STANDBY;
161 Command::getInstance()->postMessage(m);
166 Command::getInstance()->doReboot();
170 int option = sl.getCurrentOption();
176 else if (option == 1)
181 else if (option == 2)
186 else if (option == 3)
191 else if (option == 4)
193 Message* m = new Message();
194 m->message = Message::STANDBY;
195 Command::getInstance()->postMessage(m);
198 else if (option == 5)
200 Command::getInstance()->doReboot();
203 return 2; // never gets here
211 void VWelcome::doChannelsList()
213 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO);
217 VChannelList* vchan = new VChannelList(VDR::VIDEO);
218 vchan->setList(chanList);
222 viewman->updateView(vchan);
225 // Message* m = new Message();
227 // m->to = ViewMan::getInstance();
228 // m->message = Message::SWAP_ME_FOR;
229 // m->parameter = (ULONG)vchan;
230 // ViewMan::getInstance()->postMessage(m);
234 void VWelcome::doRadioList()
236 ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO);
240 VChannelList* vchan = new VChannelList(VDR::RADIO);
241 vchan->setList(chanList);
245 viewman->updateView(vchan);
249 void VWelcome::doRecordingsList()
251 VInfo* viewWait = new VInfo();
252 viewWait->create(460, 190);
253 if (Video::getInstance()->getFormat() == Video::PAL)
255 viewWait->setScreenPos(140, 170);
259 viewWait->setScreenPos(130, 140);
261 viewWait->setOneLiner(tr("Downloading recordings list"));
263 viewman->add(viewWait);
264 viewman->updateView(viewWait);
266 VDR* vdr = VDR::getInstance();
267 Directory* recDir = vdr->getRecordingsList();
271 VRecordingList* vrec = new VRecordingList(NULL);
272 vrec->setDir(recDir);
276 viewman->updateView(vrec);
279 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay start");
280 viewman->removeView(viewWait);
281 Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
284 void VWelcome::doOptions()
286 VOptions* voptions = new VOptions();
288 viewman->add(voptions);
289 viewman->updateView(voptions);
292 void VWelcome::processMessage(Message* m)
294 if (m->message == Message::REDRAW_LANG)
296 Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message");
299 viewman->updateView(this);