00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_KNOB_H
00011 #define QWT_KNOB_H
00012
00013 #include "qwt_global.h"
00014 #include "qwt_abstract_slider.h"
00015 #include "qwt_abstract_scale.h"
00016
00017 class QwtRoundScaleDraw;
00018
00034 class QWT_EXPORT QwtKnob : public QwtAbstractSlider, public QwtAbstractScale
00035 {
00036 Q_OBJECT
00037 Q_ENUMS (Symbol)
00038 Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
00039 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
00040 Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
00041 Q_PROPERTY( Symbol symbol READ symbol WRITE setSymbol )
00042
00043 public:
00049 enum Symbol { Line, Dot };
00050
00051 explicit QwtKnob(QWidget* parent = NULL);
00052 #if QT_VERSION < 0x040000
00053 explicit QwtKnob(QWidget* parent, const char *name);
00054 #endif
00055 virtual ~QwtKnob();
00056
00057 void setKnobWidth(int w);
00058 int knobWidth() const;
00059
00060 void setTotalAngle (double angle);
00061 double totalAngle() const;
00062
00063 void setBorderWidth(int bw);
00064 int borderWidth() const;
00065
00066 void setSymbol(Symbol);
00067 Symbol symbol() const;
00068
00069 virtual QSize sizeHint() const;
00070 virtual QSize minimumSizeHint() const;
00071
00072 void setScaleDraw(QwtRoundScaleDraw *);
00073 const QwtRoundScaleDraw *scaleDraw() const;
00074 QwtRoundScaleDraw *scaleDraw();
00075
00076 protected:
00077 virtual void paintEvent(QPaintEvent *e);
00078 virtual void resizeEvent(QResizeEvent *e);
00079
00080 void draw(QPainter *p, const QRect& ur);
00081 void drawKnob(QPainter *p, const QRect &r);
00082 void drawMarker(QPainter *p, double arc, const QColor &c);
00083
00084 private:
00085 void initKnob();
00086 void layoutKnob( bool update = true );
00087 double getValue(const QPoint &p);
00088 void getScrollMode( const QPoint &p, int &scrollMode, int &direction );
00089 void recalcAngle();
00090
00091 virtual void valueChange();
00092 virtual void rangeChange();
00093 virtual void scaleChange();
00094 virtual void fontChange(const QFont &oldFont);
00095
00096 class PrivateData;
00097 PrivateData *d_data;
00098 };
00099
00100 #endif