|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QABSTRACTSPINBOX_H |
|
43 #define QABSTRACTSPINBOX_H |
|
44 |
|
45 #include <QtGui/qwidget.h> |
|
46 #include <QtGui/qvalidator.h> |
|
47 |
|
48 QT_BEGIN_HEADER |
|
49 |
|
50 QT_BEGIN_NAMESPACE |
|
51 |
|
52 QT_MODULE(Gui) |
|
53 |
|
54 #ifndef QT_NO_SPINBOX |
|
55 |
|
56 class QLineEdit; |
|
57 |
|
58 class QAbstractSpinBoxPrivate; |
|
59 class QStyleOptionSpinBox; |
|
60 |
|
61 class Q_GUI_EXPORT QAbstractSpinBox : public QWidget |
|
62 { |
|
63 Q_OBJECT |
|
64 |
|
65 Q_ENUMS(ButtonSymbols) |
|
66 Q_ENUMS(CorrectionMode) |
|
67 Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping) |
|
68 Q_PROPERTY(bool frame READ hasFrame WRITE setFrame) |
|
69 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) |
|
70 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) |
|
71 Q_PROPERTY(ButtonSymbols buttonSymbols READ buttonSymbols WRITE setButtonSymbols) |
|
72 Q_PROPERTY(QString specialValueText READ specialValueText WRITE setSpecialValueText) |
|
73 Q_PROPERTY(QString text READ text) |
|
74 Q_PROPERTY(bool accelerated READ isAccelerated WRITE setAccelerated) |
|
75 Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode) |
|
76 Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) |
|
77 Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking) |
|
78 public: |
|
79 explicit QAbstractSpinBox(QWidget *parent = 0); |
|
80 ~QAbstractSpinBox(); |
|
81 |
|
82 enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01, |
|
83 StepDownEnabled = 0x02 }; |
|
84 Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag) |
|
85 |
|
86 enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons }; |
|
87 |
|
88 ButtonSymbols buttonSymbols() const; |
|
89 void setButtonSymbols(ButtonSymbols bs); |
|
90 |
|
91 enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue }; |
|
92 |
|
93 void setCorrectionMode(CorrectionMode cm); |
|
94 CorrectionMode correctionMode() const; |
|
95 |
|
96 bool hasAcceptableInput() const; |
|
97 QString text() const; |
|
98 |
|
99 QString specialValueText() const; |
|
100 void setSpecialValueText(const QString &txt); |
|
101 |
|
102 bool wrapping() const; |
|
103 void setWrapping(bool w); |
|
104 |
|
105 void setReadOnly(bool r); |
|
106 bool isReadOnly() const; |
|
107 |
|
108 void setKeyboardTracking(bool kt); |
|
109 bool keyboardTracking() const; |
|
110 |
|
111 void setAlignment(Qt::Alignment flag); |
|
112 Qt::Alignment alignment() const; |
|
113 |
|
114 void setFrame(bool); |
|
115 bool hasFrame() const; |
|
116 |
|
117 void setAccelerated(bool on); |
|
118 bool isAccelerated() const; |
|
119 |
|
120 QSize sizeHint() const; |
|
121 QSize minimumSizeHint() const; |
|
122 void interpretText(); |
|
123 bool event(QEvent *event); |
|
124 |
|
125 QVariant inputMethodQuery(Qt::InputMethodQuery) const; |
|
126 |
|
127 virtual QValidator::State validate(QString &input, int &pos) const; |
|
128 virtual void fixup(QString &input) const; |
|
129 |
|
130 virtual void stepBy(int steps); |
|
131 public Q_SLOTS: |
|
132 void stepUp(); |
|
133 void stepDown(); |
|
134 void selectAll(); |
|
135 virtual void clear(); |
|
136 protected: |
|
137 void resizeEvent(QResizeEvent *event); |
|
138 void keyPressEvent(QKeyEvent *event); |
|
139 void keyReleaseEvent(QKeyEvent *event); |
|
140 void wheelEvent(QWheelEvent *event); |
|
141 void focusInEvent(QFocusEvent *event); |
|
142 void focusOutEvent(QFocusEvent *event); |
|
143 void contextMenuEvent(QContextMenuEvent *event); |
|
144 void changeEvent(QEvent *event); |
|
145 void closeEvent(QCloseEvent *event); |
|
146 void hideEvent(QHideEvent *event); |
|
147 void mousePressEvent(QMouseEvent *event); |
|
148 void mouseReleaseEvent(QMouseEvent *event); |
|
149 void mouseMoveEvent(QMouseEvent *event); |
|
150 void timerEvent(QTimerEvent *event); |
|
151 void paintEvent(QPaintEvent *event); |
|
152 void showEvent(QShowEvent *event); |
|
153 void initStyleOption(QStyleOptionSpinBox *option) const; |
|
154 |
|
155 QLineEdit *lineEdit() const; |
|
156 void setLineEdit(QLineEdit *edit); |
|
157 |
|
158 virtual StepEnabled stepEnabled() const; |
|
159 Q_SIGNALS: |
|
160 void editingFinished(); |
|
161 protected: |
|
162 QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = 0); |
|
163 |
|
164 private: |
|
165 Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &)) |
|
166 Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int)) |
|
167 |
|
168 Q_DECLARE_PRIVATE(QAbstractSpinBox) |
|
169 Q_DISABLE_COPY(QAbstractSpinBox) |
|
170 }; |
|
171 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled) |
|
172 |
|
173 #endif // QT_NO_SPINBOX |
|
174 |
|
175 QT_END_NAMESPACE |
|
176 |
|
177 QT_END_HEADER |
|
178 |
|
179 #endif // QABSTRACTSPINBOX_H |