summaryrefslogtreecommitdiff
path: root/noncore/multimedia/powerchord/vumeter.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/powerchord/vumeter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/powerchord/vumeter.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/noncore/multimedia/powerchord/vumeter.cpp b/noncore/multimedia/powerchord/vumeter.cpp
new file mode 100644
index 0000000..0c17435
--- a/dev/null
+++ b/noncore/multimedia/powerchord/vumeter.cpp
@@ -0,0 +1,105 @@
1//
2// VUMeter class
3//
4
5// Copyright (c) 2001 Camilo Mesias
6// camilo@mesias.co.uk
7//
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU General Public License
10// as published by the Free Software Foundation; either version 2
11// of the License, or (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22#include <stdio.h>
23#include "vumeter.h"
24#include <qpainter.h>
25
26#include <math.h>
27
28VUMeter::VUMeter(QWidget *parent, const char *name )
29 : QWidget( parent, name ), Lannot("A"), Rannot("440 Hz")
30{
31 // setPalette( QPalette( QColor( 250, 250, 200) ) );
32
33 vuvalue = 0;
34
35 pix = 0;
36
37
38}
39
40VUMeter::~VUMeter()
41{
42 delete(pix);
43}
44
45void VUMeter::paintEvent(QPaintEvent *){
46
47 vupdate();
48}
49
50void VUMeter::bupdate(){
51
52 if (!pix){
53 pix = new QPixmap(rect().size());
54 }
55 // redraw whole background to buffer
56
57 pix->fill(this, 0, 0);
58
59 QPainter p( pix );
60
61 p.setBrush(white);
62 p.setPen(NoPen);
63
64 p.drawRect( QRect(0, 0, width(), height()) );
65
66 p.translate(width()/2, 0);
67
68 p.setBrush(black);
69 p.setPen(black);
70
71 // for (int i=-50;i<50;i+=4){
72 // p.drawLine((vuvalue), height()-10, vuvalue*2, 25);
73 // }
74
75 p.drawText(-100,15,Lannot);
76 p.drawText(65,15,Rannot);
77
78 p.drawText(-100, height()-25, QString("-"));
79 p.drawText(85, height()-25, QString("+"));
80 p.drawText(-2, 20, QString("0"));
81 p.end();
82
83}
84
85void VUMeter::vupdate(){
86
87 if (!pix){
88 bupdate();
89 }
90
91 // redraw line only
92
93 QPixmap tmp_pix(rect().size());
94
95 QPainter p( &tmp_pix );
96 p.drawPixmap(QPoint(0,0), *pix);
97
98 p.translate(width()/2, 0);
99 p.drawLine((vuvalue), height()-10, vuvalue*2, 25);
100 p.end();
101 bitBlt(this, rect().topLeft(), &tmp_pix);
102}
103
104
105