Qwt User's Guide 6.0.2

- 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 #ifndef QWT_DIAL_H
11 #define QWT_DIAL_H 1
12
13 #include "qwt_global.h"
14 #include "qwt_abstract_slider.h"
15 #include "qwt_round_scale_draw.h"
16 #include <qframe.h>
17 #include <qpalette.h>
18
19 class QwtDialNeedle;
20 class QwtDial;
21
27 class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw
28 {
29 public:
30 explicit QwtDialScaleDraw( QwtDial * );
31
32 virtual QwtText label( double value ) const;
33
34 void setPenWidth( double );
35 double penWidth() const;
36
37 private:
38 QwtDial *d_parent;
39 double d_penWidth;
40 };
41
66 class QWT_EXPORT QwtDial: public QwtAbstractSlider
67 {
68 Q_OBJECT
69
70 Q_ENUMS( Shadow )
71 Q_ENUMS( Mode )
72 Q_ENUMS( Direction )
73
74 Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
75 Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
76 Q_PROPERTY( Mode mode READ mode WRITE setMode )
77 Q_PROPERTY( double origin READ origin WRITE setOrigin )
78 Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
79 Q_PROPERTY( Direction direction READ direction WRITE setDirection )
80
81 friend class QwtDialScaleDraw;
82 public:
83
92 enum Shadow
93 {
95 Plain = QFrame::Plain,
96
98 Raised = QFrame::Raised,
99
101 Sunken = QFrame::Sunken
102 };
103
105 enum Mode
106 {
108 RotateNeedle,
109
111 RotateScale
112 };
113
115 enum Direction
116 {
118 Clockwise,
119
121 CounterClockwise
122 };
123
124 explicit QwtDial( QWidget *parent = NULL );
125 virtual ~QwtDial();
126
127 void setFrameShadow( Shadow );
128 Shadow frameShadow() const;
129
130 void setLineWidth( int );
131 int lineWidth() const;
132
133 void setMode( Mode );
134 Mode mode() const;
135
136 virtual void setWrapping( bool );
137 bool wrapping() const;
138
139 virtual void setScale( int maxMajIntv, int maxMinIntv, double step = 0.0 );
140
141 void setScaleArc( double min, double max );
142 void setScaleComponents( QwtAbstractScaleDraw::ScaleComponents );
143 void setScaleTicks( int minLen, int medLen, int majLen, int penWidth = 1 );
144
145 double minScaleArc() const;
146 double maxScaleArc() const;
147
148 virtual void setOrigin( double );
149 double origin() const;
150
151 void setDirection( Direction );
152 Direction direction() const;
153
154 virtual void setNeedle( QwtDialNeedle * );
155 const QwtDialNeedle *needle() const;
156 QwtDialNeedle *needle();
157
158 QRectF boundingRect() const;
159 QRectF innerRect() const;
160 virtual QRectF scaleInnerRect() const;
161
162 virtual QSize sizeHint() const;
163 virtual QSize minimumSizeHint() const;
164
165 virtual void setScaleDraw( QwtDialScaleDraw * );
166
167 QwtDialScaleDraw *scaleDraw();
168 const QwtDialScaleDraw *scaleDraw() const;
169
170 protected:
171 virtual void paintEvent( QPaintEvent * );
172 virtual void keyPressEvent( QKeyEvent * );
173
174 virtual void drawFrame( QPainter *p );
175 virtual void drawContents( QPainter * ) const;
176 virtual void drawFocusIndicator( QPainter * ) const;
177
178 virtual void drawScale(
179 QPainter *, const QPointF &center,
180 double radius, double origin,
181 double arcMin, double arcMax ) const;
182
192 virtual void drawScaleContents( QPainter *painter,
193 const QPointF &center, double radius ) const;
194
195 virtual void drawNeedle( QPainter *, const QPointF &,
196 double radius, double direction, QPalette::ColorGroup ) const;
197
198 virtual QwtText scaleLabel( double ) const;
199 void updateScale();
200
201 virtual void rangeChange();
202 virtual void valueChange();
203
204 virtual double getValue( const QPoint & );
205 virtual void getScrollMode( const QPoint &,
206 QwtAbstractSlider::ScrollMode &, int &direction ) const;
207
208 private:
209 void initDial();
210
211 class PrivateData;
212 PrivateData *d_data;
213 };
214
215 #endif