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)
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);
92 VTimerList::~VTimerList()
94 Timers::getInstance()->cancelTimer(this, 1);
97 for (UINT i = 0; i < recTimerList->size(); i++)
99 delete (*recTimerList)[i];
102 recTimerList->clear();
107 void VTimerList::insertData()
114 // FIXME all drawing stuff in this class and sl.clear somewhere?!
122 for (UINT i = 0; i < recTimerList->size(); i++)
124 recTimer = (*recTimerList)[i];
126 btime = localtime((time_t*)&recTimer->startTime);
127 strftime(strA, 299, "%d/%m %H:%M ", btime);
128 SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName());
129 sl.addOption(strB, (ULONG)recTimer, first);
134 void VTimerList::drawClock()
136 // Blank the area first
137 rectangle(area.w - 150, 0, 150, 30, titleBarColour);
142 struct tm* tms = localtime(&t);
143 strftime(timeString, 19, "%d/%m %H:%M:%S", tms);
144 drawTextRJ(timeString, 560, 5, Colour::LIGHTTEXT);
146 Timers::getInstance()->setTimerT(this, 1, t + 1);
149 void VTimerList::drawShowing()
151 int topOption = sl.getTopOption() + 1;
152 if (sl.getNumOptions() == 0) topOption = 0;
154 rectangle(220, 385, 180, 25, Colour::VIEWBACKGROUND);
156 sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
157 drawText(showing, 220, 385, Colour::LIGHTTEXT);
160 void VTimerList::drawIndicators()
162 int top = sl.getTopOption();
163 int bottom = sl.getBottomOption();
164 int yinc = surface->getFontHeight() + 1;
167 rectangle(6, 44, 18, 15*yinc, Colour::VIEWBACKGROUND);
169 // The indexes recorded from the wselectlist into the index member of the RecTimer
170 // Is the same as the position in the vector of RecTimers
171 // Because they are in order, they don't change order and wselectlist starts from 0 up consecutively
174 for (int current = top; current < bottom; current++)
176 recTimer = (*recTimerList)[current];
178 if (recTimer->recording) // Flashing red square
182 //rectangle(6, ypos, 18, 16, Colour::RED);
183 rectangle(6, ypos, 18, 16, Colour::RED);
184 drawText("R", 8, ypos-3, Colour::LIGHTTEXT);
187 else if (recTimer->pending)
189 rectangle(6, ypos, 18, 16, Colour::RED);
190 drawText("X", 8, ypos-3, Colour::BLACK);
192 else if (recTimer->active == 0)
194 rectangle(6, ypos, 18, 16, Colour::SELECTHIGHLIGHT);
195 drawText("X", 8, ypos-3, Colour::BLACK);
199 // if (flipflop) rectangle(6, ypos, 18, 16, Colour::GREEN);
206 void VTimerList::timercall(int clientReference)
209 ViewMan::getInstance()->updateView(this, &clockRegion);
211 flipflop = !flipflop;
213 ViewMan::getInstance()->updateView(this, &indicatorsRegion);
216 int VTimerList::handleCommand(int command)
227 ViewMan::getInstance()->updateView(this);
230 case Remote::DF_DOWN:
237 ViewMan::getInstance()->updateView(this);
240 case Remote::SKIPBACK:
246 ViewMan::getInstance()->updateView(this);
249 case Remote::SKIPFORWARD:
255 ViewMan::getInstance()->updateView(this);
260 RecTimer* recTimer = NULL;
261 if (recTimerList) recTimer = (RecTimer*)sl.getCurrentOptionData();
263 // int currentOption = sl.getCurrentOption();
265 // for (UINT i = 0; i < recTimerList->size(); i++)
267 // recTimer = (*recTimerList)[i];
268 // if (currentOption == recTimer->index) break;
272 if (recTimer == NULL) return 2;
274 VTimerEdit* v = new VTimerEdit(recTimer);
275 ViewMan::getInstance()->add(v);
276 ViewMan::getInstance()->updateView(v);
285 // stop command getting to any more views
289 void VTimerList::processMessage(Message* m)
291 if (m->message == Message::MOUSE_MOVE)
293 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
296 ViewMan::getInstance()->updateView(this);
299 else if (m->message == Message::MOUSE_LBDOWN)
301 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
303 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
307 //check if press is outside this view! then simulate cancel
308 int x=(m->parameter>>16)-getScreenX();
309 int y=(m->parameter&0xFFFF)-getScreenY();
310 if (x<0 || y <0 || x>getWidth() || y>getHeight())
312 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press