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