00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef QT_SVG_SLIDE_SWITCH_H
00014 #define QT_SVG_SLIDE_SWITCH_H
00015
00016 #include <QtCore/QRect>
00017 #include <QtCore/QSharedData>
00018 #include <QtCore/QUrl>
00019 #include <QtCore/QString>
00020 #include <QtGui/QAbstractButton>
00021
00022 #include "qtsvgpixmapcache.h"
00023
00024 class QTimeLine;
00025
00026 class QtSvgSlideSwitch : public QAbstractButton
00027 {
00028 Q_OBJECT
00029 Q_PROPERTY(QString skin READ skin WRITE setSkin)
00030 public:
00031 explicit QtSvgSlideSwitch(QWidget * parent = 0);
00032 explicit QtSvgSlideSwitch(const QString & text, QWidget * parent = 0);
00033 explicit QtSvgSlideSwitch(const QIcon & icon, const QString & text, QWidget * parent = 0);
00034 virtual ~QtSvgSlideSwitch();
00035
00036 void setSkin(const QString& skin);
00037 QString skin() const;
00038
00039 private Q_SLOTS:
00040 void setSwitchPosition(int position);
00041 void updateSwitchPosition(bool checked);
00042
00043 private:
00044 void init();
00045 QRectF buttonRect() const;
00046 QRectF knobRect() const;
00047
00048 virtual void paintEvent(QPaintEvent * event);
00049 virtual QSize sizeHint() const;
00050
00051
00052 void mouseMoveEvent(QMouseEvent * event);
00053 void mousePressEvent(QMouseEvent * event);
00054 void mouseReleaseEvent(QMouseEvent * event);
00055
00056 bool hitButton(const QPoint & pos) const;
00057
00059 QTimeLine *m_timeLine;
00060
00061 QtSvgPixmapCache m_rendererBase;
00062 QtSvgPixmapCache m_rendererBaseHover;
00063 QtSvgPixmapCache m_rendererKnobOn;
00064 QtSvgPixmapCache m_rendererKnobOff;
00065
00066 QtSvgPixmapCache m_rendererKnob;
00067
00069 QPoint m_dragStartPosition;
00071 int m_dragDistanceX;
00073 bool m_dragInProgress;
00074
00076 int m_position;
00077
00079 QString m_skin;
00080 };
00081
00082 #endif // QT_SVG_SLIDE_SWITCH_H