]> git.vomp.tv Git - vompclient.git/blob - vvolume.cc
Fix text corruption in channel number display on live tv
[vompclient.git] / vvolume.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vvolume.h"
22
23 #include "remote.h"
24 #include "audio.h"
25 #include "wsymbol.h"
26 #include "colour.h"
27 #include "video.h"
28 #include "timers.h"
29 #include "boxstack.h"
30 #include "command.h"
31
32 VVolume::VVolume()
33 {
34   displayVolume = Audio::getInstance()->getVolume();
35
36   setSize(227, 31);
37   createBuffer();
38   if (Video::getInstance()->getFormat() == Video::PAL)
39   {
40     setPosition(100, 499);
41   }
42   else
43   {
44     setPosition(90, 400);
45   }
46 }
47
48 VVolume::~VVolume()
49 {
50   // Make sure the timer is deleted
51   Timers::getInstance()->cancelTimer(this, 1);
52 }
53
54 void VVolume::draw()
55 {
56   Boxx::draw();
57
58   fillColour(DrawStyle::VIEWBACKGROUND);
59
60   WSymbol w;
61   TEMPADD(&w);
62   w.nextSymbol = WSymbol::VOLUME2;
63   w.setPosition(3, 10);
64   w.draw();
65
66   int i = 0;
67
68   for(; i < displayVolume; i++)
69   {
70     w.nextSymbol = WSymbol::VOLBAR;
71     w.setPosition(40 + (i * 9), 3);
72     w.draw();
73   }
74
75   for(; i < 20; i++)
76   {
77     w.nextSymbol = WSymbol::VOLDOT;
78     w.setPosition(40 + (i * 9), 13);
79     w.draw();
80   }
81
82   Timers::getInstance()->setTimerD(this, 1, 2);
83 }
84
85 void VVolume::timercall(int clientReference)
86 {
87   // delete me!
88   Message* m = new Message(); // Delete self
89   m->message = Message::CLOSE_ME;
90   m->to = BoxStack::getInstance();
91   m->from = this;
92   Command::getInstance()->postMessageFromOuterSpace(m);
93 }
94
95 int VVolume::handleCommand(int command)
96 {
97   switch(command)
98   {
99     case Remote::DF_LEFT:
100     case Remote::VOLUMEDOWN:
101     {
102       displayVolume = Audio::getInstance()->volumeDown();
103       draw();
104       BoxStack::getInstance()->update(this);
105       // handled
106       return 2;
107     }
108     case Remote::DF_RIGHT:
109     case Remote::VOLUMEUP:
110     {
111       displayVolume = Audio::getInstance()->volumeUp();
112       draw();
113       BoxStack::getInstance()->update(this);
114       // handled
115       return 2;
116     }
117   }
118
119   // allow command to drop through to other views
120   return 0;
121 }