]> git.vomp.tv Git - vompclient.git/blob - vepgsummary.cc
Some nasty hacks to support MVP
[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+40, 500+40);
52         createBuffer();
53   }
54   else
55   {
56         setSize(560, 400);
57         createBuffer();
58   }
59   setPosition(20, 20);
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 #ifndef VOMP_PLATTFORM_MVP
89 // OSDV
90   OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
91 #endif
92   summary->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
93
94   tabbar.addTab(tr("EPG"), summary);
95   summary->setVideoBackground();
96   WMovieView *movieview=NULL;
97   WSeriesView *seriesview=NULL;
98   if (event->movieInfo) {
99           movieview = new WMovieView(event->movieInfo);
100           movieview->setParaMode(true);
101           movieview->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
102           tabbar.addTab(tr("TheTVDB Info"), movieview);
103 #ifndef VOMP_PLATTFORM_MVP
104 // OSDV
105           if (osdv) {
106                   if (event->movieInfo->actors.size() > 0 && osdv)
107                   {
108                           WActorGallery *gallery= new WActorGallery(event->movieInfo->actors);
109                           gallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
110                           tabbar.addTab(tr("Cast"),gallery);
111                   }
112                   WArtworkGallery *artgallery= new WArtworkGallery(*event->movieInfo);
113                   artgallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
114                   tabbar.addTab(tr("Gallery"),artgallery);
115           }
116 #endif
117   } else if (event->seriesInfo) {
118           seriesview = new WSeriesView(event->seriesInfo);
119           seriesview->setParaMode(true);
120           seriesview->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
121           tabbar.addTab(tr("TheTVDB Info"), seriesview);
122 #ifndef VOMP_PLATTFORM_MVP
123 // OSDV
124           if (osdv) {
125                   if (event->seriesInfo->actors.size() > 0 && osdv)
126                   {
127                           WActorGallery *gallery= new WActorGallery(event->seriesInfo->actors);
128                           gallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
129                           tabbar.addTab(tr("Cast"),gallery);
130                   }
131                   WArtworkGallery *artgallery= new WArtworkGallery(*event->seriesInfo);
132                   artgallery->setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
133                   tabbar.addTab(tr("Gallery"),artgallery);
134           }
135 #endif
136
137   }
138
139   epgTVmedia.setPosition(summary->getRegionR().w-130-10,0);
140   epgTVmedia.setSize(130,195/Osd::getInstance()->getPixelAspect());
141   summary->add(&epgTVmedia);
142   if (movieview) movieview->add(&epgTVmedia);
143   if (seriesview) seriesview->add(&epgTVmedia);
144   TVMedia poster;
145   poster.height=0;
146   if (event->movieInfo) {
147           poster=event->movieInfo->poster;
148   }
149   if (event->seriesInfo) {
150           if (event->seriesInfo->seasonposter.height) {
151                   poster=event->seriesInfo->seasonposter;
152           }
153           else
154                   if (event->seriesInfo->posters.size()) {
155                           poster=event->seriesInfo->posters[0];
156                   }
157   }
158   if (poster.height) {
159           epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
160           epgTVmedia.setVisible(true);
161   } else {
162           epgTVmedia.setVisible(false);
163   }
164
165
166
167   tabbar.activateFocus(true);
168 }
169
170 VEpgSummary::~VEpgSummary()
171 {
172 }
173
174
175
176
177 int VEpgSummary::handleCommand(int command)
178 {
179         if (command==Remote::BACK) {
180                 return 4;
181         }
182         if (command==Remote::RED)
183     {
184       if (!channel) return 2;
185       Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", event->id, event->time, event->duration, event->title);
186       VEpgSetTimer* vs = new VEpgSetTimer(event, channel);
187       vs->draw();
188       BoxStack *boxstack=BoxStack::getInstance();
189       boxstack->add(vs);
190       boxstack->update(vs);
191       return 2;
192     }
193
194         // Pass to tabbar
195         int retval = tabbar.handleCommand(command);
196         if (retval == 1)
197         {
198                 BoxStack::getInstance()->update(this);
199                 return 2;
200         }
201         else if (retval == 2)
202         {
203
204                 return 2;
205         }
206
207
208
209         // stop command getting to any more views
210         return 1;
211 }
212
213
214
215 void VEpgSummary::processMessage(Message* m)
216 {
217         if (m->message == Message::MOUSE_MOVE)
218         {
219                 if (tabbar.mouseMove((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
220                 {
221                         BoxStack::getInstance()->update(this);
222                 }
223         }
224         else if (m->message == Message::MOUSE_LBDOWN)
225         {
226                 int cancel = true;
227                 int x = (m->parameter.num >> 16) - getScreenX();
228                 int y = (m->parameter.num & 0xFFFF) - getScreenY();
229
230                 if ((boxRed.getX() <= x) && (boxRed.getX() + (int)boxRed.getWidth() >= x) &&
231                                 (boxRed.getY() <= y) && (boxRed.getY() + (int)boxRed.getHeight() >= y)) {
232                         BoxStack::getInstance()->handleCommand(Remote::RED);
233                         cancel = false;
234                 }
235
236
237                 if (cancel && tabbar.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
238                 {
239                         BoxStack::getInstance()->update(this);
240                         cancel = false;
241                 }
242                 if (cancel)
243                 {
244                         //check if press is outside this view! then simulate cancel
245                         int x=(m->parameter.num>>16)-getScreenX();
246                         int y=(m->parameter.num&0xFFFF)-getScreenY();
247                         if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
248                         {
249                                 BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
250                         }
251                 }
252         } else if (m->message == Message::MOUSE_SCROLL)
253         {
254                 if (tabbar.mouseAndroidScroll((m->tag >> 16) - getScreenX(), (m->tag & 0xFFFF) - getScreenY(),
255                                 (short)(m->parameter.num >> 16), (short)(m->parameter.num & 0xFFFF)))
256                 {
257                         BoxStack::getInstance()->update(this);
258                         return;
259                 }
260         }
261 }
262
263