00001 /* 00002 File: NumericField.h 00003 00004 Copyright(C) C. Kotterink, Computed Graphics 00005 */ 00006 #ifndef NUMERICFIELD_H 00007 #define NUMERICFIELD_H 00008 00009 #include<TextField.h> 00010 00011 #include<string> 00012 00029 class NumericField : public TextField 00030 { 00031 DYNAMIC_OBJECT; 00032 public: 00034 NumericField(int i = 0); 00035 00037 void setValue(double v); 00038 00040 double asDouble() { 00041 return value; 00042 } 00043 00045 float asFloat() { 00046 return (float)value; 00047 } 00048 00050 int asInt() { 00051 return (int)value; 00052 } 00053 00055 void setFormat(unsigned short f0, unsigned short f1) { 00056 format0 = f0; 00057 format1 = f1; 00058 } 00059 00060 // Inherited from TextField 00061 void checkInput(); 00062 00063 // Inherited from DynamicObject 00064 void parseSymbol(Token &t, ObjectFile &file); 00065 void writeParams(ostream &stream); 00066 00067 protected: 00068 // Inherited from DynamicObject 00069 void createSymbols(); 00070 00072 double value; 00073 00075 unsigned short format0; 00076 00078 unsigned short format1; 00079 00080 private: 00081 typedef TextField super; 00082 }; 00083 #endif