]> git.vomp.tv Git - vompclient.git/blob - vepgsummary.cc
Add recording option to VEpgSummary
[vompclient.git] / vepgsummary.cc
1 /*
2     Copyright 2004-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vepgsummary.h"
22
23 #include "remote.h"
24 #include "vquestion.h"
25 #include "vepgsettimer.h"
26 #include "vinfo.h"
27 #include "vdr.h"
28 #include "colour.h"
29 #include "video.h"
30 #include "i18n.h"
31 #include "command.h"
32 #include "boxstack.h"
33 #include "event.h"
34 #include "channel.h"
35 #include "message.h"
36 #include "log.h"
37 #include "wmovieview.h"
38 #include "wseriesview.h"
39 #include "wpictureview.h"
40
41 #include <string>
42
43 VEpgSummary::VEpgSummary(Event *tevent, Channel* tchannel)
44 {
45   event = tevent;
46   channel = tchannel;
47   
48
49   if (Video::getInstance()->getFormat() == Video::PAL)
50   {
51     setSize(640, 500);
52         createBuffer();
53   }
54   else
55   {
56         setSize(560, 400);
57         createBuffer();
58   }
59   setPosition(40, 40);
60
61   setTitleBarOn(1);
62   setBorderOn(1);
63   setTitleText(event->title);
64
65   setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
66
67   tabbar.setPosition(10+10, 30 + 5);
68   tabbar.setSize(area.w - 20-10, area.h - 30 - 10-30);
69   add(&tabbar);
70
71   boxRed.setBackgroundColour(DrawStyle::RED);
72   boxRed.setPosition(20 /*54*/, tabbar.getY2()+8);
73   boxRed.setSize(18, 16);
74   add(&boxRed);
75
76   textRed.setPosition(boxRed.getX2(), tabbar.getY2()+4);
77   textRed.setSize(166, 30);
78   textRed.setText(tr("Record"));
79   add(&textRed);
80
81
82   WTextbox * summary=new WTextbox();
83   summary->setParaMode(true);
84
85   std::string summary_text = std::string(event->subtitle)+ "\n" +std::string(event->description);
86
87   summary->setText(summary_text.c_str());
88   OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
89
90   tabbar.addTab(tr("EPG"), summary);
91   WMovieView *movieview=NULL;
92   WSeriesView *seriesview=NULL;
93   if (event->movieInfo) {
94           movieview = new WMovieView(event->movieInfo);
95           movieview->setParaMode(true);
96           tabbar.addTab(tr("TheTVDB Info"), movieview);
97           if (osdv) {
98                   if (event->movieInfo->actors.size() > 0 && osdv)
99                   {
100                           WActorGallery *gallery= new WActorGallery(event->movieInfo->actors);
101                           tabbar.addTab(tr("Cast"),gallery);
102                   }
103                   WArtworkGallery *artgallery= new WArtworkGallery(*event->movieInfo);
104                   tabbar.addTab(tr("Gallery"),artgallery);
105           }
106   } else if (event->seriesInfo) {
107           seriesview = new WSeriesView(event->seriesInfo);
108           seriesview->setParaMode(true);
109           tabbar.addTab(tr("TheTVDB Info"), seriesview);
110           if (osdv) {
111                   if (event->seriesInfo->actors.size() > 0 && osdv)
112                   {
113                           WActorGallery *gallery= new WActorGallery(event->seriesInfo->actors);
114                           tabbar.addTab(tr("Cast"),gallery);
115                   }
116                   WArtworkGallery *artgallery= new WArtworkGallery(*event->seriesInfo);
117                   tabbar.addTab(tr("Gallery"),artgallery);
118           }
119
120   }
121
122   epgTVmedia.setPosition(summary->getRegionR().w-130-10,0);
123   epgTVmedia.setSize(130,195/Osd::getInstance()->getPixelAspect());
124   summary->add(&epgTVmedia);
125   if (movieview) movieview->add(&epgTVmedia);
126   if (seriesview) movieview->add(&epgTVmedia);
127   TVMedia poster;
128   poster.height=0;
129   if (event->movieInfo) {
130           poster=event->movieInfo->poster;
131   }
132   if (event->seriesInfo) {
133           if (event->seriesInfo->seasonposter.height) {
134                   poster=event->seriesInfo->seasonposter;
135           }
136           else
137                   if (event->seriesInfo->posters.size()) {
138                           poster=event->seriesInfo->posters[0];
139                   }
140   }
141   if (poster.height) {
142           epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
143           epgTVmedia.setVisible(true);
144   } else {
145           epgTVmedia.setVisible(false);
146   }
147
148
149
150   tabbar.activateFocus(true);
151 }
152
153 VEpgSummary::~VEpgSummary()
154 {
155 }
156
157
158
159
160 int VEpgSummary::handleCommand(int command)
161 {
162         if (command==Remote::BACK) {
163                 return 4;
164         }
165         if (command==Remote::RED)
166     {
167       if (!channel) return 2;
168       Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", event->id, event->time, event->duration, event->title);
169       VEpgSetTimer* vs = new VEpgSetTimer(event, channel);
170       vs->draw();
171       BoxStack *boxstack=BoxStack::getInstance();
172       boxstack->add(vs);
173       boxstack->update(vs);
174       return 2;
175     }
176
177         // Pass to tabbar
178         int retval = tabbar.handleCommand(command);
179         if (retval == 1)
180         {
181                 BoxStack::getInstance()->update(this);
182                 return 2;
183         }
184         else if (retval == 2)
185         {
186
187                 return 2;
188         }
189
190
191
192         // stop command getting to any more views
193         return 1;
194 }
195
196
197
198 void VEpgSummary::processMessage(Message* m)
199 {
200   if (m->message == Message::MOUSE_MOVE)
201   {
202     // todo
203   }
204   else if (m->message == Message::MOUSE_LBDOWN)
205   {
206     int cancel = true;
207     if (cancel)
208     {
209       //check if press is outside this view! then simulate cancel
210       int x=(m->parameter>>16)-getScreenX();
211       int y=(m->parameter&0xFFFF)-getScreenY();
212       if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
213       {
214         BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
215       }
216     }
217   }
218 }
219
220