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(RecTimerList* trtl)
33 if (Video::getInstance()->getFormat() == Video::PAL)
43 setBackgroundColour(Colour::VIEWBACKGROUND);
45 setTitleText(tr("Timers"));
46 setTitleBarColour(Colour::TITLEBARBACKGROUND);
48 sl.setSurface(surface);
49 sl.setSurfaceOffset(10, 30 + 5);
50 sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
57 w.setSurface(surface);
59 w.nextSymbol = WSymbol::UP;
60 w.setSurfaceOffset(20, 385);
63 w.nextSymbol = WSymbol::DOWN;
64 w.setSurfaceOffset(50, 385);
67 w.nextSymbol = WSymbol::SKIPBACK;
68 w.setSurfaceOffset(85, 385);
71 w.nextSymbol = WSymbol::SKIPFORWARD;
72 w.setSurfaceOffset(115, 385);
75 drawTextRJ("[ok] = edit", 560, 385, Colour::LIGHTTEXT);
84 VTimerList::~VTimerList()
86 Timers::getInstance()->cancelTimer(this, 1);
89 for (UINT i = 0; i < recTimerList->size(); i++)
91 delete (*recTimerList)[i];
94 recTimerList->clear();
99 void VTimerList::insertData()
107 // FIXME all drawing stuff in this class and sl.clear somewhere?!
115 for (UINT i = 0; i < recTimerList->size(); i++)
117 recTimer = (*recTimerList)[i];
118 if (recTimer->recording)
122 else if (recTimer->pending)
126 else if (recTimer->active == 0)
135 btime = localtime((time_t*)&recTimer->startTime);
136 strftime(strA, 299, "%d/%m %H:%M ", btime);
137 snprintf(strB, 299, "%c %s\t%s", status, strA, recTimer->getName());
138 recTimer->index = sl.addOption(strB, first);
143 void VTimerList::drawClock()
145 // Blank the area first
146 rectangle(area.w - 150, 0, 150, 30, titleBarColour);
151 struct tm* tms = localtime(&t);
152 strftime(timeString, 19, "%d/%m %H:%M:%S", tms);
153 drawTextRJ(timeString, 560, 5, Colour::LIGHTTEXT);
155 Timers::getInstance()->setTimer(this, 1, t + 1);
158 void VTimerList::drawShowing()
160 int topOption = sl.getTopOption() + 1;
161 if (sl.getNumOptions() == 0) topOption = 0;
163 rectangle(220, 385, 180, 25, Colour::VIEWBACKGROUND);
165 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
166 drawText(showing, 220, 385, Colour::LIGHTTEXT);
169 void VTimerList::timercall(int clientReference)
172 ViewMan::getInstance()->updateView(this, &clockRegion);
175 int VTimerList::handleCommand(int command)
185 ViewMan::getInstance()->updateView(this);
188 case Remote::DF_DOWN:
194 ViewMan::getInstance()->updateView(this);
197 case Remote::SKIPBACK:
202 ViewMan::getInstance()->updateView(this);
205 case Remote::SKIPFORWARD:
210 ViewMan::getInstance()->updateView(this);
215 RecTimer* recTimer = NULL;
218 int currentOption = sl.getCurrentOption();
220 for (UINT i = 0; i < recTimerList->size(); i++)
222 recTimer = (*recTimerList)[i];
223 if (currentOption == recTimer->index) break;
227 if (recTimer == NULL) return 2;
229 VTimerEdit* v = new VTimerEdit(recTimer);
230 ViewMan::getInstance()->add(v);
231 ViewMan::getInstance()->updateView(v);
240 // stop command getting to any more views