]> git.vomp.tv Git - vompclient.git/blob - vtimeredit.cc
View timer
[vompclient.git] / vtimeredit.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 "vtimeredit.h"
22
23 VTimerEdit::VTimerEdit(RecTimer* trt)
24 {
25   recTimer = trt;
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("Edit Timer"));
41   setTitleBarColour(Colour::TITLEBARBACKGROUND);
42
43
44   // Draw statics
45
46   draw(); // View::draw
47
48   int xpos = 20;
49   int ypos = 50;
50   drawText("Active", xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
51   drawText("Channel", xpos, ypos, Colour::LIGHTTEXT);        ypos += surface->getFontHeight();
52   drawText("Name", xpos, ypos, Colour::LIGHTTEXT);           ypos += surface->getFontHeight();
53   drawText("Directory", xpos, ypos, Colour::LIGHTTEXT);      ypos += surface->getFontHeight();
54                                                              ypos += surface->getFontHeight();
55   drawText("Start", xpos, ypos, Colour::LIGHTTEXT);          ypos += surface->getFontHeight();
56   drawText("Stop", xpos, ypos, Colour::LIGHTTEXT);           ypos += surface->getFontHeight();
57   drawText("Priority", xpos, ypos, Colour::LIGHTTEXT);       ypos += surface->getFontHeight();
58   drawText("Lifetime", xpos, ypos, Colour::LIGHTTEXT);       ypos += surface->getFontHeight();
59                                                              ypos += surface->getFontHeight();
60   drawText("Current", xpos, ypos, Colour::LIGHTTEXT);        ypos += surface->getFontHeight();
61   drawText("Recording", xpos, ypos, Colour::LIGHTTEXT);      ypos += surface->getFontHeight();
62   drawText("Summary", xpos, ypos, Colour::LIGHTTEXT);        ypos += surface->getFontHeight();
63
64
65   // Temp
66   char buffer[1000];
67   struct tm* tms;
68   xpos = 150;
69   ypos = 50;
70
71   // Active
72   if (recTimer->active) strcpy(buffer, "Yes");
73   else                  strcpy(buffer, "No");
74   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
75
76   // Channel
77   snprintf(buffer, 999, "%lu", recTimer->channelNumber);
78   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
79
80   // Name
81   snprintf(buffer, 999, "%s", recTimer->getName());
82   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
83
84   // Directory
85   if (recTimer->getDirectory()) snprintf(buffer, 999, "%s", recTimer->getDirectory());
86   else strcpy(buffer, "");
87   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
88                                                            ypos += surface->getFontHeight();
89
90   // Start
91   tms = localtime((time_t*)&recTimer->startTime);
92   strftime(buffer, 999, "%d/%m %H:%M", tms);
93   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
94
95   // Stop
96   tms = localtime((time_t*)&recTimer->stopTime);
97   strftime(buffer, 999, "%d/%m %H:%M", tms);
98   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
99
100   // Priority
101   snprintf(buffer, 999, "%lu", recTimer->priority);
102   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
103
104   // Lifetime
105   snprintf(buffer, 999, "%lu", recTimer->lifeTime);
106   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
107                                                            ypos += surface->getFontHeight();
108
109   // Current
110   if (recTimer->pending) strcpy(buffer, "Yes");
111   else                   strcpy(buffer, "No");
112   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
113
114   // Recording now
115   if (recTimer->recording) strcpy(buffer, "Yes");
116   else                     strcpy(buffer, "No");
117   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
118
119   // Summary
120   strcpy(buffer, "View summary");
121   drawText(buffer, xpos, ypos, Colour::LIGHTTEXT);         ypos += surface->getFontHeight();
122
123
124 }
125
126 VTimerEdit::~VTimerEdit()
127 {
128 }
129
130 int VTimerEdit::handleCommand(int command)
131 {
132   switch(command)
133   {
134     case Remote::DF_UP:
135     case Remote::UP:
136     {
137
138       ViewMan::getInstance()->updateView(this);
139       return 2;
140     }
141     case Remote::DF_DOWN:
142     case Remote::DOWN:
143     {
144
145       ViewMan::getInstance()->updateView(this);
146       return 2;
147     }
148     case Remote::OK:
149     {
150
151       return 2;
152     }
153     case Remote::BACK:
154     {
155       return 4;
156     }
157   }
158   // stop command getting to any more views
159   return 1;
160 }