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