00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_DIAL_NEEDLE_H
00011 #define QWT_DIAL_NEEDLE_H 1
00012
00013 #include "qwt_global.h"
00014 #include <qpalette.h>
00015
00016 class QPainter;
00017 class QPoint;
00018
00031 class QWT_EXPORT QwtDialNeedle
00032 {
00033 public:
00034 QwtDialNeedle();
00035 virtual ~QwtDialNeedle();
00036
00046 virtual void draw( QPainter *painter, const QPoint ¢er,
00047 int length, double direction,
00048 QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
00049
00050 virtual void setPalette( const QPalette & );
00051 const QPalette &palette() const;
00052
00053 protected:
00054 static void drawKnob( QPainter *, const QPoint &pos,
00055 int width, const QBrush &, bool sunken );
00056
00057 private:
00058 QPalette d_palette;
00059 };
00060
00074 class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
00075 {
00076 public:
00078 enum Style
00079 {
00080 Arrow,
00081 Ray
00082 };
00083
00084 QwtDialSimpleNeedle( Style, bool hasKnob = true,
00085 const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray );
00086
00087 virtual void draw( QPainter *, const QPoint &, int length,
00088 double direction, QPalette::ColorGroup = QPalette::Active ) const;
00089
00090 static void drawArrowNeedle( QPainter *, const QPalette &, QPalette::ColorGroup,
00091 const QPoint &, int length, int width, double direction, bool hasKnob );
00092
00093 static void drawRayNeedle( QPainter *, const QPalette &, QPalette::ColorGroup,
00094 const QPoint &, int length, int width, double direction, bool hasKnob );
00095
00096 void setWidth( int width );
00097 int width() const;
00098
00099 private:
00100 Style d_style;
00101 bool d_hasKnob;
00102 int d_width;
00103 };
00104
00122 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
00123 {
00124 public:
00126 enum Style
00127 {
00128 TriangleStyle,
00129 ThinStyle
00130 };
00131
00132 QwtCompassMagnetNeedle( Style = TriangleStyle,
00133 const QColor &light = Qt::white, const QColor &dark = Qt::red );
00134
00135 virtual void draw( QPainter *, const QPoint &, int length,
00136 double direction, QPalette::ColorGroup = QPalette::Active ) const;
00137
00138 static void drawTriangleNeedle( QPainter *,
00139 const QPalette &, QPalette::ColorGroup,
00140 const QPoint &, int length, double direction );
00141
00142 static void drawThinNeedle( QPainter *,
00143 const QPalette &, QPalette::ColorGroup,
00144 const QPoint &, int length, double direction );
00145
00146 protected:
00147 static void drawPointer( QPainter *painter, const QBrush &brush,
00148 int colorOffset, const QPoint ¢er,
00149 int length, int width, double direction );
00150
00151 private:
00152 Style d_style;
00153 };
00154
00168 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
00169 {
00170 public:
00172 enum Style
00173 {
00174 Style1,
00175 Style2
00176 };
00177
00178 QwtCompassWindArrow( Style, const QColor &light = Qt::white,
00179 const QColor &dark = Qt::gray );
00180
00181 virtual void draw( QPainter *, const QPoint &, int length,
00182 double direction, QPalette::ColorGroup = QPalette::Active ) const;
00183
00184 static void drawStyle1Needle( QPainter *,
00185 const QPalette &, QPalette::ColorGroup,
00186 const QPoint &, int length, double direction );
00187
00188 static void drawStyle2Needle( QPainter *,
00189 const QPalette &, QPalette::ColorGroup,
00190 const QPoint &, int length, double direction );
00191
00192 private:
00193 Style d_style;
00194 };
00195
00196 #endif