itom 2.2.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut fuer Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 00027 This file is a port and modified version of the 00028 Common framework (http://www.commontk.org) 00029 *********************************************************************** */ 00030 00031 #ifndef RANGESLIDER_H 00032 #define RANGESLIDER_H 00033 00034 #include <QSlider> 00035 00036 #include "commonWidgets.h" 00037 00038 00039 class QStylePainter; 00040 class RangeSliderPrivate; 00041 00042 namespace ito { 00043 class IntervalMeta; //forward declaration 00044 } 00045 00061 class ITOMWIDGETS_EXPORT RangeSlider : public QSlider 00062 { 00063 Q_OBJECT 00064 Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue) 00065 Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue) 00066 Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition) 00067 Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition) 00068 Q_PROPERTY(uint stepSizePosition READ stepSizePosition WRITE setStepSizePosition) 00069 Q_PROPERTY(uint minimumRange READ minimumRange WRITE setMinimumRange) 00070 Q_PROPERTY(uint maximumRange READ maximumRange WRITE setMaximumRange) 00071 Q_PROPERTY(uint stepSizeRange READ stepSizeRange WRITE setStepSizeRange) 00072 Q_PROPERTY(bool rangeIncludeLimits READ rangeIncludeLimits WRITE setRangeIncludeLimits) 00073 Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves) 00074 Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip) 00075 00076 public: 00077 // Superclass typedef 00078 typedef QSlider Superclass; 00082 explicit RangeSlider( Qt::Orientation o, QWidget* par= 0 ); 00083 explicit RangeSlider( QWidget* par = 0 ); 00084 virtual ~RangeSlider(); 00085 00091 int minimumValue() const; 00092 00098 int maximumValue() const; 00099 00103 int minimumPosition() const; 00104 void setMinimumPosition(int min); 00105 00109 int maximumPosition() const; 00110 void setMaximumPosition(int max); 00111 00115 uint stepSizePosition() const; 00116 void setStepSizePosition(uint stepSize); 00117 00121 uint minimumRange() const; 00122 void setMinimumRange(uint min); 00123 00127 uint maximumRange() const; 00128 void setMaximumRange(uint max); 00129 00133 uint stepSizeRange() const; 00134 void setStepSizeRange(uint stepSize); 00135 00140 bool rangeIncludeLimits() const; 00141 void setRangeIncludeLimits(bool include); 00142 00146 void setPositions(int min, int max); 00147 00151 bool symmetricMoves()const; 00152 void setSymmetricMoves(bool symmetry); 00153 00159 QString handleToolTip()const; 00160 void setHandleToolTip(const QString& toolTip); 00161 00164 bool isMinimumSliderDown()const; 00167 bool isMaximumSliderDown()const; 00168 00173 void setLimitsFromIntervalMeta(const ito::IntervalMeta &intervalMeta); 00174 00175 signals: 00179 void minimumValueChanged(int min); 00183 void maximumValueChanged(int max); 00186 void valuesChanged(int min, int max); 00187 00193 void minimumPositionChanged(int min); 00194 00200 void maximumPositionChanged(int max); 00201 00205 void positionsChanged(int min, int max); 00206 00207 public slots: 00214 void setMinimumValue(int min); 00215 00222 void setMaximumValue(int max); 00223 00231 void setValues(int min, int max); 00232 00233 protected slots: 00234 void onRangeChanged(int minimum, int maximum); 00235 00236 protected: 00237 RangeSlider( RangeSliderPrivate* impl, Qt::Orientation o, QWidget* par= 0 ); 00238 RangeSlider( RangeSliderPrivate* impl, QWidget* par = 0 ); 00239 00240 // Description: 00241 // Standard Qt UI events 00242 virtual void mousePressEvent(QMouseEvent* ev); 00243 virtual void mouseMoveEvent(QMouseEvent* ev); 00244 virtual void mouseReleaseEvent(QMouseEvent* ev); 00245 00246 // Description: 00247 // Rendering is done here. 00248 virtual void paintEvent(QPaintEvent* ev); 00249 virtual void initMinimumSliderStyleOption(QStyleOptionSlider* option) const; 00250 virtual void initMaximumSliderStyleOption(QStyleOptionSlider* option) const; 00251 00252 // Description: 00253 // Reimplemented for the tooltips 00254 virtual bool event(QEvent* event); 00255 00256 protected: 00257 QScopedPointer<RangeSliderPrivate> d_ptr; 00258 00259 private: 00260 Q_DECLARE_PRIVATE(RangeSlider); 00261 Q_DISABLE_COPY(RangeSlider); 00262 }; 00263 00264 #endif 00265