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