Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_dial_needle.h
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 <qpalette.h>
14 #include "qwt_global.h"
15
16 class QPainter;
17 class QPoint;
18
31 class QWT_EXPORT QwtDialNeedle
32 {
33 public:
34 QwtDialNeedle();
35 virtual ~QwtDialNeedle();
36
46 virtual void draw(QPainter *painter, const QPoint &center,
47 int length, double direction,
48 QPalette::ColorGroup cg = QPalette::Active) const = 0;
49
50 virtual void setPalette(const QPalette &);
51 const QPalette &palette() const;
52
53 protected:
54 static void drawKnob(QPainter *, const QPoint &pos,
55 int width, const QBrush &, bool sunken);
56
57 private:
58 QPalette d_palette;
59 };
60
73 class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
74 {
75 public:
77 enum Style
78 {
79 Arrow,
80 Ray
81 };
82
83 QwtDialSimpleNeedle(Style, bool hasKnob = true,
84 const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray);
85
86 virtual void draw(QPainter *, const QPoint &, int length,
87 double direction, QPalette::ColorGroup = QPalette::Active) const;
88
89 static void drawArrowNeedle(QPainter *,
90 const QPalette&, QPalette::ColorGroup,
91 const QPoint &, int length, int width, double direction,
92 bool hasKnob);
93
94 static void drawRayNeedle(QPainter *,
95 const QPalette&, QPalette::ColorGroup,
96 const QPoint &, int length, int width, double direction,
97 bool hasKnob);
98
99 void setWidth(int width);
100 int width() const;
101
102 private:
103 Style d_style;
104 bool d_hasKnob;
105 int d_width;
106 };
107
125 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
126 {
127 public:
129 enum Style
130 {
131 TriangleStyle,
132 ThinStyle
133 };
134 QwtCompassMagnetNeedle(Style = TriangleStyle,
135 const QColor &light = Qt::white, const QColor &dark = Qt::red);
136
137 virtual void draw(QPainter *, const QPoint &, int length,
138 double direction, QPalette::ColorGroup = QPalette::Active) const;
139
140 static void drawTriangleNeedle(QPainter *,
141 const QPalette &, QPalette::ColorGroup,
142 const QPoint &, int length, double direction);
143
144 static void drawThinNeedle(QPainter *,
145 const QPalette &, QPalette::ColorGroup,
146 const QPoint &, int length, double direction);
147
148 protected:
149 static void drawPointer(QPainter *painter, const QBrush &brush,
150 int colorOffset, const QPoint &center,
151 int length, int width, double direction);
152
153 private:
154 Style d_style;
155 };
156
170 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
171 {
172 public:
174 enum Style
175 {
176 Style1,
177 Style2
178 };
179
180 QwtCompassWindArrow(Style, const QColor &light = Qt::white,
181 const QColor &dark = Qt::gray);
182
183 virtual void draw(QPainter *, const QPoint &, int length,
184 double direction, QPalette::ColorGroup = QPalette::Active) const;
185
186 static void drawStyle1Needle(QPainter *,
187 const QPalette &, QPalette::ColorGroup,
188 const QPoint &, int length, double direction);
189
190 static void drawStyle2Needle(QPainter *,
191 const QPalette &, QPalette::ColorGroup,
192 const QPoint &, int length, double direction);
193
194 private:
195 Style d_style;
196 };
197
198 #endif // QWT_DIAL_NEEDLE_H