2 Copyright 2008 Thomas Steger
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vsleeptimer.h"
30 #include "messagequeue.h"
32 Sleeptimer* Sleeptimer::instance = NULL;
34 Sleeptimer::Sleeptimer()
43 Sleeptimer::~Sleeptimer()
49 const char* Sleeptimer::SetTime()
150 Sleeptimer* Sleeptimer::getInstance()
155 void Sleeptimer::threadMethod()
158 while (sec>-1 && active==true)
161 if (sec<31 && sec>-1)
163 VCountdown* count = new VCountdown();
164 char* temp = (char*)malloc(20);
165 sprintf(temp, "0:%02d", sec);
166 count->drawClock(temp);
168 Message* m1 = new Message();
169 m1->message = Message::ADD_VIEW;
170 m1->to = BoxStack::getInstance();
171 m1->parameter.num = (ULONG)count;
172 MessageQueue::getInstance()->postMessageNoLock(m1);
179 Message* m2 = new Message(); // Delete self
180 m2->message = Message::UDP_BUTTON;
181 m2->to = Command::getInstance();
183 m2->parameter.num = 61;
184 MessageQueue::getInstance()->postMessageFromOuterSpace(m2);
193 void Sleeptimer::shutdown()
205 VSleeptimer::VSleeptimer()
209 if (Video::getInstance()->getFormat() == Video::PAL)
211 setPosition(100, 499);
215 setPosition(90, 400);
219 VSleeptimer::~VSleeptimer()
221 // Make sure the timer is deleted
222 Timers::getInstance()->cancelTimer(this, 1);
225 void VSleeptimer::draw()
227 fillColour(DrawStyle::VIEWBACKGROUND);
230 w.nextSymbol = WSymbol::CLOCK;
235 drawText(displaySleeptimer,50,2,DrawStyle::LIGHTTEXT);
236 Timers::getInstance()->setTimerD(this, 1, 2);
239 void VSleeptimer::timercall(int clientReference)
242 Message* m = new Message(); // Delete self
243 m->message = Message::CLOSE_ME;
244 m->to = BoxStack::getInstance();
246 MessageQueue::getInstance()->postMessageFromOuterSpace(m);
249 int VSleeptimer::handleCommand(int command)
255 displaySleeptimer = Sleeptimer::getInstance()->SetTime();
257 BoxStack::getInstance()->update(this);
263 // allow command to drop through to other views
270 VCountdown::VCountdown()
275 if (Video::getInstance()->getFormat() == Video::PAL)
277 setPosition(100, 499);
281 setPosition(90, 400);
285 VCountdown::~VCountdown()
287 // Make sure the timer is deleted
288 Timers::getInstance()->cancelTimer(this, 1);
291 void VCountdown::drawClock(const char* sec)
294 fillColour(DrawStyle::VIEWBACKGROUND);
297 w.nextSymbol = WSymbol::CLOCK;
298 w.nextColour = DrawStyle::RED;
303 drawText(sec,50,2,DrawStyle::RED);
304 Timers::getInstance()->setTimerD(this, 1, 1);
307 void VCountdown::timercall(int clientReference)
310 Message* m = new Message(); // Delete self
311 m->message = Message::CLOSE_ME;
312 m->to = BoxStack::getInstance();
314 MessageQueue::getInstance()->postMessageFromOuterSpace(m);