2 Copyright 2004-2008 Chris Tallon
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
21 #include "vrecording.h"
\r
24 #include "recinfo.h"
\r
25 #include "vquestion.h"
\r
31 #include "command.h"
\r
32 #include "vrecmove.h"
\r
33 #include "boxstack.h"
\r
35 #include "vrecordinglist.h"
\r
36 #include "recording.h"
\r
37 #include "message.h"
\r
40 VRecording::VRecording(RecMan* trecman, Recording* trec)
\r
45 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
\r
47 Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
\r
51 if (Video::getInstance()->getFormat() == Video::PAL)
\r
53 setPosition(80, 70);
\r
57 setPosition(70, 35);
\r
62 setTitleText(rec->getProgName());
\r
63 setTitleBarColour(Colour::TITLEBARBACKGROUND);
\r
65 summary.setPosition(10, 30 + 5);
\r
66 summary.setSize(area.w - 20, area.h - 30 - 15 - 50);
\r
67 summary.setParaMode(true);
\r
69 if (rec->recInfo &&strlen(rec->recInfo->summary))
\r
70 summary.setText(rec->recInfo->summary);
\r
72 summary.setText(tr("Summary unavailable"));
\r
77 buttonPlay.setPosition(10, area.h - 40);
\r
78 buttonResume.setPosition(150, area.h - 40);
\r
79 buttonMove.setPosition(290, area.h - 40);
\r
80 buttonDelete.setPosition(430, area.h - 40);
\r
82 int sfh = getFontHeight();
\r
84 buttonPlay.setSize(130, sfh);
\r
85 buttonResume.setSize(130, sfh);
\r
86 buttonMove.setSize(130, sfh);
\r
87 buttonDelete.setSize(130, sfh);
\r
89 buttonRegion.x = 10;
\r
90 buttonRegion.y = area.h - 40;
\r
91 buttonRegion.w = 550;
\r
92 buttonRegion.h = sfh;
\r
94 buttonPlay.setText(tr("Play"));
\r
95 buttonResume.setText(tr("Resume"));
\r
96 buttonMove.setText(tr("Move"));
\r
97 buttonDelete.setText(tr("Delete"));
\r
100 add(&buttonResume);
\r
102 add(&buttonDelete);
\r
104 buttonPlay.setActive(1);
\r
108 VRecording::~VRecording()
\r
112 void VRecording::setParent(VRecordingList* tvRecList)
\r
114 vRecList = tvRecList;
\r
117 void VRecording::draw()
\r
122 int VRecording::handleCommand(int command)
\r
127 case Remote::DF_LEFT:
\r
128 case Remote::DF_UP:
\r
134 case Remote::RIGHT:
\r
135 case Remote::DF_RIGHT:
\r
136 case Remote::DF_DOWN:
\r
147 Message* m = new Message(); // Must be done after this view deleted
\r
150 m->message = Message::PLAY_SELECTED_RECORDING;
\r
151 Command::getInstance()->postMessageNoLock(m);
\r
157 Message* m = new Message(); // Must be done after this view deleted
\r
160 m->message = Message::RESUME_SELECTED_RECORDING;
\r
161 Command::getInstance()->postMessageNoLock(m);
\r
167 VRecMove* vrm = new VRecMove(recman);
\r
168 vrm->setParent(this);
\r
170 BoxStack::getInstance()->add(vrm);
\r
171 BoxStack::getInstance()->update(vrm);
\r
177 VQuestion* v = new VQuestion(this);
\r
178 v->setSize(260, 180);
\r
180 v->setTitleBarColour(Colour::DANGER);
\r
181 v->setTitleBarOn(1);
\r
183 v->setTitleText(tr("Delete recording"));
\r
184 v->setMainText(tr("Are you sure you want to delete this recording?"));
\r
185 v->setDefault(VQuestion::NO);
\r
186 if (Video::getInstance()->getFormat() == Video::PAL)
\r
188 v->setPosition(230, 160);
\r
192 v->setPosition(220, 140);
\r
196 BoxStack::getInstance()->add(v);
\r
197 BoxStack::getInstance()->update(v);
\r
207 // stop command getting to any more views
\r
211 void VRecording::doRight()
\r
216 buttonPlay.setActive(0);
\r
217 buttonResume.setActive(1);
\r
219 buttonResume.draw();
\r
222 buttonResume.setActive(0);
\r
223 buttonMove.setActive(1);
\r
224 buttonResume.draw();
\r
228 buttonMove.setActive(0);
\r
229 buttonDelete.setActive(1);
\r
231 buttonDelete.draw();
\r
234 buttonDelete.setActive(0);
\r
235 buttonPlay.setActive(1);
\r
236 buttonDelete.draw();
\r
241 if (++selected == 5) selected = 1;
\r
243 BoxStack::getInstance()->update(this, &buttonRegion);
\r
246 void VRecording::doLeft()
\r
251 buttonPlay.setActive(0);
\r
252 buttonDelete.setActive(1);
\r
254 buttonDelete.draw();
\r
257 buttonResume.setActive(0);
\r
258 buttonPlay.setActive(1);
\r
259 buttonResume.draw();
\r
263 buttonMove.setActive(0);
\r
264 buttonResume.setActive(1);
\r
266 buttonResume.draw();
\r
269 buttonDelete.setActive(0);
\r
270 buttonMove.setActive(1);
\r
271 buttonDelete.draw();
\r
276 if (--selected == 0) selected = 4;
\r
278 BoxStack::getInstance()->update(this, &buttonRegion);
\r
281 void VRecording::processMessage(Message* m)
\r
283 if (m->message == Message::MOUSE_MOVE)
\r
285 if (buttonPlay.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
287 buttonPlay.setActive(1);
\r
288 buttonResume.setActive(0);
\r
289 buttonMove.setActive(0);
\r
290 buttonDelete.setActive(0);
\r
293 BoxStack::getInstance()->update(this);
\r
295 else if (buttonResume.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
297 buttonPlay.setActive(0);
\r
298 buttonResume.setActive(1);
\r
299 buttonMove.setActive(0);
\r
300 buttonDelete.setActive(0);
\r
303 BoxStack::getInstance()->update(this);
\r
305 else if (buttonMove.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
307 buttonPlay.setActive(0);
\r
308 buttonResume.setActive(0);
\r
309 buttonMove.setActive(1);
\r
310 buttonDelete.setActive(0);
\r
313 BoxStack::getInstance()->update(this);
\r
315 else if (buttonDelete.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
317 buttonPlay.setActive(0);
\r
318 buttonResume.setActive(0);
\r
319 buttonMove.setActive(0);
\r
320 buttonDelete.setActive(1);
\r
323 BoxStack::getInstance()->update(this);
\r
326 else if (m->message == Message::MOUSE_LBDOWN)
\r
328 if (buttonPlay.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
330 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
\r
332 else if (buttonResume.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
334 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
\r
336 else if (buttonMove.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
338 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
\r
340 else if (buttonDelete.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
\r
342 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
\r
346 //check if press is outside this view! then simulate cancel
\r
347 int x=(m->parameter>>16)-getScreenX();
\r
348 int y=(m->parameter&0xFFFF)-getScreenY();
\r
349 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
\r
351 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
\r
355 else if (m->message == Message::QUESTION_YES)
\r
359 Message* m2 = new Message(); // Delete self
\r
361 m2->to = BoxStack::getInstance();
\r
362 m2->message = Message::CLOSE_ME;
\r
363 Command::getInstance()->postMessageNoLock(m2);
\r
365 m2 = new Message(); // OK. Want this to delete before this message does its job
\r
368 m2->message = Message::DELETE_SELECTED_RECORDING;
\r
369 Command::getInstance()->postMessageNoLock(m2);
\r
372 else if (m->message == Message::MOVE_RECORDING)
\r
374 Message* m2 = new Message(); // Delete self
\r
376 m2->to = BoxStack::getInstance();
\r
377 m2->message = Message::CLOSE_ME;
\r
378 Command::getInstance()->postMessageNoLock(m2);
\r
380 m2 = new Message();
\r
383 m2->message = Message::MOVE_RECORDING;
\r
384 m2->parameter = m->parameter;
\r
385 Command::getInstance()->postMessageNoLock(m2);
\r