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 | // vim: expandtab
|
---|
11 |
|
---|
12 | #ifndef QWT_SLIDER_H
|
---|
13 | #define QWT_SLIDER_H
|
---|
14 |
|
---|
15 | #include "qwt_global.h"
|
---|
16 | #include "qwt_abstract_scale.h"
|
---|
17 | #include "qwt_abstract_slider.h"
|
---|
18 |
|
---|
19 | class QwtScaleDraw;
|
---|
20 |
|
---|
21 | /*!
|
---|
22 | \brief The Slider Widget
|
---|
23 |
|
---|
24 | QwtSlider is a slider widget which operates on an interval
|
---|
25 | of type double. QwtSlider supports different layouts as
|
---|
26 | well as a scale.
|
---|
27 |
|
---|
28 | \image html sliders.png
|
---|
29 |
|
---|
30 | \sa QwtAbstractSlider and QwtAbstractScale for the descriptions
|
---|
31 | of the inherited members.
|
---|
32 | */
|
---|
33 |
|
---|
34 | class QWT_EXPORT QwtSlider : public QwtAbstractSlider, public QwtAbstractScale
|
---|
35 | {
|
---|
36 | Q_OBJECT
|
---|
37 | Q_ENUMS( ScalePos )
|
---|
38 | Q_ENUMS( BGSTYLE )
|
---|
39 | Q_PROPERTY( ScalePos scalePosition READ scalePosition
|
---|
40 | WRITE setScalePosition )
|
---|
41 | Q_PROPERTY( BGSTYLE bgStyle READ bgStyle WRITE setBgStyle )
|
---|
42 | Q_PROPERTY( int thumbLength READ thumbLength WRITE setThumbLength )
|
---|
43 | Q_PROPERTY( int thumbWidth READ thumbWidth WRITE setThumbWidth )
|
---|
44 | Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
|
---|
45 |
|
---|
46 | public:
|
---|
47 |
|
---|
48 | /*!
|
---|
49 | Scale position. QwtSlider tries to enforce valid combinations of its
|
---|
50 | orientation and scale position:
|
---|
51 | - Qt::Horizonal combines with NoScale, TopScale and BottomScale
|
---|
52 | - Qt::Vertical combines with NoScale, LeftScale and RightScale
|
---|
53 |
|
---|
54 | \sa QwtSlider()
|
---|
55 | */
|
---|
56 | enum ScalePos
|
---|
57 | {
|
---|
58 | NoScale,
|
---|
59 |
|
---|
60 | LeftScale,
|
---|
61 | RightScale,
|
---|
62 | TopScale,
|
---|
63 | BottomScale
|
---|
64 | };
|
---|
65 |
|
---|
66 | /*!
|
---|
67 | Background style.
|
---|
68 | \sa QwtSlider()
|
---|
69 | */
|
---|
70 | enum BGSTYLE
|
---|
71 | {
|
---|
72 | BgTrough = 0x1,
|
---|
73 | BgSlot = 0x2,
|
---|
74 | BgBoth = BgTrough | BgSlot
|
---|
75 | };
|
---|
76 |
|
---|
77 | explicit QwtSlider(QWidget *parent,
|
---|
78 | Qt::Orientation = Qt::Horizontal,
|
---|
79 | ScalePos = NoScale, BGSTYLE bgStyle = BgTrough);
|
---|
80 | #if QT_VERSION < 0x040000
|
---|
81 | explicit QwtSlider(QWidget *parent, const char *name);
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | virtual ~QwtSlider();
|
---|
85 |
|
---|
86 | virtual void setOrientation(Qt::Orientation);
|
---|
87 |
|
---|
88 | void setBgStyle(BGSTYLE);
|
---|
89 | BGSTYLE bgStyle() const;
|
---|
90 |
|
---|
91 | void setScalePosition(ScalePos s);
|
---|
92 | ScalePos scalePosition() const;
|
---|
93 |
|
---|
94 | int thumbLength() const;
|
---|
95 | int thumbWidth() const;
|
---|
96 | int borderWidth() const;
|
---|
97 |
|
---|
98 | void setThumbLength(int l);
|
---|
99 | void setThumbWidth(int w);
|
---|
100 | void setBorderWidth(int bw);
|
---|
101 | void setMargins(int x, int y);
|
---|
102 |
|
---|
103 | virtual QSize sizeHint() const;
|
---|
104 | virtual QSize minimumSizeHint() const;
|
---|
105 |
|
---|
106 | void setScaleDraw(QwtScaleDraw *);
|
---|
107 | const QwtScaleDraw *scaleDraw() const;
|
---|
108 |
|
---|
109 | protected:
|
---|
110 | virtual double getValue(const QPoint &p);
|
---|
111 | virtual void getScrollMode(const QPoint &p,
|
---|
112 | int &scrollMode, int &direction);
|
---|
113 |
|
---|
114 | void draw(QPainter *p, const QRect& update_rect);
|
---|
115 | virtual void drawSlider (QPainter *p, const QRect &r);
|
---|
116 | virtual void drawThumb(QPainter *p, const QRect &, int pos);
|
---|
117 |
|
---|
118 | virtual void resizeEvent(QResizeEvent *e);
|
---|
119 | virtual void paintEvent (QPaintEvent *e);
|
---|
120 |
|
---|
121 | virtual void valueChange();
|
---|
122 | virtual void rangeChange();
|
---|
123 | virtual void scaleChange();
|
---|
124 | virtual void fontChange(const QFont &oldFont);
|
---|
125 |
|
---|
126 | void layoutSlider( bool update = true );
|
---|
127 | int xyPosition(double v) const;
|
---|
128 |
|
---|
129 | QwtScaleDraw *scaleDraw();
|
---|
130 |
|
---|
131 | private:
|
---|
132 | void initSlider(Qt::Orientation, ScalePos scalePos, BGSTYLE bgStyle);
|
---|
133 |
|
---|
134 | class PrivateData;
|
---|
135 | PrivateData *d_data;
|
---|
136 | };
|
---|
137 |
|
---|
138 | #endif
|
---|