qabstractslider.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QABSTRACTSLIDER_H
00043 #define QABSTRACTSLIDER_H
00044 
00045 #include <QtGui/qwidget.h>
00046 
00047 QT_BEGIN_HEADER
00048 
00049 QT_BEGIN_NAMESPACE
00050 
00051 QT_MODULE(Gui)
00052 
00053 class QAbstractSliderPrivate;
00054 
00055 class Q_GUI_EXPORT QAbstractSlider : public QWidget
00056 {
00057     Q_OBJECT
00058 
00059     Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
00060     Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
00061     Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
00062     Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
00063     Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
00064     Q_PROPERTY(int sliderPosition READ sliderPosition WRITE setSliderPosition NOTIFY sliderMoved)
00065     Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
00066     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
00067     Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
00068     Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
00069     Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
00070 
00071 public:
00072     explicit QAbstractSlider(QWidget *parent=0);
00073     ~QAbstractSlider();
00074 
00075     Qt::Orientation orientation() const;
00076 
00077     void setMinimum(int);
00078     int minimum() const;
00079 
00080     void setMaximum(int);
00081     int maximum() const;
00082 
00083     void setRange(int min, int max);
00084 
00085     void setSingleStep(int);
00086     int singleStep() const;
00087 
00088     void setPageStep(int);
00089     int pageStep() const;
00090 
00091     void setTracking(bool enable);
00092     bool hasTracking() const;
00093 
00094     void setSliderDown(bool);
00095     bool isSliderDown() const;
00096 
00097     void setSliderPosition(int);
00098     int sliderPosition() const;
00099 
00100     void setInvertedAppearance(bool);
00101     bool invertedAppearance() const;
00102 
00103     void setInvertedControls(bool);
00104     bool invertedControls() const;
00105 
00106     enum SliderAction {
00107         SliderNoAction,
00108         SliderSingleStepAdd,
00109         SliderSingleStepSub,
00110         SliderPageStepAdd,
00111         SliderPageStepSub,
00112         SliderToMinimum,
00113         SliderToMaximum,
00114         SliderMove
00115     };
00116 
00117     int value() const;
00118 
00119     void triggerAction(SliderAction action);
00120 
00121 public Q_SLOTS:
00122     void setValue(int);
00123     void setOrientation(Qt::Orientation);
00124 
00125 Q_SIGNALS:
00126     void valueChanged(int value);
00127 
00128     void sliderPressed();
00129     void sliderMoved(int position);
00130     void sliderReleased();
00131 
00132     void rangeChanged(int min, int max);
00133 
00134     void actionTriggered(int action);
00135 
00136 protected:
00137     bool event(QEvent *e);
00138 
00139     void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
00140     SliderAction repeatAction() const;
00141 
00142     enum SliderChange {
00143         SliderRangeChange,
00144         SliderOrientationChange,
00145         SliderStepsChange,
00146         SliderValueChange
00147     };
00148     virtual void sliderChange(SliderChange change);
00149 
00150     void keyPressEvent(QKeyEvent *ev);
00151     void timerEvent(QTimerEvent *);
00152 #ifndef QT_NO_WHEELEVENT
00153     void wheelEvent(QWheelEvent *e);
00154 #endif
00155     void changeEvent(QEvent *e);
00156 
00157 #ifdef QT3_SUPPORT
00158 public:
00159     inline QT3_SUPPORT int minValue() const { return minimum(); }
00160     inline QT3_SUPPORT int maxValue() const { return maximum(); }
00161     inline QT3_SUPPORT int lineStep() const { return singleStep(); }
00162     inline QT3_SUPPORT void setMinValue(int v) { setMinimum(v); }
00163     inline QT3_SUPPORT void setMaxValue(int v) { setMaximum(v); }
00164     inline QT3_SUPPORT void setLineStep(int v) { setSingleStep(v); }
00165     inline QT3_SUPPORT void setSteps(int single, int page) { setSingleStep(single); setPageStep(page); }
00166     inline QT3_SUPPORT void addPage() { triggerAction(SliderPageStepAdd); }
00167     inline QT3_SUPPORT void subtractPage() { triggerAction(SliderPageStepSub); }
00168     inline QT3_SUPPORT void addLine() { triggerAction(SliderSingleStepAdd); }
00169     inline QT3_SUPPORT void subtractLine() { triggerAction(SliderSingleStepSub); }
00170 #endif
00171 
00172 protected:
00173     QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent=0);
00174 
00175 private:
00176     Q_DISABLE_COPY(QAbstractSlider)
00177     Q_DECLARE_PRIVATE(QAbstractSlider)
00178 };
00179 
00180 QT_END_NAMESPACE
00181 
00182 QT_END_HEADER
00183 
00184 #endif // QABSTRACTSLIDER_H