- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

uvalidator.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/uvalidator.hpp 00008 begin : Tue Apr 5 2005 00009 $Id: uvalidator.hpp,v 1.1 2005/05/21 15:37:15 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UVALIDATOR_HPP 00029 #define UVALIDATOR_HPP 00030 00031 #include "uobject.hpp" 00032 00033 namespace ufo { 00034 00039 class UFO_EXPORT UValidator : public UObject { 00040 UFO_DECLARE_ABSTRACT_CLASS(UValidator) 00041 public: // Public types 00042 enum State { 00043 Invalid = 0, 00044 Intermediate, 00045 Acceptable 00046 }; 00047 public: 00048 virtual void fixup(std::string * text) const = 0; 00049 virtual State validate(std::string * text, int * pos) const = 0; 00050 }; 00051 00056 class UFO_EXPORT UIntValidator : public UValidator { 00057 UFO_DECLARE_DYNAMIC_CLASS(UIntValidator) 00058 public: 00060 UIntValidator(); 00062 UIntValidator(int min, int max); 00063 public: // Implements UValidator 00064 virtual void fixup(std::string * text) const; 00065 virtual State validate(std::string * text, int * pos) const; 00066 public: 00067 void setRange(int min, int max); 00068 int getMinimum() const; 00069 int getMaximum() const; 00070 private: 00071 int m_min; 00072 int m_max; 00073 }; 00074 00079 class UFO_EXPORT UDoubleValidator : public UValidator { 00080 UFO_DECLARE_DYNAMIC_CLASS(UDoubleValidator) 00081 public: 00083 UDoubleValidator(); 00085 UDoubleValidator(double min, double max, int decimals); 00086 public: // Implements UValidator 00087 virtual void fixup(std::string * text) const; 00088 virtual State validate(std::string * text, int * pos) const; 00089 public: 00090 void setRange(double min, double max); 00091 double getMinimum() const; 00092 double getMaximum() const; 00094 void setDecimals(int decimals); 00095 int getDecimals() const; 00096 private: 00097 double m_min; 00098 double m_max; 00099 int m_decimals; 00100 }; 00101 00102 } // namespace ufo 00103 00104 #endif // UVALIDATOR_HPP

The libUFO Project - written by Johannes Schmidt