CFugue
qvumeter.h
1 /*
2  This is part of CFugue, a C++ Runtime for MIDI Score Programming
3  Copyright (C) 2011 Gopalakrishna Palem
4 
5  For links to further information, or to contact the author,
6  see <http://musicnote.sourceforge.net/>.
7 */
8 /* */
9 /************ Modified from original code by Gopalakrishna Palem *********/
10 /* */
11 /***************************************************************************
12  * Copyright (C) 2008 - Giuseppe Cigala *
13  * g_cigala@virgilio.it *
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  * This program is distributed in the hope that it will be useful, *
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23  * GNU General Public License for more details. *
24  * *
25  * You should have received a copy of the GNU General Public License *
26  * along with this program; if not, write to the *
27  * Free Software Foundation, Inc., *
28  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
29  ***************************************************************************/
30 
31 #ifndef QVUMETER_H
32 #define QVUMETER_H
33 
34 #include <QtGui>
35 #include <QtDesigner/QDesignerExportWidget>
36 #include <math.h>
37 #include <QList>
38 #include <QStringList>
39 
40 class QVUBar : public QObject
41 {
42  Q_OBJECT
43  Q_PROPERTY(QColor colorOfText READ colorOfText WRITE setColorOfText);
44  Q_PROPERTY(QColor colorLow READ colorLow WRITE setColorLow);
45  Q_PROPERTY(QColor colorHigh READ colorHigh WRITE setColorHigh);
46  Q_PROPERTY(double Value READ value WRITE setValue);
47  Q_PROPERTY(double minValue READ minValue WRITE setMinValue);
48  Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue);
49  Q_PROPERTY(int dimValue READ valueDim WRITE setValueDim);
50  Q_PROPERTY(QString lable READ lable WRITE setLable);
51 
52  QColor colorOfText() const
53  {
54  return colText;
55  }
56  QColor colorLow() const
57  {
58  return colLow;
59  }
60  QColor colorHigh() const
61  {
62  return colHigh;
63  }
64  double value() const
65  {
66  return Value;
67  }
68  double minValue() const
69  {
70  return min;
71  }
72  double maxValue() const
73  {
74  return max;
75  }
76  int valueDim() const
77  {
78  return dimVal;
79  }
80  QString lable() const
81  {
82  return _lable;
83  }
84 
85 
86 public:
87 
88  QVUBar(QObject* pParent = NULL, QString strLabel = "", double min=0, double max = 100);
89 
90 
91 signals:
92 
93  void valueChanged(double);
94 
95 public slots:
96 
97  void setColorOfText(QColor);
98  void setColorHigh(QColor);
99  void setColorLow(QColor);
100  void setValueDim(int);
101  void setValue(double);
102  void setMinValue(double);
103  void setMaxValue(double);
104  void setMinMaxValues(double, double);
105  void setLable(QString);
106 
107 
108 protected:
109 
110  void paintEvent(QPaintEvent *);
111  void paintBorder();
112  void paintBar();
113  void paintValue();
114 
115  friend class QVUMeter;
116 
117 private:
118 
119  double min;
120  double max;
121  double Value;
122  int dimVal;
123  QColor colText;
124  QColor colHigh;
125  QColor colLow;
126  QString _lable;
127 };
128 
129 class /*QDESIGNER_WIDGET_EXPORT*/ QVUMeter : public QWidget
130 {
131  Q_OBJECT
132  Q_PROPERTY(QColor colorBg READ colorBg WRITE setColorBg);
133 
134  QColor colorBg() const
135  {
136  return colBack;
137  }
138 
139 public:
140 
141  QVUMeter(QWidget *parent = 0);
142 
143  QVUMeter(QStringList strBarLables, QWidget *parent = 0) ;
144 
145  /**
146  <Summary>
147  Sets the number of bars and their associated labels.
148  Sets value min, max ranges for all bars.
149  Existing bars will be deleted and replaced with new ones.
150  </Summary>
151  */
152  void SetBars(QStringList strBarLables, double min=0, double max=100);
153 
154  /**
155  <Summary>
156  Sets the number of Bars in the Meter.
157  Existing bars will be reduced or added to based on nCount.
158  </Summary>
159  */
160  void SetBarCount(int nCount, double min=0.0, double max=100.0);
161 
162  QSize minimumSizeHint() const;
163  QSize sizeHint() const;
164 
165  // Sets the Minimum and Maximum values for all bars present in the Meter
166  void SetMinMaxValues(double, double);
167 
168 signals:
169 
170  void valueLChanged(double);
171  void valueRChanged(double);
172 
173 public slots:
174 
175  void setColorBg(QColor);
176  QVUBar* GetBar(int nIndex) const;
177  int GetBarCount() const;
178 
179 protected:
180 
181  void paintEvent(QPaintEvent *);
182  void paintBorder();
183  void paintBar();
184  void paintValue();
185 
186 private:
187 
188  QColor colBack;
189 
190  int m_nBars; // Number of vertical bars to show
191  int m_nTotalWindowWidth;
192 
193  QList<QVUBar*> m_Bars;
194 
195 };
196 
197 #endif
void SetBars(QStringList strBarLables, double min=0, double max=100)
Definition: qvumeter.cpp:82
void SetBarCount(int nCount, double min=0.0, double max=100.0)
Definition: qvumeter.cpp:96

CFugue, the C++ Music Programming Library © Copyright 2009 Cenacle Research India Private Limited Gopalakrishna Palem