/src/gui/widgets/qspinbox.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 188 lines · 106 code · 42 blank · 40 comment · 0 complexity · a47a9d27db6a43599105eecac9b04635 MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 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. ** GNU Lesser General Public License Usage
  11. ** This file may be used under the terms of the GNU Lesser General Public
  12. ** License version 2.1 as published by the Free Software Foundation and
  13. ** appearing in the file LICENSE.LGPL included in the packaging of this
  14. ** file. Please review the following information to ensure the GNU Lesser
  15. ** General Public License version 2.1 requirements will be met:
  16. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  17. **
  18. ** In addition, as a special exception, Nokia gives you certain additional
  19. ** rights. These rights are described in the Nokia Qt LGPL Exception
  20. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  21. **
  22. ** GNU General Public License Usage
  23. ** Alternatively, this file may be used under the terms of the GNU General
  24. ** Public License version 3.0 as published by the Free Software Foundation
  25. ** and appearing in the file LICENSE.GPL included in the packaging of this
  26. ** file. Please review the following information to ensure the GNU General
  27. ** Public License version 3.0 requirements will be met:
  28. ** http://www.gnu.org/copyleft/gpl.html.
  29. **
  30. ** Other Usage
  31. ** Alternatively, this file may be used in accordance with the terms and
  32. ** conditions contained in a signed written agreement between you and Nokia.
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #ifndef QSPINBOX_H
  42. #define QSPINBOX_H
  43. #include <QtGui/qabstractspinbox.h>
  44. QT_BEGIN_HEADER
  45. QT_BEGIN_NAMESPACE
  46. QT_MODULE(Gui)
  47. #ifndef QT_NO_SPINBOX
  48. class QSpinBoxPrivate;
  49. class Q_GUI_EXPORT QSpinBox : public QAbstractSpinBox
  50. {
  51. Q_OBJECT
  52. Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
  53. Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
  54. Q_PROPERTY(QString cleanText READ cleanText)
  55. Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
  56. Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
  57. Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
  58. Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
  59. public:
  60. explicit QSpinBox(QWidget *parent = 0);
  61. #ifdef QT3_SUPPORT
  62. QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name);
  63. QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent,
  64. const char *name = 0);
  65. #endif
  66. int value() const;
  67. QString prefix() const;
  68. void setPrefix(const QString &prefix);
  69. QString suffix() const;
  70. void setSuffix(const QString &suffix);
  71. QString cleanText() const;
  72. int singleStep() const;
  73. void setSingleStep(int val);
  74. int minimum() const;
  75. void setMinimum(int min);
  76. int maximum() const;
  77. void setMaximum(int max);
  78. void setRange(int min, int max);
  79. #ifdef QT3_SUPPORT
  80. inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); }
  81. inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); }
  82. inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); }
  83. inline QT3_SUPPORT int maxValue() const { return maximum(); }
  84. inline QT3_SUPPORT int minValue() const { return minimum(); }
  85. #endif
  86. protected:
  87. bool event(QEvent *event);
  88. virtual QValidator::State validate(QString &input, int &pos) const;
  89. virtual int valueFromText(const QString &text) const;
  90. virtual QString textFromValue(int val) const;
  91. virtual void fixup(QString &str) const;
  92. public Q_SLOTS:
  93. void setValue(int val);
  94. Q_SIGNALS:
  95. void valueChanged(int);
  96. void valueChanged(const QString &);
  97. private:
  98. Q_DISABLE_COPY(QSpinBox)
  99. Q_DECLARE_PRIVATE(QSpinBox)
  100. };
  101. class QDoubleSpinBoxPrivate;
  102. class Q_GUI_EXPORT QDoubleSpinBox : public QAbstractSpinBox
  103. {
  104. Q_OBJECT
  105. Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
  106. Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
  107. Q_PROPERTY(QString cleanText READ cleanText)
  108. Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
  109. Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
  110. Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
  111. Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
  112. Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
  113. public:
  114. explicit QDoubleSpinBox(QWidget *parent = 0);
  115. double value() const;
  116. QString prefix() const;
  117. void setPrefix(const QString &prefix);
  118. QString suffix() const;
  119. void setSuffix(const QString &suffix);
  120. QString cleanText() const;
  121. double singleStep() const;
  122. void setSingleStep(double val);
  123. double minimum() const;
  124. void setMinimum(double min);
  125. double maximum() const;
  126. void setMaximum(double max);
  127. void setRange(double min, double max);
  128. int decimals() const;
  129. void setDecimals(int prec);
  130. virtual QValidator::State validate(QString &input, int &pos) const;
  131. virtual double valueFromText(const QString &text) const;
  132. virtual QString textFromValue(double val) const;
  133. virtual void fixup(QString &str) const;
  134. public Q_SLOTS:
  135. void setValue(double val);
  136. Q_SIGNALS:
  137. void valueChanged(double);
  138. void valueChanged(const QString &);
  139. private:
  140. Q_DISABLE_COPY(QDoubleSpinBox)
  141. Q_DECLARE_PRIVATE(QDoubleSpinBox)
  142. };
  143. #endif // QT_NO_SPINBOX
  144. QT_END_NAMESPACE
  145. QT_END_HEADER
  146. #endif // QSPINBOX_H