source: ntrip/trunk/BNC/qwt/qwt_dial_needle.h@ 10403

Last change on this file since 10403 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.0 KB
Line 
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
16class QPainter;
17class 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
28class QWT_EXPORT QwtDialNeedle
29{
30public:
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 &center,
38 double length, double direction,
39 QPalette::ColorGroup = QPalette::Active ) const;
40
41protected:
42 /*!
43 \brief Draw the needle
44
45 The origin of the needle is at position (0.0, 0.0 )
46 pointing in direction 0.0 ( = east ).
47
48 The painter is already initialized with translation and
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 */
57 virtual void drawNeedle( QPainter *painter,
58 double length, QPalette::ColorGroup colorGroup ) const = 0;
59
60 virtual void drawKnob( QPainter *, double width,
61 const QBrush &, bool sunken ) const;
62
63private:
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
80class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
81{
82public:
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
99protected:
100 virtual void drawNeedle( QPainter *, double length,
101 QPalette::ColorGroup ) const;
102
103private:
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
126class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
127{
128public:
129 //! Style of the needle
130 enum Style
131 {
132 //! A needle with a triangular shape
133 TriangleStyle,
134
135 //! A thin needle
136 ThinStyle
137 };
138
139 QwtCompassMagnetNeedle( Style = TriangleStyle,
140 const QColor &light = Qt::white, const QColor &dark = Qt::red );
141
142protected:
143 virtual void drawNeedle( QPainter *,
144 double length, QPalette::ColorGroup ) const;
145
146private:
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
163class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
164{
165public:
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
179protected:
180 virtual void drawNeedle( QPainter *,
181 double length, QPalette::ColorGroup ) const;
182
183private:
184 Style d_style;
185};
186
187#endif
Note: See TracBrowser for help on using the repository browser.