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"
33 #include "staticartwork.h"
35 VTimerEdit::VTimerEdit(RecTimer* trt)
41 if (Video::getInstance()->getFormat() == Video::PAL)
50 buttonBack.setPosition(30,350);
51 buttonDelete.setPosition(400,350);
52 buttonBack.setText(tr("Back"));
53 buttonBack.setActive(1);
54 buttonDelete.setText(tr("Delete"));
59 setTitleText(tr("Edit Timer"));
60 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
61 TVMediaInfo *info= new TVMediaInfo();
62 info->setStaticArtwork(sa_timers);
63 setTitleBarIcon(info);
66 VTimerEdit::~VTimerEdit()
70 void VTimerEdit::setParent(VTimerList* tvTimerList)
72 vTimerList = tvTimerList;
75 void VTimerEdit::draw()
81 int fontheight=getFontHeight();
82 drawText(tr("Active"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
83 drawText(tr("Channel"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
84 drawText(tr("Name"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
85 drawText(tr("Directory"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
87 drawText(tr("Start"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
88 drawText(tr("Stop"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
89 drawText(tr("Priority"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
90 drawText(tr("Lifetime"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
92 drawText(tr("Current"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
93 drawText(tr("Recording"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
103 if (recTimer->active) strcpy(buffer, tr("Yes"));
104 else strcpy(buffer, tr("No"));
105 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
108 SNPRINTF(buffer, 999, "%lu", recTimer->channelNumber);
109 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
112 SNPRINTF(buffer, 999, "%s", recTimer->getName());
113 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
116 if (recTimer->getDirectory()) SNPRINTF(buffer, 999, "%s", recTimer->getDirectory());
117 else strcpy(buffer, "");
118 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
122 time_t rectime = recTimer->startTime;
123 LOCALTIME_R((time_t*)&rectime, &tms);
124 strftime(buffer, 999, "%d/%m %H:%M", &tms);
125 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
128 rectime = recTimer->startTime;
129 LOCALTIME_R((time_t*)&rectime, &tms);
130 strftime(buffer, 999, "%d/%m %H:%M", &tms);
131 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
134 SNPRINTF(buffer, 999, "%lu", recTimer->priority);
135 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
138 SNPRINTF(buffer, 999, "%lu", recTimer->lifeTime);
139 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
143 if (recTimer->pending) strcpy(buffer, tr("Yes"));
144 else strcpy(buffer, tr("No"));
145 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
148 if (recTimer->recording) strcpy(buffer, "Yes");
149 else strcpy(buffer, "No");
150 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
153 void VTimerEdit::swap()
155 if (selectedButton == 0)
157 buttonBack.setActive(0);
158 buttonDelete.setActive(1);
163 buttonDelete.setActive(0);
164 buttonBack.setActive(1);
169 int VTimerEdit::handleCommand(int command)
178 ViewMan::getInstance()->updateView(this);
181 case Remote::DF_DOWN:
185 ViewMan::getInstance()->updateView(this);
190 case Remote::DF_RIGHT:
195 BoxStack::getInstance()->update(this);
199 case Remote::DF_LEFT:
204 BoxStack::getInstance()->update(this);
210 if (selectedButton == 0) return 4;
212 VQuestion* v = new VQuestion(this);
213 v->setSize(260, 180);
215 v->setTitleBarColour(DrawStyle::DANGER);
218 v->setTitleText(tr("Delete timer"));
219 v->setMainText(tr("Are you sure you want to delete this timer?"));
220 v->setDefault(VQuestion::NO);
221 if (Video::getInstance()->getFormat() == Video::PAL)
222 v->setPosition(230, 160);
224 v->setPosition(220, 140);
226 BoxStack::getInstance()->add(v);
227 BoxStack::getInstance()->update(v);
235 // stop command getting to any more views
239 void VTimerEdit::processMessage(Message* m)
241 if (m->message == Message::MOUSE_MOVE)
243 int x=(m->parameter.num>>16)-getScreenX();
244 int y=(m->parameter.num&0xFFFF)-getScreenY();
245 if (buttonBack.mouseMove(x,y)) {
247 buttonDelete.setActive(false);
250 BoxStack::getInstance()->update(this);
251 } else if (buttonDelete.mouseMove(x,y)) {
253 buttonBack.setActive(false);
256 BoxStack::getInstance()->update(this);
259 } else if (m->message == Message::MOUSE_LBDOWN)
261 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
263 else if (m->message == Message::QUESTION_YES)
265 if (selectedButton == 1)
267 Message* m2 = new Message(); // Delete self
269 m2->to = BoxStack::getInstance();
270 m2->message = Message::CLOSE_ME;
271 Command::getInstance()->postMessageNoLock(m2);
273 m2 = new Message(); // OK. Want this to delete before this message does its job
276 m2->message = Message::DELETE_SELECTED_TIMER;
277 Command::getInstance()->postMessageNoLock(m2);