UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
QfNumericField.H
1 /* QfNumericField.H */
2 /* $Id: QfNumericField.H,v 1.6 2003/11/21 14:41:11 vlad Exp $ */
3 #ifndef __QfNumericField_H
4 #define __QfNumericField_H
5 
6 #include <float.h>
7 #include <limits.h>
8 
9 #include <zm/qvfcdefs.h>
10 #include <zm/QfTextField.H>
11 
12 
13 /***********************************************************************
14  * Numeric field object. Provides way to enter or edit number.
15  */
17 {
18 protected:
19 
20  char szTextBuf[QfNUMERIC_FIELD_LENGTH+1];
21  AtomType eType; /* Type of pointer. */
22  int nfOptions; /* ORed options passed to constructor */
23  Widget wScaler; /* XmScale widget if QfNFM_SCALER is set */
24  union NumberValue {
25 #define VAR_VERIFY(T,I) \
26  struct {\
27  T *p; /* Pointer to variable. */\
28  T min, max; /* Allowed range. */\
29  } I
30 /* end def */
31 
32  VAR_VERIFY(Int1, int_1);
33  VAR_VERIFY(Int2, int_2);
34  VAR_VERIFY(Int4, int_4);
35  VAR_VERIFY(Real4, real_4);
36  VAR_VERIFY(Real8, real_8);
37 #undef VAR_VERIFY
38  } t;
39 
40  /* Textfield verification callback. */
41  static void verify_text_cb (Widget w, XtPointer pUserData,
42  XtPointer pCallData);
43 
44  /* Scaler tracking callback. */
45  static void scale_changed_cb (Widget w, XtPointer pUserData,
46  XtPointer pCallData);
47 
48  /* Put internal number content to scaler */
49  virtual void this_to_scaler (char* szBuf = NULL);
50 
51  /* Update internal number content from scaler */
52  virtual void scaler_to_this ();
53 
54  /* Add callbacks and scaler. */
55  virtual void create_self (Widget wParent);
56 
57  /* Called to parse user input to get number. Returns 0 if OK and !0
58  if user input is not a valid number. */
59  virtual int parse_input (char* szInput,
60  Int4* pIntNumber,
61  Real8* pRealNumber);
62 
63  /* Called when szInput contains already proposed number, entered
64  by user. Function calls *_fault() methods on demand.
65  Returns 0 is OK, 1 for conversion error, 2 for range error. */
66  virtual int check_input (char* szInput);
67 
68  /* Called when numeric value is out of allowed range. */
69  virtual void numeric_range_fault ();
70 
71  /* Called when text can't be successfully converted to number. */
72  virtual void convert_to_number_fault (char* szInput);
73 
74 public:
75 
76  /* In/out buffer: pNumVar; verifier is set by vMin and vMax. */
77  QfNumericField (const char* szLabel, Int1* pNumVar,
78  Int1 vMin = SCHAR_MIN, Int1 vMax = SCHAR_MAX,
79  int mNFOptions = 0);
80  QfNumericField (const char* szLabel, Int2* pNumVar,
81  Int2 vMin = SHRT_MIN, Int2 vMax = SHRT_MAX,
82  int mNFOptions = 0);
83  QfNumericField (const char* szLabel, Int4* pNumVar,
84  Int4 vMin = INT_MIN, Int4 vMax = INT_MAX,
85  int mNFOptions = 0);
86  QfNumericField (const char* szLabel, Real4* pNumVar,
87  Real4 vMin = -FLT_MAX, Real4 vMax = FLT_MAX,
88  int mNFOptions = 0);
89  QfNumericField (const char* szLabel, Real8* pNumVar,
90  Real8 vMin = -DBL_MAX, Real8 vMax = DBL_MAX,
91  int mNFOptions = 0);
92 
93  /*
94  * Adjustable features.
95  */
96 
97  virtual void store_gui ();
98  virtual void load_gui ();
99 
100 };
101 
102 
103 #endif /* QfNumericField.H */
virtual void load_gui()
Definition: QfTextField.H:14
Definition: QfNumericField.H:16
virtual void store_gui()
Definition: QfNumericField.H:24
virtual void create_self(Widget wParent)