| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
|---|
| 4 | ** Contact: https://www.qt.io/licensing/ | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial License Usage | 
|---|
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
|---|
| 11 | ** accordance with the commercial license agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
|---|
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
|---|
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
|---|
| 16 | ** | 
|---|
| 17 | ** GNU Lesser General Public License Usage | 
|---|
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 19 | ** General Public License version 3 as published by the Free Software | 
|---|
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
|---|
| 21 | ** packaging of this file. Please review the following information to | 
|---|
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
|---|
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
|---|
| 24 | ** | 
|---|
| 25 | ** GNU General Public License Usage | 
|---|
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
|---|
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
|---|
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
|---|
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
|---|
| 31 | ** included in the packaging of this file. Please review the following | 
|---|
| 32 | ** information to ensure the GNU General Public License requirements will | 
|---|
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
|---|
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** $QT_END_LICENSE$ | 
|---|
| 37 | ** | 
|---|
| 38 | ****************************************************************************/ | 
|---|
| 39 |  | 
|---|
| 40 | #ifndef QSPINBOX_H | 
|---|
| 41 | #define QSPINBOX_H | 
|---|
| 42 |  | 
|---|
| 43 | #include <QtWidgets/qtwidgetsglobal.h> | 
|---|
| 44 | #include <QtWidgets/qabstractspinbox.h> | 
|---|
| 45 |  | 
|---|
| 46 | QT_REQUIRE_CONFIG(spinbox); | 
|---|
| 47 |  | 
|---|
| 48 | QT_BEGIN_NAMESPACE | 
|---|
| 49 |  | 
|---|
| 50 | class QSpinBoxPrivate; | 
|---|
| 51 | class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox | 
|---|
| 52 | { | 
|---|
| 53 | Q_OBJECT | 
|---|
| 54 |  | 
|---|
| 55 | Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) | 
|---|
| 56 | Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) | 
|---|
| 57 | Q_PROPERTY(QString cleanText READ cleanText) | 
|---|
| 58 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) | 
|---|
| 59 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) | 
|---|
| 60 | Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep) | 
|---|
| 61 | Q_PROPERTY(StepType stepType READ stepType WRITE setStepType) | 
|---|
| 62 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true) | 
|---|
| 63 | Q_PROPERTY(int displayIntegerBase READ displayIntegerBase WRITE setDisplayIntegerBase) | 
|---|
| 64 |  | 
|---|
| 65 | public: | 
|---|
| 66 | explicit QSpinBox(QWidget *parent = nullptr); | 
|---|
| 67 | ~QSpinBox(); | 
|---|
| 68 |  | 
|---|
| 69 | int value() const; | 
|---|
| 70 |  | 
|---|
| 71 | QString prefix() const; | 
|---|
| 72 | void setPrefix(const QString &prefix); | 
|---|
| 73 |  | 
|---|
| 74 | QString suffix() const; | 
|---|
| 75 | void setSuffix(const QString &suffix); | 
|---|
| 76 |  | 
|---|
| 77 | QString cleanText() const; | 
|---|
| 78 |  | 
|---|
| 79 | int singleStep() const; | 
|---|
| 80 | void setSingleStep(int val); | 
|---|
| 81 |  | 
|---|
| 82 | int minimum() const; | 
|---|
| 83 | void setMinimum(int min); | 
|---|
| 84 |  | 
|---|
| 85 | int maximum() const; | 
|---|
| 86 | void setMaximum(int max); | 
|---|
| 87 |  | 
|---|
| 88 | void setRange(int min, int max); | 
|---|
| 89 |  | 
|---|
| 90 | StepType stepType() const; | 
|---|
| 91 | void setStepType(StepType stepType); | 
|---|
| 92 |  | 
|---|
| 93 | int displayIntegerBase() const; | 
|---|
| 94 | void setDisplayIntegerBase(int base); | 
|---|
| 95 |  | 
|---|
| 96 | protected: | 
|---|
| 97 | bool event(QEvent *event) override; | 
|---|
| 98 | QValidator::State validate(QString &input, int &pos) const override; | 
|---|
| 99 | virtual int valueFromText(const QString &text) const; | 
|---|
| 100 | virtual QString textFromValue(int val) const; | 
|---|
| 101 | void fixup(QString &str) const override; | 
|---|
| 102 |  | 
|---|
| 103 |  | 
|---|
| 104 | public Q_SLOTS: | 
|---|
| 105 | void setValue(int val); | 
|---|
| 106 |  | 
|---|
| 107 | Q_SIGNALS: | 
|---|
| 108 | void valueChanged(int); | 
|---|
| 109 | void textChanged(const QString &); | 
|---|
| 110 | #if QT_DEPRECATED_SINCE(5, 14) | 
|---|
| 111 | QT_DEPRECATED_X( "Use textChanged(QString) instead") | 
|---|
| 112 | void valueChanged(const QString &); | 
|---|
| 113 | #endif | 
|---|
| 114 |  | 
|---|
| 115 | private: | 
|---|
| 116 | Q_DISABLE_COPY(QSpinBox) | 
|---|
| 117 | Q_DECLARE_PRIVATE(QSpinBox) | 
|---|
| 118 | }; | 
|---|
| 119 |  | 
|---|
| 120 | class QDoubleSpinBoxPrivate; | 
|---|
| 121 | class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox | 
|---|
| 122 | { | 
|---|
| 123 | Q_OBJECT | 
|---|
| 124 |  | 
|---|
| 125 | Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) | 
|---|
| 126 | Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) | 
|---|
| 127 | Q_PROPERTY(QString cleanText READ cleanText) | 
|---|
| 128 | Q_PROPERTY(int decimals READ decimals WRITE setDecimals) | 
|---|
| 129 | Q_PROPERTY(double minimum READ minimum WRITE setMinimum) | 
|---|
| 130 | Q_PROPERTY(double maximum READ maximum WRITE setMaximum) | 
|---|
| 131 | Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep) | 
|---|
| 132 | Q_PROPERTY(StepType stepType READ stepType WRITE setStepType) | 
|---|
| 133 | Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true) | 
|---|
| 134 | public: | 
|---|
| 135 | explicit QDoubleSpinBox(QWidget *parent = nullptr); | 
|---|
| 136 | ~QDoubleSpinBox(); | 
|---|
| 137 |  | 
|---|
| 138 | double value() const; | 
|---|
| 139 |  | 
|---|
| 140 | QString prefix() const; | 
|---|
| 141 | void setPrefix(const QString &prefix); | 
|---|
| 142 |  | 
|---|
| 143 | QString suffix() const; | 
|---|
| 144 | void setSuffix(const QString &suffix); | 
|---|
| 145 |  | 
|---|
| 146 | QString cleanText() const; | 
|---|
| 147 |  | 
|---|
| 148 | double singleStep() const; | 
|---|
| 149 | void setSingleStep(double val); | 
|---|
| 150 |  | 
|---|
| 151 | double minimum() const; | 
|---|
| 152 | void setMinimum(double min); | 
|---|
| 153 |  | 
|---|
| 154 | double maximum() const; | 
|---|
| 155 | void setMaximum(double max); | 
|---|
| 156 |  | 
|---|
| 157 | void setRange(double min, double max); | 
|---|
| 158 |  | 
|---|
| 159 | StepType stepType() const; | 
|---|
| 160 | void setStepType(StepType stepType); | 
|---|
| 161 |  | 
|---|
| 162 | int decimals() const; | 
|---|
| 163 | void setDecimals(int prec); | 
|---|
| 164 |  | 
|---|
| 165 | QValidator::State validate(QString &input, int &pos) const override; | 
|---|
| 166 | virtual double valueFromText(const QString &text) const; | 
|---|
| 167 | virtual QString textFromValue(double val) const; | 
|---|
| 168 | void fixup(QString &str) const override; | 
|---|
| 169 |  | 
|---|
| 170 | public Q_SLOTS: | 
|---|
| 171 | void setValue(double val); | 
|---|
| 172 |  | 
|---|
| 173 | Q_SIGNALS: | 
|---|
| 174 | void valueChanged(double); | 
|---|
| 175 | void textChanged(const QString &); | 
|---|
| 176 | #if QT_DEPRECATED_SINCE(5, 14) | 
|---|
| 177 | QT_DEPRECATED_X( "Use textChanged(QString) instead") | 
|---|
| 178 | void valueChanged(const QString &); | 
|---|
| 179 | #endif | 
|---|
| 180 |  | 
|---|
| 181 | private: | 
|---|
| 182 | Q_DISABLE_COPY(QDoubleSpinBox) | 
|---|
| 183 | Q_DECLARE_PRIVATE(QDoubleSpinBox) | 
|---|
| 184 | }; | 
|---|
| 185 |  | 
|---|
| 186 | QT_END_NAMESPACE | 
|---|
| 187 |  | 
|---|
| 188 | #endif // QSPINBOX_H | 
|---|
| 189 |  | 
|---|