knumvalidator.h
00001 /********************************************************************** 00002 ** 00003 ** $Id$ 00004 ** 00005 ** Copyright (C) 1999 Glen Parker <glenebob@nwlink.com> 00006 ** Copyright (C) 2002 Marc Mutz <mutz@kde.org> 00007 ** 00008 ** This library is free software; you can redistribute it and/or 00009 ** modify it under the terms of the GNU Library General Public 00010 ** License as published by the Free Software Foundation; either 00011 ** version 2 of the License, or (at your option) any later version. 00012 ** 00013 ** This library is distributed in the hope that it will be useful, 00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 ** Library General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU Library General Public 00019 ** License along with this library; if not, write to the Free 00020 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 ** 00022 *****************************************************************************/ 00023 00024 #ifndef __KNUMVALIDATOR_H 00025 #define __KNUMVALIDATOR_H 00026 00027 #include <tqvalidator.h> 00028 00029 #include <kdelibs_export.h> 00030 00031 class TQWidget; 00032 class TQString; 00033 00044 class KDEUI_EXPORT KIntValidator : public TQValidator { 00045 00046 public: 00050 KIntValidator ( TQWidget * parent, int base = 10, const char * name = 0 ); 00054 KIntValidator ( int bottom, int top, TQWidget * parent, int base = 10, const char * name = 0 ); 00058 virtual ~KIntValidator (); 00062 virtual State validate ( TQString &, int & ) const; 00066 virtual void fixup ( TQString & ) const; 00070 virtual void setRange ( int bottom, int top ); 00074 virtual void setBase ( int base ); 00078 virtual int bottom () const; 00082 virtual int top () const; 00086 virtual int base () const; 00087 00088 private: 00089 int _base; 00090 int _min; 00091 int _max; 00092 00093 }; 00094 00095 class KFloatValidatorPrivate; 00096 00109 class KDEUI_EXPORT KFloatValidator : public TQValidator { 00110 00111 public: 00115 KFloatValidator ( TQWidget * parent, const char * name = 0 ); 00119 KFloatValidator ( double bottom, double top, TQWidget * parent, const char * name = 0 ); 00123 KFloatValidator ( double bottom, double top, bool localeAware, TQWidget * parent, const char * name = 0 ); 00127 virtual ~KFloatValidator (); 00131 virtual State validate ( TQString &, int & ) const; 00135 virtual void fixup ( TQString & ) const; 00139 virtual void setRange ( double bottom, double top ); 00143 virtual double bottom () const; 00147 virtual double top () const; 00153 void setAcceptLocalizedNumbers(bool b); 00158 bool acceptLocalizedNumbers() const; 00159 00160 private: 00161 double _min; 00162 double _max; 00163 00164 KFloatValidatorPrivate *d; 00165 }; 00166 00181 class KDEUI_EXPORT KDoubleValidator : public TQDoubleValidator { 00182 Q_OBJECT 00183 Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers ) 00184 public: 00188 KDoubleValidator( TQObject * parent, const char * name=0 ); 00192 KDoubleValidator( double bottom, double top, int decimals, 00193 TQObject * parent, const char * name=0 ); 00196 virtual ~KDoubleValidator(); 00197 00199 virtual TQValidator::State validate( TQString & input, int & pos ) const; 00200 00202 bool acceptLocalizedNumbers() const; 00204 void setAcceptLocalizedNumbers( bool accept ); 00205 00206 private: 00207 typedef TQDoubleValidator base; 00208 class Private; 00209 Private * d; 00210 }; 00211 00212 #endif