Qwt User's Guide svn
qwt_dial_needle.h
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 
00031 class QWT_EXPORT QwtDialNeedle
00032 {
00033 public:
00034     QwtDialNeedle();
00035     virtual ~QwtDialNeedle();
00036 
00037     virtual void setPalette( const QPalette & );
00038     const QPalette &palette() const;
00039 
00040     virtual void draw( QPainter *painter, const QPointF &center,
00041         double length, double direction, 
00042         QPalette::ColorGroup = QPalette::Active ) const;
00043 
00044 protected:
00060     virtual void drawNeedle( QPainter *painter, 
00061         double length, QPalette::ColorGroup colorGroup ) const = 0;
00062 
00063     virtual void drawKnob( QPainter *, double width, 
00064         const QBrush &, bool sunken ) const;
00065 
00066 private:
00067     QPalette d_palette;
00068 };
00069 
00083 class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
00084 {
00085 public:
00087     enum Style
00088     {
00090         Arrow,
00091 
00093         Ray
00094     };
00095 
00096     QwtDialSimpleNeedle( Style, bool hasKnob = true,
00097         const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray );
00098 
00099     void setWidth( double width );
00100     double width() const;
00101 
00102 protected:
00103     virtual void drawNeedle( QPainter *, double length,
00104         QPalette::ColorGroup ) const;
00105 
00106 private:
00107     Style d_style;
00108     bool d_hasKnob;
00109     double d_width;
00110 };
00111 
00129 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
00130 {
00131 public:
00133     enum Style
00134     {
00136         TriangleStyle,
00137 
00139         ThinStyle
00140     };
00141 
00142     QwtCompassMagnetNeedle( Style = TriangleStyle,
00143         const QColor &light = Qt::white, const QColor &dark = Qt::red );
00144 
00145 protected:
00146     virtual void drawNeedle( QPainter *, 
00147         double length, QPalette::ColorGroup ) const;
00148 
00149 private:
00150     Style d_style;
00151 };
00152 
00166 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
00167 {
00168 public:
00170     enum Style
00171     {
00173         Style1,
00174 
00176         Style2
00177     };
00178 
00179     QwtCompassWindArrow( Style, const QColor &light = Qt::white,
00180         const QColor &dark = Qt::gray );
00181 
00182 protected:
00183     virtual void drawNeedle( QPainter *, 
00184         double length, QPalette::ColorGroup ) const;
00185 
00186 private:
00187     Style d_style;
00188 };
00189 
00190 #endif 
qmi style