]> git.vomp.tv Git - vompclient.git/blob - vtimerlist.cc
Recording timer list
[vompclient.git] / vtimerlist.cc
1 /*
2     Copyright 2004-2005 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, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vtimerlist.h"
22
23 VTimerList::VTimerList(RecTimerList* trtl)
24 {
25   recTimerList = trtl;
26
27   create(570, 420);
28   if (Video::getInstance()->getFormat() == Video::PAL)
29   {
30     setScreenPos(80, 70);
31   }
32   else
33   {
34     setScreenPos(70, 35);
35   }
36
37
38   setBackgroundColour(Colour::VIEWBACKGROUND);
39   setTitleBarOn(1);
40   setTitleText(tr("Timers"));
41   setTitleBarColour(Colour::TITLEBARBACKGROUND);
42
43   sl.setSurface(surface);
44   sl.setSurfaceOffset(10, 30 + 5);
45   sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
46
47   drawData();
48 }
49
50 VTimerList::~VTimerList()
51 {
52   if (recTimerList)
53   {
54     for (UINT i = 0; i < recTimerList->size(); i++)
55     {
56       delete (*recTimerList)[i];
57     }
58
59     recTimerList->clear();
60     delete recTimerList;
61   }
62 }
63
64 void VTimerList::drawData()
65 {
66   char str[500];
67
68   sl.addColumn(0);
69   sl.addColumn(60);
70
71   RecTimer* recTimer;
72   int first = 1;
73
74   for (UINT i = 0; i < recTimerList->size(); i++)
75   {
76     recTimer = (*recTimerList)[i];
77     sprintf(str, "%u\t%s", i, recTimer->file);
78     recTimer->index = sl.addOption(str, first);
79     first = 0;
80   }
81 }
82
83 void VTimerList::draw()
84 {
85   View::draw();
86   sl.draw();
87
88   // Put the status stuff at the bottom
89
90   WSymbol w;
91   w.setSurface(surface);
92
93   w.nextSymbol = WSymbol::UP;
94   w.setSurfaceOffset(20, 385);
95   w.draw();
96
97   w.nextSymbol = WSymbol::DOWN;
98   w.setSurfaceOffset(50, 385);
99   w.draw();
100
101   w.nextSymbol = WSymbol::SKIPBACK;
102   w.setSurfaceOffset(85, 385);
103   w.draw();
104
105   w.nextSymbol = WSymbol::SKIPFORWARD;
106   w.setSurfaceOffset(115, 385);
107   w.draw();
108
109 //  w.nextSymbol = WSymbol::PLAY;
110 //  w.setSurfaceOffset(150, 385);
111 //  w.draw();
112
113   doShowingBar();
114 }
115
116 void VTimerList::doShowingBar()
117 {
118   int topOption = sl.getTopOption() + 1;
119   if (sl.getNumOptions() == 0) topOption = 0;
120
121   char showing[200];
122   sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
123
124   rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
125   drawText(showing, 220, 385, Colour::LIGHTTEXT);
126 }
127
128 int VTimerList::handleCommand(int command)
129 {
130   switch(command)
131   {
132     case Remote::DF_UP:
133     case Remote::UP:
134     {
135       sl.up();
136       sl.draw();
137
138       doShowingBar();
139       ViewMan::getInstance()->updateView(this);
140       return 2;
141     }
142     case Remote::DF_DOWN:
143     case Remote::DOWN:
144     {
145       sl.down();
146       sl.draw();
147
148       doShowingBar();
149       ViewMan::getInstance()->updateView(this);
150       return 2;
151     }
152     case Remote::SKIPBACK:
153     {
154       sl.pageUp();
155       sl.draw();
156
157       doShowingBar();
158       ViewMan::getInstance()->updateView(this);
159       return 2;
160     }
161     case Remote::SKIPFORWARD:
162     {
163       sl.pageDown();
164       sl.draw();
165
166       doShowingBar();
167       ViewMan::getInstance()->updateView(this);
168       return 2;
169     }
170     case Remote::OK:
171     {
172       RecTimer* recTimer = NULL;
173       if (recTimerList)
174       {
175         int currentOption = sl.getCurrentOption();
176
177         for (UINT i = 0; i < recTimerList->size(); i++)
178         {
179           recTimer = (*recTimerList)[i];
180           if (currentOption == recTimer->index) break;
181         }
182       }
183
184       if (recTimer == NULL) return 2;
185
186       // recTimer is the one you want FIXME
187
188       return 2;
189     }
190     case Remote::BACK:
191     {
192       return 4;
193     }
194   }
195   // stop command getting to any more views
196   return 1;
197 }