| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qrangecontrol.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QRangeControl class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 940427
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QRANGECONTROL_H
|
|---|
| 39 | #define QRANGECONTROL_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qglobal.h"
|
|---|
| 43 | #include "qframe.h"
|
|---|
| 44 | #endif // QT_H
|
|---|
| 45 |
|
|---|
| 46 | #ifndef QT_NO_RANGECONTROL
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | class QRangeControlPrivate;
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | class Q_EXPORT QRangeControl
|
|---|
| 53 | {
|
|---|
| 54 | public:
|
|---|
| 55 | QRangeControl();
|
|---|
| 56 | QRangeControl( int minValue, int maxValue,
|
|---|
| 57 | int lineStep, int pageStep, int value );
|
|---|
| 58 | virtual ~QRangeControl();
|
|---|
| 59 | int value() const;
|
|---|
| 60 | void setValue( int );
|
|---|
| 61 | void addPage();
|
|---|
| 62 | void subtractPage();
|
|---|
| 63 | void addLine();
|
|---|
| 64 | void subtractLine();
|
|---|
| 65 |
|
|---|
| 66 | int minValue() const;
|
|---|
| 67 | int maxValue() const;
|
|---|
| 68 | void setRange( int minValue, int maxValue );
|
|---|
| 69 | void setMinValue( int minVal );
|
|---|
| 70 | void setMaxValue( int minVal );
|
|---|
| 71 |
|
|---|
| 72 | int lineStep() const;
|
|---|
| 73 | int pageStep() const;
|
|---|
| 74 | void setSteps( int line, int page );
|
|---|
| 75 |
|
|---|
| 76 | int bound( int ) const;
|
|---|
| 77 |
|
|---|
| 78 | protected:
|
|---|
| 79 | int positionFromValue( int val, int space ) const;
|
|---|
| 80 | int valueFromPosition( int pos, int space ) const;
|
|---|
| 81 | void directSetValue( int val );
|
|---|
| 82 | int prevValue() const;
|
|---|
| 83 |
|
|---|
| 84 | virtual void valueChange();
|
|---|
| 85 | virtual void rangeChange();
|
|---|
| 86 | virtual void stepChange();
|
|---|
| 87 |
|
|---|
| 88 | private:
|
|---|
| 89 | int minVal, maxVal;
|
|---|
| 90 | int line, page;
|
|---|
| 91 | int val, prevVal;
|
|---|
| 92 |
|
|---|
| 93 | QRangeControlPrivate * d;
|
|---|
| 94 |
|
|---|
| 95 | private: // Disabled copy constructor and operator=
|
|---|
| 96 | #if defined(Q_DISABLE_COPY)
|
|---|
| 97 | QRangeControl( const QRangeControl & );
|
|---|
| 98 | QRangeControl &operator=( const QRangeControl & );
|
|---|
| 99 | #endif
|
|---|
| 100 | };
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | inline int QRangeControl::value() const
|
|---|
| 104 | { return val; }
|
|---|
| 105 |
|
|---|
| 106 | inline int QRangeControl::prevValue() const
|
|---|
| 107 | { return prevVal; }
|
|---|
| 108 |
|
|---|
| 109 | inline int QRangeControl::minValue() const
|
|---|
| 110 | { return minVal; }
|
|---|
| 111 |
|
|---|
| 112 | inline int QRangeControl::maxValue() const
|
|---|
| 113 | { return maxVal; }
|
|---|
| 114 |
|
|---|
| 115 | inline int QRangeControl::lineStep() const
|
|---|
| 116 | { return line; }
|
|---|
| 117 |
|
|---|
| 118 | inline int QRangeControl::pageStep() const
|
|---|
| 119 | { return page; }
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | #endif // QT_NO_RANGECONTROL
|
|---|
| 123 |
|
|---|
| 124 | #ifndef QT_NO_SPINWIDGET
|
|---|
| 125 |
|
|---|
| 126 | class QSpinWidgetPrivate;
|
|---|
| 127 | class Q_EXPORT QSpinWidget : public QWidget
|
|---|
| 128 | {
|
|---|
| 129 | Q_OBJECT
|
|---|
| 130 | public:
|
|---|
| 131 | QSpinWidget( QWidget* parent=0, const char* name=0 );
|
|---|
| 132 | ~QSpinWidget();
|
|---|
| 133 |
|
|---|
| 134 | void setEditWidget( QWidget * widget );
|
|---|
| 135 | QWidget * editWidget();
|
|---|
| 136 |
|
|---|
| 137 | QRect upRect() const;
|
|---|
| 138 | QRect downRect() const;
|
|---|
| 139 |
|
|---|
| 140 | void setUpEnabled( bool on );
|
|---|
| 141 | void setDownEnabled( bool on );
|
|---|
| 142 |
|
|---|
| 143 | bool isUpEnabled() const;
|
|---|
| 144 | bool isDownEnabled() const;
|
|---|
| 145 |
|
|---|
| 146 | enum ButtonSymbols { UpDownArrows, PlusMinus };
|
|---|
| 147 | virtual void setButtonSymbols( ButtonSymbols bs );
|
|---|
| 148 | ButtonSymbols buttonSymbols() const;
|
|---|
| 149 |
|
|---|
| 150 | void arrange();
|
|---|
| 151 |
|
|---|
| 152 | signals:
|
|---|
| 153 | void stepUpPressed();
|
|---|
| 154 | void stepDownPressed();
|
|---|
| 155 |
|
|---|
| 156 | public slots:
|
|---|
| 157 | void stepUp();
|
|---|
| 158 | void stepDown();
|
|---|
| 159 |
|
|---|
| 160 | protected:
|
|---|
| 161 | void mousePressEvent( QMouseEvent *e );
|
|---|
| 162 | void resizeEvent( QResizeEvent* ev );
|
|---|
| 163 | void mouseReleaseEvent( QMouseEvent *e );
|
|---|
| 164 | void mouseMoveEvent( QMouseEvent *e );
|
|---|
| 165 | #ifndef QT_NO_WHEELEVENT
|
|---|
| 166 | void wheelEvent( QWheelEvent * );
|
|---|
| 167 | #endif
|
|---|
| 168 | void styleChange( QStyle& );
|
|---|
| 169 | void paintEvent( QPaintEvent * );
|
|---|
| 170 | void enableChanged( bool old );
|
|---|
| 171 | void windowActivationChange( bool );
|
|---|
| 172 |
|
|---|
| 173 | private slots:
|
|---|
| 174 | void timerDone();
|
|---|
| 175 | void timerDoneEx();
|
|---|
| 176 |
|
|---|
| 177 | private:
|
|---|
| 178 | QSpinWidgetPrivate * d;
|
|---|
| 179 |
|
|---|
| 180 | void updateDisplay();
|
|---|
| 181 |
|
|---|
| 182 | private: // Disabled copy constructor and operator=
|
|---|
| 183 | #if defined(Q_DISABLE_COPY)
|
|---|
| 184 | QSpinWidget( const QSpinWidget& );
|
|---|
| 185 | QSpinWidget& operator=( const QSpinWidget& );
|
|---|
| 186 | #endif
|
|---|
| 187 | };
|
|---|
| 188 |
|
|---|
| 189 | #endif // QT_NO_SPINWIDGET
|
|---|
| 190 |
|
|---|
| 191 | #endif // QRANGECONTROL_H
|
|---|