Qwt User's Guide svn
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 "qwt_global.h"
00014 #include "qwt_double_range.h"
00015 #include <qwidget.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     Q_PROPERTY( Qt::Orientation orientation
00035                 READ orientation WRITE setOrientation )
00036 
00037 public:
00042     enum ScrollMode
00043     {
00045         ScrNone,
00046 
00051         ScrMouse,
00052 
00057         ScrTimer,
00058 
00059         ScrDirect,
00060 
00062         ScrPage
00063     };
00064 
00065     explicit QwtAbstractSlider( Qt::Orientation, QWidget *parent = NULL );
00066     virtual ~QwtAbstractSlider();
00067 
00068     void setUpdateTime( int t );
00069     void stopMoving();
00070     void setTracking( bool enable );
00071 
00072     virtual void setMass( double val );
00073     virtual double mass() const;
00074 
00075     virtual void setOrientation( Qt::Orientation o );
00076     Qt::Orientation orientation() const;
00077 
00078     bool isReadOnly() const;
00079 
00080     /*
00081         Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made
00082         to be available as Q_PROPERTY in the designer.
00083     */
00084 
00088     bool isValid() const
00089     {
00090         return QwtDoubleRange::isValid();
00091     }
00092 
00097     void setValid( bool valid )
00098     {
00099         QwtDoubleRange::setValid( valid );
00100     }
00101 
00102 public Q_SLOTS:
00103     virtual void setValue( double val );
00104     virtual void fitValue( double val );
00105     virtual void incValue( int steps );
00106 
00107     virtual void setReadOnly( bool );
00108 
00109 Q_SIGNALS:
00110 
00119     void valueChanged( double value );
00120 
00125     void sliderPressed();
00126 
00132     void sliderReleased();
00138     void sliderMoved( double value );
00139 
00140 protected:
00141     virtual void setPosition( const QPoint & );
00142     virtual void valueChange();
00143 
00144     virtual void timerEvent( QTimerEvent *e );
00145     virtual void mousePressEvent( QMouseEvent *e );
00146     virtual void mouseReleaseEvent( QMouseEvent *e );
00147     virtual void mouseMoveEvent( QMouseEvent *e );
00148     virtual void keyPressEvent( QKeyEvent *e );
00149     virtual void wheelEvent( QWheelEvent *e );
00150 
00159     virtual double getValue( const QPoint & p ) = 0;
00160 
00173     virtual void getScrollMode( const QPoint &pos,
00174         ScrollMode &scrollMode, int &direction ) const = 0;
00175 
00176     void setMouseOffset( double );
00177     double mouseOffset() const;
00178 
00179     int scrollMode() const;
00180 
00181 private:
00182     void buttonReleased();
00183 
00184     class PrivateData;
00185     PrivateData *d_data;
00186 };
00187 
00188 #endif
qmi style