src/gui/widgets/qspinbox.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     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 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