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 "vtimeredit.h"
31 #include "vquestion.h"
34 VTimerEdit::VTimerEdit(RecTimer* trt)
40 if (Video::getInstance()->getFormat() == Video::PAL)
49 buttonBack.setPosition(30,350);
50 buttonDelete.setPosition(400,350);
51 buttonBack.setText("Back");
52 buttonBack.setActive(1);
53 buttonDelete.setText("Delete");
58 setTitleText(tr("Edit Timer"));
59 setTitleBarColour(Colour::TITLEBARBACKGROUND);
62 VTimerEdit::~VTimerEdit()
66 void VTimerEdit::setParent(VTimerList* tvTimerList)
68 vTimerList = tvTimerList;
71 void VTimerEdit::draw()
77 drawText(tr("Active"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
78 drawText(tr("Channel"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
79 drawText(tr("Name"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
80 drawText(tr("Directory"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
81 ypos += surface->getFontHeight();
82 drawText(tr("Start"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
83 drawText(tr("Stop"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
84 drawText(tr("Priority"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
85 drawText(tr("Lifetime"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
86 ypos += surface->getFontHeight();
87 drawText(tr("Current"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
88 drawText(tr("Recording"), xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
98 if (recTimer->active) strcpy(buffer, "Yes");
99 else strcpy(buffer, "No");
100 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
103 SNPRINTF(buffer, 999, "%lu", recTimer->channelNumber);
104 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
107 SNPRINTF(buffer, 999, "%s", recTimer->getName());
108 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
111 if (recTimer->getDirectory()) SNPRINTF(buffer, 999, "%s", recTimer->getDirectory());
112 else strcpy(buffer, "");
113 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
114 ypos += surface->getFontHeight();
117 tms = localtime((time_t*)&recTimer->startTime);
118 strftime(buffer, 999, "%d/%m %H:%M", tms);
119 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
122 tms = localtime((time_t*)&recTimer->stopTime);
123 strftime(buffer, 999, "%d/%m %H:%M", tms);
124 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
127 SNPRINTF(buffer, 999, "%lu", recTimer->priority);
128 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
131 SNPRINTF(buffer, 999, "%lu", recTimer->lifeTime);
132 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
133 ypos += surface->getFontHeight();
136 if (recTimer->pending) strcpy(buffer, "Yes");
137 else strcpy(buffer, "No");
138 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
141 if (recTimer->recording) strcpy(buffer, "Yes");
142 else strcpy(buffer, "No");
143 drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight();
146 void VTimerEdit::swap()
148 if (selectedButton == 0)
150 buttonBack.setActive(0);
151 buttonDelete.setActive(1);
156 buttonDelete.setActive(0);
157 buttonBack.setActive(1);
162 int VTimerEdit::handleCommand(int command)
171 ViewMan::getInstance()->updateView(this);
174 case Remote::DF_DOWN:
178 ViewMan::getInstance()->updateView(this);
183 case Remote::DF_RIGHT:
188 BoxStack::getInstance()->update(this);
192 case Remote::DF_LEFT:
197 BoxStack::getInstance()->update(this);
203 if (selectedButton == 0) return 4;
205 VQuestion* v = new VQuestion(this);
206 v->setSize(260, 180);
208 v->setTitleBarColour(Colour::DANGER);
211 v->setTitleText("Delete timer");
212 v->setMainText("Are you sure you want to delete this timer?");
213 v->setDefault(VQuestion::NO);
214 if (Video::getInstance()->getFormat() == Video::PAL)
215 v->setPosition(230, 160);
217 v->setPosition(220, 140);
219 BoxStack::getInstance()->add(v);
220 BoxStack::getInstance()->update(v);
228 // stop command getting to any more views
232 void VTimerEdit::processMessage(Message* m)
234 if (m->message == Message::MOUSE_MOVE)
236 int x=(m->parameter>>16)-getScreenX();
237 int y=(m->parameter&0xFFFF)-getScreenY();
238 if (buttonBack.mouseMove(x,y)) {
240 buttonDelete.setActive(false);
243 BoxStack::getInstance()->update(this);
244 } else if (buttonDelete.mouseMove(x,y)) {
246 buttonBack.setActive(false);
249 BoxStack::getInstance()->update(this);
252 } else if (m->message == Message::MOUSE_LBDOWN)
254 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
256 else if (m->message == Message::QUESTION_YES)
258 if (selectedButton == 1)
260 Message* m2 = new Message(); // Delete self
262 m2->to = BoxStack::getInstance();
263 m2->message = Message::CLOSE_ME;
264 Command::getInstance()->postMessageNoLock(m2);
266 m2 = new Message(); // OK. Want this to delete before this message does its job
269 m2->message = Message::DELETE_SELECTED_TIMER;
270 Command::getInstance()->postMessageNoLock(m2);