1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtGui 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 Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QSPINBOX_H |
43 | #define QSPINBOX_H |
44 | |
45 | #include <QtGui/qabstractspinbox.h> |
46 | |
47 | QT_BEGIN_HEADER |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | QT_MODULE(Gui) |
52 | |
53 | #ifndef QT_NO_SPINBOX |
54 | |
55 | class QSpinBoxPrivate; |
56 | class Q_GUI_EXPORT QSpinBox : public QAbstractSpinBox |
57 | { |
58 | Q_OBJECT |
59 | |
60 | Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) |
61 | Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) |
62 | Q_PROPERTY(QString cleanText READ cleanText) |
63 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) |
64 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) |
65 | Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep) |
66 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true) |
67 | |
68 | public: |
69 | explicit QSpinBox(QWidget *parent = 0); |
70 | #ifdef QT3_SUPPORT |
71 | QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name); |
72 | QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent, |
73 | const char *name = 0); |
74 | #endif |
75 | |
76 | int value() const; |
77 | |
78 | QString prefix() const; |
79 | void setPrefix(const QString &prefix); |
80 | |
81 | QString suffix() const; |
82 | void setSuffix(const QString &suffix); |
83 | |
84 | QString cleanText() const; |
85 | |
86 | int singleStep() const; |
87 | void setSingleStep(int val); |
88 | |
89 | int minimum() const; |
90 | void setMinimum(int min); |
91 | |
92 | int maximum() const; |
93 | void setMaximum(int max); |
94 | |
95 | void setRange(int min, int max); |
96 | |
97 | #ifdef QT3_SUPPORT |
98 | inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); } |
99 | inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); } |
100 | inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); } |
101 | inline QT3_SUPPORT int maxValue() const { return maximum(); } |
102 | inline QT3_SUPPORT int minValue() const { return minimum(); } |
103 | #endif |
104 | |
105 | protected: |
106 | bool event(QEvent *event); |
107 | virtual QValidator::State validate(QString &input, int &pos) const; |
108 | virtual int valueFromText(const QString &text) const; |
109 | virtual QString textFromValue(int val) const; |
110 | virtual void fixup(QString &str) const; |
111 | |
112 | |
113 | public Q_SLOTS: |
114 | void setValue(int val); |
115 | |
116 | Q_SIGNALS: |
117 | void valueChanged(int); |
118 | void valueChanged(const QString &); |
119 | |
120 | private: |
121 | Q_DISABLE_COPY(QSpinBox) |
122 | Q_DECLARE_PRIVATE(QSpinBox) |
123 | }; |
124 | |
125 | class QDoubleSpinBoxPrivate; |
126 | class Q_GUI_EXPORT QDoubleSpinBox : public QAbstractSpinBox |
127 | { |
128 | Q_OBJECT |
129 | |
130 | Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) |
131 | Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) |
132 | Q_PROPERTY(QString cleanText READ cleanText) |
133 | Q_PROPERTY(int decimals READ decimals WRITE setDecimals) |
134 | Q_PROPERTY(double minimum READ minimum WRITE setMinimum) |
135 | Q_PROPERTY(double maximum READ maximum WRITE setMaximum) |
136 | Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep) |
137 | Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true) |
138 | public: |
139 | explicit QDoubleSpinBox(QWidget *parent = 0); |
140 | |
141 | double value() const; |
142 | |
143 | QString prefix() const; |
144 | void setPrefix(const QString &prefix); |
145 | |
146 | QString suffix() const; |
147 | void setSuffix(const QString &suffix); |
148 | |
149 | QString cleanText() const; |
150 | |
151 | double singleStep() const; |
152 | void setSingleStep(double val); |
153 | |
154 | double minimum() const; |
155 | void setMinimum(double min); |
156 | |
157 | double maximum() const; |
158 | void setMaximum(double max); |
159 | |
160 | void setRange(double min, double max); |
161 | |
162 | int decimals() const; |
163 | void setDecimals(int prec); |
164 | |
165 | virtual QValidator::State validate(QString &input, int &pos) const; |
166 | virtual double valueFromText(const QString &text) const; |
167 | virtual QString textFromValue(double val) const; |
168 | virtual void fixup(QString &str) const; |
169 | |
170 | public Q_SLOTS: |
171 | void setValue(double val); |
172 | |
173 | Q_SIGNALS: |
174 | void valueChanged(double); |
175 | void valueChanged(const QString &); |
176 | |
177 | private: |
178 | Q_DISABLE_COPY(QDoubleSpinBox) |
179 | Q_DECLARE_PRIVATE(QDoubleSpinBox) |
180 | }; |
181 | |
182 | #endif // QT_NO_SPINBOX |
183 | |
184 | QT_END_NAMESPACE |
185 | |
186 | QT_END_HEADER |
187 | |
188 | #endif // QSPINBOX_H |
189 | |