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"
31 Sleeptimer* Sleeptimer::instance = NULL;
33 Sleeptimer::Sleeptimer()
42 Sleeptimer::~Sleeptimer()
48 const char* Sleeptimer::SetTime()
149 Sleeptimer* Sleeptimer::getInstance()
154 void Sleeptimer::threadMethod()
157 while (sec>-1 && active==true)
160 if (sec<31 && sec>-1)
162 VCountdown* count = new VCountdown();
163 char* temp = (char*)malloc(20);
164 sprintf(temp, "0:%02d", sec);
167 Message* m1 = new Message();
168 m1->message = Message::ADD_VIEW;
169 m1->to = BoxStack::getInstance();
170 m1->parameter = (ULONG)count;
171 Command::getInstance()->postMessageNoLock(m1);
178 Message* m2 = new Message(); // Delete self
179 m2->message = Message::UDP_BUTTON;
180 m2->to = Command::getInstance();
183 Command::getInstance()->postMessageFromOuterSpace(m2);
192 void Sleeptimer::shutdown()
204 VSleeptimer::VSleeptimer()
208 if (Video::getInstance()->getFormat() == Video::PAL)
210 setPosition(100, 499);
214 setPosition(90, 400);
218 VSleeptimer::~VSleeptimer()
220 // Make sure the timer is deleted
221 Timers::getInstance()->cancelTimer(this, 1);
224 void VSleeptimer::draw()
226 fillColour(DrawStyle::VIEWBACKGROUND);
229 w.nextSymbol = WSymbol::CLOCK;
234 drawText(displaySleeptimer,50,2,DrawStyle::LIGHTTEXT);
235 Timers::getInstance()->setTimerD(this, 1, 2);
238 void VSleeptimer::timercall(int clientReference)
241 Message* m = new Message(); // Delete self
242 m->message = Message::CLOSE_ME;
243 m->to = BoxStack::getInstance();
245 Command::getInstance()->postMessageFromOuterSpace(m);
248 int VSleeptimer::handleCommand(int command)
254 displaySleeptimer = Sleeptimer::getInstance()->SetTime();
256 BoxStack::getInstance()->update(this);
262 // allow command to drop through to other views
269 VCountdown::VCountdown()
274 if (Video::getInstance()->getFormat() == Video::PAL)
276 setPosition(100, 499);
280 setPosition(90, 400);
284 VCountdown::~VCountdown()
286 // Make sure the timer is deleted
287 Timers::getInstance()->cancelTimer(this, 1);
290 void VCountdown::draw(const char* sec)
293 fillColour(DrawStyle::VIEWBACKGROUND);
296 w.nextSymbol = WSymbol::CLOCK;
297 w.nextColour = DrawStyle::RED;
302 drawText(sec,50,2,DrawStyle::RED);
303 Timers::getInstance()->setTimerD(this, 1, 1);
306 void VCountdown::timercall(int clientReference)
309 Message* m = new Message(); // Delete self
310 m->message = Message::CLOSE_ME;
311 m->to = BoxStack::getInstance();
313 Command::getInstance()->postMessageFromOuterSpace(m);