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, see <https://www.gnu.org/licenses/>.
20 #include "vrecordingmenu.h"
24 #include "vquestion.h"
30 #include "messagequeue.h"
34 #include "recording.h"
37 VRecordingMenu::VRecordingMenu(RecMan* trecman)
44 if (Video::getInstance()->getFormat() == Video::PAL)
46 setPosition(260, 190);
50 setPosition(250, 160);
55 setTitleText(tr("Programme menu"));
56 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
58 sl.setPosition(10, 30 + 5);
59 sl.setSize(area.w - 20, area.h - 30 - 15);
60 sl.addOption(tr("Play"), reinterpret_cast<void*>(1), 1);
61 sl.addOption(tr("Resume"), reinterpret_cast<void*>(2), 0);
62 sl.addOption(tr("Summary"), reinterpret_cast<void*>(3), 0);
63 sl.addOption(tr("Move"), reinterpret_cast<void*>(4), 0);
64 sl.addOption(tr("Delete"), reinterpret_cast<void*>(5), 0);
67 MessageQueue::getInstance()->addReceiver(this);
70 VRecordingMenu::~VRecordingMenu()
72 MessageQueue::getInstance()->removeReceiver(this);
75 void VRecordingMenu::setParent(MessageReceiver* tvRecList)
80 void VRecordingMenu::setRecording(Recording* trec)
85 int VRecordingMenu::handleCommand(int command)
93 BoxStack::getInstance()->update(this);
94 return BoxStack::COMMAND_HANDLED;
100 BoxStack::getInstance()->update(this);
101 return BoxStack::COMMAND_HANDLED;
105 u4 slCurrentOption = reinterpret_cast<u4>(sl.getCurrentOptionData());
106 if (slCurrentOption == 1)
108 Message* m = new Message(); // Must be done after this view deleted
111 m->message = Message::PLAY_SELECTED_RECORDING;
112 MessageQueue::getInstance()->postMessage(m);
113 return BoxStack::DELETE_ME;
116 if (slCurrentOption == 2)
118 Message* m = new Message(); // Must be done after this view deleted
121 m->message = Message::RESUME_SELECTED_RECORDING;
122 MessageQueue::getInstance()->postMessage(m);
123 return BoxStack::DELETE_ME;
126 if (slCurrentOption == 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);
148 return BoxStack::COMMAND_HANDLED;
151 if (slCurrentOption == 4)
153 VRecMove* vrm = new VRecMove(recman);
154 vrm->setParent(this);
156 BoxStack::getInstance()->add(vrm);
157 BoxStack::getInstance()->update(vrm);
158 return BoxStack::COMMAND_HANDLED;
161 if (slCurrentOption == 5)
163 VQuestion* v = new VQuestion(this);
164 v->setSize(260, 180);
166 v->setTitleBarColour(DrawStyle::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);
184 return BoxStack::COMMAND_HANDLED;
188 // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy
192 return BoxStack::DELETE_ME;
195 // stop command getting to any more views
196 return BoxStack::ABANDON_COMMAND;
199 void VRecordingMenu::processMessage(Message* m)
201 if (m->message == Message::MOUSE_MOVE)
203 if (sl.mouseMove(m->parameter - getScreenX(), m->tag - getScreenY()))
206 BoxStack::getInstance()->update(this);
209 else if (m->message == Message::MOUSE_LBDOWN)
211 if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY()))
213 Input::sendInputKey(Input::OK);
215 else if (coordsOutsideBox(m))
217 Input::sendInputKey(Input::BACK);
220 else if (m->message == Message::QUESTION_YES)
222 if (reinterpret_cast<u4>(sl.getCurrentOptionData()) == 5)
224 Message* m2 = new Message(); // Delete self
226 m2->p_to = Message::BOXSTACK;
227 m2->message = Message::CLOSE_ME;
228 MessageQueue::getInstance()->postMessage(m2);
230 m2 = new Message(); // OK. Want this to delete before this message does its job
233 m2->message = Message::DELETE_SELECTED_RECORDING;
234 MessageQueue::getInstance()->postMessage(m2);
237 else if (m->message == Message::MOVE_RECORDING)
239 Message* m2 = new Message(); // Delete self
241 m2->p_to = Message::BOXSTACK;
242 m2->message = Message::CLOSE_ME;
243 MessageQueue::getInstance()->postMessage(m2);
248 m2->message = Message::MOVE_RECORDING;
249 m2->parameter = m->parameter;
250 MessageQueue::getInstance()->postMessage(m2);