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"
24 #include "vquestion.h"
34 #include "vrecordinglist.h"
35 #include "recording.h"
38 VRecordingMenu::VRecordingMenu(RecMan* trecman)
45 if (Video::getInstance()->getFormat() == Video::PAL)
47 setPosition(260, 190);
51 setPosition(250, 160);
56 setTitleText(tr("Programme menu"));
57 setTitleBarColour(Colour::TITLEBARBACKGROUND);
59 sl.setPosition(10, 30 + 5);
60 sl.setSize(area.w - 20, area.h - 30 - 15);
61 sl.addOption(tr("Play"), 1, 1);
62 sl.addOption(tr("Resume"), 2, 0);
63 sl.addOption(tr("Summary"), 3, 0);
64 sl.addOption(tr("Move"), 4, 0);
65 sl.addOption(tr("Delete"), 5, 0);
69 VRecordingMenu::~VRecordingMenu()
73 void VRecordingMenu::setParent(VRecordingList* tvRecList)
78 void VRecordingMenu::setRecording(Recording* trec)
83 int VRecordingMenu::handleCommand(int command)
92 BoxStack::getInstance()->update(this);
100 BoxStack::getInstance()->update(this);
105 if (sl.getCurrentOptionData() == 1)
107 Message* m = new Message(); // Must be done after this view deleted
110 m->message = Message::PLAY_SELECTED_RECORDING;
111 Command::getInstance()->postMessageNoLock(m);
115 if (sl.getCurrentOptionData() == 2)
117 Message* m = new Message(); // Must be done after this view deleted
120 m->message = Message::RESUME_SELECTED_RECORDING;
121 Command::getInstance()->postMessageNoLock(m);
125 if (sl.getCurrentOptionData() == 3)
129 VInfo* vi = new VInfo();
130 vi->setSize(490, 300);
132 if (Video::getInstance()->getFormat() == Video::PAL)
133 vi->setPosition(120, 130);
135 vi->setPosition(110, 90);
136 vi->setTitleText(tr("Programme summary"));
139 if (strlen(rec->recInfo->summary))
140 vi->setMainText(rec->recInfo->summary);
142 vi->setMainText(tr("Summary unavailable"));
144 BoxStack::getInstance()->add(vi);
145 BoxStack::getInstance()->update(vi);
150 if (sl.getCurrentOptionData() == 4)
152 VRecMove* vrm = new VRecMove(recman);
153 vrm->setParent(this);
155 BoxStack::getInstance()->add(vrm);
156 BoxStack::getInstance()->update(vrm);
160 if (sl.getCurrentOptionData() == 5)
162 VQuestion* v = new VQuestion(this);
163 v->setSize(260, 180);
165 v->setTitleBarColour(Colour::DANGER);
168 v->setTitleText(tr("Delete recording"));
169 v->setMainText(tr("Are you sure you want to delete this recording?"));
170 v->setDefault(VQuestion::NO);
171 if (Video::getInstance()->getFormat() == Video::PAL)
173 v->setPosition(230, 160);
177 v->setPosition(220, 140);
181 BoxStack::getInstance()->add(v);
182 BoxStack::getInstance()->update(v);
191 // stop command getting to any more views
195 void VRecordingMenu::processMessage(Message* m)
197 if (m->message == Message::MOUSE_MOVE)
199 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
202 BoxStack::getInstance()->update(this);
205 else if (m->message == Message::MOUSE_LBDOWN)
207 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
209 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
213 //check if press is outside this view! then simulate cancel
214 int x=(m->parameter>>16)-getScreenX();
215 int y=(m->parameter&0xFFFF)-getScreenY();
216 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
218 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
222 else if (m->message == Message::QUESTION_YES)
224 if (sl.getCurrentOptionData() == 5)
226 Message* m2 = new Message(); // Delete self
228 m2->to = BoxStack::getInstance();
229 m2->message = Message::CLOSE_ME;
230 Command::getInstance()->postMessageNoLock(m2);
232 m2 = new Message(); // OK. Want this to delete before this message does its job
235 m2->message = Message::DELETE_SELECTED_RECORDING;
236 Command::getInstance()->postMessageNoLock(m2);
239 else if (m->message == Message::MOVE_RECORDING)
241 Message* m2 = new Message(); // Delete self
243 m2->to = BoxStack::getInstance();
244 m2->message = Message::CLOSE_ME;
245 Command::getInstance()->postMessageNoLock(m2);
250 m2->message = Message::MOVE_RECORDING;
251 m2->parameter = m->parameter;
252 Command::getInstance()->postMessageNoLock(m2);