]> git.vomp.tv Git - vompclient.git/blob - vmute.cc
More compiler warning fixes
[vompclient.git] / vmute.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 "vmute.h"
22
23 #include "remote.h"
24 #include "audio.h"
25 #include "video.h"
26 #include "wsymbol.h"
27 #include "colour.h"
28 #include "timers.h"
29 #include "boxstack.h"
30 #include "command.h"
31
32 VMute::VMute()
33 {
34   isMuted = Audio::getInstance()->toggleUserMute();
35
36   setSize(40, 40);
37   createBuffer();
38   if (Video::getInstance()->getFormat() == Video::PAL)
39   {
40     setPosition(600, 500);
41   }
42   else
43   {
44     setPosition(590, 400);
45   }
46 }
47
48 VMute::~VMute()
49 {
50   // Make sure the timer is deleted
51   Timers::getInstance()->cancelTimer(this, 1);
52 }
53
54 void VMute::draw()
55 {
56   // draw background?
57   fillColour(DrawStyle::VIEWBACKGROUND);
58
59   WSymbol w;
60   TEMPADD(&w);
61   if (isMuted) w.nextSymbol = WSymbol::MUTE;
62   else w.nextSymbol = WSymbol::UNMUTE;
63   w.setPosition(5, 5);
64   w.draw();
65
66   Timers::getInstance()->setTimerD(this, 1, 2);
67 }
68
69 void VMute::timercall(int clientReference)
70 {
71   // delete me!
72   Message* m = new Message(); // Delete self
73   m->message = Message::CLOSE_ME;
74   m->to = BoxStack::getInstance();
75   m->from = this;
76   Command::getInstance()->postMessageFromOuterSpace(m);
77 }
78
79 int VMute::handleCommand(int command)
80 {
81   switch(command)
82   {
83     case Remote::MUTE:
84     {
85       isMuted = Audio::getInstance()->toggleUserMute();
86       draw();
87       BoxStack::getInstance()->update(this);
88       // handled
89       return 2;
90     }
91   }
92
93   // allow command to drop through to other views
94   return 0;
95 }