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, bool bannerTakesCommands)
27 takeCommands = bannerTakesCommands;
30 if (Video::getInstance()->getFormat() == Video::PAL)
32 setScreenPos(125, 410);
36 setScreenPos(115, 320);
40 setBackgroundColour(Colour::VIEWBACKGROUND);
42 setTitleBarColour(Colour::TITLEBARBACKGROUND);
44 sl.setSurface(surface);
45 sl.setSurfaceOffset(0, 30);
46 sl.setDimensions(area.w, area.h - 60);
52 VLiveBanner::~VLiveBanner()
57 void VLiveBanner::delData()
61 int eventListSize = eventList->size();
62 for(int i = 0; i < eventListSize; i++)
64 delete (*eventList)[i];
73 void VLiveBanner::setChannel(Channel* tChannel)
76 currentChannel = tChannel;
79 setTitleText(currentChannel->name);
80 eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
84 sl.addOption(tr("No channel data available"), 1);
89 Log::getInstance()->log("Banner", Log::DEBUG, "Start sort");
90 sort(eventList->begin(), eventList->end(), EventSorter());
91 Log::getInstance()->log("Banner", Log::DEBUG, "End sort");
94 char tempString2[300];
98 int eventListSize = eventList->size();
99 for(int i = 0; i < eventListSize; i++)
101 event = (*eventList)[i];
103 btime = localtime((time_t*)&event->time);
104 strftime(tempString2, 299, "%0H:%0M ", btime);
105 snprintf(tempString, 299, "%s %s", tempString2, event->title);
106 event->index = sl.addOption(tempString, first);
110 // Reset the timer as it probably took 1-2 seconds to change the channel
111 ViewMan::getInstance()->timedDelete(this, 4, 0);
115 void VLiveBanner::draw()
119 rectangle(0, area.h - 30, area.w, 30, titleBarColour);
121 rectangle(7, area.h - 24, 18, 16, Colour::RED);
122 drawText(tr("info"), 32, area.h - 25, Colour::LIGHTTEXT);
125 int VLiveBanner::handleCommand(int command)
136 if (!takeCommands) return 0; // banner was auto, old remote
137 } // else drop through
146 case Remote::DF_DOWN:
148 if (!takeCommands) return 0; // banner was auto, old remote
149 } // else drop through
158 case Remote::CHANNELUP:
160 ViewMan::getInstance()->timedDelete(this, 0, 0); // cancel timer so this view is still here later
162 Message* m = new Message();
165 m->message = Message::CHANNEL_UP;
166 ViewMan::getInstance()->postMessage(m);
169 case Remote::CHANNELDOWN:
171 ViewMan::getInstance()->timedDelete(this, 0, 0);
173 Message* m = new Message();
176 m->message = Message::CHANNEL_DOWN;
177 ViewMan::getInstance()->postMessage(m);
183 if (!eventList) return 2;
185 int eventListSize = eventList->size();
186 for(int i = 0; i < eventListSize; i++)
188 event = (*eventList)[i];
189 if (event->index == sl.getCurrentOption())
191 Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
192 // First, cancel my delete timer
193 ViewMan::getInstance()->timedDelete(this, 0, 0);
195 VInfo* vi = new VInfo();
196 vi->setTitleText(event->title);
199 if (event->description) vi->setMainText(event->description);
200 else vi->setMainText(tr("Summary unavailable"));
201 if (Video::getInstance()->getFormat() == Video::PAL)
203 vi->setScreenPos(120, 130);
207 vi->setScreenPos(110, 90);
209 vi->create(510, 270);
211 ViewMan::getInstance()->addNoLock(vi);
219 return 2; // should not get here