qabstractspinbox.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #ifndef QABSTRACTSPINBOX_H
  40. #define QABSTRACTSPINBOX_H
  41. #include <QtWidgets/qwidget.h>
  42. #include <QtGui/qvalidator.h>
  43. QT_BEGIN_NAMESPACE
  44. #ifndef QT_NO_SPINBOX
  45. class QLineEdit;
  46. class QAbstractSpinBoxPrivate;
  47. class QStyleOptionSpinBox;
  48. class Q_WIDGETS_EXPORT QAbstractSpinBox : public QWidget
  49. {
  50. Q_OBJECT
  51. Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
  52. Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
  53. Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
  54. Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
  55. Q_PROPERTY(ButtonSymbols buttonSymbols READ buttonSymbols WRITE setButtonSymbols)
  56. Q_PROPERTY(QString specialValueText READ specialValueText WRITE setSpecialValueText)
  57. Q_PROPERTY(QString text READ text)
  58. Q_PROPERTY(bool accelerated READ isAccelerated WRITE setAccelerated)
  59. Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode)
  60. Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
  61. Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
  62. Q_PROPERTY(bool showGroupSeparator READ isGroupSeparatorShown WRITE setGroupSeparatorShown)
  63. public:
  64. explicit QAbstractSpinBox(QWidget *parent = Q_NULLPTR);
  65. ~QAbstractSpinBox();
  66. enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
  67. StepDownEnabled = 0x02 };
  68. Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)
  69. enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons };
  70. Q_ENUM(ButtonSymbols)
  71. ButtonSymbols buttonSymbols() const;
  72. void setButtonSymbols(ButtonSymbols bs);
  73. enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue };
  74. Q_ENUM(CorrectionMode)
  75. void setCorrectionMode(CorrectionMode cm);
  76. CorrectionMode correctionMode() const;
  77. bool hasAcceptableInput() const;
  78. QString text() const;
  79. QString specialValueText() const;
  80. void setSpecialValueText(const QString &txt);
  81. bool wrapping() const;
  82. void setWrapping(bool w);
  83. void setReadOnly(bool r);
  84. bool isReadOnly() const;
  85. void setKeyboardTracking(bool kt);
  86. bool keyboardTracking() const;
  87. void setAlignment(Qt::Alignment flag);
  88. Qt::Alignment alignment() const;
  89. void setFrame(bool);
  90. bool hasFrame() const;
  91. void setAccelerated(bool on);
  92. bool isAccelerated() const;
  93. void setGroupSeparatorShown(bool shown);
  94. bool isGroupSeparatorShown() const;
  95. QSize sizeHint() const;
  96. QSize minimumSizeHint() const;
  97. void interpretText();
  98. bool event(QEvent *event);
  99. QVariant inputMethodQuery(Qt::InputMethodQuery) const;
  100. virtual QValidator::State validate(QString &input, int &pos) const;
  101. virtual void fixup(QString &input) const;
  102. virtual void stepBy(int steps);
  103. public Q_SLOTS:
  104. void stepUp();
  105. void stepDown();
  106. void selectAll();
  107. virtual void clear();
  108. protected:
  109. void resizeEvent(QResizeEvent *event);
  110. void keyPressEvent(QKeyEvent *event);
  111. void keyReleaseEvent(QKeyEvent *event);
  112. #ifndef QT_NO_WHEELEVENT
  113. void wheelEvent(QWheelEvent *event);
  114. #endif
  115. void focusInEvent(QFocusEvent *event);
  116. void focusOutEvent(QFocusEvent *event);
  117. void contextMenuEvent(QContextMenuEvent *event);
  118. void changeEvent(QEvent *event);
  119. void closeEvent(QCloseEvent *event);
  120. void hideEvent(QHideEvent *event);
  121. void mousePressEvent(QMouseEvent *event);
  122. void mouseReleaseEvent(QMouseEvent *event);
  123. void mouseMoveEvent(QMouseEvent *event);
  124. void timerEvent(QTimerEvent *event);
  125. void paintEvent(QPaintEvent *event);
  126. void showEvent(QShowEvent *event);
  127. void initStyleOption(QStyleOptionSpinBox *option) const;
  128. QLineEdit *lineEdit() const;
  129. void setLineEdit(QLineEdit *edit);
  130. virtual StepEnabled stepEnabled() const;
  131. Q_SIGNALS:
  132. void editingFinished();
  133. protected:
  134. QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = Q_NULLPTR);
  135. private:
  136. Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
  137. Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int))
  138. Q_DECLARE_PRIVATE(QAbstractSpinBox)
  139. Q_DISABLE_COPY(QAbstractSpinBox)
  140. friend class QAccessibleAbstractSpinBox;
  141. };
  142. Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled)
  143. #endif // QT_NO_SPINBOX
  144. QT_END_NAMESPACE
  145. #endif // QABSTRACTSPINBOX_H