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(DrawStyle::TITLEBARBACKGROUND);
65 summary.setPosition(10, 30 + 5);
66 summary.setSize(area.w - 20, area.h - 30 - 15 - 50);
67 summary.setParaMode(true);
69 if (rec->recInfo &&strlen(rec->recInfo->summary))
70 summary.setText(rec->recInfo->summary);
72 summary.setText(tr("Summary unavailable"));
76 int sfh = getFontHeight();
78 buttonRegion.y = area.h - 40;
82 button[PLAY].setText(tr("Play"));
83 button[RESUME].setText(tr("Resume"));
84 button[MOVE].setText(tr("Move"));
85 button[A_DELETE].setText(tr("Delete"));
87 for (int i=PLAY, hor=10; i<last; i++, hor+= 140)
89 button[i].setPosition(hor, area.h - 40);
90 button[i].setSize(130, sfh);
95 button[selected].setActive(1);
98 VRecording::~VRecording()
102 void VRecording::setParent(VRecordingList* tvRecList)
104 vRecList = tvRecList;
107 void VRecording::draw()
112 int VRecording::handleCommand(int command)
117 case Remote::DF_LEFT:
125 case Remote::DF_RIGHT:
126 case Remote::DF_DOWN:
135 if (selected == PLAY)
137 Message* m = new Message(); // Must be done after this view deleted
140 m->message = Message::PLAY_SELECTED_RECORDING;
141 Command::getInstance()->postMessageNoLock(m);
145 if (selected == RESUME)
147 Message* m = new Message(); // Must be done after this view deleted
150 m->message = Message::RESUME_SELECTED_RECORDING;
151 Command::getInstance()->postMessageNoLock(m);
155 if (selected == MOVE)
157 VRecMove* vrm = new VRecMove(recman);
158 vrm->setParent(this);
160 BoxStack::getInstance()->add(vrm);
161 BoxStack::getInstance()->update(vrm);
165 if (selected == A_DELETE)
167 VQuestion* v = new VQuestion(this);
168 v->setSize(260, 180);
170 v->setTitleBarColour(DrawStyle::DANGER);
173 v->setTitleText(tr("Delete recording"));
174 v->setMainText(tr("Are you sure you want to delete this recording?"));
175 v->setDefault(VQuestion::NO);
176 if (Video::getInstance()->getFormat() == Video::PAL)
178 v->setPosition(230, 160);
182 v->setPosition(220, 140);
186 BoxStack::getInstance()->add(v);
187 BoxStack::getInstance()->update(v);
197 // stop command getting to any more views
201 void VRecording::moveCursor(Direction direction)
203 button[selected].setActive(0);
204 button[selected].draw();
205 if (direction == RIGHT)
207 if (++selected == last) selected = PLAY;
211 if (--selected < 0) selected = last - 1;
213 button[selected].setActive(1);
214 button[selected].draw();
215 BoxStack::getInstance()->update(this, &buttonRegion);
218 void VRecording::processMessage(Message* m)
220 if (m->message == Message::MOUSE_MOVE)
222 for (int i = PLAY; i < last; i++)
224 if (button[i].mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
226 for (int j = PLAY; j < last; j++)
227 button[j].setActive(0);
228 button[i].setActive(1);
231 BoxStack::getInstance()->update(this);
236 else if (m->message == Message::MOUSE_LBDOWN)
239 for (int i = PLAY; i < last; i++)
241 if (button[i].mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
243 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
250 //check if press is outside this view! then simulate cancel
251 int x=(m->parameter>>16)-getScreenX();
252 int y=(m->parameter&0xFFFF)-getScreenY();
253 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
255 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
259 else if (m->message == Message::QUESTION_YES)
261 if (selected == A_DELETE)
263 Message* m2 = new Message(); // Delete self
265 m2->to = BoxStack::getInstance();
266 m2->message = Message::CLOSE_ME;
267 Command::getInstance()->postMessageNoLock(m2);
269 m2 = new Message(); // OK. Want this to delete before this message does its job
272 m2->message = Message::DELETE_SELECTED_RECORDING;
273 Command::getInstance()->postMessageNoLock(m2);
276 else if (m->message == Message::MOVE_RECORDING)
278 Message* m2 = new Message(); // Delete self
280 m2->to = BoxStack::getInstance();
281 m2->message = Message::CLOSE_ME;
282 Command::getInstance()->postMessageNoLock(m2);
287 m2->message = Message::MOVE_RECORDING;
288 m2->parameter = m->parameter;
289 Command::getInstance()->postMessageNoLock(m2);