Home

qtthumbwheel.h

This is the verbatim text of the qtthumbwheel.h include file. It is provided only for illustration; the copyright remains with Trolltech.


#ifndef QTTHUMBWHEEL_H
#define QTTHUMBWHEEL_H

#include <qframe.h>
#include <qpixmap.h>
#include <qrangecontrol.h>

#if defined(Q_WS_WIN)
#  if !defined(QT_QTTHUMBWHEEL_EXPORT) && !defined(QT_QTTHUMBWHEEL_IMPORT)
#    define QT_QTTHUMBWHEEL_EXPORT
#  elif defined(QT_QTTHUMBWHEEL_IMPORT)
#    if defined(QT_QTTHUMBWHEEL_EXPORT)
#      undef QT_QTTHUMBWHEEL_EXPORT
#    endif
#    define QT_QTTHUMBWHEEL_EXPORT __declspec(dllimport)
#  elif defined(QT_QTTHUMBWHEEL_EXPORT)
#    undef QT_QTTHUMBWHEEL_EXPORT
#    define QT_QTTHUMBWHEEL_EXPORT __declspec(dllexport)
#  endif
#else
#  define QT_QTTHUMBWHEEL_EXPORT
#endif

class QT_QTTHUMBWHEEL_EXPORT QtThumbWheel : public QFrame, public QRangeControl
{
    Q_OBJECT
    Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation)
    Q_PROPERTY(bool tracking READ tracking WRITE setTracking)
    Q_PROPERTY(int minValue READ minValue WRITE setMinValue)
    Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue)
    Q_PROPERTY(double transmissionRatio READ transmissionRatio WRITE setTransmissionRatio)
    Q_PROPERTY(bool wrapsAround READ wrapsAround WRITE setWrapsAround)
    Q_PROPERTY(int cogCount READ cogCount WRITE setCogCount)

public:
    QtThumbWheel(QWidget *parent = 0, const char *name = 0);
    QtThumbWheel(int minValue, int maxValue, int pageStep,
		 int value, Orientation orientation,
		 QWidget *parent = 0, const char *name = 0);

    ~QtThumbWheel();

    Orientation orientation() const;
    virtual void setOrientation(Orientation);

    void setRange(int min, int max);

    int minValue() const;
    void setMinValue(int v);

    int maxValue() const;
    void setMaxValue(int v);

    bool wrapsAround() const;
    void setWrapsAround(bool enabled);

    double transmissionRatio() const;
    virtual void setTransmissionRatio(double r);

    bool tracking() const;
    virtual void setTracking(bool enable);

    int cogCount() const;
    void setCogCount(int c);

    QSize sizeHint() const;

    int value() const;

signals:
    void valueChanged(int value);

public slots:
    virtual void setValue(int v);

protected:
    void valueChange();
    void rangeChange();
    void stepChange();

    void keyPressEvent(QKeyEvent *);
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void wheelEvent(QWheelEvent *);
    void focusInEvent(QFocusEvent *e);
    void focusOutEvent(QFocusEvent *e);
    void resizeEvent(QResizeEvent *e);

    void drawContents(QPainter *);

private:
    void init();
    void generateBackground();
    int valueFromPosition(const QPoint &);

    int cogs;
    bool wrap;
    double rat;
    int pressedAt;
    Orientation orient;
    uint track : 1;
    uint mousePressed : 1;

    QPixmap pix;
    QPixmap background;
    bool mustGenerateBackground;
};

#endif // QTTHUMBWHEEL_H

Copyright © 2003-2006 TrolltechTrademarks
Qt Solutions