2 Copyright 2004-2008 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 "vrecording.h"
25 #include "vquestion.h"
35 #include "vrecordinglist.h"
36 #include "recording.h"
40 VRecording::VRecording(RecMan* trecman, Recording* trec)
45 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
47 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
51 if (Video::getInstance()->getFormat() == Video::PAL)
62 setTitleText(rec->getProgName());
63 setTitleBarColour(Colour::TITLEBARBACKGROUND);
65 summary.setPosition(10, 30 + 5);
66 summary.setSize(area.w - 20, area.h - 30 - 15 - 50);
67 summary.setParaMode(true);
69 if (strlen(rec->recInfo->summary))
70 summary.setText(rec->recInfo->summary);
72 summary.setText(tr("Summary unavailable"));
77 buttonPlay.setPosition(70, area.h - 40);
78 buttonResume.setPosition(180, area.h - 40);
79 buttonMove.setPosition(290, area.h - 40);
80 buttonDelete.setPosition(400, area.h - 40);
83 buttonRegion.y = area.h - 40;
85 buttonRegion.h = Surface::getFontHeight();
87 buttonPlay.setText(tr("Play"));
88 buttonResume.setText(tr("Resume"));
89 buttonMove.setText(tr("Move"));
90 buttonDelete.setText(tr("Delete"));
97 buttonPlay.setActive(1);
101 VRecording::~VRecording()
105 void VRecording::setParent(VRecordingList* tvRecList)
107 vRecList = tvRecList;
110 void VRecording::draw()
115 int VRecording::handleCommand(int command)
127 case Remote::DF_DOWN:
138 Message* m = new Message(); // Must be done after this view deleted
141 m->message = Message::PLAY_SELECTED_RECORDING;
142 Command::getInstance()->postMessageNoLock(m);
148 Message* m = new Message(); // Must be done after this view deleted
151 m->message = Message::RESUME_SELECTED_RECORDING;
152 Command::getInstance()->postMessageNoLock(m);
158 VRecMove* vrm = new VRecMove(recman);
159 vrm->setParent(this);
161 BoxStack::getInstance()->add(vrm);
162 BoxStack::getInstance()->update(vrm);
168 VQuestion* v = new VQuestion(this);
169 v->setSize(260, 180);
171 v->setTitleBarColour(Colour::DANGER);
174 v->setTitleText(tr("Delete recording"));
175 v->setMainText(tr("Are you sure you want to delete this recording?"));
176 v->setDefault(VQuestion::NO);
177 if (Video::getInstance()->getFormat() == Video::PAL)
179 v->setPosition(230, 160);
183 v->setPosition(220, 140);
187 BoxStack::getInstance()->add(v);
188 BoxStack::getInstance()->update(v);
198 // stop command getting to any more views
202 void VRecording::doRight()
207 buttonPlay.setActive(0);
208 buttonResume.setActive(1);
213 buttonResume.setActive(0);
214 buttonMove.setActive(1);
219 buttonMove.setActive(0);
220 buttonDelete.setActive(1);
225 buttonDelete.setActive(0);
226 buttonPlay.setActive(1);
232 if (++selected == 5) selected = 1;
234 BoxStack::getInstance()->update(this, &buttonRegion);
237 void VRecording::doLeft()
242 buttonPlay.setActive(0);
243 buttonDelete.setActive(1);
248 buttonResume.setActive(0);
249 buttonPlay.setActive(1);
254 buttonMove.setActive(0);
255 buttonResume.setActive(1);
260 buttonDelete.setActive(0);
261 buttonMove.setActive(1);
267 if (--selected == 0) selected = 4;
269 BoxStack::getInstance()->update(this, &buttonRegion);
272 void VRecording::processMessage(Message* m)
275 if (m->message == Message::MOUSE_MOVE)
277 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
280 BoxStack::getInstance()->update(this);
283 else if (m->message == Message::MOUSE_LBDOWN)
285 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
287 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
291 //check if press is outside this view! then simulate cancel
292 int x=(m->parameter>>16)-getScreenX();
293 int y=(m->parameter&0xFFFF)-getScreenY();
294 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
296 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
301 if (m->message == Message::QUESTION_YES)
305 Message* m2 = new Message(); // Delete self
307 m2->to = BoxStack::getInstance();
308 m2->message = Message::CLOSE_ME;
309 Command::getInstance()->postMessageNoLock(m2);
311 m2 = new Message(); // OK. Want this to delete before this message does its job
314 m2->message = Message::DELETE_SELECTED_RECORDING;
315 Command::getInstance()->postMessageNoLock(m2);
318 else if (m->message == Message::MOVE_RECORDING)
320 Message* m2 = new Message(); // Delete self
322 m2->to = BoxStack::getInstance();
323 m2->message = Message::CLOSE_ME;
324 Command::getInstance()->postMessageNoLock(m2);
329 m2->message = Message::MOVE_RECORDING;
330 m2->parameter = m->parameter;
331 Command::getInstance()->postMessageNoLock(m2);