1 //============================================================================= 2 // Awl 3 // Audio Widget Library 4 // 5 // Copyright (C) 2002-2006 by Werner Schweer and others 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 //============================================================================= 19 20 #ifndef __AWLASLIDER_H__ 21 #define __AWLASLIDER_H__ 22 23 // #include "synthesizer/sparm.h" 24 #include <QAccessibleWidget> 25 26 namespace Awl { 27 28 //--------------------------------------------------------- 29 // AbstractSlider 30 // 31 //! The AwlAbstractSlider class provides an double value 32 //! within a range 33 // 34 //! The class is designed as a common super class for 35 //! widgets like AwlKnob and AwlSlider 36 //! 37 //--------------------------------------------------------- 38 39 class AbstractSlider : public QWidget { 40 Q_OBJECT 41 Q_PROPERTY(double value READ value WRITE setValue) 42 Q_PROPERTY(bool center READ center WRITE setCenter) 43 Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance) 44 45 Q_PROPERTY(int scaleWidth READ scaleWidth WRITE setScaleWidth) 46 Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor) 47 Q_PROPERTY(QColor scaleValueColor READ scaleValueColor WRITE setScaleValueColor) 48 49 Q_PROPERTY(int id READ id WRITE setId) 50 51 Q_PROPERTY(double minValue READ minValue WRITE setMinValue) 52 Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue) 53 Q_PROPERTY(double lineStep READ lineStep WRITE setLineStep) 54 Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep) 55 Q_PROPERTY(bool log READ log WRITE setLog) 56 57 Q_PROPERTY(double dclickValue1 READ dclickValue1 WRITE setDclickValue1) 58 Q_PROPERTY(double dclickValue2 READ dclickValue2 WRITE setDclickValue2) 59 60 protected: 61 int __id; 62 double _value; 63 double _minValue, _maxValue, _lineStep, _pageStep; 64 double _dclickValue1; 65 double _dclickValue2; 66 bool _center; 67 bool _enableMouseWheel; 68 bool _invert; 69 int _scaleWidth; //! scale line width 70 QColor _scaleColor; 71 QColor _scaleValueColor; 72 bool _log; 73 bool _useActualValue; //! for user value 74 75 virtual void wheelEvent(QWheelEvent*); 76 virtual void keyPressEvent(QKeyEvent*); 77 virtual void mouseDoubleClickEvent(QMouseEvent*); 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 enableMouseWheel()94 bool enableMouseWheel() { return _enableMouseWheel; } 95 virtual void setEnableMouseWheel(bool enabled); 96 97 //! return the center flag center()98 bool center() const { return _center; } 99 100 //! return the scale line width scaleWidth()101 int scaleWidth() const { return _scaleWidth; } 102 103 //! return current scale color scaleColor()104 QColor scaleColor() const { return _scaleColor; } 105 106 //! return color of active scale part scaleValueColor()107 QColor scaleValueColor() const { return _scaleValueColor; } 108 setInvertedAppearance(bool val)109 virtual void setInvertedAppearance(bool val) { _invert = val; } invertedAppearance()110 bool invertedAppearance() const { return _invert; } 111 id()112 int id() const { return __id; } setId(int i)113 void setId(int i) { __id = i; } 114 115 virtual double value() const; 116 virtual QString userValue() const; 117 minValue()118 double minValue() const { return _minValue; } setMinValue(double v)119 void setMinValue(double v) { _minValue = v; } 120 void setMinLogValue(double v); maxValue()121 double maxValue() const {return _maxValue; } setMaxValue(double v)122 void setMaxValue(double v) { _maxValue = v; } 123 void setMaxLogValue(double v); setRange(double a,double b)124 void setRange(double a, double b) { 125 setMinValue(a); 126 setMaxValue(b); 127 } setLogRange(double a,double b)128 void setLogRange(double a, double b) { 129 setMinLogValue(a); 130 setMaxLogValue(b); 131 } log()132 bool log() const { return _log; } setLog(bool v)133 void setLog(bool v) { _log = v; } lineStep()134 double lineStep() const { return _lineStep; } setLineStep(double v)135 void setLineStep(double v) { _lineStep = v; } pageStep()136 double pageStep() const { return _pageStep; } setPageStep(double f)137 void setPageStep(double f) { _pageStep = f; } dclickValue1()138 double dclickValue1() const { return _dclickValue1; } dclickValue2()139 double dclickValue2() const { return _dclickValue2; } setDclickValue1(double val)140 void setDclickValue1(double val) { _dclickValue1 = val; } setDclickValue2(double val)141 void setDclickValue2(double val) { _dclickValue2 = val; } 142 void setEnabled(bool val); setUseActualValue(bool v)143 void setUseActualValue(bool v) { _useActualValue = v; } 144 }; 145 146 class AccessibleAbstractSlider : public QObject, QAccessibleWidget { 147 Q_OBJECT 148 AbstractSlider* slider; 149 QAccessible::Role role() const Q_DECL_OVERRIDE; 150 QString text(QAccessible::Text t) const Q_DECL_OVERRIDE; 151 public: 152 static QAccessibleInterface* AbstractSliderFactory(const QString &classname, QObject *object); 153 AccessibleAbstractSlider(AbstractSlider*); 154 public slots: 155 void valueChanged(double,int); 156 }; 157 158 } 159 160 #endif 161 162