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