SpinBox.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_SPINBOX_H
00025 #define GUI_SPINBOX_H
00026 
00027 #include <QValidator>
00028 #include <QSpinBox>
00029 
00030 namespace Gui {
00031 
00036 class GuiExport UnsignedValidator : public QValidator
00037 {
00038     Q_OBJECT
00039     Q_PROPERTY( uint bottom READ bottom WRITE setBottom )
00040     Q_PROPERTY( uint top READ top WRITE setTop )
00041 
00042 public:
00043     UnsignedValidator( QObject * parent );
00044     UnsignedValidator( uint bottom, uint top, QObject * parent );
00045     ~UnsignedValidator();
00046 
00047     QValidator::State validate( QString &, int & ) const;
00048 
00049     void setBottom( uint );
00050     void setTop( uint );
00051     virtual void setRange( uint bottom, uint top );
00052 
00053     uint bottom() const { return b; }
00054     uint top() const { return t; }
00055 
00056 private:
00057     uint b, t;
00058 };
00059 
00060 class UIntSpinBoxPrivate;
00067 class GuiExport UIntSpinBox : public QSpinBox
00068 {
00069     Q_OBJECT
00070     Q_OVERRIDE( uint maximum READ maximum WRITE setMaximum )
00071     Q_OVERRIDE( uint minimum READ minimum WRITE setMinimum )
00072     Q_OVERRIDE( uint value READ value WRITE setValue )
00073 
00074 public:
00075     UIntSpinBox ( QWidget* parent=0 );
00076     virtual ~UIntSpinBox();
00077 
00078     void setRange( uint minVal, uint maxVal );
00079     uint value() const;
00080     virtual QValidator::State validate ( QString & input, int & pos ) const;
00081     uint minimum() const;
00082     void setMinimum( uint value );
00083     uint maximum() const;
00084     void setMaximum( uint value );
00085 
00086 Q_SIGNALS:
00087     void valueChanged( uint value );
00088 
00089 public Q_SLOTS:
00090     void setValue( uint value );
00091 
00092 private Q_SLOTS:
00093     void valueChange( int value );
00094 
00095 protected:
00096     virtual QString textFromValue ( int v ) const;
00097     virtual int valueFromText ( const QString & text ) const;
00098 
00099 private:
00100     void updateValidator();
00101     UIntSpinBoxPrivate * d;
00102 };
00103 
00104 } // namespace Gui
00105 
00106 #endif // GUI_SPINBOX_H

Generated on Wed Nov 23 19:00:40 2011 for FreeCAD by  doxygen 1.6.1