2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "vlivebanner.h"
23 VLiveBanner::VLiveBanner(View* tparent, Channel* channel)
29 if (Video::getInstance()->getFormat() == Video::PAL)
31 setScreenPos(125, 410);
35 setScreenPos(115, 320);
39 setBackgroundColour(Colour::VIEWBACKGROUND);
41 setTitleBarColour(Colour::TITLEBARBACKGROUND);
43 sl.setSurface(surface);
44 sl.setSurfaceOffset(0, 30);
45 sl.setDimensions(width, height - 60);
51 VLiveBanner::~VLiveBanner()
56 void VLiveBanner::delData()
60 int eventListSize = eventList->size();
61 for(int i = 0; i < eventListSize; i++)
63 delete (*eventList)[i];
72 void VLiveBanner::setChannel(Channel* tChannel)
75 currentChannel = tChannel;
78 setTitleText(currentChannel->name);
79 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
83 sl.addOption("No channel data available", 1);
88 Log::getInstance()->log("Banner", Log::DEBUG, "Start sort");
89 sort(eventList->begin(), eventList->end(), EventSorter());
90 Log::getInstance()->log("Banner", Log::DEBUG, "End sort");
93 char tempString2[300];
97 int eventListSize = eventList->size();
98 for(int i = 0; i < eventListSize; i++)
100 event = (*eventList)[i];
102 btime = localtime((time_t*)&event->time);
103 strftime(tempString2, 299, "%0H:%0M ", btime);
104 snprintf(tempString, 299, "%s %s", tempString2, event->title);
105 event->index = sl.addOption(tempString, first);
109 // Reset the timer as it probably took 1-2 seconds to change the channel
110 ViewMan::getInstance()->timedDelete(this, 4, 0);
114 void VLiveBanner::draw()
118 rectangle(0, height - 30, width, 30, titleBarColour);
120 rectangle(7, height - 24, 18, 16, Colour::RED);
121 drawText("info", 32, height - 25, Colour::LIGHTTEXT);
124 int VLiveBanner::handleCommand(int command)
142 case Remote::DF_DOWN:
151 case Remote::CHANNELUP:
153 Message* m = new Message();
156 m->message = Message::CHANNEL_UP;
157 ViewMan::getInstance()->postMessage(m);
160 case Remote::CHANNELDOWN:
162 Message* m = new Message();
165 m->message = Message::CHANNEL_DOWN;
166 ViewMan::getInstance()->postMessage(m);
172 if (!eventList) return 2;
174 int eventListSize = eventList->size();
175 for(int i = 0; i < eventListSize; i++)
177 event = (*eventList)[i];
178 if (event->index == sl.getCurrentOption())
180 Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
181 // First, cancel my delete timer
182 ViewMan::getInstance()->timedDelete(this, 0, 0);
184 VInfo* vi = new VInfo();
185 vi->setTitleText(event->title);
188 if (event->description) vi->setMainText(event->description);
189 else vi->setMainText("Summary unavailable");
190 if (Video::getInstance()->getFormat() == Video::PAL)
192 vi->setScreenPos(120, 130);
196 vi->setScreenPos(110, 90);
198 vi->create(510, 270);
200 ViewMan::getInstance()->addNoLock(vi);
208 return 2; // should not get here