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 "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(DrawStyle::TITLEBARBACKGROUND);
59 sl.setPosition(10, 30 + 5);
60 sl.setSize(area.w - 20, area.h - 30 - 15);
61 sl.addOption(tr("Play"), reinterpret_cast<void*>(1), 1);
62 sl.addOption(tr("Resume"), reinterpret_cast<void*>(2), 0);
63 sl.addOption(tr("Summary"), reinterpret_cast<void*>(3), 0);
64 sl.addOption(tr("Move"), reinterpret_cast<void*>(4), 0);
65 sl.addOption(tr("Delete"), reinterpret_cast<void*>(5), 0);
69 VRecordingMenu::~VRecordingMenu()
73 void VRecordingMenu::setParent(VRecordingList* tvRecList)
78 void VRecordingMenu::setRecording(Recording* trec)
83 int VRecordingMenu::handleCommand(int command)
91 BoxStack::getInstance()->update(this);
98 BoxStack::getInstance()->update(this);
103 ULONG slCurrentOption = reinterpret_cast<ULONG>(sl.getCurrentOptionData());
104 if (slCurrentOption == 1)
106 Message* m = new Message(); // Must be done after this view deleted
109 m->message = Message::PLAY_SELECTED_RECORDING;
110 MessageQueue::getInstance()->postMessage(m);
114 if (slCurrentOption == 2)
116 Message* m = new Message(); // Must be done after this view deleted
119 m->message = Message::RESUME_SELECTED_RECORDING;
120 MessageQueue::getInstance()->postMessage(m);
124 if (slCurrentOption == 3)
128 VInfo* vi = new VInfo();
129 vi->setSize(490, 300);
131 if (Video::getInstance()->getFormat() == Video::PAL)
132 vi->setPosition(120, 130);
134 vi->setPosition(110, 90);
135 vi->setTitleText(tr("Programme summary"));
138 if (strlen(rec->recInfo->summary))
139 vi->setMainText(rec->recInfo->summary);
141 vi->setMainText(tr("Summary unavailable"));
143 BoxStack::getInstance()->add(vi);
144 BoxStack::getInstance()->update(vi);
149 if (slCurrentOption == 4)
151 VRecMove* vrm = new VRecMove(recman);
152 vrm->setParent(this);
154 BoxStack::getInstance()->add(vrm);
155 BoxStack::getInstance()->update(vrm);
159 if (slCurrentOption == 5)
161 VQuestion* v = new VQuestion(this);
162 v->setSize(260, 180);
164 v->setTitleBarColour(DrawStyle::DANGER);
167 v->setTitleText(tr("Delete recording"));
168 v->setMainText(tr("Are you sure you want to delete this recording?"));
169 v->setDefault(VQuestion::NO);
170 if (Video::getInstance()->getFormat() == Video::PAL)
172 v->setPosition(230, 160);
176 v->setPosition(220, 140);
180 BoxStack::getInstance()->add(v);
181 BoxStack::getInstance()->update(v);
186 // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy
193 // stop command getting to any more views
197 void VRecordingMenu::processMessage(Message* m)
199 if (m->message == Message::MOUSE_MOVE)
201 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
204 BoxStack::getInstance()->update(this);
207 else if (m->message == Message::MOUSE_LBDOWN)
209 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
211 BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
213 else if (coordsOutsideBox(m))
215 BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press
218 else if (m->message == Message::QUESTION_YES)
220 if (reinterpret_cast<ULONG>(sl.getCurrentOptionData()) == 5)
222 Message* m2 = new Message(); // Delete self
224 m2->p_to = Message::BOXSTACK;
225 m2->message = Message::CLOSE_ME;
226 MessageQueue::getInstance()->postMessage(m2);
228 m2 = new Message(); // OK. Want this to delete before this message does its job
231 m2->message = Message::DELETE_SELECTED_RECORDING;
232 MessageQueue::getInstance()->postMessage(m2);
235 else if (m->message == Message::MOVE_RECORDING)
237 Message* m2 = new Message(); // Delete self
239 m2->p_to = Message::BOXSTACK;
240 m2->message = Message::CLOSE_ME;
241 MessageQueue::getInstance()->postMessage(m2);
246 m2->message = Message::MOVE_RECORDING;
247 m2->parameter = m->parameter;
248 MessageQueue::getInstance()->postMessage(m2);