3 Copyright 2004-2005 Chris Tallon
5 This file is part of VOMP.
7 VOMP is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 VOMP is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
21 #include "vtimeredit.h"
30 #include "vquestion.h"
31 #include "messagequeue.h"
32 #include "staticartwork.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);
60 TVMediaInfo *info= new TVMediaInfo();
61 info->setStaticArtwork(sa_timers);
62 setTitleBarIcon(info);
65 VTimerEdit::~VTimerEdit()
69 void VTimerEdit::setParent(VTimerList* tvTimerList)
71 vTimerList = tvTimerList;
74 void VTimerEdit::draw()
80 int fontheight=getFontHeight();
81 drawText(tr("Active"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
82 drawText(tr("Channel"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
83 drawText(tr("Name"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
84 drawText(tr("Directory"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
86 drawText(tr("Start"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
87 drawText(tr("Stop"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
88 drawText(tr("Priority"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
89 drawText(tr("Lifetime"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
91 drawText(tr("Current"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
92 drawText(tr("Recording"), xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
102 if (recTimer->active) strcpy(buffer, tr("Yes"));
103 else strcpy(buffer, tr("No"));
104 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
107 SNPRINTF(buffer, 999, "%lu", recTimer->channelNumber);
108 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
111 SNPRINTF(buffer, 999, "%s", recTimer->getName());
112 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
115 if (recTimer->getDirectory()) SNPRINTF(buffer, 999, "%s", recTimer->getDirectory());
116 else strcpy(buffer, "");
117 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
121 time_t rectime = recTimer->startTime;
122 LOCALTIME_R(&rectime, &tms);
123 strftime(buffer, 999, "%d/%m %H:%M", &tms);
124 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
127 rectime = recTimer->stopTime;
128 LOCALTIME_R(&rectime, &tms);
129 strftime(buffer, 999, "%d/%m %H:%M", &tms);
130 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
133 SNPRINTF(buffer, 999, "%lu", recTimer->priority);
134 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
137 SNPRINTF(buffer, 999, "%lu", recTimer->lifeTime);
138 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
142 if (recTimer->pending) strcpy(buffer, tr("Yes"));
143 else strcpy(buffer, tr("No"));
144 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
147 if (recTimer->recording) strcpy(buffer, "Yes");
148 else strcpy(buffer, "No");
149 drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT); ypos += fontheight;
152 void VTimerEdit::swap()
154 if (selectedButton == 0)
156 buttonBack.setActive(0);
157 buttonDelete.setActive(1);
162 buttonDelete.setActive(0);
163 buttonBack.setActive(1);
168 int VTimerEdit::handleCommand(int command)
176 ViewMan::getInstance()->updateView(this);
182 ViewMan::getInstance()->updateView(this);
191 BoxStack::getInstance()->update(this);
199 BoxStack::getInstance()->update(this);
205 if (selectedButton == 0) return 4;
207 VQuestion* v = new VQuestion(this);
208 v->setSize(260, 180);
210 v->setTitleBarColour(DrawStyle::DANGER);
213 v->setTitleText(tr("Delete timer"));
214 v->setMainText(tr("Are you sure you want to delete this timer?"));
215 v->setDefault(VQuestion::NO);
216 if (Video::getInstance()->getFormat() == Video::PAL)
217 v->setPosition(230, 160);
219 v->setPosition(220, 140);
221 BoxStack::getInstance()->add(v);
222 BoxStack::getInstance()->update(v);
230 // stop command getting to any more views
234 void VTimerEdit::processMessage(Message* m)
236 if (m->message == Message::MOUSE_MOVE)
238 int x=(m->parameter>>16)-getScreenX();
239 int y=(m->parameter&0xFFFF)-getScreenY();
240 if (buttonBack.mouseMove(x,y)) {
242 buttonDelete.setActive(false);
245 BoxStack::getInstance()->update(this);
246 } else if (buttonDelete.mouseMove(x,y)) {
248 buttonBack.setActive(false);
251 BoxStack::getInstance()->update(this);
254 } else if (m->message == Message::MOUSE_LBDOWN)
256 BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
258 else if (m->message == Message::QUESTION_YES)
260 if (selectedButton == 1)
262 Message* m2 = new Message(); // Delete self
264 m2->to = BoxStack::getInstance();
265 m2->message = Message::CLOSE_ME;
266 MessageQueue::getInstance()->postMessage(m2);
268 m2 = new Message(); // OK. Want this to delete before this message does its job
271 m2->message = Message::DELETE_SELECTED_TIMER;
272 MessageQueue::getInstance()->postMessage(m2);