source: ntrip/trunk/BNC/qwt/qwt_knob.h@ 8154

Last change on this file since 8154 was 8127, checked in by stoecker, 7 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 4.7 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_KNOB_H
11#define QWT_KNOB_H
12
13#include "qwt_global.h"
14#include "qwt_abstract_slider.h"
15
16class QwtRoundScaleDraw;
17
18/*!
19 \brief The Knob Widget
20
21 The QwtKnob widget imitates look and behavior of a volume knob on a radio.
22 It looks similar to QDial - not to QwtDial.
23
24 The value range of a knob might be divided into several turns.
25
26 The layout of the knob depends on the knobWidth().
27
28 - width > 0
29 The diameter of the knob is fixed and the knob is aligned
30 according to the alignment() flags inside of the contentsRect().
31
32 - width <= 0
33 The knob is extended to the minimum of width/height of the contentsRect()
34 and aligned in the other direction according to alignment().
35
36 Setting a fixed knobWidth() is helpful to align several knobs with different
37 scale labels.
38
39 \image html knob.png
40*/
41
42class QWT_EXPORT QwtKnob: public QwtAbstractSlider
43{
44 Q_OBJECT
45
46 Q_ENUMS ( KnobStyle MarkerStyle )
47
48 Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle )
49 Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
50 Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment )
51 Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
52 Q_PROPERTY( int numTurns READ numTurns WRITE setNumTurns )
53 Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle )
54 Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize )
55 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
56
57public:
58 /*!
59 \brief Style of the knob surface
60
61 Depending on the KnobStyle the surface of the knob is
62 filled from the brushes of the widget palette().
63
64 \sa setKnobStyle(), knobStyle()
65 */
66 enum KnobStyle
67 {
68 //! Fill the knob with a brush from QPalette::Button.
69 Flat,
70
71 //! Build a gradient from QPalette::Midlight and QPalette::Button
72 Raised,
73
74 /*!
75 Build a gradient from QPalette::Midlight, QPalette::Button
76 and QPalette::Midlight
77 */
78 Sunken,
79
80 /*!
81 Build a radial gradient from QPalette::Button
82 like it is used for QDial in various Qt styles.
83 */
84 Styled
85 };
86
87 /*!
88 \brief Marker type
89
90 The marker indicates the current value on the knob
91 The default setting is a Notch marker.
92
93 \sa setMarkerStyle(), setMarkerSize()
94 */
95 enum MarkerStyle
96 {
97 //! Don't paint any marker
98 NoMarker = -1,
99
100 //! Paint a single tick in QPalette::ButtonText color
101 Tick,
102
103 //! Paint a triangle in QPalette::ButtonText color
104 Triangle,
105
106 //! Paint a circle in QPalette::ButtonText color
107 Dot,
108
109 /*!
110 Draw a raised ellipse with a gradient build from
111 QPalette::Light and QPalette::Mid
112 */
113 Nub,
114
115 /*!
116 Draw a sunken ellipse with a gradient build from
117 QPalette::Light and QPalette::Mid
118 */
119 Notch
120 };
121
122 explicit QwtKnob( QWidget* parent = NULL );
123 virtual ~QwtKnob();
124
125 void setAlignment( Qt::Alignment );
126 Qt::Alignment alignment() const;
127
128 void setKnobWidth( int );
129 int knobWidth() const;
130
131 void setNumTurns( int );
132 int numTurns() const;
133
134 void setTotalAngle ( double angle );
135 double totalAngle() const;
136
137 void setKnobStyle( KnobStyle );
138 KnobStyle knobStyle() const;
139
140 void setBorderWidth( int bw );
141 int borderWidth() const;
142
143 void setMarkerStyle( MarkerStyle );
144 MarkerStyle markerStyle() const;
145
146 void setMarkerSize( int );
147 int markerSize() const;
148
149 virtual QSize sizeHint() const;
150 virtual QSize minimumSizeHint() const;
151
152 void setScaleDraw( QwtRoundScaleDraw * );
153
154 const QwtRoundScaleDraw *scaleDraw() const;
155 QwtRoundScaleDraw *scaleDraw();
156
157 QRect knobRect() const;
158
159protected:
160 virtual void paintEvent( QPaintEvent * );
161 virtual void changeEvent( QEvent * );
162
163 virtual void drawKnob( QPainter *, const QRectF & ) const;
164
165 virtual void drawFocusIndicator( QPainter * ) const;
166
167 virtual void drawMarker( QPainter *,
168 const QRectF &, double arc ) const;
169
170 virtual double scrolledTo( const QPoint & ) const;
171 virtual bool isScrollPosition( const QPoint & ) const;
172
173private:
174 class PrivateData;
175 PrivateData *d_data;
176};
177
178#endif
Note: See TracBrowser for help on using the repository browser.