You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
5.5 KiB
196 lines
5.5 KiB
15 years ago
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||
|
* Qwt Widget Library
|
||
|
* Copyright (C) 1997 Josef Wilgen
|
||
|
* Copyright (C) 2002 Uwe Rathmann
|
||
14 years ago
|
*
|
||
15 years ago
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the Qwt License, Version 1.0
|
||
|
*****************************************************************************/
|
||
|
|
||
|
#ifndef QWT_ABSTRACT_SLIDER_H
|
||
|
#define QWT_ABSTRACT_SLIDER_H
|
||
|
|
||
|
#include <qwidget.h>
|
||
|
#include "qwt_global.h"
|
||
|
#include "qwt_double_range.h"
|
||
|
|
||
|
/*!
|
||
|
\brief An abstract base class for slider widgets
|
||
|
|
||
|
QwtAbstractSlider is a base class for
|
||
|
slider widgets. It handles mouse events
|
||
|
and updates the slider's value accordingly. Derived classes
|
||
14 years ago
|
only have to implement the getValue() and
|
||
15 years ago
|
getScrollMode() members, and should react to a
|
||
14 years ago
|
valueChange(), which normally requires repainting.
|
||
15 years ago
|
*/
|
||
|
|
||
|
class QWT_EXPORT QwtAbstractSlider : public QWidget, public QwtDoubleRange
|
||
|
{
|
||
14 years ago
|
Q_OBJECT
|
||
15 years ago
|
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
|
||
|
Q_PROPERTY( bool valid READ isValid WRITE setValid )
|
||
|
Q_PROPERTY( double mass READ mass WRITE setMass )
|
||
|
#ifndef Q_MOC_RUN // Qt3 moc
|
||
|
#define QWT_PROPERTY Q_PROPERTY
|
||
14 years ago
|
Q_PROPERTY( Orientation orientation
|
||
|
READ orientation WRITE setOrientation )
|
||
15 years ago
|
#else // Qt4 moc
|
||
|
// MOC_SKIP_BEGIN
|
||
14 years ago
|
Q_PROPERTY( Qt::Orientation orientation
|
||
|
READ orientation WRITE setOrientation )
|
||
15 years ago
|
// MOC_SKIP_END
|
||
|
#endif
|
||
|
|
||
|
public:
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Scroll mode
|
||
|
\sa getScrollMode()
|
||
|
*/
|
||
14 years ago
|
enum ScrollMode {
|
||
|
ScrNone,
|
||
|
ScrMouse,
|
||
|
ScrTimer,
|
||
|
ScrDirect,
|
||
|
ScrPage
|
||
15 years ago
|
};
|
||
14 years ago
|
|
||
15 years ago
|
explicit QwtAbstractSlider(Qt::Orientation, QWidget *parent = NULL);
|
||
|
virtual ~QwtAbstractSlider();
|
||
|
|
||
|
void setUpdateTime(int t);
|
||
|
void stopMoving();
|
||
|
void setTracking(bool enable);
|
||
14 years ago
|
|
||
15 years ago
|
virtual void setMass(double val);
|
||
|
virtual double mass() const;
|
||
|
|
||
|
#if QT_VERSION >= 0x040000
|
||
|
virtual void setOrientation(Qt::Orientation o);
|
||
|
Qt::Orientation orientation() const;
|
||
|
#else
|
||
|
virtual void setOrientation(Orientation o);
|
||
|
Orientation orientation() const;
|
||
|
#endif
|
||
|
|
||
|
bool isReadOnly() const;
|
||
|
|
||
14 years ago
|
/*
|
||
15 years ago
|
Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made
|
||
|
to be available as Q_PROPERTY in the designer.
|
||
|
*/
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
\sa QwtDblRange::isValid
|
||
|
*/
|
||
14 years ago
|
bool isValid() const {
|
||
|
return QwtDoubleRange::isValid();
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
\sa QwtDblRange::isValid
|
||
|
*/
|
||
14 years ago
|
void setValid(bool valid) {
|
||
|
QwtDoubleRange::setValid(valid);
|
||
|
}
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
virtual void setValue(double val);
|
||
|
virtual void fitValue(double val);
|
||
|
virtual void incValue(int steps);
|
||
|
|
||
14 years ago
|
virtual void setReadOnly(bool);
|
||
15 years ago
|
|
||
|
signals:
|
||
|
|
||
|
/*!
|
||
|
\brief Notify a change of value.
|
||
|
|
||
14 years ago
|
In the default setting
|
||
|
(tracking enabled), this signal will be emitted every
|
||
|
time the value changes ( see setTracking() ).
|
||
15 years ago
|
\param value new value
|
||
|
*/
|
||
|
void valueChanged(double value);
|
||
|
|
||
|
/*!
|
||
14 years ago
|
This signal is emitted when the user presses the
|
||
15 years ago
|
movable part of the slider (start ScrMouse Mode).
|
||
|
*/
|
||
|
void sliderPressed();
|
||
|
|
||
|
/*!
|
||
14 years ago
|
This signal is emitted when the user releases the
|
||
15 years ago
|
movable part of the slider.
|
||
|
*/
|
||
|
|
||
|
void sliderReleased();
|
||
|
/*!
|
||
|
This signal is emitted when the user moves the
|
||
|
slider with the mouse.
|
||
|
\param value new value
|
||
|
*/
|
||
|
void sliderMoved(double value);
|
||
14 years ago
|
|
||
15 years ago
|
protected:
|
||
|
virtual void setPosition(const QPoint &);
|
||
|
virtual void valueChange();
|
||
|
|
||
|
virtual void timerEvent(QTimerEvent *e);
|
||
|
virtual void mousePressEvent(QMouseEvent *e);
|
||
|
virtual void mouseReleaseEvent(QMouseEvent *e);
|
||
|
virtual void mouseMoveEvent(QMouseEvent *e);
|
||
|
virtual void keyPressEvent(QKeyEvent *e);
|
||
|
virtual void wheelEvent(QWheelEvent *e);
|
||
|
|
||
14 years ago
|
/*!
|
||
|
\brief Determine the value corresponding to a specified poind
|
||
15 years ago
|
|
||
14 years ago
|
This is an abstract virtual function which is called when
|
||
|
the user presses or releases a mouse button or moves the
|
||
|
mouse. It has to be implemented by the derived class.
|
||
|
\param p point
|
||
|
*/
|
||
15 years ago
|
virtual double getValue(const QPoint & p) = 0;
|
||
14 years ago
|
/*!
|
||
|
\brief Determine what to do when the user presses a mouse button.
|
||
|
|
||
|
This function is abstract and has to be implemented by derived classes.
|
||
|
It is called on a mousePress event. The derived class can determine
|
||
|
what should happen next in dependence of the position where the mouse
|
||
|
was pressed by returning scrolling mode and direction. QwtAbstractSlider
|
||
|
knows the following modes:<dl>
|
||
|
<dt>QwtAbstractSlider::ScrNone
|
||
|
<dd>Scrolling switched off. Don't change the value.
|
||
|
<dt>QwtAbstractSlider::ScrMouse
|
||
|
<dd>Change the value while the user keeps the
|
||
|
button pressed and moves the mouse.
|
||
|
<dt>QwtAbstractSlider::ScrTimer
|
||
|
<dd>Automatic scrolling. Increment the value
|
||
|
in the specified direction as long as
|
||
|
the user keeps the button pressed.
|
||
|
<dt>QwtAbstractSlider::ScrPage
|
||
|
<dd>Automatic scrolling. Same as ScrTimer, but
|
||
|
increment by page size.</dl>
|
||
|
|
||
|
\param p point where the mouse was pressed
|
||
|
\retval scrollMode The scrolling mode
|
||
|
\retval direction direction: 1, 0, or -1.
|
||
|
*/
|
||
15 years ago
|
virtual void getScrollMode( const QPoint &p,
|
||
14 years ago
|
int &scrollMode, int &direction) = 0;
|
||
15 years ago
|
|
||
|
void setMouseOffset(double);
|
||
|
double mouseOffset() const;
|
||
|
|
||
|
int scrollMode() const;
|
||
|
|
||
|
private:
|
||
|
void buttonReleased();
|
||
|
|
||
|
class PrivateData;
|
||
|
PrivateData *d_data;
|
||
|
};
|
||
|
|
||
|
#endif
|