5 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
8 <I>------------------------------------------------------------------------------</I>
10 <I>-- <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding --</I>
12 <I>-- Terminal_Interface.Curses.Forms.Field_Types --</I>
16 <I>------------------------------------------------------------------------------</I>
17 <I>-- Copyright (c) 1998 Free Software Foundation, Inc. --</I>
19 <I>-- Permission is hereby granted, free of charge, to any person obtaining a --</I>
20 <I>-- copy of this software and associated documentation files (the --</I>
21 <I>-- "Software"), to deal in the Software without restriction, including --</I>
22 <I>-- without limitation the rights to use, copy, modify, merge, publish, --</I>
23 <I>-- distribute, distribute with modifications, sublicense, and/or sell --</I>
24 <I>-- copies of the Software, and to permit persons to whom the Software is --</I>
25 <I>-- furnished to do so, subject to the following conditions: --</I>
27 <I>-- The above copyright notice and this permission notice shall be included --</I>
28 <I>-- in all copies or substantial portions of the Software. --</I>
30 <I>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --</I>
31 <I>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --</I>
32 <I>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --</I>
33 <I>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --</I>
34 <I>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --</I>
35 <I>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --</I>
36 <I>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --</I>
38 <I>-- Except as contained in this notice, the name(s) of the above copyright --</I>
39 <I>-- holders shall not be used in advertising or otherwise to promote the --</I>
40 <I>-- sale, use or other dealings in this Software without prior written --</I>
41 <I>-- authorization. --</I>
42 <I>------------------------------------------------------------------------------</I>
43 <I>-- <A HREF="http://home.t-online.de/home/Juergen.Pfeifer">Jürgen Pfeifer</A>, Email: <A HREF="mailto:Juergen.Pfeifer@T-Online.de">Juergen.Pfeifer@T-Online.de</A> --</I>
44 <I>-- Version Control:</I>
45 <I>-- @Revision: 1.1 @</I>
46 <I>------------------------------------------------------------------------------</I>
47 <B>with</B> Terminal_Interface.Curses.<A HREF="terminal_interface-curses-aux_s.html#32:35">Aux</A>;
49 <B>package</B> Terminal_Interface.Curses.Forms.Field_Types <B>is</B>
51 <I>-- |=====================================================================</I>
52 <I>-- | Man page <A HREF="form_fieldtype.3x.html">form_fieldtype.3x</A></I>
53 <I>-- |=====================================================================</I>
55 type Field_Type <B>is</B> <B>abstract</B> <B>tagged</B> <B>null</B> <B>record</B>;
56 <I>-- Abstract base type for all field types. A concrete field type</I>
57 <I>-- is an extension that adds some data elements describing formats or</I>
58 <I>-- boundary values for the type and validation routines.</I>
59 <I>-- For the builtin low-level fieldtypes, the validation routines are</I>
60 <I>-- already defined by the low-level C library.</I>
61 <I>-- The builtin types like Alpha or AlphaNumeric etc. are defined in</I>
62 <I>-- child packages of this package. You may use one of them as example</I>
63 <I>-- how to create you own child packages for low-level field types that</I>
64 <I>-- you may have already written in C.</I>
66 type Field_Type_Access <B>is</B> <B>access</B> <B>all</B> Field_Type'Class;
68 <I>-- <A NAME="AFU_1">|</I>
69 <B>procedure</B> Set_Field_Type (Fld : <B>in</B> Field;
70 Fld_Type : <B>in</B> Field_Type) <B>is</B> <B>abstract</B>;
71 <I>-- AKA: <A HREF="form_fieldtype.3x.html">set_field_type()</A></I>
72 <I>-- But: we hide the vararg mechanism of the C interface. You always</I>
73 <I>-- have to pass a single Field_Type parameter.</I>
75 <I>-- ---------------------------------------------------------------------</I>
77 <I>-- |=====================================================================</I>
78 <I>-- | Man page <A HREF="form_field_validation.3x.html">form_field_validation.3x</A></I>
79 <I>-- |=====================================================================</I>
81 <I>-- <A NAME="AFU_2">|</I>
82 <B>function</B> Get_Type (Fld : <B>in</B> Field) <B>return</B> Field_Type_Access;
83 <I>-- AKA: <A HREF="form_field_validation.3x.html">field_type()</A></I>
84 <I>-- AKA: field_arg()</I>
85 <I>-- In Ada95 we can combine these. If you try to retrieve the field type</I>
86 <I>-- that is not defined as extension of the abstract tagged type above,</I>
87 <I>-- you will raise a Form_Exception.</I>
89 <I>-- +----------------------------------------------------------------------</I>
90 <I>-- | Private Part.</I>
91 <I>-- | Most of this is used by the implementations of the child packages.</I>
94 <B>use</B> Terminal_Interface.Curses.<A HREF="terminal_interface-curses-aux_s.html#32:35">Aux</A>;
96 type Makearg_Function <B>is</B> <B>access</B>
97 <B>function</B> (Args : System.Address) <B>return</B> System.Address;
98 <B>pragma</B> Convention (C, Makearg_Function);
100 type Copyarg_Function <B>is</B> <B>access</B>
101 <B>function</B> (Usr : System.Address) <B>return</B> System.Address;
102 <B>pragma</B> Convention (C, Copyarg_Function);
104 type Freearg_Function <B>is</B> <B>access</B>
105 <B>procedure</B> (Usr : System.Address);
106 <B>pragma</B> Convention (C, Freearg_Function);
108 type Field_Check_Function <B>is</B> <B>access</B>
109 <B>function</B> (Fld : Field; Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
110 <B>pragma</B> Convention (C, Field_Check_Function);
112 type Char_Check_Function <B>is</B> <B>access</B>
113 <B>function</B> (Ch : <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>; Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
114 <B>pragma</B> Convention (C, Char_Check_Function);
116 type Choice_Function <B>is</B> <B>access</B>
117 <B>function</B> (Fld : Field; Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
118 <B>pragma</B> Convention (C, Choice_Function);
120 <I>-- +----------------------------------------------------------------------</I>
121 <I>-- | This must be in sync with the FIELDTYPE structure in form.h</I>
123 type Low_Level_Field_Type <B>is</B>
125 Status : <A HREF="terminal_interface-curses-aux_s.html#37:12">C_Short</A>;
126 Ref_Count : <A HREF="terminal_interface-curses-aux_s.html#38:12">C_Long_Int</A>;
127 Left, Right : System.Address;
128 Makearg : Makearg_Function;
129 Copyarg : Copyarg_Function;
130 Freearg : Freearg_Function;
131 Fcheck : Field_Check_Function;
132 Ccheck : Char_Check_Function;
133 Next, Prev : Choice_Function;
134 <B>end</B> <B>record</B>;
135 <B>pragma</B> Convention (C, Low_Level_Field_Type);
136 type C_Field_Type <B>is</B> <B>access</B> <B>all</B> Low_Level_Field_Type;
138 Null_Field_Type : <B>constant</B> C_Field_Type := <B>null</B>;
140 <I>-- +----------------------------------------------------------------------</I>
141 <I>-- | This four low-level fieldtypes are the ones associated with</I>
142 <I>-- | fieldtypes handled by this binding. Any other low-level fieldtype</I>
143 <I>-- | will result in a Form_Exception is function Get_Type.</I>
145 C_Generic_Type : C_Field_Type := Null_Field_Type;
146 C_Generic_Choice : C_Field_Type := Null_Field_Type;
147 C_Builtin_Router : C_Field_Type := Null_Field_Type;
148 C_Choice_Router : C_Field_Type := Null_Field_Type;
150 <B>procedure</B> Wrap_Builtin (Fld : Field;
151 Typ : Field_Type'Class;
152 Cft : C_Field_Type := C_Builtin_Router);
153 <I>-- This procedure has to be called by the Set_Field_Type implementation</I>
154 <I>-- for builtin low-level fieldtypes to replace it by an Ada95</I>
155 <I>-- conformant Field_Type object.</I>
156 <I>-- The parameter Cft must be C_Builtin_Router for regular low-level</I>
157 <I>-- fieldtypes (like TYP_ALPHA or TYP_ALNUM) and C_Choice_Router for</I>
158 <I>-- low-level fieldtypes witch choice functions (like TYP_ENUM).</I>
159 <I>-- Any other value will raise a Form_Exception.</I>
161 <B>function</B> Make_Arg (Args : System.Address) <B>return</B> System.Address;
162 <B>pragma</B> Convention (C, Make_Arg);
163 <I>-- This is the Makearg_Function for the internal low-level types</I>
164 <I>-- introduced by this binding.</I>
166 <B>function</B> Copy_Arg (Usr : System.Address) <B>return</B> System.Address;
167 <B>pragma</B> Convention (C, Copy_Arg);
168 <I>-- This is the Copyarg_Function for the internal low-level types</I>
169 <I>-- introduced by this binding.</I>
171 <B>procedure</B> Free_Arg (Usr : System.Address);
172 <B>pragma</B> Convention (C, Free_Arg);
173 <I>-- This is the Freearg_Function for the internal low-level types</I>
174 <I>-- introduced by this binding.</I>
176 <B>function</B> Field_Check_Router (Fld : Field;
177 Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
178 <B>pragma</B> Convention (C, Field_Check_Router);
179 <I>-- This is the Field_Check_Function for the internal low-level types</I>
180 <I>-- introduced to wrap the low-level types by a Field_Type derived</I>
181 <I>-- type. It routes the call to the corresponding low-level validation</I>
184 <B>function</B> Char_Check_Router (Ch : <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
185 Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
186 <B>pragma</B> Convention (C, Char_Check_Router);
187 <I>-- This is the Char_Check_Function for the internal low-level types</I>
188 <I>-- introduced to wrap the low-level types by a Field_Type derived</I>
189 <I>-- type. It routes the call to the corresponding low-level validation</I>
192 <B>function</B> Next_Router (Fld : Field;
193 Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
194 <B>pragma</B> Convention (C, Next_Router);
195 <I>-- This is the Choice_Function for the internal low-level types</I>
196 <I>-- introduced to wrap the low-level types by a Field_Type derived</I>
197 <I>-- type. It routes the call to the corresponding low-level next_choice</I>
200 <B>function</B> Prev_Router (Fld : Field;
201 Usr : System.Address) <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
202 <B>pragma</B> Convention (C, Prev_Router);
203 <I>-- This is the Choice_Function for the internal low-level types</I>
204 <I>-- introduced to wrap the low-level types by a Field_Type derived</I>
205 <I>-- type. It routes the call to the corresponding low-level prev_choice</I>
208 <I>-- This is the Argument structure maintained by all low-level field types</I>
209 <I>-- introduced by this binding.</I>
210 type Argument <B>is</B> <B>record</B>
211 Typ : Field_Type_Access; <I>-- the Field_Type creating this record</I>
212 Usr : System.Address; <I>-- original arg for builtin low-level types</I>
213 Cft : C_Field_Type; <I>-- the original low-level type</I>
214 <B>end</B> <B>record</B>;
215 type Argument_Access <B>is</B> <B>access</B> <B>all</B> Argument;
217 <I>-- +----------------------------------------------------------------------</I>
219 <I>-- | Some Imports of libform routines to deal with low-level fieldtypes.</I>
221 <B>function</B> New_Fieldtype (Fcheck : Field_Check_Function;
222 Ccheck : Char_Check_Function)
223 <B>return</B> C_Field_Type;
224 <B>pragma</B> Import (C, New_Fieldtype, "new_fieldtype");
226 <B>function</B> Set_Fieldtype_Arg (Cft : C_Field_Type;
227 Mak : Makearg_Function := Make_Arg'<B>Access</B>;
228 Cop : Copyarg_Function := Copy_Arg'<B>Access</B>;
229 Fre : Freearg_Function := Free_Arg'<B>Access</B>)
230 <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
231 <B>pragma</B> Import (C, Set_Fieldtype_Arg, "set_fieldtype_arg");
233 <B>function</B> Set_Fieldtype_Choice (Cft : C_Field_Type;
234 Next, Prev : Choice_Function)
235 <B>return</B> <A HREF="terminal_interface-curses-aux_s.html#36:12">C_Int</A>;
236 <B>pragma</B> Import (C, Set_Fieldtype_Choice, "set_fieldtype_choice");
238 <B>end</B> Terminal_Interface.Curses.Forms.Field_Types;
244 This is BETA software. The interface is subject to change without notice.<P>
245 <!-- Do NOT delete my name or the tool name from below; -->
246 <!-- giving me credit is a condition of use of ada2html -->
247 <P><I>This hypertext format was generated by <A HREF="http://www.adahome.com/Tutorials/Lovelace/dwheeler.htm">David A. Wheeler</A>'s <A HREF="http://www.adahome.com/Resources/Tools/ada2html/ada2html.htm">ada2html</A></I>