Qwt User's Guide: qwt_knob.h Source File

Qwt User's Guide 5.2.3

- 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 Q_ENUMS (Symbol)
38 Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
39 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
40 Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
41 Q_PROPERTY( Symbol symbol READ symbol WRITE setSymbol )
42
43 public:
49 enum Symbol { Line, Dot };
50
51 explicit QwtKnob(QWidget* parent = NULL);
52 #if QT_VERSION < 0x040000
53 explicit QwtKnob(QWidget* parent, const char *name);
54 #endif
55 virtual ~QwtKnob();
56
57 void setKnobWidth(int w);
58 int knobWidth() const;
59
60 void setTotalAngle (double angle);
61 double totalAngle() const;
62
63 void setBorderWidth(int bw);
64 int borderWidth() const;
65
66 void setSymbol(Symbol);
67 Symbol symbol() const;
68
69 virtual QSize sizeHint() const;
70 virtual QSize minimumSizeHint() const;
71
72 void setScaleDraw(QwtRoundScaleDraw *);
73 const QwtRoundScaleDraw *scaleDraw() const;
74 QwtRoundScaleDraw *scaleDraw();
75
76 protected:
77 virtual void paintEvent(QPaintEvent *e);
78 virtual void resizeEvent(QResizeEvent *e);
79
80 void draw(QPainter *p, const QRect& ur);
81 void drawKnob(QPainter *p, const QRect &r);
82 void drawMarker(QPainter *p, double arc, const QColor &c);
83
84 private:
85 void initKnob();
86 void layoutKnob( bool update = true );
87 double getValue(const QPoint &p);
88 void getScrollMode( const QPoint &p, int &scrollMode, int &direction );
89 void recalcAngle();
90
91 virtual void valueChange();
92 virtual void rangeChange();
93 virtual void scaleChange();
94 virtual void fontChange(const QFont &oldFont);
95
96 class PrivateData;
97 PrivateData *d_data;
98 };
99
100 #endif