Qwt User's Guide
svn
|
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** 00002 * Qwt Widget Library 00003 * Copyright (C) 1997 Josef Wilgen 00004 * Copyright (C) 2002 Uwe Rathmann 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the Qwt License, Version 1.0 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 00038 Q_ENUMS ( KnobStyle ) 00039 Q_ENUMS ( MarkerStyle ) 00040 00041 Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle ) 00042 Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle ) 00043 Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth ) 00044 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) 00045 Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle ) 00046 Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize ) 00047 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) 00048 00049 public: 00058 enum KnobStyle 00059 { 00061 NoStyle = -1, 00062 00064 Raised, 00065 00070 Sunken 00071 }; 00072 00081 enum MarkerStyle 00082 { 00084 NoMarker = -1, 00085 00087 Tick, 00088 00090 Dot, 00091 00096 Nub, 00097 00102 Notch 00103 }; 00104 00105 explicit QwtKnob( QWidget* parent = NULL ); 00106 virtual ~QwtKnob(); 00107 00108 void setKnobWidth( int w ); 00109 int knobWidth() const; 00110 00111 void setTotalAngle ( double angle ); 00112 double totalAngle() const; 00113 00114 void setKnobStyle( KnobStyle ); 00115 KnobStyle knobStyle() const; 00116 00117 void setBorderWidth( int bw ); 00118 int borderWidth() const; 00119 00120 void setMarkerStyle( MarkerStyle ); 00121 MarkerStyle markerStyle() const; 00122 00123 void setMarkerSize( int ); 00124 int markerSize() const; 00125 00126 virtual QSize sizeHint() const; 00127 virtual QSize minimumSizeHint() const; 00128 00129 void setScaleDraw( QwtRoundScaleDraw * ); 00130 const QwtRoundScaleDraw *scaleDraw() const; 00131 QwtRoundScaleDraw *scaleDraw(); 00132 00133 protected: 00134 virtual void paintEvent( QPaintEvent * ); 00135 virtual void resizeEvent( QResizeEvent * ); 00136 virtual void changeEvent( QEvent * ); 00137 00138 virtual void drawKnob( QPainter *, const QRectF & ) const; 00139 virtual void drawMarker( QPainter *, 00140 const QRectF &, double arc ) const; 00141 00142 virtual double getValue( const QPoint &p ); 00143 virtual void getScrollMode( const QPoint &, 00144 QwtAbstractSlider::ScrollMode &, int &direction ) const; 00145 00146 private: 00147 void initKnob(); 00148 void layoutKnob( bool update ); 00149 void recalcAngle(); 00150 00151 virtual void valueChange(); 00152 virtual void rangeChange(); 00153 virtual void scaleChange(); 00154 00155 class PrivateData; 00156 PrivateData *d_data; 00157 }; 00158 00159 #endif