]> git.vomp.tv Git - vompclient.git/blob - vrecordingmenu.cc
Update for windows
[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(RecMan* trecman)
24 {
25   rec = NULL;
26   recman = trecman;
27
28   create(200, 164);
29   if (Video::getInstance()->getFormat() == Video::PAL)
30   {
31     setScreenPos(260, 190);
32   }
33   else
34   {
35     setScreenPos(250, 160);
36   }
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setBorderOn(1);
41   setTitleText(tr("Programme menu"));
42   setTitleBarColour(Colour::TITLEBARBACKGROUND);
43
44   sl.setSurface(surface);
45   sl.setSurfaceOffset(10, 30 + 5);
46   sl.setDimensions(area.w - 20, area.h - 30 - 15);
47   sl.addOption(tr("Play"), 1, 1);
48   sl.addOption(tr("Resume"), 2, 0);
49   sl.addOption(tr("Summary"), 3, 0);
50   sl.addOption(tr("Move"), 4, 0);
51   sl.addOption(tr("Delete"), 5, 0);
52 }
53
54 VRecordingMenu::~VRecordingMenu()
55 {
56 }
57
58 void VRecordingMenu::setParent(VRecordingList* tvRecList)
59 {
60   vRecList = tvRecList;
61 }
62
63 void VRecordingMenu::setRecording(Recording* trec)
64 {
65   rec = trec;
66 }
67
68 void VRecordingMenu::draw()
69 {
70   View::draw();
71   sl.draw();
72 }
73
74 int VRecordingMenu::handleCommand(int command)
75 {
76   switch(command)
77   {
78     case Remote::DF_UP:
79     case Remote::UP:
80     {
81       sl.up();
82       sl.draw();
83       ViewMan::getInstance()->updateView(this);
84       return 2;
85     }
86     case Remote::DF_DOWN:
87     case Remote::DOWN:
88     {
89       sl.down();
90       sl.draw();
91       ViewMan::getInstance()->updateView(this);
92       return 2;
93     }
94     case Remote::OK:
95     {
96       if (sl.getCurrentOptionData() == 1)
97       {
98         Message* m = new Message(); // Must be done after this view deleted
99         m->from = this;
100         m->to = vRecList;
101         m->message = Message::PLAY_SELECTED_RECORDING;
102         Command::getInstance()->postMessageNoLock(m);
103         return 4;
104       }
105
106       if (sl.getCurrentOptionData() == 2)
107       {
108         Message* m = new Message(); // Must be done after this view deleted
109         m->from = this;
110         m->to = vRecList;
111         m->message = Message::RESUME_SELECTED_RECORDING;
112         Command::getInstance()->postMessageNoLock(m);
113         return 4;
114       }
115
116       if (sl.getCurrentOptionData() == 3)
117       {
118         rec->loadRecInfo();
119
120         VInfo* vi = new VInfo();
121         vi->setTitleText(tr("Programme summary"));
122         vi->setBorderOn(1);
123         vi->setExitable();
124         if (strlen(rec->recInfo->summary))
125           vi->setMainText(rec->recInfo->summary);
126         else
127           vi->setMainText(tr("Summary unavailable"));
128         if (Video::getInstance()->getFormat() == Video::PAL)
129         {
130           vi->setScreenPos(120, 130);
131         }
132         else
133         {
134           vi->setScreenPos(110, 90);
135         }
136         vi->create(490, 300);
137         vi->draw();
138         ViewMan::getInstance()->add(vi);
139         ViewMan::getInstance()->updateView(vi);
140
141         return 2;
142       }
143
144       if (sl.getCurrentOptionData() == 4)
145       {
146         VRecMove* vrm = new VRecMove(recman);
147         vrm->setParent(this);
148         vrm->draw();
149         ViewMan::getInstance()->add(vrm);
150         ViewMan::getInstance()->updateView(vrm);
151         return 2;
152       }
153
154       if (sl.getCurrentOptionData() == 5)
155       {
156         VQuestion* v = new VQuestion(this);
157         v->create(260, 180);
158         v->setBackgroundColour(Colour::VIEWBACKGROUND);
159         v->setTitleBarColour(Colour::DANGER);
160         v->setTitleBarOn(1);
161         v->setBorderOn(1);
162         v->setTitleText(tr("Delete recording"));
163         v->setMainText(tr("Are you sure you want to delete this recording?"));
164         v->setDefault(VQuestion::NO);
165         if (Video::getInstance()->getFormat() == Video::PAL)
166         {
167           v->setScreenPos(230, 160);
168         }
169         else
170         {
171           v->setScreenPos(220, 140);
172         }
173
174         v->draw();
175         ViewMan::getInstance()->add(v);
176         ViewMan::getInstance()->updateView(v);
177         return 2;
178       }
179     }
180     case Remote::BACK:
181     {
182       return 4;
183     }
184   }
185   // stop command getting to any more views
186   return 1;
187 }
188
189 void VRecordingMenu::processMessage(Message* m)
190 {
191   if (m->message == Message::QUESTION_YES)
192   {
193     if (sl.getCurrentOptionData() == 5)
194     {
195       Message* m2 = new Message(); // Delete self
196       m2->from = this;
197       m2->to = ViewMan::getInstance();
198       m2->message = Message::CLOSE_ME;
199       Command::getInstance()->postMessageNoLock(m2);
200
201       m2 = new Message(); // OK. Want this to delete before this message does its job
202       m2->from = this;
203       m2->to = vRecList;
204       m2->message = Message::DELETE_SELECTED_RECORDING;
205       Command::getInstance()->postMessageNoLock(m2);
206     }
207   }
208   else if (m->message == Message::MOVE_RECORDING)
209   {
210     Message* m2 = new Message(); // Delete self
211     m2->from = this;
212     m2->to = ViewMan::getInstance();
213     m2->message = Message::CLOSE_ME;
214     Command::getInstance()->postMessageNoLock(m2);
215
216     m2 = new Message();
217     m2->from = this;
218     m2->to = vRecList;
219     m2->message = Message::MOVE_RECORDING;
220     m2->parameter = m->parameter;
221     Command::getInstance()->postMessageNoLock(m2);
222   }
223 }