Skip to content
Snippets Groups Projects
qwt_slider.h 3.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     * Qwt Widget Library
     * Copyright (C) 1997   Josef Wilgen
     * Copyright (C) 2002   Uwe Rathmann
     *
     * 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_SLIDER_H
    #define QWT_SLIDER_H
    
    #include "qwt_global.h"
    #include "qwt_abstract_slider.h"
    
    class QwtScaleDraw;
    
    /*!
      \brief The Slider Widget
    
      QwtSlider is a slider widget which operates on an interval
    
    Bryant's avatar
    Bryant committed
      of type double. Its position is related to a scale showing
      the current value.
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
      The slider can be customized by having a through, a groove - or both.
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
      \image html sliders.png
    
    pixhawk's avatar
    pixhawk committed
    */
    
    
    Bryant's avatar
    Bryant committed
    class QWT_EXPORT QwtSlider: public QwtAbstractSlider
    
    pixhawk's avatar
    pixhawk committed
    {
        Q_OBJECT
    
    Bryant's avatar
    Bryant committed
    
        Q_ENUMS( ScalePosition BackgroundStyle )
    
        Q_PROPERTY( Qt::Orientation orientation
                    READ orientation WRITE setOrientation )
        Q_PROPERTY( ScalePosition scalePosition READ scalePosition
            WRITE setScalePosition )
    
        Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
        Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
    
        Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
    
    pixhawk's avatar
    pixhawk committed
        Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
    
    Bryant's avatar
    Bryant committed
        Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
    
    pixhawk's avatar
    pixhawk committed
    public:
    
    
    Bryant's avatar
    Bryant committed
          Position of the scale
          \sa QwtSlider(), setScalePosition(), setOrientation()
    
    pixhawk's avatar
    pixhawk committed
         */
    
    Bryant's avatar
    Bryant committed
        enum ScalePosition
        {
            //! The slider has no scale
    
    Bryant's avatar
    Bryant committed
            //! The scale is right of a vertical or below a horizontal slider
            LeadingScale,
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
            //! The scale is left of a vertical or above a horizontal slider
            TrailingScale
    
    pixhawk's avatar
    pixhawk committed
        };
    
    
    Bryant's avatar
    Bryant committed
        explicit QwtSlider( QWidget *parent = NULL );
        explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL );
    
    pixhawk's avatar
    pixhawk committed
        virtual ~QwtSlider();
    
    
    Bryant's avatar
    Bryant committed
        void setOrientation( Qt::Orientation );
        Qt::Orientation orientation() const;
    
        void setScalePosition( ScalePosition );
        ScalePosition scalePosition() const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        void setTrough( bool );
        bool hasTrough() const;
    
    Bryant's avatar
    Bryant committed
        void setGroove( bool );
        bool hasGroove() const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        void setHandleSize( const QSize & );
        QSize handleSize() const;
    
        void setBorderWidth( int bw );
    
    pixhawk's avatar
    pixhawk committed
        int borderWidth() const;
    
    
    Bryant's avatar
    Bryant committed
        void setSpacing( int );
        int spacing() const;
    
    pixhawk's avatar
    pixhawk committed
    
        virtual QSize sizeHint() const;
        virtual QSize minimumSizeHint() const;
    
    Bryant's avatar
    Bryant committed
        void setScaleDraw( QwtScaleDraw * );
    
    pixhawk's avatar
    pixhawk committed
        const QwtScaleDraw *scaleDraw() const;
    
    
    Bryant's avatar
    Bryant committed
        void setUpdateInterval( int );
        int updateInterval() const;
    
    
    pixhawk's avatar
    pixhawk committed
    protected:
    
    Bryant's avatar
    Bryant committed
        virtual double scrolledTo( const QPoint & ) const;
        virtual bool isScrollPosition( const QPoint & ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual void drawSlider ( QPainter *, const QRect & ) const;
        virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
        virtual void mousePressEvent( QMouseEvent * );
        virtual void mouseReleaseEvent( QMouseEvent * );
        virtual void resizeEvent( QResizeEvent * );
        virtual void paintEvent ( QPaintEvent * );
        virtual void changeEvent( QEvent * );
        virtual void timerEvent( QTimerEvent * );
    
    pixhawk's avatar
    pixhawk committed
    
        virtual void scaleChange();
    
    
    Bryant's avatar
    Bryant committed
        QRect sliderRect() const;
        QRect handleRect() const;
    
    pixhawk's avatar
    pixhawk committed
    
    
    Bryant's avatar
    Bryant committed
    private:
    
    pixhawk's avatar
    pixhawk committed
        QwtScaleDraw *scaleDraw();
    
    
    Bryant's avatar
    Bryant committed
        void layoutSlider( bool );
        void initSlider( Qt::Orientation );
    
    pixhawk's avatar
    pixhawk committed
    
        class PrivateData;
        PrivateData *d_data;
    };
    
    #endif