source: trunk/src/gui/widgets/qspinbox.h@ 1166

Last change on this file since 1166 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QSPINBOX_H
43#define QSPINBOX_H
44
45#include <QtGui/qabstractspinbox.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Gui)
52
53#ifndef QT_NO_SPINBOX
54
55class QSpinBoxPrivate;
56class 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
68public:
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
105protected:
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
113public Q_SLOTS:
114 void setValue(int val);
115
116Q_SIGNALS:
117 void valueChanged(int);
118 void valueChanged(const QString &);
119
120private:
121 Q_DISABLE_COPY(QSpinBox)
122 Q_DECLARE_PRIVATE(QSpinBox)
123};
124
125class QDoubleSpinBoxPrivate;
126class 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)
138public:
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);