svgui  1.9
Thumbwheel.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _THUMBWHEEL_H_
00017 #define _THUMBWHEEL_H_
00018 
00019 #include <QWidget>
00020 #include <QImage>
00021 
00022 #include <map>
00023 
00024 class RangeMapper;
00025 
00026 class Thumbwheel : public QWidget
00027 {
00028     Q_OBJECT
00029 
00030 public:
00031     Thumbwheel(Qt::Orientation orientation, QWidget *parent = 0);
00032     virtual ~Thumbwheel();
00033 
00034     int getMinimumValue() const;
00035     int getMaximumValue() const;
00036     int getDefaultValue() const;
00037     float getSpeed() const;
00038     bool getTracking() const;
00039     bool getShowScale() const;
00040     int getValue() const;
00041 
00042     void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
00043     const RangeMapper *getRangeMapper() const { return m_rangeMapper; }
00044     float getMappedValue() const;
00045 
00046     void setShowToolTip(bool show);
00047 
00048     QSize sizeHint() const;
00049 
00050 signals:
00051     void valueChanged(int);
00052 
00053     void mouseEntered();
00054     void mouseLeft();
00055 
00056 public slots:
00057     void setMinimumValue(int min);
00058     void setMaximumValue(int max);
00059     void setDefaultValue(int deft);
00060     void setSpeed(float speed);
00061     void setTracking(bool tracking);
00062     void setShowScale(bool show);
00063     void setValue(int value);
00064     void setMappedValue(float mappedValue);
00065     void scroll(bool up);
00066     void resetToDefault();
00067 
00068 protected slots:
00069     void updateMappedValue(int value);
00070 
00071 protected:
00072     virtual void mousePressEvent(QMouseEvent *e);
00073     virtual void mouseDoubleClickEvent(QMouseEvent *e);
00074     virtual void mouseMoveEvent(QMouseEvent *e);
00075     virtual void mouseReleaseEvent(QMouseEvent *e);
00076     virtual void wheelEvent(QWheelEvent *e);
00077     virtual void paintEvent(QPaintEvent *e);
00078     virtual void enterEvent(QEvent *);
00079     virtual void leaveEvent(QEvent *);
00080 
00081     int m_min;
00082     int m_max;
00083     int m_default;
00084     int m_value;
00085     float m_mappedValue;
00086     bool m_noMappedUpdate;
00087     float m_rotation;
00088     Qt::Orientation m_orientation;
00089     float m_speed;
00090     bool m_tracking;
00091     bool m_showScale;
00092     bool m_clicked;
00093     bool m_atDefault;
00094     QPoint m_clickPos;
00095     float m_clickRotation;
00096     bool m_showTooltip;
00097     RangeMapper *m_rangeMapper;
00098     QImage m_cache;
00099 };
00100 
00101 #endif