]> git.vomp.tv Git - vompclient.git/blob - vepglistadvanced.cc
Compile fix for MVP re: location change of hmsf
[vompclient.git] / vepglistadvanced.cc
1 /*
2     Copyright 2004-2007 Chris Tallon, 2014 Marten Richter
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 "vepglistadvanced.h"
22
23 #include "boxstack.h"
24 #include "remote.h"
25 #include "wsymbol.h"
26 #include "boxstack.h"
27 #include "vdr.h"
28 #include "colour.h"
29 #include "video.h"
30 #include "i18n.h"
31 #include "command.h"
32 #include "log.h"
33 #include "movieinfo.h"
34 #include "seriesinfo.h"
35 #include "event.h"
36 #include "channel.h"
37 #include "vepgsummary.h"
38 #include "vepgsettimer.h"
39 #include "vepg.h"
40 #include "staticartwork.h"
41
42 #include <sstream>
43
44
45 VEpgListAdvanced::VEpgListAdvanced(VVideoLiveTV *tvideolive, ChannelList* tchanList,ULONG initialChannelNumber)
46 {
47         channelNumber = initialChannelNumber;
48         chanList = tchanList;
49         videolive = tvideolive;
50         boxstack = BoxStack::getInstance();
51
52         mode = OneChannel;
53
54         setSize(640+40, 500+40); //old   setSize(570, 420);
55         createBuffer();
56
57         setPosition(20, 20);
58
59         setTitleBarOn(1);
60         setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
61         TVMediaInfo *info= new TVMediaInfo();
62         info->setChannelLogo(channelNumber);
63         info->setStaticFallback(sa_tv);
64         setTitleBarIcon(info);
65
66         sl.setPosition(10, 30 + 5);
67         sl.setSize(area.w*42/100 - 20, area.h - 30 - 15 - 30);
68         sl.setLinesPerOption(2.4f);
69         add(&sl);
70
71         Region slarea=sl.getRegionR();
72
73         epg.setParaMode(true);
74         epg.setPosition(slarea.x  +slarea.w+10 ,30+5);
75         epg.setSize(area.w -slarea.x -slarea.w -10, area.h - 30 - 15 - 30);
76         add(&epg);
77         epg.setText("");
78         epg.setVideoBackground();
79         epg.setBackgroundColour(DrawStyle::VIEWTRANSPARENTBACKGROUND);
80
81         epgTVmedia.setPosition(epg.getRegionR().w-100-10,10);
82         epgTVmedia.setSize(100,(UINT)(150/Osd::getInstance()->getPixelAspect()));
83         epg.add(&epgTVmedia);
84
85         boxRed.setBackgroundColour(DrawStyle::RED);
86         boxRed.setPosition(165 /*54*/, sl.getY2()+8);
87         boxRed.setSize(18, 16);
88         add(&boxRed);
89
90         textRed.setPosition(boxRed.getX2(), sl.getY2()+4);
91         textRed.setSize(116, 30);
92
93         add(&textRed);
94
95         boxGreen.setBackgroundColour(DrawStyle::GREEN);
96         boxGreen.setPosition(165 +1*110, sl.getY2()+8);
97         boxGreen.setSize(18, 16);
98         add(&boxGreen);
99
100         textGreen.setPosition(boxGreen.getX2(), sl.getY2()+4);
101         textGreen.setSize(116, 30);
102         add(&textGreen);
103
104         boxYellow.setBackgroundColour(DrawStyle::YELLOW);
105         boxYellow.setPosition(165 +2*110, sl.getY2()+8);
106         boxYellow.setSize(18, 16);
107         add(&boxYellow);
108
109         textYellow.setPosition(boxYellow.getX2(), sl.getY2()+4);
110         textYellow.setSize(116, 30);
111         add(&textYellow);
112
113         boxBlue.setBackgroundColour(DrawStyle::BLUE);
114         boxBlue.setPosition(165 +3*110, sl.getY2()+8);
115         boxBlue.setSize(18, 16);
116         add(&boxBlue);
117
118         textBlue.setPosition(boxBlue.getX2(), sl.getY2()+4);
119         textBlue.setSize(116, 30);
120         add(&textBlue);
121
122         setButtonText();
123
124
125         updateEpgDataChannel();
126 }
127
128 VEpgListAdvanced::~VEpgListAdvanced()
129 {
130         clearEventList();
131 }
132
133
134 void VEpgListAdvanced::setButtonText()
135 {
136         switch (mode)
137         {
138         case OneChannel: {
139                 textRed.setText(tr("Record"));
140                 textGreen.setText(tr("Now"));
141                 textYellow.setText(tr("Next"));
142                 textBlue.setText(tr("Guide"));
143
144         } break;
145         case Now: {
146                 textRed.setText(tr("Record"));
147                 textGreen.setText(tr("Next"));
148                 textYellow.setText(tr("Schedule"));
149                 textBlue.setText(tr("Switch"));
150         } break;
151         case Next: {
152                 textRed.setText(tr("Record"));
153                 textGreen.setText(tr("Now"));
154                 textYellow.setText(tr("Schedule"));
155                 textBlue.setText(tr("Switch"));
156         } break;
157
158         };
159 }
160
161 void VEpgListAdvanced::doRed()
162 {
163         doRecord();
164 }
165
166 void VEpgListAdvanced::doGreen()
167 {
168         switch (mode)
169         {
170         case Now: {
171                 doNext();
172         } break;
173         case OneChannel:
174         case Next: {
175                 doNow();
176         } break;
177         };
178 }
179
180 void VEpgListAdvanced::doYellow()
181 {
182         switch (mode)
183         {
184         case OneChannel: {
185                 doNext();
186         } break;
187         case Next:
188         case Now: {
189                 doProgramm();
190         } break;
191         };
192 }
193
194 void VEpgListAdvanced::doBlue()
195 {
196         switch (mode)
197         {
198         case OneChannel: {
199                 doGrid();
200         } break;
201         case Next:
202         case Now: {
203                 doSwitch();
204         } break;
205         };
206 }
207
208 void VEpgListAdvanced::doNext()
209 {
210         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doNext");
211         if (mode!=OneChannel) {
212                 Channel * chan=(*chanList)[ sl.getCurrentOptionData()];
213                 channelNumber = chan->number;
214         }
215         mode=Next;
216         updateEpgDataNowNext(true);
217         setButtonText();
218         TVMediaInfo *info= new TVMediaInfo();
219         info->setStaticArtwork(sa_tv);
220         setTitleBarIcon(info);
221         draw(true);
222         boxstack->update(this);
223 }
224 void VEpgListAdvanced::doNow()
225 {
226         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doNow");
227         if (mode!=OneChannel) {
228                 Channel * chan=(*chanList)[ sl.getCurrentOptionData()];
229                 channelNumber = chan->number;
230         }
231         mode=Now;
232         updateEpgDataNowNext(true);
233         setButtonText();
234         TVMediaInfo *info= new TVMediaInfo();
235         info->setStaticArtwork(sa_tv);
236         setTitleBarIcon(info);
237         draw(true);
238         boxstack->update(this);
239 }
240
241 void VEpgListAdvanced::doProgramm()
242 {
243         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doProgram");
244         mode=OneChannel;
245
246         Channel * chan=(*chanList)[ sl.getCurrentOptionData()];
247         channelNumber = chan->number;
248         updateEpgDataChannel();
249         setButtonText();
250         TVMediaInfo *info= new TVMediaInfo();
251         info->setChannelLogo(channelNumber);
252         info->setStaticFallback(sa_tv);
253         setTitleBarIcon(info);
254         draw(true);
255         boxstack->update(this);
256 }
257
258 void VEpgListAdvanced::doSwitch()
259 {
260
261         if (videolive)
262         {
263                 if (mode!=OneChannel) {
264                         Channel * chan=(*chanList)[ sl.getCurrentOptionData()];
265                         channelNumber = chan->number;
266                 }
267                 Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "doSwitch %d", channelNumber);
268                 Message* m = new Message(); // Must be done after this view deleted
269                 m->from = this;
270                 m->to = videolive;
271                 m->message = Message::CHANNEL_CHANGE;
272                 m->parameter.num = channelNumber;
273                 m->tag = 0;
274                 Command::getInstance()->postMessageNoLock(m);
275         }
276 }
277
278 void VEpgListAdvanced::doRecord()
279 {
280         int channel;
281         Event* current = getCurrentOptionEvent(channel);
282         if (current)
283         {
284                 Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id);
285                 unsigned int chanlistsize=chanList->size();
286                 Channel * chan;
287                 UINT listIndex;
288                 for(listIndex = 0; listIndex < chanlistsize; listIndex++)
289                 {
290                         chan = (*chanList)[listIndex];
291                         if ((int)chan->number == channel) break;
292                 }
293
294                 Log::getInstance()->log("VEpgSummary", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", current->id, current->time,
295                                 current->duration, current->title);
296                 VEpgSetTimer* vs = new VEpgSetTimer(current, chan);
297                 vs->draw();
298                 boxstack->add(vs);
299                 boxstack->update(vs);
300         }
301
302 }
303
304 void VEpgListAdvanced::doGrid()
305 {
306
307         if (mode!=OneChannel) {
308                 Channel * chan=(*chanList)[ sl.getCurrentOptionData()];
309                 channelNumber = chan->number;
310         }
311         UINT listIndex;
312         unsigned int chanlistsize=chanList->size();
313         Channel *chan;
314         for(listIndex = 0; listIndex < chanlistsize; listIndex++)
315         {
316                 chan = (*chanList)[listIndex];
317                 if (chan->number == channelNumber) break;
318         }
319
320         VEpg* vepg = new VEpg(videolive, listIndex, chanList);
321         vepg->draw();
322         boxstack->add(vepg);
323         boxstack->update(vepg);
324
325 }
326
327 void VEpgListAdvanced::clearEventList()
328 {
329         std::vector<EventList*>::iterator itty = eventLista.begin();
330         while (itty!= eventLista.end()) {
331                 if (*itty) {
332                         (*itty)->clear();
333                         delete (*itty);
334                 }
335                 itty++;
336         }
337         eventLista.clear();
338
339 }
340
341
342 /* Prototype
343  *
344  *   if (!chanList) return;
345   Channel* chan;
346   for(UINT listIndex = 0; listIndex < gridRows; listIndex++)
347   {
348     if(listTop + listIndex >= UINT(chanListbox.getBottomOption()))
349       continue;
350     chan = (*chanList)[listTop + listIndex];
351     eventLista[listIndex] = VDR::getInstance()->getChannelSchedule(chan->number, ltime - 1, window_width * 60 + 2); // ltime - 1 to get prog before window (allows cursor left past ltime). + 2 to get prog after window
352   }
353
354  */
355
356 void VEpgListAdvanced::updateEpgData()
357 {
358         switch (mode)
359         {
360         case OneChannel: {
361                 //updateEpgDataChannel();
362         } break;
363         case Next:
364         case Now: {
365                 updateEpgDataNowNext(false);
366         } break;
367         };
368
369 }
370
371 void VEpgListAdvanced::updateEpgDataNowNext(bool changeState)
372 {
373         int startupdate=0;
374         int endupdate=0;
375
376         unsigned int chanlistsize=chanList->size();
377         if (changeState) {
378                 clearEventList();
379                 eventLista.resize(chanList->size());
380                 Channel* chan;
381                 for(UINT listIndex = 0; listIndex < chanlistsize; listIndex++)
382                 {
383                         if (listIndex < 0) continue;
384                         if (listIndex >= chanlistsize) continue;
385                         chan = (*chanList)[listIndex];
386                         if (chan->number == channelNumber) {
387                                 startupdate = listIndex-sl.getNumOptionsDisplayable()-2;
388                                 endupdate = listIndex+sl.getNumOptionsDisplayable()+2;
389                                 break;
390                         }
391                 }
392         } else {
393                 startupdate=sl.getTopOption()-2;
394                 endupdate=sl.getBottomOption()+1;
395         }
396
397         time_t now;
398         time(&now);
399
400         Channel* chan;
401         for(int listIndex = startupdate; listIndex < endupdate; listIndex++)
402         {
403                 if (listIndex < 0) continue;
404                 if (listIndex >= (int)chanlistsize) continue;
405
406             chan = (*chanList)[listIndex];
407                 if (!eventLista[listIndex]) eventLista[listIndex] = VDR::getInstance()->getChannelSchedule(chan->number, now, 4 * 60 *60);
408
409         }
410
411 }
412
413 void VEpgListAdvanced::updateEpgDataChannel()
414 {
415         clearEventList();
416         eventLista.resize(1);
417         time_t now;
418         time(&now);
419         eventLista[0] = VDR::getInstance()->getChannelSchedule(channelNumber, now, 24 * 60 *60 *30); // one month
420         Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Eventlist %x %d", eventLista[0],channelNumber);
421
422 }
423
424 void VEpgListAdvanced::drawData(bool doIndexPop)
425 {
426         switch (mode)
427         {
428         case OneChannel: {
429                 drawDataChannel(doIndexPop);
430         } break;
431         case Next: {
432                 drawDataNowNext(true, doIndexPop);
433         } break;
434         case Now: {
435                 drawDataNowNext(false, doIndexPop);
436         } break;
437         };
438
439 }
440
441 void VEpgListAdvanced::drawDataChannel(bool doIndexPop)
442 {
443   int saveIndex = sl.getCurrentOption();
444   int saveTop = sl.getTopOption();
445   sl.clear();
446   sl.addColumn(0);
447   sl.addColumn(25 );
448   sl.addColumn(25 + 7);
449   sl.addColumn(25 + 7+ 7);
450   //sl.addColumn(118);
451
452   int first = 1;
453
454   char tempA[300]; // FIXME  this is guesswork!
455   char tempB[300]; // FIXME
456   char tempC[300]; // FIXME
457   struct tm btime;
458
459
460
461
462   Event* currentEvent = NULL;
463   EventList::iterator j;
464   EventList* eventList = eventLista[0];
465   if (eventList) {
466           for (j = eventList->begin(); j != eventList->end(); j++)
467           {
468                   currentEvent = *j;
469                   time_t eventStartTime = (time_t)currentEvent->time;
470                   time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
471
472                   LOCALTIME_R(&eventStartTime, &btime);
473                   strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
474                   LOCALTIME_R(&eventEndTime, &btime);
475                   strftime(tempB, 299, "- %H:%M ", &btime);
476                   //#endif
477                   sprintf(tempC, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
478                   // New TVMedia stuff
479                   TVMediaInfo *info= new TVMediaInfo();
480                   info->setPosterThumb(channelNumber, currentEvent->id);
481                   info->setStaticFallback(sa_defposter);
482                   currentEvent->index = sl.addOption(tempC, currentEvent->id, first, info);
483                   first = 0;
484           }
485   }
486
487   if (doIndexPop)
488   {
489     sl.hintSetCurrent(0);
490   }
491   else
492   {
493     sl.hintSetCurrent(saveIndex);
494     sl.hintSetTop(saveTop);
495   }
496   updateSelection();
497
498 }
499
500 void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop)
501 {
502   int saveIndex = sl.getCurrentOption();
503   int saveTop = sl.getTopOption();
504   sl.clear();
505   sl.addColumn(0);
506   sl.addColumn(42 );
507   sl.addColumn(160);
508
509   int first = 1;
510
511   char tempA[300]; // FIXME  this is guesswork!
512   char tempB[300]; // FIXME
513   char tempC[300]; // FIXME
514   struct tm btime;
515
516
517
518
519   Event* currentEvent = NULL;
520   EventList::iterator j;
521   int minevents=1;
522   if (next) minevents++;
523   int setcurrenthelper =0;
524
525   unsigned int chanlistsize=chanList->size();
526   for(UINT listIndex = 0; listIndex < chanlistsize; listIndex++)
527   {
528           Channel* chan;
529           chan = (*chanList)[listIndex];
530
531           EventList* eventList = eventLista[listIndex];
532           if (eventList && ((int)eventList->size() >= minevents)) {
533                   j = eventList->begin();
534
535                   currentEvent = j[minevents-1];
536                   time_t eventStartTime = (time_t)currentEvent->time;
537                   time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
538
539                   LOCALTIME_R(&eventStartTime, &btime);
540                   strftime(tempA, 299, "%H:%M ", &btime);
541                   LOCALTIME_R(&eventEndTime, &btime);
542                   strftime(tempB, 299, "- %H:%M ", &btime);
543                   //#endif
544                   sprintf(tempC, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
545
546           } else {
547                   sprintf(tempC, "\n%s", chan->name);
548
549           }
550           TVMediaInfo *info= new TVMediaInfo();
551           if ((*chanList)[listIndex]->number == channelNumber) {
552                   first = 1;
553                   setcurrenthelper = listIndex;
554           }
555           info->setChannelLogo((*chanList)[listIndex]->number);
556           info->setStaticFallback(sa_tv);
557           int index =sl.addOption(tempC, listIndex, first, info);
558           if (currentEvent) currentEvent->index = index;
559           first = 0;
560   }
561
562   if (doIndexPop)
563   {
564     sl.hintSetCurrent(setcurrenthelper);
565   }
566   else
567   {
568     sl.hintSetCurrent(saveIndex);
569     sl.hintSetTop(saveTop);
570   }
571   updateSelection();
572 }
573
574 void VEpgListAdvanced::draw(bool doIndexPop)
575 {
576
577         // Single channel mode
578         switch (mode) {
579         case OneChannel: {
580                 char tempA[300];
581                  unsigned int chanlistsize=chanList->size();
582                  Channel * chan;
583                  UINT listIndex;
584                  for(listIndex = 0; listIndex < chanlistsize; listIndex++)
585                  {
586                          chan = (*chanList)[listIndex];
587                          if (chan->number == channelNumber) break;
588                  }
589                 sprintf(tempA, tr("Schedule - %s"), (*chanList)[listIndex]->name);
590                 setTitleText(tempA);
591         } break;
592         case Now: {
593                 setTitleText(tr("Now"));
594         } break;
595         case Next: {
596                 setTitleText(tr("Next"));
597         } break;
598         };
599
600
601
602         drawData(doIndexPop);
603
604         TBBoxx::draw();
605
606
607
608
609
610
611
612         char freeSpace[50];
613         struct tm btime;
614         time_t now;
615         time(&now);
616         LOCALTIME_R(&now, &btime);
617         strftime(freeSpace, 299, "%d/%m/%y", &btime);
618
619         drawTextRJ(freeSpace, getWidth(), 5, DrawStyle::LIGHTTEXT);
620
621         // Symbols
622
623         WSymbol w;
624         TEMPADD(&w);
625         w.nextSymbol = WSymbol::UP;
626         w.setPosition(20, area.h-35);
627         w.draw();
628         w.nextSymbol = WSymbol::DOWN;
629         w.setPosition(50, area.h-35);
630         w.draw();
631         w.nextSymbol = WSymbol::SKIPBACK;
632         w.setPosition(85, area.h-35);
633         w.draw();
634         w.nextSymbol = WSymbol::SKIPFORWARD;
635         w.setPosition(115, area.h-35);
636         w.draw();
637
638         drawTextRJ(tr("[ok] = info"), 560+70, sl.getY2()+4, DrawStyle::LIGHTTEXT);
639
640         // All static stuff done
641
642
643 }
644
645 Event* VEpgListAdvanced::getCurrentOptionEvent(int& channel)
646 {
647         // version for channel
648         Event* currentEvent = NULL;
649         EventList::iterator j;
650         EventList* eventList = NULL;
651         switch (mode)
652         {
653         case OneChannel: {
654                 eventList = eventLista[0];
655                 if (eventList) {
656                         channel = channelNumber;
657                         for (j = eventList->begin(); j != eventList->end(); j++)
658                         {
659                                 currentEvent = *j;
660                                 if (currentEvent->index == sl.getCurrentOption()) return currentEvent;
661                         }
662
663
664                 } break;
665         case Next: {
666                 eventList = eventLista[sl.getCurrentOptionData()];
667                 channel = (*chanList)[sl.getCurrentOptionData()]->number;
668
669
670                 if (eventList && eventList->size()>1) {
671                         j = eventList->begin();
672                         currentEvent = j[1];
673                 } else {
674                         currentEvent = NULL;
675                 }
676         } break;
677         case Now: {
678                 eventList = eventLista[sl.getCurrentOptionData()];
679                 channel = (*chanList)[sl.getCurrentOptionData()]->number;
680
681                 if (eventList && eventList->size()>0) {
682                         j = eventList->begin();
683                         currentEvent = j[0];
684                 } else {
685                         currentEvent = NULL;
686                 }
687         } break;
688         };
689
690
691   }
692   return currentEvent;
693 }
694
695
696
697 void VEpgListAdvanced::updateSelection()
698 {
699         int channel=0;
700         if (mode==OneChannel) {
701                 TVMediaInfo *info= new TVMediaInfo();
702                 info->setChannelLogo(channelNumber);
703                 info->setStaticFallback(sa_tv);
704                 setTitleBarIcon(info);
705         }
706         Event* toShow = getCurrentOptionEvent(channel);
707         if (toShow)
708         {
709                 toShow->loadinfos(channel);
710                 std::stringstream description;
711
712                 description << "\n"<< toShow->title  << "\n\n";
713                 description << toShow->subtitle <<"\n";
714                 description << toShow->description;
715
716                 TVMedia poster;
717                 poster.height=0;
718                 if (toShow->movieInfo) {
719                         poster=toShow->movieInfo->poster;
720                 }
721                 if (toShow->seriesInfo) {
722                         if (toShow->seriesInfo->seasonposter.height) {
723                                 poster=toShow->seriesInfo->seasonposter;
724                         }
725                         else if (toShow->seriesInfo->posters.size()) {
726                                 poster=toShow->seriesInfo->posters[0];
727                         }
728                 }
729                 if (poster.height) {
730                         epgTVmedia.setTVMedia(poster.info, WTVMedia::ZoomHorizontal);
731                         epgTVmedia.setVisible(true);
732                 } else {
733                         if (toShow->epgImage)
734                         {
735                                 TVMediaInfo info;
736                                 info.setPosterThumb(channel,toShow->id);
737                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
738                                 epgTVmedia.setVisible(true);
739                         }else if (mode!=OneChannel) {
740                                 TVMediaInfo info;
741                                 info.setChannelLogo(channel);
742                                 epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
743                                 epgTVmedia.setVisible(true);
744                         } else {
745                                 epgTVmedia.setVisible(false);
746                         }
747                 }
748
749                 epg.setText(description.str().c_str());
750         } else {
751                 epg.setText("");
752                 if (mode!=OneChannel) {
753                         TVMediaInfo info;
754                         info.setChannelLogo(channel);
755                         epgTVmedia.setTVMedia(info, WTVMedia::ZoomHorizontal);
756                         epgTVmedia.setVisible(true);
757                 } else {
758                         epgTVmedia.setVisible(false);
759                 }
760         }
761
762 }
763
764 int VEpgListAdvanced::handleCommand(int command)
765 {
766   switch(command)
767   {
768     case Remote::DF_UP:
769     case Remote::UP:
770     {
771       sl.up();
772       quickUpdate();
773
774       boxstack->update(this);
775       return 2;
776     }
777     case Remote::DF_DOWN:
778     case Remote::DOWN:
779     {
780       sl.down();
781       quickUpdate();
782
783       boxstack->update(this);
784       return 2;
785     }
786     case Remote::SKIPBACK:
787     {
788       sl.pageUp();
789       quickUpdate();
790
791       boxstack->update(this);
792       return 2;
793     }
794     case Remote::SKIPFORWARD:
795     {
796       sl.pageDown();
797       quickUpdate();
798
799       boxstack->update(this);
800       return 2;
801     }
802     case Remote::RED:
803     {
804         doRed();
805         return 2;
806     }
807     case Remote::GREEN:
808     {
809         doGreen();
810         return 2;
811     }
812     case Remote::YELLOW:
813     {
814         doYellow();
815         return 2;
816     }
817     case Remote::BLUE:
818     {
819         doBlue();
820         return 2;
821     }
822     case Remote::OK:
823     {
824       if (sl.getNumOptions() == 0) return 2;
825
826
827       int channel;
828       Event* current = getCurrentOptionEvent(channel);
829       if (current)
830       {
831           Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "Found the option you pointed at. %s %d", current->title, current->id);
832           unsigned int chanlistsize=chanList->size();
833           Channel * chan;
834           UINT listIndex;
835           for(listIndex = 0; listIndex < chanlistsize; listIndex++)
836           {
837                   chan = (*chanList)[listIndex];
838                   if ((int)chan->number == channel) break;
839           }
840
841           VEpgSummary* vr = new VEpgSummary(current, (*chanList)[listIndex]);
842           vr->draw();
843           boxstack->add(vr);
844           boxstack->update(vr);
845
846           return 2;
847       }
848       // should not get to here
849       return 1;
850     }
851     case Remote::BACK:
852     {
853         return 4;
854     }
855   }
856   // stop command getting to any more views
857   return 1;
858 }
859
860 void VEpgListAdvanced::processMessage(Message* m)
861 {
862   Log::getInstance()->log("VEpgListAdvanced", Log::DEBUG, "Got message value %lu", m->message);
863
864   if (m->message == Message::MOUSE_MOVE)
865   {
866     if (sl.mouseMove((m->parameter.num>>16)-getScreenX(),(m->parameter.num&0xFFFF)-getScreenY()))
867     {
868       quickUpdate();
869       boxstack->update(this);
870     }
871   }
872   else if (m->message == Message::MOUSE_LBDOWN)
873   {
874     if (sl.mouseLBDOWN((m->parameter.num>>16)-getScreenX(),(m->parameter.num&0xFFFF)-getScreenY()))
875     {
876       boxstack->handleCommand(Remote::OK); //simulate OK press
877     }
878         else if (boxRed.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
879         {
880                 boxstack->handleCommand(Remote::RED);
881         }
882         else if (boxGreen.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
883         {
884                 boxstack->handleCommand(Remote::GREEN);
885         }
886         else if (boxYellow.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
887         {
888                 boxstack->handleCommand(Remote::GREEN);
889         }
890         else if (boxBlue.mouseLBDOWN((m->parameter.num >> 16) - getScreenX(), (m->parameter.num & 0xFFFF) - getScreenY()))
891         {
892                 boxstack->handleCommand(Remote::GREEN);
893         }
894     else
895     {
896       //check if press is outside this view! then simulate cancel
897       int x=(m->parameter.num>>16)-getScreenX();
898       int y=(m->parameter.num&0xFFFF)-getScreenY();
899       if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
900       {
901         boxstack->handleCommand(Remote::BACK); //simulate cancel press
902       }
903     }
904   }
905 }
906
907
908
909 void VEpgListAdvanced::quickUpdate() { //only quick for plattform that need it!
910         updateEpgData();
911         updateSelection();
912 #ifdef GRADIENT_DRAWING
913       draw();
914 #else
915       sl.draw();
916       epg.draw();
917 #endif
918 }