00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include "vumeter.h"
00024 #include <qpainter.h>
00025
00026 #include <math.h>
00027
00028 VUMeter::VUMeter(QWidget *parent, const char *name )
00029 : QWidget( parent, name ), Lannot("A"), Rannot("440 Hz")
00030 {
00031
00032
00033 vuvalue = 0;
00034
00035 pix = 0;
00036
00037
00038 }
00039
00040 VUMeter::~VUMeter()
00041 {
00042 delete(pix);
00043 }
00044
00045 void VUMeter::paintEvent(QPaintEvent *){
00046
00047 vupdate();
00048 }
00049
00050 void VUMeter::bupdate(){
00051
00052 if (!pix){
00053 pix = new QPixmap(rect().size());
00054 }
00055
00056
00057 pix->fill(this, 0, 0);
00058
00059 QPainter p( pix );
00060
00061 p.setBrush(white);
00062 p.setPen(NoPen);
00063
00064 p.drawRect( QRect(0, 0, width(), height()) );
00065
00066 p.translate(width()/2, 0);
00067
00068 p.setBrush(black);
00069 p.setPen(black);
00070
00071
00072
00073
00074
00075 p.drawText(-100,15,Lannot);
00076 p.drawText(65,15,Rannot);
00077
00078 p.drawText(-100, height()-25, QString("-"));
00079 p.drawText(85, height()-25, QString("+"));
00080 p.drawText(-2, 20, QString("0"));
00081 p.end();
00082
00083 }
00084
00085 void VUMeter::vupdate(){
00086
00087 if (!pix){
00088 bupdate();
00089 }
00090
00091
00092
00093 QPixmap tmp_pix(rect().size());
00094
00095 QPainter p( &tmp_pix );
00096 p.drawPixmap(QPoint(0,0), *pix);
00097
00098 p.translate(width()/2, 0);
00099 p.drawLine((vuvalue), height()-10, vuvalue*2, 25);
00100 p.end();
00101 bitBlt(this, rect().topLeft(), &tmp_pix);
00102 }
00103
00104
00105