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, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vrecordingmenu.h"
25 #include "vquestion.h"
35 #include "vrecordinglist.h"
36 #include "recording.h"
39 VRecordingMenu::VRecordingMenu(RecMan* trecman)
46 if (Video::getInstance()->getFormat() == Video::PAL)
48 setPosition(260, 190);
52 setPosition(250, 160);
57 setTitleText(tr("Programme menu"));
58 setTitleBarColour(Colour::TITLEBARBACKGROUND);
60 sl.setPosition(10, 30 + 5);
61 sl.setSize(area.w - 20, area.h - 30 - 15);
62 sl.addOption(tr("Play"), 1, 1);
63 sl.addOption(tr("Resume"), 2, 0);
64 sl.addOption(tr("Summary"), 3, 0);
65 sl.addOption(tr("Move"), 4, 0);
66 sl.addOption(tr("Delete"), 5, 0);
70 VRecordingMenu::~VRecordingMenu()
74 void VRecordingMenu::setParent(VRecordingList* tvRecList)
79 void VRecordingMenu::setRecording(Recording* trec)
84 int VRecordingMenu::handleCommand(int command)
93 BoxStack::getInstance()->update(this);
101 BoxStack::getInstance()->update(this);
106 if (sl.getCurrentOptionData() == 1)
108 Message* m = new Message(); // Must be done after this view deleted
111 m->message = Message::PLAY_SELECTED_RECORDING;
112 Command::getInstance()->postMessageNoLock(m);
116 if (sl.getCurrentOptionData() == 2)
118 Message* m = new Message(); // Must be done after this view deleted
121 m->message = Message::RESUME_SELECTED_RECORDING;
122 Command::getInstance()->postMessageNoLock(m);
126 if (sl.getCurrentOptionData() == 3)
130 VInfo* vi = new VInfo();
131 vi->setSize(490, 300);
133 if (Video::getInstance()->getFormat() == Video::PAL)
134 vi->setPosition(120, 130);
136 vi->setPosition(110, 90);
137 vi->setTitleText(tr("Programme summary"));
140 if (strlen(rec->recInfo->summary))
141 vi->setMainText(rec->recInfo->summary);
143 vi->setMainText(tr("Summary unavailable"));
145 BoxStack::getInstance()->add(vi);
146 BoxStack::getInstance()->update(vi);
151 if (sl.getCurrentOptionData() == 4)
153 VRecMove* vrm = new VRecMove(recman);
154 vrm->setParent(this);
156 BoxStack::getInstance()->add(vrm);
157 BoxStack::getInstance()->update(vrm);
161 if (sl.getCurrentOptionData() == 5)
163 VQuestion* v = new VQuestion(this);
164 v->setSize(260, 180);
166 v->setTitleBarColour(Colour::DANGER);
169 v->setTitleText(tr("Delete recording"));
170 v->setMainText(tr("Are you sure you want to delete this recording?"));
171 v->setDefault(VQuestion::NO);
172 if (Video::getInstance()->getFormat() == Video::PAL)
174 v->setPosition(230, 160);
178 v->setPosition(220, 140);
182 BoxStack::getInstance()->add(v);
183 BoxStack::getInstance()->update(v);
192 // stop command getting to any more views
196 void VRecordingMenu::processMessage(Message* m)
198 if (m->message == Message::MOUSE_MOVE)
200 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
203 BoxStack::getInstance()->update(this);
206 else if (m->message == Message::MOUSE_LBDOWN)
208 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
210 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
214 //check if press is outside this view! then simulate cancel
215 int x=(m->parameter>>16)-getScreenX();
216 int y=(m->parameter&0xFFFF)-getScreenY();
217 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
219 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
223 else if (m->message == Message::QUESTION_YES)
225 if (sl.getCurrentOptionData() == 5)
227 Message* m2 = new Message(); // Delete self
229 m2->to = BoxStack::getInstance();
230 m2->message = Message::CLOSE_ME;
231 Command::getInstance()->postMessageNoLock(m2);
233 m2 = new Message(); // OK. Want this to delete before this message does its job
236 m2->message = Message::DELETE_SELECTED_RECORDING;
237 Command::getInstance()->postMessageNoLock(m2);
240 else if (m->message == Message::MOVE_RECORDING)
242 Message* m2 = new Message(); // Delete self
244 m2->to = BoxStack::getInstance();
245 m2->message = Message::CLOSE_ME;
246 Command::getInstance()->postMessageNoLock(m2);
251 m2->message = Message::MOVE_RECORDING;
252 m2->parameter = m->parameter;
253 Command::getInstance()->postMessageNoLock(m2);