Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

qwt_knob.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_KNOB_H
11 #define QWT_KNOB_H
12
13 #include "qwt_global.h"
14 #include "qwt_abstract_slider.h"
15 #include "qwt_abstract_scale.h"
16
17 class QwtRoundScaleDraw;
18
34 class QWT_EXPORT QwtKnob : public QwtAbstractSlider, public QwtAbstractScale
35 {
36 Q_OBJECT
37
38 Q_ENUMS ( KnobStyle )
39 Q_ENUMS ( MarkerStyle )
40
41 Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle )
42 Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle )
43 Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
44 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
45 Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
46 Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize )
47 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
48
49 public:
58 enum KnobStyle
59 {
61 NoStyle = -1,
62
64 Raised,
65
70 Sunken
71 };
72
81 enum MarkerStyle
82 {
84 NoMarker = -1,
85
87 Tick,
88
90 Dot,
91
96 Nub,
97
102 Notch
103 };
104
105 explicit QwtKnob( QWidget* parent = NULL );
106 virtual ~QwtKnob();
107
108 void setKnobWidth( int w );
109 int knobWidth() const;
110
111 void setTotalAngle ( double angle );
112 double totalAngle() const;
113
114 void setKnobStyle( KnobStyle );
115 KnobStyle knobStyle() const;
116
117 void setBorderWidth( int bw );
118 int borderWidth() const;
119
120 void setMarkerStyle( MarkerStyle );
121 MarkerStyle markerStyle() const;
122
123 void setMarkerSize( int );
124 int markerSize() const;
125
126 virtual QSize sizeHint() const;
127 virtual QSize minimumSizeHint() const;
128
129 void setScaleDraw( QwtRoundScaleDraw * );
130 const QwtRoundScaleDraw *scaleDraw() const;
131 QwtRoundScaleDraw *scaleDraw();
132
133 protected:
134 virtual void paintEvent( QPaintEvent * );
135 virtual void resizeEvent( QResizeEvent * );
136 virtual void changeEvent( QEvent * );
137
138 virtual void drawKnob( QPainter *, const QRectF & ) const;
139 virtual void drawMarker( QPainter *,
140 const QRectF &, double arc ) const;
141
142 virtual double getValue( const QPoint &p );
143 virtual void getScrollMode( const QPoint &,
144 QwtAbstractSlider::ScrollMode &, int &direction ) const;
145
146 private:
147 void initKnob();
148 void layoutKnob( bool update );
149 void recalcAngle();
150
151 virtual void valueChange();
152 virtual void rangeChange();
153 virtual void scaleChange();
154
155 class PrivateData;
156 PrivateData *d_data;
157 };
158
159 #endif