1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML><HEAD><TITLE>terminal_interface-curses-forms-field_types.ads</TITLE></HEAD>
4 <HR><DIV ALIGN="center"><H1> File : terminal_interface-curses-forms-field_types.ads </H1></DIV><HR>
7 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
8 <FONT COLOR=green><EM>-- --</EM></FONT>
9 <FONT COLOR=green><EM>-- <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding --</EM></FONT>
10 <FONT COLOR=green><EM>-- --</EM></FONT>
11 <FONT COLOR=green><EM>-- Terminal_Interface.Curses.Forms.Field_Types --</EM></FONT>
12 <FONT COLOR=green><EM>-- --</EM></FONT>
13 <FONT COLOR=green><EM>-- S P E C --</EM></FONT>
14 <FONT COLOR=green><EM>-- --</EM></FONT>
15 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
16 <FONT COLOR=green><EM>-- Copyright (c) 1998 Free Software Foundation, Inc. --</EM></FONT>
17 <FONT COLOR=green><EM>-- --</EM></FONT>
18 <FONT COLOR=green><EM>-- Permission is hereby granted, free of charge, to any person obtaining a --</EM></FONT>
19 <FONT COLOR=green><EM>-- copy of this software and associated documentation files (the --</EM></FONT>
20 <FONT COLOR=green><EM>-- "Software"), to deal in the Software without restriction, including --</EM></FONT>
21 <FONT COLOR=green><EM>-- without limitation the rights to use, copy, modify, merge, publish, --</EM></FONT>
22 <FONT COLOR=green><EM>-- distribute, distribute with modifications, sublicense, and/or sell --</EM></FONT>
23 <FONT COLOR=green><EM>-- copies of the Software, and to permit persons to whom the Software is --</EM></FONT>
24 <FONT COLOR=green><EM>-- furnished to do so, subject to the following conditions: --</EM></FONT>
25 <FONT COLOR=green><EM>-- --</EM></FONT>
26 <FONT COLOR=green><EM>-- The above copyright notice and this permission notice shall be included --</EM></FONT>
27 <FONT COLOR=green><EM>-- in all copies or substantial portions of the Software. --</EM></FONT>
28 <FONT COLOR=green><EM>-- --</EM></FONT>
29 <FONT COLOR=green><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --</EM></FONT>
30 <FONT COLOR=green><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --</EM></FONT>
31 <FONT COLOR=green><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --</EM></FONT>
32 <FONT COLOR=green><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --</EM></FONT>
33 <FONT COLOR=green><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --</EM></FONT>
34 <FONT COLOR=green><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --</EM></FONT>
35 <FONT COLOR=green><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --</EM></FONT>
36 <FONT COLOR=green><EM>-- --</EM></FONT>
37 <FONT COLOR=green><EM>-- Except as contained in this notice, the name(s) of the above copyright --</EM></FONT>
38 <FONT COLOR=green><EM>-- holders shall not be used in advertising or otherwise to promote the --</EM></FONT>
39 <FONT COLOR=green><EM>-- sale, use or other dealings in this Software without prior written --</EM></FONT>
40 <FONT COLOR=green><EM>-- authorization. --</EM></FONT>
41 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
42 <FONT COLOR=green><EM>-- Author: Juergen Pfeifer, 1996</EM></FONT>
43 <FONT COLOR=green><EM>-- Version Control:</EM></FONT>
44 <FONT COLOR=green><EM>-- @Revision: 1.14 @</EM></FONT>
45 <FONT COLOR=green><EM>-- Binding Version 01.00</EM></FONT>
46 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
47 <b>with</b> Interfaces.C;
49 <b>package</b> Terminal_Interface.Curses.Forms.Field_Types <b>is</b>
50 <b>pragma</b> Preelaborate (Terminal_Interface.Curses.Forms.Field_Types);
51 <b>use</b> <b>type</b><FONT COLOR=red><A NAME="ref_46_12"> </A></FONT>Interfaces.C.int;
52 <b>subtype</b> C_Int <b>is</b> Interfaces.C.int;
54 <FONT COLOR=green><EM>-- |=====================================================================</EM></FONT>
55 <FONT COLOR=green><EM>-- | Man page <A HREF="../man/form_fieldtype.3x.html">form_fieldtype.3x</A></EM></FONT>
56 <FONT COLOR=green><EM>-- |=====================================================================</EM></FONT>
58 <b>type</b> Field_Type <b>is</b> <b>abstract</b> <b>tagged</b> <b>null</b> <b>record</b>;
59 <FONT COLOR=green><EM>-- Abstract base type for all field types. A concrete field type</EM></FONT>
60 <FONT COLOR=green><EM>-- is an extension that adds some data elements describing formats or</EM></FONT>
61 <FONT COLOR=green><EM>-- boundary values for the type and validation routines.</EM></FONT>
62 <FONT COLOR=green><EM>-- For the builtin low-level fieldtypes, the validation routines are</EM></FONT>
63 <FONT COLOR=green><EM>-- already defined by the low-level C library.</EM></FONT>
64 <FONT COLOR=green><EM>-- The builtin types like Alpha or AlphaNumeric etc. are defined in</EM></FONT>
65 <FONT COLOR=green><EM>-- child packages of this package. You may use one of them as example</EM></FONT>
66 <FONT COLOR=green><EM>-- how to create you own child packages for low-level field types that</EM></FONT>
67 <FONT COLOR=green><EM>-- you may have already written in C.</EM></FONT>
69 <b>type</b> Field_Type_Access <b>is</b> <b>access</b> <b>all</b> Field_Type'Class;
71 <FONT COLOR=green><EM>-- #1A NAME="AFU_1"#2|</EM></FONT>
72 <b>procedure</b> Set_Field_Type (<FONT COLOR=red><A NAME="ref_67_30">Fld</A></FONT> : <b>in</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_52_9">Field</A>;
73 Fld_Type : <b>in</b> Field_Type) <b>is</b> <b>abstract</b>;
74 <FONT COLOR=green><EM>-- AKA: <A HREF="../man/form_fieldtype.3x.html">set_field_type()</A></EM></FONT>
75 <FONT COLOR=green><EM>-- But: we hide the vararg mechanism of the C interface. You always</EM></FONT>
76 <FONT COLOR=green><EM>-- have to pass a single Field_Type parameter.</EM></FONT>
78 <FONT COLOR=green><EM>-- ---------------------------------------------------------------------</EM></FONT>
80 <FONT COLOR=green><EM>-- |=====================================================================</EM></FONT>
81 <FONT COLOR=green><EM>-- | Man page <A HREF="../man/form_field_validation.3x.html">form_field_validation.3x</A></EM></FONT>
82 <FONT COLOR=green><EM>-- |=====================================================================</EM></FONT>
84 <FONT COLOR=green><EM>-- #1A NAME="AFU_2"#2|</EM></FONT>
85 <b>function</b> Get_Type (Fld : <b>in</b> Field) <b>return</b> Field_Type_Access;
86 <FONT COLOR=green><EM>-- AKA: <A HREF="../man/form_field_validation.3x.html">field_type()</A></EM></FONT>
87 <FONT COLOR=green><EM>-- AKA: field_arg()</EM></FONT>
88 <FONT COLOR=green><EM>-- In Ada95 we can combine these. If you try to retrieve the field type</EM></FONT>
89 <FONT COLOR=green><EM>-- that is not defined as extension of the abstract tagged type above,</EM></FONT>
90 <FONT COLOR=green><EM>-- you will raise a Form_Exception.</EM></FONT>
91 <FONT COLOR=green><EM>-- This is not inlined</EM></FONT>
93 <FONT COLOR=green><EM>-- +----------------------------------------------------------------------</EM></FONT>
94 <FONT COLOR=green><EM>-- | Private Part.</EM></FONT>
95 <FONT COLOR=green><EM>-- | Most of this is used by the implementations of the child packages.</EM></FONT>
96 <FONT COLOR=green><EM>-- |</EM></FONT>
98 <b>type</b> Makearg_Function <b>is</b> <b>access</b>
99 <b>function</b> (Args : System.Address) <b>return</b> System.Address;
100 <b>pragma</b> Convention (C, Makearg_Function);
102 <b>type</b> Copyarg_Function <b>is</b> <b>access</b>
103 <b>function</b> (Usr : System.Address) <b>return</b> System.Address;
104 <b>pragma</b> Convention (C, Copyarg_Function);
106 <b>type</b> Freearg_Function <b>is</b> <b>access</b>
107 <b>procedure</b> (Usr : System.Address);
108 <b>pragma</b> Convention (C, Freearg_Function);
110 <b>type</b> Field_Check_Function<FONT COLOR=red><A NAME="ref_105_29"> </A></FONT><b>is</b> <b>access</b>
111 <b>function</b> (Fld : Field; Usr : System.Address) <b>return</b> C_Int;
112 <b>pragma</b> Convention (C, Field_Check_Function);
114 <b>type</b> Char_Check_Function<FONT COLOR=red><A NAME="ref_109_28"> </A></FONT><b>is</b> <b>access</b>
115 <b>function</b> (Ch : C_Int<A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_108_9">;</A> Usr : System.Address) <b>return</b> C_Int;
116 <b>pragma</b> Convention (C, Char_Check_Function);
118 <b>type</b> Choice_Function <b>is</b> <b>access</b>
119 <b>function</b> (Fld : Field; Usr : System.Address) <b>return</b> C_Int;
120 <b>pragma</b> Convention (C, Choice_Function);
122 <FONT COLOR=green><EM>-- +----------------------------------------------------------------------</EM></FONT>
123 <FONT COLOR=green><EM>-- | This must be in sync with the FIELDTYPE structure in form.h</EM></FONT>
124 <FONT COLOR=green><EM>-- |</EM></FONT>
125 <b>type</b> Low_Level_Field_Type <b>is</b>
127 <FONT COLOR=red><A NAME="ref_122_10">Status</A></FONT> : <A HREF="interfac__ads.htm#ref_23_9">Interfaces</A>.C.short;
128 <FONT COLOR=red><A NAME="ref_123_10">Ref_Count</A></FONT> : Interfaces.C.long;
129 <FONT COLOR=red><A NAME="ref_124_10">Left</A></FONT>, Right : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_92_9">System</A>.Address;
130 <FONT COLOR=red><A NAME="ref_125_10">Makearg</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_96_9">Makearg_Function</A>;
131 <FONT COLOR=red><A NAME="ref_126_10">Copyarg</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_100_9">Copyarg_Function</A>;
132 <FONT COLOR=red><A NAME="ref_127_10">Freearg</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_104_9">Freearg_Function</A>;
133 <FONT COLOR=red><A NAME="ref_128_10">Fcheck</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_108_9">Field_Check_Function</A>;
134 <FONT COLOR=red><A NAME="ref_129_10">Ccheck</A></FONT><FONT COLOR=red><A NAME="ref_129_16"> </A></FONT>: <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_112_9">Char_Check_Function</A>;
135 Next, Prev : Choice_Function;
136 <b>end</b> <b>record</b>;
137 <b>pragma</b> Convention (C, Low_Level_Field_Type);
138 <b>type</b> C_Field_Type <b>is</b> <b>access</b> <b>all</b> Low_Level_Field_Type;
140 Null_Field_Type : <b>constant</b> C_Field_Type := <b>null</b>;
142 <FONT COLOR=green><EM>-- +----------------------------------------------------------------------</EM></FONT>
143 <FONT COLOR=green><EM>-- | This four low-level fieldtypes are the ones associated with</EM></FONT>
144 <FONT COLOR=green><EM>-- | fieldtypes handled by this binding. Any other low-level fieldtype</EM></FONT>
145 <FONT COLOR=green><EM>-- | will result in a Form_Exception is function Get_Type.</EM></FONT>
146 <FONT COLOR=green><EM>-- |</EM></FONT>
147 <FONT COLOR=red><A NAME="ref_142_4">M_Generic_Type</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">C_Field_Type</A> := <b>null</b>;
148 <FONT COLOR=red><A NAME="ref_143_4">M_Generic_Choice</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">C_Field_Type</A> := <b>null</b>;
149 <FONT COLOR=red><A NAME="ref_144_4">M_Builtin_Router</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">C_Field_Type</A> := <b>null</b>;
150 M_Choice_Router : C_Field_Type := <b>null</b>;
152 <FONT COLOR=green><EM>-- Two wrapper functions to access those low-level fieldtypes defined</EM></FONT>
153 <FONT COLOR=green><EM>-- in this package.</EM></FONT>
154 <b>function</b> <FONT COLOR=red><A NAME="ref_149_13" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_265_13">C_Builtin_Router</A></FONT> <b>return</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">C_Field_Type</A>;
155 <b>function</b> C_Choice_Router <b>return</b> C_Field_Type;
157 <b>procedure</b> Wrap_Builtin (<FONT COLOR=red><A NAME="ref_152_28" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_145_28">Fld</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_52_9">Field</A>;
158 <FONT COLOR=red><A NAME="ref_153_28" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_146_28">Typ</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">Field_Type</A>'Class<A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_148_13">;</A>
159 Cft : C_Field_Type := C_Builtin_Router);
160 <FONT COLOR=green><EM>-- This procedure has to be called by the Set_Field_Type implementation</EM></FONT>
161 <FONT COLOR=green><EM>-- for builtin low-level fieldtypes to replace it by an Ada95</EM></FONT>
162 <FONT COLOR=green><EM>-- conformant Field_Type object.</EM></FONT>
163 <FONT COLOR=green><EM>-- The parameter Cft must be C_Builtin_Router for regular low-level</EM></FONT>
164 <FONT COLOR=green><EM>-- fieldtypes (like TYP_ALPHA or TYP_ALNUM) and C_Choice_Router for</EM></FONT>
165 <FONT COLOR=green><EM>-- low-level fieldtypes witch choice functions (like TYP_ENUM).</EM></FONT>
166 <FONT COLOR=green><EM>-- Any other value will raise a Form_Exception.</EM></FONT>
168 <b>function</b> Make_Arg (Args : System.Address) <b>return</b> System.Address;
169 <b>pragma</b> Convention (C, Make_Arg);
170 <FONT COLOR=green><EM>-- This is the Makearg_Function for the internal low-level types</EM></FONT>
171 <FONT COLOR=green><EM>-- introduced by this binding.</EM></FONT>
173 <b>function</b> Copy_Arg (Usr<A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_167_13"> </A>: System.Address) <b>return</b> System.Address;
174 <b>pragma</b> Convention (C, Copy_Arg);
175 <FONT COLOR=green><EM>-- This is the Copyarg_Function for the internal low-level types</EM></FONT>
176 <FONT COLOR=green><EM>-- introduced by this binding.</EM></FONT>
178 <b>procedure</b> Free_Arg (Usr : System.Address);
179 <b>pragma</b> Convention (C, Free_Arg);
180 <FONT COLOR=green><EM>-- This is the Freearg_Function for the internal low-level types</EM></FONT>
181 <FONT COLOR=green><EM>-- introduced by this binding.</EM></FONT>
183 <b>function</b> Field_Check_Router (<FONT COLOR=red><A NAME="ref_178_33" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_181_33">Fld</A></FONT> : Field;
184 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_177_13"> </A> Usr : System.Address) <b>return</b> C_Int;
185 <b>pragma</b> Convention (C, Field_Check_Router);
186 <FONT COLOR=green><EM>-- This is the Field_Check_Function for the internal low-level types</EM></FONT>
187 <FONT COLOR=green><EM>-- introduced to wrap the low-level types by a Field_Type derived</EM></FONT>
188 <FONT COLOR=green><EM>-- type. It routes the call to the corresponding low-level validation</EM></FONT>
189 <FONT COLOR=green><EM>-- function.</EM></FONT>
191 <b>function</b> Char_Check_Router (<FONT COLOR=red><A NAME="ref_186_32" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_195_32">Ch</A></FONT> : C_Int;
192 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_185_13"> </A> Usr : System.Address) <b>return</b> C_Int;
193 <b>pragma</b> Convention (C, Char_Check_Router);
194 <FONT COLOR=green><EM>-- This is the Char_Check_Function for the internal low-level types</EM></FONT>
195 <FONT COLOR=green><EM>-- introduced to wrap the low-level types by a Field_Type derived</EM></FONT>
196 <FONT COLOR=green><EM>-- type. It routes the call to the corresponding low-level validation</EM></FONT>
197 <FONT COLOR=green><EM>-- function.</EM></FONT>
199 <b>function</b> Next_Router (<FONT COLOR=red><A NAME="ref_194_26" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_209_26">Fld</A></FONT> : Field;
200 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_193_13">Usr</A> : System.Address) <b>return</b> C_Int;
201 <b>pragma</b> Convention (C, Next_Router);
202 <FONT COLOR=green><EM>-- This is the Choice_Function for the internal low-level types</EM></FONT>
203 <FONT COLOR=green><EM>-- introduced to wrap the low-level types by a Field_Type derived</EM></FONT>
204 <FONT COLOR=green><EM>-- type. It routes the call to the corresponding low-level next_choice</EM></FONT>
205 <FONT COLOR=green><EM>-- function.</EM></FONT>
207 <b>function</b> Prev_Router (<FONT COLOR=red><A NAME="ref_202_26" HREF="terminal_interface-curses-forms-field_types__adb.htm#ref_223_26">Fld</A></FONT> : Field;
208 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_201_13">Usr</A> : System.Address) <b>return</b> C_Int;
209 <b>pragma</b> Convention (C, Prev_Router);
210 <FONT COLOR=green><EM>-- This is the Choice_Function for the internal low-level types</EM></FONT>
211 <FONT COLOR=green><EM>-- introduced to wrap the low-level types by a Field_Type derived</EM></FONT>
212 <FONT COLOR=green><EM>-- type. It routes the call to the corresponding low-level prev_choice</EM></FONT>
213 <FONT COLOR=green><EM>-- function.</EM></FONT>
215 <FONT COLOR=green><EM>-- This is the Argument structure maintained by all low-level field types</EM></FONT>
216 <FONT COLOR=green><EM>-- introduced by this binding.</EM></FONT>
217 <b>type</b> Argument <b>is</b> <b>record</b>
218 <FONT COLOR=red><A NAME="ref_213_7">Typ</A></FONT> : Field_Type_Access; <FONT COLOR=green><EM>-- the Field_Type creating this record</EM></FONT>
219 <FONT COLOR=red><A NAME="ref_214_7">Usr</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9">System</A>.Address; <FONT COLOR=green><EM>-- original arg for builtin low-level types</EM></FONT>
220 Cft : C_Field_Type; <FONT COLOR=green><EM>-- the original low-level type</EM></FONT>
221 <b>end</b> <b>record</b>;
222 <b>type</b> Argument_Access <b>is</b> <b>access</b> <b>all</b> Argument;
224 <FONT COLOR=green><EM>-- +----------------------------------------------------------------------</EM></FONT>
225 <FONT COLOR=green><EM>-- |</EM></FONT>
226 <FONT COLOR=green><EM>-- | Some Imports of libform routines to deal with low-level fieldtypes.</EM></FONT>
227 <FONT COLOR=green><EM>-- |</EM></FONT>
228 <b>function</b> New_Fieldtype (<FONT COLOR=red><A NAME="ref_223_28">Fcheck</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_108_9">Field_Check_Function</A>;
229 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_132_9"> </A> Ccheck : Char_Check_Function)
230 <b>return</b> C_Field_Type;
231 <b>pragma</b> Import (C, New_Fieldtype, "new_fieldtype");
233 <b>function</b> Set_Fieldtype_Arg (<FONT COLOR=red><A NAME="ref_228_32">Cft</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_92_9">C_Field_Type</A>;
234 <FONT COLOR=red><A NAME="ref_229_32">Mak</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_96_9">Makearg_Function</A> := <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_167_13">Make_Arg</A>'<b>Access</b>;
235 <FONT COLOR=red><A NAME="ref_230_32">Cop</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_100_9">Copyarg_Function</A> := <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_172_14">Copy_Arg</A>'<b>Access</b>;
236 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_46_12"> </A> Fre : Freearg_Function := Free_Arg'<b>Access</b>)
238 <b>pragma</b> Import (C, Set_Fieldtype_Arg, "set_fieldtype_arg");
240 <b>function</b> Set_Fieldtype_Choice (<FONT COLOR=red><A NAME="ref_235_35">Cft</A></FONT> : <FONT COLOR=red><A NAME="ref_235_41">C_Field_Type</A></FONT>;
241 <A HREF="terminal_interface-curses-forms-field_types__ads.htm#ref_46_12"> </A> Next, Prev : Choice_Function)
243 <b>pragma</b> Import (C, Set_Fieldtype_Choice, "set_fieldtype_choice");
245 <b>end</b> Terminal_Interface.Curses.Forms.Field_Types;