]> git.vomp.tv Git - vompclient.git/blob - vrecordingmenu.cc
Clean up of all video init system, NTSC/PAL, screen size functions.
[vompclient.git] / vrecordingmenu.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vrecordingmenu.h"
22
23 VRecordingMenu::VRecordingMenu()
24 {
25   rec = NULL;
26
27   if (Video::getInstance()->getFormat() == Video::PAL)
28   {
29     setScreenPos(260, 190);
30   }
31   else
32   {
33     setScreenPos(250, 160);
34   }
35
36   setDimensions(140, 200);
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setBorderOn(1);
41   setTitleText("Programme menu");
42   setTitleBarColour(Colour::TITLEBARBACKGROUND);
43
44   sl.setScreenPos(screenX + 10, screenY + 30 + 5);
45   sl.setDimensions(height - 30 - 15, width - 20);
46   sl.addOption("Play", 1);
47   sl.addOption("Resume", 0);
48   sl.addOption("Summary", 0);
49   sl.addOption("Delete", 0);
50 }
51
52 VRecordingMenu::~VRecordingMenu()
53 {
54 }
55
56 void VRecordingMenu::setParent(VRecordingList* tvRecList)
57 {
58   vRecList = tvRecList;
59 }
60
61 void VRecordingMenu::setRecording(Recording* trec)
62 {
63   rec = trec;
64 }
65
66 void VRecordingMenu::draw()
67 {
68   View::draw();
69   sl.draw();
70 }
71
72 int VRecordingMenu::handleCommand(int command)
73 {
74   if (command == Remote::UP)
75   {
76     sl.up();
77     sl.draw();
78     show();
79     return 2;
80   }
81   else if (command == Remote::DOWN)
82   {
83     sl.down();
84     sl.draw();
85     show();
86     return 2;
87   }
88   else if (command == Remote::OK)
89   {
90     if (sl.getCurrentOption() == 0)
91     {
92       Message* m = new Message();
93       m->from = this;
94       m->to = vRecList;
95       m->message = Message::PLAY_SELECTED_RECORDING;
96       ViewMan::getInstance()->postMessage(m);
97       return 4;
98     }
99
100     if (sl.getCurrentOption() == 1)
101     {
102       Message* m = new Message();
103       m->from = this;
104       m->to = vRecList;
105       m->message = Message::RESUME_SELECTED_RECORDING;
106       ViewMan::getInstance()->postMessage(m);
107       return 4;
108     }
109
110     if (sl.getCurrentOption() == 2)
111     {
112       char* summary = VDR::getInstance()->getRecordingSummary(rec->fileName);
113
114       VInfo* vi = new VInfo();
115       vi->setTitleText("Programme summary");
116       vi->setBorderOn(1);
117       vi->setExitable();
118       if (summary) vi->setMainText(summary);
119       else vi->setMainText("Summary unavailable");
120       if (Video::getInstance()->getFormat() == Video::PAL)
121       {
122         vi->setScreenPos(120, 130);
123       }
124       else
125       {
126         vi->setScreenPos(110, 90);
127       }
128       vi->setDimensions(300, 490);
129
130       ViewMan::getInstance()->addNoLock(vi);
131       vi->draw();
132       vi->show();
133
134       if (summary) delete[] summary;
135
136       return 2;
137     }
138     else if (sl.getCurrentOption() == 3)
139     {
140       VQuestion* v = new VQuestion();
141       v->setParent(this);
142       v->setBackgroundColour(Colour::VIEWBACKGROUND);
143       v->setTitleBarColour(Colour::DANGER);
144       v->setTitleBarOn(1);
145       v->setBorderOn(1);
146       v->setTitleText("Delete recording");
147       v->setMainText("Are you sure you want to delete this recording?");
148       v->setDefault(VQuestion::NO);
149       if (Video::getInstance()->getFormat() == Video::PAL)
150       {
151         v->setScreenPos(230, 160);
152       }
153       else
154       {
155         v->setScreenPos(220, 140);
156       }
157       v->setDimensions(180, 260);
158
159       ViewMan::getInstance()->addNoLock(v);
160       v->draw();
161       v->show();
162       return 2;
163     }
164   }
165   else if (command == Remote::BACK)
166   {
167     return 4;
168   }
169
170   // stop command getting to any more views
171   return 1;
172 }
173
174 void VRecordingMenu::processMessage(Message* m)
175 {
176   if (m->message == Message::QUESTION_YES)
177   {
178     if (sl.getCurrentOption() == 3)
179     {
180       Message* m = new Message();
181       m->from = this;
182       m->to = ViewMan::getInstance();
183       m->message = Message::CLOSE_ME;
184       ViewMan::getInstance()->postMessage(m);
185
186       m = new Message();
187       m->from = this;
188       m->to = vRecList;
189       m->message = Message::DELETE_SELECTED_RECORDING;
190       ViewMan::getInstance()->postMessage(m);
191     }
192   }
193 }