Audacity 3.2.0
FreqGauge.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FreqGauge.cpp
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11/*
12 Salvo Ventura - November 2006
13 Extended range check for additional FFT windows
14*/
15
16#include "FreqGauge.h"
17#include "FFT.h"
18
19#include <wx/dcclient.h>
20
21FreqGauge::FreqGauge(wxWindow * parent, wxWindowID winid)
22: wxStatusBar(parent, winid, wxST_SIZEGRIP)
23{
24 mRange = 0;
25}
26
27void FreqGauge::SetRange(int range, int bar, int gap)
28{
29 mRange = range;
30 mBar = bar;
31 mGap = gap;
32
33 GetFieldRect(0, mRect);
34 mRect.Inflate(-1);
35
36 mInterval = mRange / (mRect.width / (mBar + mGap));
37 mRect.width = mBar;
38 mMargin = mRect.x;
39 mLast = -1;
40
41 Update();
42}
43
44void FreqGauge::SetValue(int value)
45{
46 mCur = value / mInterval;
47
48 if (mCur != mLast)
49 {
50 wxClientDC dc(this);
51 dc.SetPen(*wxTRANSPARENT_PEN);
52 dc.SetBrush(wxColour(100, 100, 220));
53
54 while (mLast < mCur)
55 {
56 mLast++;
57 mRect.x = mMargin + mLast * (mBar + mGap);
58 dc.DrawRectangle(mRect);
59 }
60 Update();
61 }
62}
63
65{
66 mRange = 0;
67 Refresh(true);
68}
static const int gap
Definition: MeterPanel.cpp:194
int mInterval
Definition: FreqGauge.h:30
int mRange
Definition: FreqGauge.h:27
int mGap
Definition: FreqGauge.h:32
int mBar
Definition: FreqGauge.h:31
int mLast
Definition: FreqGauge.h:29
int mCur
Definition: FreqGauge.h:28
int mMargin
Definition: FreqGauge.h:33
void SetRange(int range, int bar=12, int gap=3)
Definition: FreqGauge.cpp:27
void Reset()
Definition: FreqGauge.cpp:64
void SetValue(int value)
Definition: FreqGauge.cpp:44
wxRect mRect
Definition: FreqGauge.h:26
FreqGauge(wxWindow *parent, wxWindowID winid)
Definition: FreqGauge.cpp:21