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, see <https://www.gnu.org/licenses/>.
20 #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((time_t*)&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((time_t*)&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)
177 ViewMan::getInstance()->updateView(this);
184 ViewMan::getInstance()->updateView(this);
189 case Input::DF_RIGHT:
194 BoxStack::getInstance()->update(this);
203 BoxStack::getInstance()->update(this);
209 if (selectedButton == 0) return 4;
211 VQuestion* v = new VQuestion(this);
212 v->setSize(260, 180);
214 v->setTitleBarColour(DrawStyle::DANGER);
217 v->setTitleText(tr("Delete timer"));
218 v->setMainText(tr("Are you sure you want to delete this timer?"));
219 v->setDefault(VQuestion::NO);
220 if (Video::getInstance()->getFormat() == Video::PAL)
221 v->setPosition(230, 160);
223 v->setPosition(220, 140);
225 BoxStack::getInstance()->add(v);
226 BoxStack::getInstance()->update(v);
234 // stop command getting to any more views
238 void VTimerEdit::processMessage(Message* m)
240 if (m->message == Message::MOUSE_MOVE)
242 int x=(m->parameter>>16)-getScreenX();
243 int y=(m->parameter&0xFFFF)-getScreenY();
244 if (buttonBack.mouseMove(x,y)) {
246 buttonDelete.setActive(false);
249 BoxStack::getInstance()->update(this);
250 } else if (buttonDelete.mouseMove(x,y)) {
252 buttonBack.setActive(false);
255 BoxStack::getInstance()->update(this);
258 } else if (m->message == Message::MOUSE_LBDOWN)
260 BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
262 else if (m->message == Message::QUESTION_YES)
264 if (selectedButton == 1)
266 Message* m2 = new Message(); // Delete self
268 m2->to = BoxStack::getInstance();
269 m2->message = Message::CLOSE_ME;
270 MessageQueue::getInstance()->postMessage(m2);
272 m2 = new Message(); // OK. Want this to delete before this message does its job
275 m2->message = Message::DELETE_SELECTED_TIMER;
276 MessageQueue::getInstance()->postMessage(m2);