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
21 #include "vtimerlist.h"
23 VTimerList::VTimerList()
32 indicatorsRegion.x = 6;
33 indicatorsRegion.y = 44;
34 indicatorsRegion.w = 18;
35 indicatorsRegion.h = 15 * (surface->getFontHeight() + 1);
40 if (Video::getInstance()->getFormat() == Video::PAL)
50 setBackgroundColour(Colour::VIEWBACKGROUND);
52 setTitleText(tr("Timers"));
53 setTitleBarColour(Colour::TITLEBARBACKGROUND);
55 sl.setSurface(surface);
56 sl.setSurfaceOffset(30, 30 + 5);
57 sl.setDimensions(area.w - 40, area.h - 30 - 15 - 30);
64 w.setSurface(surface);
66 w.nextSymbol = WSymbol::UP;
67 w.setSurfaceOffset(20, 385);
70 w.nextSymbol = WSymbol::DOWN;
71 w.setSurfaceOffset(50, 385);
74 w.nextSymbol = WSymbol::SKIPBACK;
75 w.setSurfaceOffset(85, 385);
78 w.nextSymbol = WSymbol::SKIPFORWARD;
79 w.setSurfaceOffset(115, 385);
82 drawTextRJ("[ok] = edit", 560, 385, Colour::LIGHTTEXT);
87 VTimerList::~VTimerList()
89 Timers::getInstance()->cancelTimer(this, 1);
92 for (UINT i = 0; i < recTimerList->size(); i++)
94 delete (*recTimerList)[i];
97 recTimerList->clear();
102 bool VTimerList::load()
104 recTimerList = VDR::getInstance()->getRecTimersList();
106 if (!recTimerList) return false;
113 // FIXME all drawing stuff in this class and sl.clear somewhere?!
121 for (UINT i = 0; i < recTimerList->size(); i++)
123 recTimer = (*recTimerList)[i];
125 btime = localtime((time_t*)&recTimer->startTime);
126 strftime(strA, 299, "%d/%m %H:%M ", btime);
127 SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName());
128 sl.addOption(strB, (ULONG)recTimer, first);
135 ViewMan::getInstance()->updateView(this);
139 void VTimerList::drawClock()
141 // Blank the area first
142 rectangle(area.w - 150, 0, 150, 30, titleBarColour);
147 struct tm* tms = localtime(&t);
148 strftime(timeString, 19, "%d/%m %H:%M:%S", tms);
149 drawTextRJ(timeString, 560, 5, Colour::LIGHTTEXT);
151 Timers::getInstance()->setTimerT(this, 1, t + 1);
154 void VTimerList::drawShowing()
156 int topOption = sl.getTopOption() + 1;
157 if (sl.getNumOptions() == 0) topOption = 0;
159 rectangle(220, 385, 180, 25, Colour::VIEWBACKGROUND);
161 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
162 drawText(showing, 220, 385, Colour::LIGHTTEXT);
165 void VTimerList::drawIndicators()
167 int top = sl.getTopOption();
168 int bottom = sl.getBottomOption();
169 int yinc = surface->getFontHeight() + 1;
172 rectangle(6, 44, 18, 15*yinc, Colour::VIEWBACKGROUND);
174 // The indexes recorded from the wselectlist into the index member of the RecTimer
175 // Is the same as the position in the vector of RecTimers
176 // Because they are in order, they don't change order and wselectlist starts from 0 up consecutively
179 for (int current = top; current < bottom; current++)
181 recTimer = (*recTimerList)[current];
183 if (recTimer->recording) // Flashing red square
187 //rectangle(6, ypos, 18, 16, Colour::RED);
188 rectangle(6, ypos, 18, 16, Colour::RED);
189 drawText("R", 8, ypos-3, Colour::LIGHTTEXT);
192 else if (recTimer->pending)
194 rectangle(6, ypos, 18, 16, Colour::RED);
195 drawText("X", 8, ypos-3, Colour::BLACK);
197 else if (recTimer->active == 0)
199 rectangle(6, ypos, 18, 16, Colour::SELECTHIGHLIGHT);
200 drawText("X", 8, ypos-3, Colour::BLACK);
204 // if (flipflop) rectangle(6, ypos, 18, 16, Colour::GREEN);
211 void VTimerList::timercall(int clientReference)
215 Message* m = new Message();
216 m->message = Message::REDRAW;
217 m->to = ViewMan::getInstance();
219 m->parameter = (ULONG)&clockRegion;
220 Command::getInstance()->postMessageFromOuterSpace(m);
222 flipflop = !flipflop;
226 m->message = Message::REDRAW;
227 m->to = ViewMan::getInstance();
229 m->parameter = (ULONG)&indicatorsRegion;
230 Command::getInstance()->postMessageFromOuterSpace(m);
233 int VTimerList::handleCommand(int command)
244 ViewMan::getInstance()->updateView(this);
247 case Remote::DF_DOWN:
254 ViewMan::getInstance()->updateView(this);
257 case Remote::SKIPBACK:
263 ViewMan::getInstance()->updateView(this);
266 case Remote::SKIPFORWARD:
272 ViewMan::getInstance()->updateView(this);
277 RecTimer* recTimer = NULL;
278 if (recTimerList) recTimer = (RecTimer*)sl.getCurrentOptionData();
280 // int currentOption = sl.getCurrentOption();
282 // for (UINT i = 0; i < recTimerList->size(); i++)
284 // recTimer = (*recTimerList)[i];
285 // if (currentOption == recTimer->index) break;
289 if (recTimer == NULL) return 2;
291 VTimerEdit* v = new VTimerEdit(recTimer);
292 ViewMan::getInstance()->add(v);
293 ViewMan::getInstance()->updateView(v);
302 // stop command getting to any more views
306 void VTimerList::processMessage(Message* m)
308 if (m->message == Message::MOUSE_MOVE)
310 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
313 ViewMan::getInstance()->updateView(this);
316 else if (m->message == Message::MOUSE_LBDOWN)
318 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
320 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
324 //check if press is outside this view! then simulate cancel
325 int x=(m->parameter>>16)-getScreenX();
326 int y=(m->parameter&0xFFFF)-getScreenY();
327 if (x<0 || y <0 || x>getWidth() || y>getHeight())
329 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press