4
4
#include <qpainter.h>
7
7
//-------------------------------------------------------------
8
//.H Slider | 3 | 02/04/98 | Qwt Widget Library | Qwt Programmer's Manual
11
8
// Slider - The Slider Widget
14
// #include <qwt_slider.h>
17
10
// Slider is a slider widget which operates on an interval
18
11
// of type double. Slider supports different layouts as
19
12
// well as a scale.
22
//.U INHERITED CLASSES
23
// @^SliderBase@, @^QwtScaleIf@
27
// Slider::Slider -- Constructor
28
// Slider::~Slider -- Destructor
29
// Slider::setThumbLength -- Set the length of the slider's thumb
30
// Slider::setThumbWidth -- Set the length of the slider's thumb
31
// Slider::setBorderWidth -- Set the border width
32
// Slider::setMargins -- Set the internal border distance
35
// @^SliderBase@ and @^QwtScaleIf@ for the descriptions
36
// of the inherited members.
37
//------------------------------------------------------------
39
//------------------------------------------------------------
40
//.C MEMBER FUNCTION DESCRIPTION
41
//------------------------------------------------------------
44
//------------------------------------------------------------
13
//------------------------------------------------------------
15
//------------------------------------------------------------
46
16
//.F Slider::Slider
51
//.f Slider::Slider(QWidget *parent, const char *name, OrientationX orient = Horizontal, ScalePos scalePos = None, int bgStyle = BgTrough)
21
//.f Slider::Slider(QWidget *parent, const char *name, Orientation orient = Horizontal, ScalePos scalePos = None, int bgStyle = BgTrough)
64
34
// slider button in a trough, Slider::BgSlot draws
65
35
// a slot underneath the button. An or-combination of both
66
36
// may also be used. The default is Slider::BgTrough.
69
37
//------------------------------------------------------------
70
39
Slider::Slider(QWidget *parent, const char *name,
71
OrientationX orient, ScalePos scalePos, int bgStyle)
40
Orientation orient, ScalePos scalePos, int bgStyle)
72
41
: SliderBase(parent,name)
74
ScaleDraw::OrientationX so;
77
46
if (bgStyle == BgSlot) {
92
d_scalePos = scalePos;
60
d_scalePos = scalePos;
97
65
if (bgStyle & BgTrough)
98
66
d_bwTrough = d_borderWidth;
102
d_sliderRect.setRect(0,0,8,8);
107
if (d_scalePos == Right)
108
so = ScaleDraw::Right;
110
so = ScaleDraw::Left;
113
if (d_scalePos == Bottom)
114
so = ScaleDraw::Bottom;
120
d_scale.setGeometry(0, 0, 40, so);
122
if (d_orient == Vertical)
123
setMinimumSize(10,20);
125
setMinimumSize(20,10);
70
d_sliderRect.setRect(0, 0, 8, 8);
71
setOrientation(orient);
129
74
//------------------------------------------------------------
130
75
//.F Slider::~Slider
149
94
//.p int bd -- border width
151
96
//------------------------------------------------------------
152
98
void Slider::setBorderWidth(int bd)
154
100
d_borderWidth = qwtMin(qwtMax(bd,0),10);
234
180
//------------------------------------------------------------
236
//.F Slider::drawSlider
237
// Draw the slider into the specified rectangle.
240
//.f void Slider::drawSlider(QPaiter *p, const QRect &r)
243
//.p QPainter *p, const QRect &r
182
// Draw the slider into the specified rectangle.
245
183
//------------------------------------------------------------
246
void Slider::drawSlider (QPainter *p, const QRect &r)
249
QColorGroup g = colorGroup();
250
QBrush brBack(g.background());
252
QBrush brDark(g.dark());
262
qDrawShadePanel(p, r.x(), r.y(),
185
void Slider::drawSlider(QPainter *p, const QRect &r)
187
QColorGroup g = colorGroup();
188
QBrush brBack(g.background());
190
QBrush brDark(g.dark());
198
if (d_bwTrough > 0) {
199
qDrawShadePanel(p, r.x(), r.y(),
263
200
r.width(), r.height(),
264
201
g, TRUE, d_bwTrough,0);
265
cr.setRect(r.x() + d_bwTrough,
202
cr.setRect(r.x() + d_bwTrough,
266
203
r.y() + d_bwTrough,
267
204
r.width() - 2*d_bwTrough,
268
205
r.height() - 2*d_bwTrough);
269
brMid = QBrush(g.mid());
206
brMid = QBrush(g.mid());
278
213
rpos = (value() - minValue()) / (maxValue() - minValue());
666
601
//------------------------------------------------------------
668
602
//.F Slider::paintEvent
669
603
// Qt paint event
675
606
//.f void Slider::paintEvent(QPaintEvent *e)
677
//------------------------------------------------------------
678
void Slider::paintEvent(QPaintEvent * /*e*/)
684
if (d_scalePos != None)
686
p.fillRect(this->rect(), this->backgroundColor());
690
drawSlider(&p, d_sliderRect);
696
//------------------------------------------------------------
607
//------------------------------------------------------------
609
void Slider::paintEvent(QPaintEvent* /*e*/)
614
if (d_scalePos != None) {
615
p.fillRect(this->rect(), this->backgroundColor());
618
drawSlider(&p, d_sliderRect);
623
//------------------------------------------------------------
698
624
//.F Slider::resizeEvent
699
625
// Qt resize event
795
721
//.f void Slider::valueChange()
797
723
//------------------------------------------------------------
798
725
void Slider::valueChange()
803
drawSlider(&p,d_sliderRect);
806
SliderBase::valueChange();
730
drawSlider(&p, d_sliderRect);
733
SliderBase::valueChange();
734
emit valueChanged(value(), _id);
811
737
//------------------------------------------------------------
889
815
w = 16 + 2 * d_bwTrough;
892
818
h = 16 + 2 * d_bwTrough;
896
822
return QSize(w, h);
825
//---------------------------------------------------------
827
//---------------------------------------------------------
829
void Slider::setOrientation(Orientation o)
832
ScaleDraw::OrientationX so = ScaleDraw::Bottom;
835
if (d_scalePos == Right)
836
so = ScaleDraw::Right;
838
so = ScaleDraw::Left;
841
if (d_scalePos == Bottom)
842
so = ScaleDraw::Bottom;
848
d_scale.setGeometry(0, 0, 40, so);
849
if (d_orient == Vertical)
850
setMinimumSize(10,20);
852
setMinimumSize(20,10);
853
QRect r = geometry();
854
setGeometry(r.x(), r.y(), r.height(), r.width());
858
Qt::Orientation Slider::orientation() const
863
double Slider::lineStep() const
868
double Slider::pageStep() const
873
void Slider::setLineStep(double)
877
void Slider::setPageStep(double)