Qwt User's Guide
|
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_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 00028 class QWT_EXPORT QwtDialNeedle 00029 { 00030 public: 00031 QwtDialNeedle(); 00032 virtual ~QwtDialNeedle(); 00033 00034 virtual void setPalette( const QPalette & ); 00035 const QPalette &palette() const; 00036 00037 virtual void draw( QPainter *painter, const QPointF ¢er, 00038 double length, double direction, 00039 QPalette::ColorGroup = QPalette::Active ) const; 00040 00041 protected: 00057 virtual void drawNeedle( QPainter *painter, 00058 double length, QPalette::ColorGroup colorGroup ) const = 0; 00059 00060 virtual void drawKnob( QPainter *, double width, 00061 const QBrush &, bool sunken ) const; 00062 00063 private: 00064 QPalette d_palette; 00065 }; 00066 00080 class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle 00081 { 00082 public: 00084 enum Style 00085 { 00087 Arrow, 00088 00090 Ray 00091 }; 00092 00093 QwtDialSimpleNeedle( Style, bool hasKnob = true, 00094 const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray ); 00095 00096 void setWidth( double width ); 00097 double width() const; 00098 00099 protected: 00100 virtual void drawNeedle( QPainter *, double length, 00101 QPalette::ColorGroup ) const; 00102 00103 private: 00104 Style d_style; 00105 bool d_hasKnob; 00106 double d_width; 00107 }; 00108 00126 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle 00127 { 00128 public: 00130 enum Style 00131 { 00133 TriangleStyle, 00134 00136 ThinStyle 00137 }; 00138 00139 QwtCompassMagnetNeedle( Style = TriangleStyle, 00140 const QColor &light = Qt::white, const QColor &dark = Qt::red ); 00141 00142 protected: 00143 virtual void drawNeedle( QPainter *, 00144 double length, QPalette::ColorGroup ) const; 00145 00146 private: 00147 Style d_style; 00148 }; 00149 00163 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle 00164 { 00165 public: 00167 enum Style 00168 { 00170 Style1, 00171 00173 Style2 00174 }; 00175 00176 QwtCompassWindArrow( Style, const QColor &light = Qt::white, 00177 const QColor &dark = Qt::gray ); 00178 00179 protected: 00180 virtual void drawNeedle( QPainter *, 00181 double length, QPalette::ColorGroup ) const; 00182 00183 private: 00184 Style d_style; 00185 }; 00186 00187 #endif