WidgetPack/qwpdoubleslider.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  qwpdoubleslider.h
00004  * 
00005  *  Created by Aidan Lane on Wed Feb 01 2006.
00006  *  Copyright (c) 2006 Optimisation and Constraint Solving Group,
00007  *  Monash University. All rights reserved.
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022  */
00023 
00024 #ifndef QWPDOUBLESLIDER_H
00025 #define QWPDOUBLESLIDER_H
00026 
00027 
00028 #include <QWidget>
00029 #include <QtDesigner/QDesignerExportWidget>
00030 
00031 #include <QPointer>
00032 #include <QSlider>
00033 
00034 
00035 class QDESIGNER_WIDGET_EXPORT QwpDoubleSlider : public QWidget {
00036 
00037   Q_OBJECT
00038 
00039   // TODO: add RESET methods for the properties for use in Qt Designer
00040 
00041   // Note: The properties are in the order that they appear for QSlider in Qt 4.1
00042 
00043   Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
00044   Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
00045   Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
00046   Q_PROPERTY( double pageStep READ pageStep WRITE setPageStep )
00047   Q_PROPERTY( double value READ value WRITE setValue )
00048   Q_PROPERTY( bool sliderDown READ isSliderDown WRITE setSliderDown \
00049               DESIGNABLE false )
00050   Q_PROPERTY( double sliderPosition READ sliderPosition WRITE setSliderPosition )
00051   Q_PROPERTY( bool tracking READ hasTracking WRITE setTracking )
00052   Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
00053   Q_PROPERTY( bool invertedAppearance READ invertedAppearance \
00054               WRITE setInvertedAppearance )
00055   Q_PROPERTY( bool invertedControls READ invertedControls \
00056               WRITE setInvertedControls )
00057  
00058   Q_PROPERTY( QSlider::TickPosition tickPosition READ tickPosition \
00059               WRITE setTickPosition )
00060   Q_PROPERTY( double tickInterval READ tickInterval WRITE setTickInterval )
00061 
00062   Q_ENUMS( Qt::Orientation );
00063   Q_ENUMS( QSlider::TickPosition );
00064 
00065 
00066 public:
00067   QwpDoubleSlider( QWidget* parent );
00068   QwpDoubleSlider( Qt::Orientation orientation, QWidget* parent );
00069 
00070   double value() const;
00071 
00072   double minimum() const;
00073   double maximum() const;
00074   void setMinimum( double min );
00075   void setMaximum( double max );
00076   void setRange( double min, double max );
00077 
00078   Qt::Orientation orientation() const;
00079 
00080   bool    hasTracking() const;
00081   bool    invertedAppearance() const;
00082   bool    invertedControls() const;
00083   bool    isSliderDown() const;
00084   double  pageStep() const;
00085   double  sliderPosition() const;
00086   double  singleStep() const;
00087   void    setTracking( bool enable );
00088   void    setInvertedAppearance( bool enable );
00089   void    setInvertedControls( bool enable );
00090   void    setPageStep( double step );
00091   void    setSliderDown( bool enable );
00092   void    setSliderPosition( double position );
00093   void    setSingleStep( double step );
00094 
00095   double  tickInterval() const;
00096   void setTickInterval( double interval );
00097 
00098   QSlider::TickPosition tickPosition() const;
00099   void setTickPosition( QSlider::TickPosition position );
00100 
00101   void triggerAction( QSlider::SliderAction action );
00102 
00103   QSize sizeHint() const;
00104 
00105 
00106 signals:
00107   void actionTriggered( int action );
00108   void rangeChanged( double min, double max );
00109   void sliderMoved( double value );
00110   void sliderPressed();
00111   void sliderReleased();
00112   void valueChanged( double value );
00113   
00114 
00115 
00116 public slots:
00117   void setOrientation( Qt::Orientation orientation );
00118   void setValue( double value );
00119 
00120 
00121 protected:
00122   QSlider* slider() const;
00123 
00124   double sliderValueToDouble( int value ) const;
00125   int    doubleToSliderValue( double value ) const;
00126 
00127   void resizeEvent( QResizeEvent* event );
00128 
00129 
00130 private slots:
00131   // actionTriggered, sliderPressed and sliderReleased are re-sent directly
00132   // rangeChanged isn't needed, as the internal slider's range never changes
00133   void onSliderMoved( int value );
00134   void onSliderValueChanged( int value );
00135 
00136 
00137 private:
00138   void init();
00139 
00140   QPointer<QSlider> m_slider;
00141 
00142   double m_value;
00143   double m_min;
00144   double m_max;
00145   double m_pageStep;
00146   double m_singleStep;
00147   double m_sliderPosition;
00148   double m_tickInterval;
00149 };
00150 
00151 
00157 class QDESIGNER_WIDGET_EXPORT QwpHDoubleSlider : public QwpDoubleSlider {
00158   Q_OBJECT
00159 public:
00160   QwpHDoubleSlider( QWidget* parent )
00161     : QwpDoubleSlider(Qt::Horizontal, parent) {}
00162 };
00163 
00164 
00170 class QDESIGNER_WIDGET_EXPORT QwpVDoubleSlider : public QwpDoubleSlider {
00171   Q_OBJECT
00172 public:
00173   QwpVDoubleSlider( QWidget* parent )
00174     : QwpDoubleSlider(Qt::Vertical, parent) {}
00175 };
00176 
00177 
00178 #endif  // ! QWPDOUBLESLIDER_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2