1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
10
#ifndef QWT_ABSTRACT_SLIDER_H
11
#define QWT_ABSTRACT_SLIDER_H
14
#include "qwt_global.h"
15
#include "qwt_double_range.h"
18
\brief An abstract base class for slider widgets
20
QwtAbstractSlider is a base class for
21
slider widgets. It handles mouse events
22
and updates the slider's value accordingly. Derived classes
23
only have to implement the getValue() and
24
getScrollMode() members, and should react to a
25
valueChange(), which normally requires repainting.
28
class QWT_EXPORT QwtAbstractSlider : public QWidget, public QwtDoubleRange
31
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
32
Q_PROPERTY( bool valid READ isValid WRITE setValid )
33
Q_PROPERTY( double mass READ mass WRITE setMass )
34
#ifndef Q_MOC_RUN // Qt3 moc
35
#define QWT_PROPERTY Q_PROPERTY
36
Q_PROPERTY( Orientation orientation
37
READ orientation WRITE setOrientation )
40
Q_PROPERTY( Qt::Orientation orientation
41
READ orientation WRITE setOrientation )
59
explicit QwtAbstractSlider(Qt::Orientation, QWidget *parent = NULL);
60
virtual ~QwtAbstractSlider();
62
void setUpdateTime(int t);
64
void setTracking(bool enable);
66
virtual void setMass(double val);
67
virtual double mass() const;
69
#if QT_VERSION >= 0x040000
70
virtual void setOrientation(Qt::Orientation o);
71
Qt::Orientation orientation() const;
73
virtual void setOrientation(Orientation o);
74
Orientation orientation() const;
77
bool isReadOnly() const;
80
Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made
81
to be available as Q_PROPERTY in the designer.
85
\sa QwtDblRange::isValid
87
bool isValid() const { return QwtDoubleRange::isValid(); }
90
\sa QwtDblRange::isValid
92
void setValid(bool valid) { QwtDoubleRange::setValid(valid); }
95
virtual void setValue(double val);
96
virtual void fitValue(double val);
97
virtual void incValue(int steps);
99
virtual void setReadOnly(bool);
104
\brief Notify a change of value.
106
In the default setting
107
(tracking enabled), this signal will be emitted every
108
time the value changes ( see setTracking() ).
109
\param value new value
111
void valueChanged(double value);
114
This signal is emitted when the user presses the
115
movable part of the slider (start ScrMouse Mode).
117
void sliderPressed();
120
This signal is emitted when the user releases the
121
movable part of the slider.
124
void sliderReleased();
126
This signal is emitted when the user moves the
127
slider with the mouse.
128
\param value new value
130
void sliderMoved(double value);
133
virtual void setPosition(const QPoint &);
134
virtual void valueChange();
136
virtual void timerEvent(QTimerEvent *e);
137
virtual void mousePressEvent(QMouseEvent *e);
138
virtual void mouseReleaseEvent(QMouseEvent *e);
139
virtual void mouseMoveEvent(QMouseEvent *e);
140
virtual void keyPressEvent(QKeyEvent *e);
141
virtual void wheelEvent(QWheelEvent *e);
144
\brief Determine the value corresponding to a specified poind
146
This is an abstract virtual function which is called when
147
the user presses or releases a mouse button or moves the
148
mouse. It has to be implemented by the derived class.
151
virtual double getValue(const QPoint & p) = 0;
153
\brief Determine what to do when the user presses a mouse button.
155
This function is abstract and has to be implemented by derived classes.
156
It is called on a mousePress event. The derived class can determine
157
what should happen next in dependence of the position where the mouse
158
was pressed by returning scrolling mode and direction. QwtAbstractSlider
159
knows the following modes:<dl>
160
<dt>QwtAbstractSlider::ScrNone
161
<dd>Scrolling switched off. Don't change the value.
162
<dt>QwtAbstractSlider::ScrMouse
163
<dd>Change the value while the user keeps the
164
button pressed and moves the mouse.
165
<dt>QwtAbstractSlider::ScrTimer
166
<dd>Automatic scrolling. Increment the value
167
in the specified direction as long as
168
the user keeps the button pressed.
169
<dt>QwtAbstractSlider::ScrPage
170
<dd>Automatic scrolling. Same as ScrTimer, but
171
increment by page size.</dl>
173
\param p point where the mouse was pressed
174
\retval scrollMode The scrolling mode
175
\retval direction direction: 1, 0, or -1.
177
virtual void getScrollMode( const QPoint &p,
178
int &scrollMode, int &direction) = 0;
180
void setMouseOffset(double);
181
double mouseOffset() const;
183
int scrollMode() const;
186
void buttonReleased();