[8127] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #ifndef QWT_DIAL_NEEDLE_H
|
---|
| 11 | #define QWT_DIAL_NEEDLE_H 1
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include <qpalette.h>
|
---|
| 15 |
|
---|
| 16 | class QPainter;
|
---|
| 17 | class QPoint;
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief Base class for needles that can be used in a QwtDial.
|
---|
| 21 |
|
---|
| 22 | QwtDialNeedle is a pointer that indicates a value by pointing
|
---|
| 23 | to a specific direction.
|
---|
| 24 |
|
---|
| 25 | \sa QwtDial, QwtCompass
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | class QWT_EXPORT QwtDialNeedle
|
---|
| 29 | {
|
---|
| 30 | public:
|
---|
| 31 | QwtDialNeedle();
|
---|
| 32 | virtual ~QwtDialNeedle();
|
---|
| 33 |
|
---|
| 34 | virtual void setPalette( const QPalette & );
|
---|
| 35 | const QPalette &palette() const;
|
---|
| 36 |
|
---|
| 37 | virtual void draw( QPainter *painter, const QPointF ¢er,
|
---|
[9383] | 38 | double length, double direction,
|
---|
[8127] | 39 | QPalette::ColorGroup = QPalette::Active ) const;
|
---|
| 40 |
|
---|
| 41 | protected:
|
---|
| 42 | /*!
|
---|
| 43 | \brief Draw the needle
|
---|
| 44 |
|
---|
| 45 | The origin of the needle is at position (0.0, 0.0 )
|
---|
[9383] | 46 | pointing in direction 0.0 ( = east ).
|
---|
[8127] | 47 |
|
---|
[9383] | 48 | The painter is already initialized with translation and
|
---|
[8127] | 49 | rotation.
|
---|
| 50 |
|
---|
| 51 | \param painter Painter
|
---|
| 52 | \param length Length of the needle
|
---|
| 53 | \param colorGroup Color group, used for painting
|
---|
| 54 |
|
---|
| 55 | \sa setPalette(), palette()
|
---|
| 56 | */
|
---|
[9383] | 57 | virtual void drawNeedle( QPainter *painter,
|
---|
[8127] | 58 | double length, QPalette::ColorGroup colorGroup ) const = 0;
|
---|
| 59 |
|
---|
[9383] | 60 | virtual void drawKnob( QPainter *, double width,
|
---|
[8127] | 61 | const QBrush &, bool sunken ) const;
|
---|
| 62 |
|
---|
| 63 | private:
|
---|
| 64 | QPalette d_palette;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | /*!
|
---|
| 68 | \brief A needle for dial widgets
|
---|
| 69 |
|
---|
| 70 | The following colors are used:
|
---|
| 71 |
|
---|
| 72 | - QPalette::Mid\n
|
---|
| 73 | Pointer
|
---|
| 74 | - QPalette::Base\n
|
---|
| 75 | Knob
|
---|
| 76 |
|
---|
| 77 | \sa QwtDial, QwtCompass
|
---|
| 78 | */
|
---|
| 79 |
|
---|
| 80 | class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
|
---|
| 81 | {
|
---|
| 82 | public:
|
---|
| 83 | //! Style of the needle
|
---|
| 84 | enum Style
|
---|
| 85 | {
|
---|
| 86 | //! Arrow
|
---|
| 87 | Arrow,
|
---|
| 88 |
|
---|
| 89 | //! A straight line from the center
|
---|
| 90 | Ray
|
---|
| 91 | };
|
---|
| 92 |
|
---|
| 93 | QwtDialSimpleNeedle( Style, bool hasKnob = true,
|
---|
| 94 | const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray );
|
---|
| 95 |
|
---|
| 96 | void setWidth( double width );
|
---|
| 97 | double width() const;
|
---|
| 98 |
|
---|
| 99 | protected:
|
---|
| 100 | virtual void drawNeedle( QPainter *, double length,
|
---|
| 101 | QPalette::ColorGroup ) const;
|
---|
| 102 |
|
---|
| 103 | private:
|
---|
| 104 | Style d_style;
|
---|
| 105 | bool d_hasKnob;
|
---|
| 106 | double d_width;
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 | /*!
|
---|
| 110 | \brief A magnet needle for compass widgets
|
---|
| 111 |
|
---|
| 112 | A magnet needle points to two opposite directions indicating
|
---|
| 113 | north and south.
|
---|
| 114 |
|
---|
| 115 | The following colors are used:
|
---|
| 116 | - QPalette::Light\n
|
---|
| 117 | Used for pointing south
|
---|
| 118 | - QPalette::Dark\n
|
---|
| 119 | Used for pointing north
|
---|
| 120 | - QPalette::Base\n
|
---|
| 121 | Knob (ThinStyle only)
|
---|
| 122 |
|
---|
| 123 | \sa QwtDial, QwtCompass
|
---|
| 124 | */
|
---|
| 125 |
|
---|
| 126 | class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
|
---|
| 127 | {
|
---|
| 128 | public:
|
---|
| 129 | //! Style of the needle
|
---|
| 130 | enum Style
|
---|
| 131 | {
|
---|
| 132 | //! A needle with a triangular shape
|
---|
| 133 | TriangleStyle,
|
---|
| 134 |
|
---|
[9383] | 135 | //! A thin needle
|
---|
[8127] | 136 | ThinStyle
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 | QwtCompassMagnetNeedle( Style = TriangleStyle,
|
---|
| 140 | const QColor &light = Qt::white, const QColor &dark = Qt::red );
|
---|
| 141 |
|
---|
| 142 | protected:
|
---|
[9383] | 143 | virtual void drawNeedle( QPainter *,
|
---|
[8127] | 144 | double length, QPalette::ColorGroup ) const;
|
---|
| 145 |
|
---|
| 146 | private:
|
---|
| 147 | Style d_style;
|
---|
| 148 | };
|
---|
| 149 |
|
---|
| 150 | /*!
|
---|
| 151 | \brief An indicator for the wind direction
|
---|
| 152 |
|
---|
| 153 | QwtCompassWindArrow shows the direction where the wind comes from.
|
---|
| 154 |
|
---|
| 155 | - QPalette::Light\n
|
---|
| 156 | Used for Style1, or the light half of Style2
|
---|
| 157 | - QPalette::Dark\n
|
---|
| 158 | Used for the dark half of Style2
|
---|
| 159 |
|
---|
| 160 | \sa QwtDial, QwtCompass
|
---|
| 161 | */
|
---|
| 162 |
|
---|
| 163 | class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
|
---|
| 164 | {
|
---|
| 165 | public:
|
---|
| 166 | //! Style of the arrow
|
---|
| 167 | enum Style
|
---|
| 168 | {
|
---|
| 169 | //! A needle pointing to the center
|
---|
| 170 | Style1,
|
---|
| 171 |
|
---|
| 172 | //! A needle pointing to the center
|
---|
| 173 | Style2
|
---|
| 174 | };
|
---|
| 175 |
|
---|
| 176 | QwtCompassWindArrow( Style, const QColor &light = Qt::white,
|
---|
| 177 | const QColor &dark = Qt::gray );
|
---|
| 178 |
|
---|
| 179 | protected:
|
---|
[9383] | 180 | virtual void drawNeedle( QPainter *,
|
---|
[8127] | 181 | double length, QPalette::ColorGroup ) const;
|
---|
| 182 |
|
---|
| 183 | private:
|
---|
| 184 | Style d_style;
|
---|
| 185 | };
|
---|
| 186 |
|
---|
[9383] | 187 | #endif
|
---|