Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

qwt_slider.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_SLIDER_H
11 #define QWT_SLIDER_H
12
13 #include "qwt_global.h"
14 #include "qwt_abstract_scale.h"
15 #include "qwt_abstract_slider.h"
16
17 class QwtScaleDraw;
18
32 class QWT_EXPORT QwtSlider : public QwtAbstractSlider, public QwtAbstractScale
33 {
34 Q_OBJECT
35 Q_ENUMS( ScalePos )
36 Q_ENUMS( BackgroundStyle )
37 Q_PROPERTY( ScalePos scalePosition READ scalePosition
38 WRITE setScalePosition )
39 Q_PROPERTY( BackgroundStyles backgroundStyle
40 READ backgroundStyle WRITE setBackgroundStyle )
41 Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
42 Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
43 Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
44
45 public:
46
56 enum ScalePos
57 {
59 NoScale,
60
62 LeftScale,
63
65 RightScale,
66
68 TopScale,
69
71 BottomScale
72 };
73
78 enum BackgroundStyle
79 {
81 Trough = 0x01,
82
84 Groove = 0x02,
85 };
86
88 typedef QFlags<BackgroundStyle> BackgroundStyles;
89
90 explicit QwtSlider( QWidget *parent,
91 Qt::Orientation = Qt::Horizontal,
92 ScalePos = NoScale, BackgroundStyles = Trough );
93
94 virtual ~QwtSlider();
95
96 virtual void setOrientation( Qt::Orientation );
97
98 void setBackgroundStyle( BackgroundStyles );
99 BackgroundStyles backgroundStyle() const;
100
101 void setScalePosition( ScalePos s );
102 ScalePos scalePosition() const;
103
104 void setHandleSize( int width, int height );
105 void setHandleSize( const QSize & );
106 QSize handleSize() const;
107
108 void setBorderWidth( int bw );
109 int borderWidth() const;
110
111 void setSpacing( int );
112 int spacing() const;
113
114 virtual QSize sizeHint() const;
115 virtual QSize minimumSizeHint() const;
116
117 void setScaleDraw( QwtScaleDraw * );
118 const QwtScaleDraw *scaleDraw() const;
119
120 protected:
121 virtual double getValue( const QPoint &p );
122 virtual void getScrollMode( const QPoint &p,
123 QwtAbstractSlider::ScrollMode &, int &direction ) const;
124
125 virtual void drawSlider ( QPainter *, const QRect & ) const;
126 virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
127
128 virtual void resizeEvent( QResizeEvent * );
129 virtual void paintEvent ( QPaintEvent * );
130 virtual void changeEvent( QEvent * );
131
132 virtual void valueChange();
133 virtual void rangeChange();
134 virtual void scaleChange();
135
136 int transform( double v ) const;
137
138 QwtScaleDraw *scaleDraw();
139
140 private:
141 void layoutSlider( bool );
142 void initSlider( Qt::Orientation, ScalePos, BackgroundStyles );
143
144 class PrivateData;
145 PrivateData *d_data;
146 };
147
148 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtSlider::BackgroundStyles )
149
150 #endif