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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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(tr("Back"));
52 buttonBack.setActive(1);
53 buttonDelete.setText(tr("Delete"));
58 setTitleText(tr("Edit Timer"));
59 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
62 VTimerEdit::~VTimerEdit()
66 void VTimerEdit::setParent(VTimerList* tvTimerList)
68 vTimerList = tvTimerList;
71 void VTimerEdit::draw()
77 int fontheight=getFontHeight();
78 drawText(tr("Active"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
79 drawText(tr("Channel"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
80 drawText(tr("Name"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
81 drawText(tr("Directory"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
83 drawText(tr("Start"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
84 drawText(tr("Stop"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
85 drawText(tr("Priority"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
86 drawText(tr("Lifetime"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
88 drawText(tr("Current"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
89 drawText(tr("Recording"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
99 if (recTimer->active) strcpy(buffer, tr("Yes"));
100 else strcpy(buffer, tr("No"));
101 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
104 SNPRINTF(buffer, 999, "%lu", recTimer->channelNumber);
105 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
108 SNPRINTF(buffer, 999, "%s", recTimer->getName());
109 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
112 if (recTimer->getDirectory()) SNPRINTF(buffer, 999, "%s", recTimer->getDirectory());
113 else strcpy(buffer, "");
114 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
118 tms = localtime((time_t*)&recTimer->startTime);
119 strftime(buffer, 999, "%d/%m %H:%M", tms);
120 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
123 tms = localtime((time_t*)&recTimer->stopTime);
124 strftime(buffer, 999, "%d/%m %H:%M", tms);
125 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
128 SNPRINTF(buffer, 999, "%lu", recTimer->priority);
129 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
132 SNPRINTF(buffer, 999, "%lu", recTimer->lifeTime);
133 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
137 if (recTimer->pending) strcpy(buffer, tr("Yes"));
138 else strcpy(buffer, tr("No"));
139 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
142 if (recTimer->recording) strcpy(buffer, "Yes");
143 else strcpy(buffer, "No");
144 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
147 void VTimerEdit::swap()
149 if (selectedButton == 0)
151 buttonBack.setActive(0);
152 buttonDelete.setActive(1);
157 buttonDelete.setActive(0);
158 buttonBack.setActive(1);
163 int VTimerEdit::handleCommand(int command)
172 ViewMan::getInstance()->updateView(this);
175 case Remote::DF_DOWN:
179 ViewMan::getInstance()->updateView(this);
184 case Remote::DF_RIGHT:
189 BoxStack::getInstance()->update(this);
193 case Remote::DF_LEFT:
198 BoxStack::getInstance()->update(this);
204 if (selectedButton == 0) return 4;
206 VQuestion* v = new VQuestion(this);
207 v->setSize(260, 180);
209 v->setTitleBarColour(DrawStyle::DANGER);
212 v->setTitleText(tr("Delete timer"));
213 v->setMainText(tr("Are you sure you want to delete this timer?"));
214 v->setDefault(VQuestion::NO);
215 if (Video::getInstance()->getFormat() == Video::PAL)
216 v->setPosition(230, 160);
218 v->setPosition(220, 140);
220 BoxStack::getInstance()->add(v);
221 BoxStack::getInstance()->update(v);
229 // stop command getting to any more views
233 void VTimerEdit::processMessage(Message* m)
235 if (m->message == Message::MOUSE_MOVE)
237 int x=(m->parameter>>16)-getScreenX();
238 int y=(m->parameter&0xFFFF)-getScreenY();
239 if (buttonBack.mouseMove(x,y)) {
241 buttonDelete.setActive(false);
244 BoxStack::getInstance()->update(this);
245 } else if (buttonDelete.mouseMove(x,y)) {
247 buttonBack.setActive(false);
250 BoxStack::getInstance()->update(this);
253 } else if (m->message == Message::MOUSE_LBDOWN)
255 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
257 else if (m->message == Message::QUESTION_YES)
259 if (selectedButton == 1)
261 Message* m2 = new Message(); // Delete self
263 m2->to = BoxStack::getInstance();
264 m2->message = Message::CLOSE_ME;
265 Command::getInstance()->postMessageNoLock(m2);
267 m2 = new Message(); // OK. Want this to delete before this message does its job
270 m2->message = Message::DELETE_SELECTED_TIMER;
271 Command::getInstance()->postMessageNoLock(m2);