qwt_abstract_slider.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_ABSTRACT_SLIDER_H
00011 #define QWT_ABSTRACT_SLIDER_H
00012 
00013 #include <qwidget.h>
00014 #include "qwt_global.h"
00015 #include "qwt_double_range.h"
00016 
00028 class QWT_EXPORT QwtAbstractSlider : public QWidget, public QwtDoubleRange
00029 {
00030     Q_OBJECT 
00031     Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
00032     Q_PROPERTY( bool valid READ isValid WRITE setValid )
00033     Q_PROPERTY( double mass READ mass WRITE setMass )
00034 #ifndef Q_MOC_RUN // Qt3 moc
00035 #define QWT_PROPERTY Q_PROPERTY
00036     Q_PROPERTY( Orientation orientation 
00037         READ orientation WRITE setOrientation )
00038 #else // Qt4 moc
00039 // MOC_SKIP_BEGIN
00040     Q_PROPERTY( Qt::Orientation orientation 
00041         READ orientation WRITE setOrientation )
00042 // MOC_SKIP_END
00043 #endif
00044 
00045 public:
00050     enum ScrollMode 
00051     { 
00052         ScrNone, 
00053         ScrMouse, 
00054         ScrTimer, 
00055         ScrDirect, 
00056         ScrPage 
00057     };
00058     
00059     explicit QwtAbstractSlider(Qt::Orientation, QWidget *parent = NULL);
00060     virtual ~QwtAbstractSlider();
00061 
00062     void setUpdateTime(int t);
00063     void stopMoving();
00064     void setTracking(bool enable);
00065     
00066     virtual void setMass(double val);
00067     virtual double mass() const;
00068 
00069 #if QT_VERSION >= 0x040000
00070     virtual void setOrientation(Qt::Orientation o);
00071     Qt::Orientation orientation() const;
00072 #else
00073     virtual void setOrientation(Orientation o);
00074     Orientation orientation() const;
00075 #endif
00076 
00077     bool isReadOnly() const;
00078 
00079     /* 
00080         Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made
00081         to be available as Q_PROPERTY in the designer.
00082     */
00083 
00087     bool isValid() const { return QwtDoubleRange::isValid(); }
00088 
00092     void setValid(bool valid) { QwtDoubleRange::setValid(valid); }
00093 
00094 public slots:
00095     virtual void setValue(double val);
00096     virtual void fitValue(double val);
00097     virtual void incValue(int steps);
00098 
00099     virtual void setReadOnly(bool); 
00100 
00101 signals:
00102 
00111     void valueChanged(double value);
00112 
00117     void sliderPressed();
00118 
00124     void sliderReleased();
00130     void sliderMoved(double value);
00131     
00132 protected:
00133     virtual void setPosition(const QPoint &);
00134     virtual void valueChange();
00135 
00136     virtual void timerEvent(QTimerEvent *e);
00137     virtual void mousePressEvent(QMouseEvent *e);
00138     virtual void mouseReleaseEvent(QMouseEvent *e);
00139     virtual void mouseMoveEvent(QMouseEvent *e);
00140     virtual void keyPressEvent(QKeyEvent *e);
00141     virtual void wheelEvent(QWheelEvent *e);
00142 
00151     virtual double getValue(const QPoint & p) = 0;
00177     virtual void getScrollMode( const QPoint &p,
00178                   int &scrollMode, int &direction) = 0;
00179 
00180     void setMouseOffset(double);
00181     double mouseOffset() const;
00182 
00183     int scrollMode() const;
00184 
00185 private:
00186     void buttonReleased();
00187 
00188     class PrivateData;
00189     PrivateData *d_data;
00190 };
00191 
00192 #endif

Generated on Mon Feb 26 21:22:36 2007 for Qwt User's Guide by  doxygen 1.4.6