OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Validator.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGUI_VALIDATOR
15 #define OSGUI_VALIDATOR
16 
17 #include <osg/Object>
18 #include <osgUI/Export>
19 
20 namespace osgUI
21 {
22 
24 {
25 public:
26  Validator();
27  Validator(const Validator& validator, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
29 
30  enum State
31  {
34  ACCEPTABLE
35  };
36 
41  virtual State validate(std::string& /*str*/, int& cursorpos) const;
42 
44  virtual State validateImplementation(std::string& /*str*/, int& /*cursorpos*/) const;
45 
49  virtual void fixup(std::string& /*str*/) const;
50 
52  virtual void fixupImplementation(std::string& /*str*/) const;
53 
54 protected:
55  virtual ~Validator() {}
56 };
57 
59 {
60 public:
61  IntValidator();
62  IntValidator(const IntValidator& widget, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
64 
66  void setBottom(int bottom) { _bottom = bottom; }
67  int getBottom() const { return _bottom; }
68 
70  void setTop(int top) { _top = top; }
71  int getTop() const { return _top; }
72 
74  virtual State validateImplementation(std::string& str, int& cursorpos) const;
76  virtual void fixupImplementation(std::string& str) const;
77 
78 protected:
79  virtual ~IntValidator() {}
80  int _bottom;
81  int _top;
82 };
83 
85 {
86 public:
90 
93  void setDecimals(int numDecimals) { _decimals = numDecimals; }
94  int getDecimals() const { return _decimals; }
95 
97  void setBottom(double bottom) { _bottom = bottom; }
98  double getBottom() const { return _bottom; }
99 
101  void setTop(double top) { _top = top; }
102  double getTop() const { return _top; }
103 
105  virtual State validateImplementation(std::string& str, int& cursorpos) const;
107  virtual void fixupImplementation(std::string& str) const;
108 
109 protected:
110  virtual ~DoubleValidator() {}
112  double _bottom;
113  double _top;
114 };
115 
116 }
117 
118 #endif
int getDecimals() const
Definition: Validator.h:94
double getTop() const
Definition: Validator.h:102
int getTop() const
Definition: Validator.h:71
void setDecimals(int numDecimals)
Definition: Validator.h:93
virtual ~DoubleValidator()
Definition: Validator.h:110
void setTop(int top)
set the top value that is accepted as valid, default INT_MAX
Definition: Validator.h:70
void setTop(double top)
set the top value that is accepted as valid, default DBL_MAX
Definition: Validator.h:101
#define META_Object(library, name)
Definition: Object.h:42
int getBottom() const
Definition: Validator.h:67
virtual ~Validator()
Definition: Validator.h:55
void setBottom(double bottom)
set the bottom value that is accepted as valid, default -DBL_MAX
Definition: Validator.h:97
virtual ~IntValidator()
Definition: Validator.h:79
void setBottom(int bottom)
set the bottom value that is accepted as valid, default -INT_MAX
Definition: Validator.h:66
double getBottom() const
Definition: Validator.h:98
#define OSGUI_EXPORT
Definition: Widget.h:22