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_DIAL_H 00011 #define QWT_DIAL_H 1 00012 00013 #include "qwt_global.h" 00014 #include "qwt_abstract_slider.h" 00015 #include "qwt_round_scale_draw.h" 00016 #include <qframe.h> 00017 #include <qpalette.h> 00018 00019 class QwtDialNeedle; 00020 class QwtDial; 00021 00027 class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw 00028 { 00029 public: 00030 explicit QwtDialScaleDraw( QwtDial * ); 00031 00032 virtual QwtText label( double value ) const; 00033 00034 void setPenWidth( double ); 00035 double penWidth() const; 00036 00037 private: 00038 QwtDial *d_parent; 00039 double d_penWidth; 00040 }; 00041 00066 class QWT_EXPORT QwtDial: public QwtAbstractSlider 00067 { 00068 Q_OBJECT 00069 00070 Q_ENUMS( Shadow ) 00071 Q_ENUMS( Mode ) 00072 Q_ENUMS( Direction ) 00073 00074 Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth ) 00075 Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow ) 00076 Q_PROPERTY( Mode mode READ mode WRITE setMode ) 00077 Q_PROPERTY( double origin READ origin WRITE setOrigin ) 00078 Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping ) 00079 Q_PROPERTY( Direction direction READ direction WRITE setDirection ) 00080 00081 friend class QwtDialScaleDraw; 00082 public: 00083 00092 enum Shadow 00093 { 00095 Plain = QFrame::Plain, 00096 00098 Raised = QFrame::Raised, 00099 00101 Sunken = QFrame::Sunken 00102 }; 00103 00105 enum Mode 00106 { 00108 RotateNeedle, 00109 00111 RotateScale 00112 }; 00113 00115 enum Direction 00116 { 00118 Clockwise, 00119 00121 CounterClockwise 00122 }; 00123 00124 explicit QwtDial( QWidget *parent = NULL ); 00125 virtual ~QwtDial(); 00126 00127 void setFrameShadow( Shadow ); 00128 Shadow frameShadow() const; 00129 00130 void setLineWidth( int ); 00131 int lineWidth() const; 00132 00133 void setMode( Mode ); 00134 Mode mode() const; 00135 00136 virtual void setWrapping( bool ); 00137 bool wrapping() const; 00138 00139 virtual void setScale( int maxMajIntv, int maxMinIntv, double step = 0.0 ); 00140 00141 void setScaleArc( double min, double max ); 00142 void setScaleComponents( QwtAbstractScaleDraw::ScaleComponents ); 00143 void setScaleTicks( int minLen, int medLen, int majLen, int penWidth = 1 ); 00144 00145 double minScaleArc() const; 00146 double maxScaleArc() const; 00147 00148 virtual void setOrigin( double ); 00149 double origin() const; 00150 00151 void setDirection( Direction ); 00152 Direction direction() const; 00153 00154 virtual void setNeedle( QwtDialNeedle * ); 00155 const QwtDialNeedle *needle() const; 00156 QwtDialNeedle *needle(); 00157 00158 QRectF boundingRect() const; 00159 QRectF innerRect() const; 00160 virtual QRectF scaleInnerRect() const; 00161 00162 virtual QSize sizeHint() const; 00163 virtual QSize minimumSizeHint() const; 00164 00165 virtual void setScaleDraw( QwtDialScaleDraw * ); 00166 00167 QwtDialScaleDraw *scaleDraw(); 00168 const QwtDialScaleDraw *scaleDraw() const; 00169 00170 protected: 00171 virtual void paintEvent( QPaintEvent * ); 00172 virtual void keyPressEvent( QKeyEvent * ); 00173 00174 virtual void drawFrame( QPainter *p ); 00175 virtual void drawContents( QPainter * ) const; 00176 virtual void drawFocusIndicator( QPainter * ) const; 00177 00178 virtual void drawScale( 00179 QPainter *, const QPointF ¢er, 00180 double radius, double origin, 00181 double arcMin, double arcMax ) const; 00182 00192 virtual void drawScaleContents( QPainter *painter, 00193 const QPointF ¢er, double radius ) const; 00194 00195 virtual void drawNeedle( QPainter *, const QPointF &, 00196 double radius, double direction, QPalette::ColorGroup ) const; 00197 00198 virtual QwtText scaleLabel( double ) const; 00199 void updateScale(); 00200 00201 virtual void rangeChange(); 00202 virtual void valueChange(); 00203 00204 virtual double getValue( const QPoint & ); 00205 virtual void getScrollMode( const QPoint &, 00206 QwtAbstractSlider::ScrollMode &, int &direction ) const; 00207 00208 private: 00209 void initDial(); 00210 00211 class PrivateData; 00212 PrivateData *d_data; 00213 }; 00214 00215 #endif