1 //============================================================================= 2 // Awl 3 // Audio Widget Library 4 // $Id:$ 5 // 6 // Copyright (C) 1999-2011 by Werner Schweer and others 7 // 8 // This program is free software; you can redistribute it and/or modify 9 // it under the terms of the GNU General Public License 10 // as published by the Free Software Foundation; version 2 of 11 // 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 //============================================================================= 22 23 #ifndef __AWLASLIDER_H__ 24 #define __AWLASLIDER_H__ 25 26 #include <QWidget> 27 28 class QKeyEvent; 29 class QWheelEvent; 30 31 namespace Awl { 32 33 //--------------------------------------------------------- 34 // AbstractSlider 35 // 36 //! The AwlAbstractSlider class provides an double value 37 //! within a range 38 // 39 //! The class is designed as a common super class for 40 //! widgets like AwlKnob and AwlSlider 41 //! 42 //--------------------------------------------------------- 43 44 class AbstractSlider : public QWidget { 45 46 Q_OBJECT 47 Q_PROPERTY(double value READ value WRITE setValue) 48 Q_PROPERTY(bool center READ center WRITE setCenter) 49 Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance) 50 51 Q_PROPERTY(int scaleWidth READ scaleWidth WRITE setScaleWidth) 52 Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor) 53 Q_PROPERTY(QColor scaleValueColor READ scaleValueColor WRITE setScaleValueColor) 54 55 Q_PROPERTY(int id READ id WRITE setId) 56 57 Q_PROPERTY(double minValue READ minValue WRITE setMinValue) 58 Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue) 59 Q_PROPERTY(double lineStep READ lineStep WRITE setLineStep) 60 Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep) 61 Q_PROPERTY(bool log READ log WRITE setLog) 62 Q_PROPERTY(bool integer READ integer WRITE setInteger) 63 64 protected: 65 int _id; 66 double _value; 67 double _minValue, _maxValue, _lineStep, _pageStep; 68 bool _center; 69 bool _invert; 70 int _scaleWidth; //! scale line width 71 QColor _scaleColor; 72 QColor _scaleValueColor; 73 bool _log; 74 bool _integer; 75 76 virtual void wheelEvent(QWheelEvent*); 77 virtual void keyPressEvent(QKeyEvent*); 78 virtual void valueChange(); 79 80 signals: 81 void valueChanged(double, int); 82 83 public slots: 84 virtual void setValue(double v); 85 86 public: 87 AbstractSlider(QWidget* parent = 0); 88 89 virtual void setCenter(bool val); 90 virtual void setScaleWidth(int); 91 virtual void setScaleColor(const QColor&); 92 virtual void setScaleValueColor(const QColor&); 93 94 //! return the center flag center()95 bool center() const { return _center; } 96 97 //! return the scale line width scaleWidth()98 int scaleWidth() const { return _scaleWidth; } 99 100 //! return current scale color scaleColor()101 QColor scaleColor() const { return _scaleColor; } 102 103 //! return color of active scale part scaleValueColor()104 QColor scaleValueColor() const { return _scaleValueColor; } 105 setInvertedAppearance(bool val)106 virtual void setInvertedAppearance(bool val) { _invert = val; } invertedAppearance()107 bool invertedAppearance() const { return _invert; } 108 id()109 int id() const { return _id; } setId(int i)110 void setId(int i) { _id = i; } 111 112 virtual double value() const; 113 minValue()114 double minValue() const { return _minValue; } setMinValue(double v)115 void setMinValue(double v) { _minValue = v; } 116 void setMinLogValue(double v); maxValue()117 double maxValue() const {return _maxValue; } setMaxValue(double v)118 void setMaxValue(double v) { _maxValue = v; } 119 void setMaxLogValue(double v); setRange(double a,double b)120 void setRange(double a, double b) { 121 setMinValue(a); 122 setMaxValue(b); 123 } setLogRange(double a,double b)124 void setLogRange(double a, double b) { 125 setMinLogValue(a); 126 setMaxLogValue(b); 127 } log()128 bool log() const { return _log; } setLog(bool v)129 void setLog(bool v) { _log = v; } integer()130 bool integer() const { return _integer; } setInteger(bool v)131 void setInteger(bool v) { _integer = v; } lineStep()132 double lineStep() const { return _lineStep; } setLineStep(double v)133 void setLineStep(double v) { _lineStep = v; } pageStep()134 double pageStep() const { return _pageStep; } setPageStep(double f)135 void setPageStep(double f) { _pageStep = f; } 136 void setEnabled(bool val); 137 }; 138 139 } 140 141 #endif 142 143