Qwt User's Guide: qwt_dial.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_dial.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 // vim: expandtab
11
12 #ifndef QWT_DIAL_H
13 #define QWT_DIAL_H 1
14
15 #include <qframe.h>
16 #include <qpalette.h>
17 #include "qwt_global.h"
18 #include "qwt_abstract_slider.h"
19 #include "qwt_round_scale_draw.h"
20
21 class QwtDialNeedle;
22 class QwtDial;
23
29 class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw
30 {
31 public:
32 explicit QwtDialScaleDraw(QwtDial *);
33 virtual QwtText label(double value) const;
34
35 void setPenWidth(uint);
36 uint penWidth() const;
37
38 private:
39 QwtDial *d_parent;
40 int d_penWidth;
41 };
42
67 class QWT_EXPORT QwtDial: public QwtAbstractSlider
68 {
69 Q_OBJECT
70
71 Q_ENUMS(Shadow)
72 Q_ENUMS(Mode)
73 Q_ENUMS(Direction)
74
75 Q_PROPERTY(bool visibleBackground READ hasVisibleBackground WRITE showBackground)
76 Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
77 Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
78 Q_PROPERTY(Mode mode READ mode WRITE setMode)
79 Q_PROPERTY(double origin READ origin WRITE setOrigin)
80 Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
81 Q_PROPERTY(Direction direction READ direction WRITE setDirection)
82
83 friend class QwtDialScaleDraw;
84 public:
85
94 enum Shadow
95 {
96 Plain = QFrame::Plain,
97 Raised = QFrame::Raised,
98 Sunken = QFrame::Sunken
99 };
100
102 enum ScaleOptions
103 {
104 ScaleBackbone = 1,
105 ScaleTicks = 2,
106 ScaleLabel = 4
107 };
108
114 enum Mode
115 {
116 RotateNeedle,
117 RotateScale
118 };
119
123 enum Direction
124 {
125 Clockwise,
126 CounterClockwise
127 };
128
129 explicit QwtDial( QWidget *parent = NULL);
130 #if QT_VERSION < 0x040000
131 explicit QwtDial( QWidget *parent, const char *name);
132 #endif
133
134 virtual ~QwtDial();
135
136 void setFrameShadow(Shadow);
137 Shadow frameShadow() const;
138
139 bool hasVisibleBackground() const;
140 void showBackground(bool);
141
142 void setLineWidth(int);
143 int lineWidth() const;
144
145 void setMode(Mode);
146 Mode mode() const;
147
148 virtual void setWrapping(bool);
149 bool wrapping() const;
150
151 virtual void setScale(int maxMajIntv, int maxMinIntv, double step = 0.0);
152
153 void setScaleArc(double min, double max);
154 void setScaleOptions(int);
155 void setScaleTicks(int minLen, int medLen, int majLen, int penWidth = 1);
156
157 double minScaleArc() const;
158 double maxScaleArc() const;
159
160 virtual void setOrigin(double);
161 double origin() const;
162
163 void setDirection(Direction);
164 Direction direction() const;
165
166 virtual void setNeedle(QwtDialNeedle *);
167 const QwtDialNeedle *needle() const;
168 QwtDialNeedle *needle();
169
170 QRect boundingRect() const;
171 QRect contentsRect() const;
172 virtual QRect scaleContentsRect() const;
173
174 virtual QSize sizeHint() const;
175 virtual QSize minimumSizeHint() const;
176
177 virtual void setScaleDraw(QwtDialScaleDraw *);
178
179 QwtDialScaleDraw *scaleDraw();
180 const QwtDialScaleDraw *scaleDraw() const;
181
182 protected:
183 virtual void paintEvent(QPaintEvent *);
184 virtual void resizeEvent(QResizeEvent *);
185 virtual void keyPressEvent(QKeyEvent *);
186
187 virtual void updateMask();
188
189 virtual void drawFrame(QPainter *p);
190 virtual void drawContents(QPainter *) const;
191 virtual void drawFocusIndicator(QPainter *) const;
192
193 virtual void drawScale(QPainter *, const QPoint &center,
194 int radius, double origin, double arcMin, double arcMax) const;
195
205 virtual void drawScaleContents(QPainter *painter, const QPoint &center,
206 int radius) const;
207
208 virtual void drawNeedle(QPainter *, const QPoint &,
209 int radius, double direction, QPalette::ColorGroup) const;
210
211 virtual QwtText scaleLabel(double) const;
212 void updateScale();
213
214 virtual void rangeChange();
215 virtual void valueChange();
216
217 virtual double getValue(const QPoint &);
218 virtual void getScrollMode(const QPoint &,
219 int &scrollMode, int &direction);
220
221 private:
222 void initDial();
223
224 class PrivateData;
225 PrivateData *d_data;
226 };
227
228 #endif