]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/html/ada/terminal_interface-curses-forms-field_types__ads.htm
9e086cac031d4681529af80fa19b21b375818618
[ncurses.git] / Ada95 / html / ada / terminal_interface-curses-forms-field_types__ads.htm
1 <HEAD><TITLE>terminal_interface-curses-forms-field_types.ads</TITLE></HEAD>
2 <BODY>
3 <HR><DIV ALIGN="center"><H1> File : terminal_interface-curses-forms-field_types.ads </H1></DIV><HR>
4 <PRE>
5
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>--  <A HREF="http://home.t-online.de/home/Juergen.Pfeifer">J&uuml;rgen Pfeifer</A> (<A HREF="mailto:juergen.pfeifer@gmx.net">juergen.pfeifer@gmx.net</A>) 1996                          --</EM></FONT>
42 <FONT COLOR=green><EM>--  Version Control:</EM></FONT>
43 <FONT COLOR=green><EM>--  @Revision: 1.11 @</EM></FONT>
44 <FONT COLOR=green><EM>--  Binding Version 00.93</EM></FONT>
45 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
46 <b>with</b> Interfaces.C;
47
48 <b>package</b> Terminal_Interface.Curses.Forms.Field_Types <b>is</b>
49    <b>pragma</b> Preelaborate <A HREF="i-c__ads.htm>0_20">(</A>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;
52
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>
56
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>
67
68    <b>type</b> Field_Type_Access <b>is</b> <b>access</b> <b>all</b> Field_Type'Class;
69
70   <FONT COLOR=green><EM>--  <A NAME="AFU_1">|</EM></FONT>
71    <b>procedure</b> Set_Field_Type (Fld      : <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>
76
77   <FONT COLOR=green><EM>--  ---------------------------------------------------------------------</EM></FONT>
78
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>
82
83   <FONT COLOR=green><EM>--  <A NAME="AFU_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>
91
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>
96 <b>private</b>
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);
100
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);
104
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);
108
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);
112
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<08_9">;</A> Usr : System.Address) <b>return</b> C_Int;
115    <b>pragma</b> Convention (C, Char_Check_Function);
116
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);
120
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>
125       <b>record</b>
126          Status :              <A HREF="interfac__ads.htm>3_9">Interfaces</A>.<A HREF="i-c__ads.htm>0_20">C</A>.<A HREF="i-c__ads.htm#37_9">short</A>;
127          <FONT COLOR=red><A NAME="123_10">Ref_Count</A></FONT> :           <A HREF="system__ads.htm>3_9">Interfaces</A>.C.long;
128          Left, Right :         <A HREF="terminal_interface-curses-forms-field_types__ads.htm#92_9">System</A>.Address;
129          Makearg :             <A HREF="terminal_interface-curses-forms-field_types__ads.htm#96_9">Makearg_Function</A>;
130          Copyarg :             <A HREF="terminal_interface-curses-forms-field_types__ads.htm<00_9">Copyarg_Function</A>;
131          Freearg :             <A HREF="terminal_interface-curses-forms-field_types__ads.htm<04_9">Freearg_Function</A>;
132          Fcheck :              <A HREF="terminal_interface-curses-forms-field_types__ads.htm<08_9">Field_Check_Function</A>;
133          Ccheck :              <A HREF="terminal_interface-curses-forms-field_types__ads.htm<12_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;
138
139    Null_Field_Type   : <b>constant</b> C_Field_Type := <b>null</b>;
140
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    M_Generic_Type   : C_Field_Type := <b>null</b>;
147    M_Generic_Choice : C_Field_Type := <b>null</b>;
148    M_Builtin_Router : C_Field_Type := <b>null</b>;
149    M_Choice_Router  : C_Field_Type := <b>null</b>;
150
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> <A HREF="terminal_interface-curses-forms-field_types__adb.htm>64_13">C_Builtin_Router</A><FONT COLOR=red><A NAME="149_13"></A></FONT> <b>return</b> C_Field_Type;
154    <b>function</b> C_Choice_Router  <b>return</b> C_Field_Type;
155
156    <b>procedure</b> Wrap_Builtin (Fld : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#52_9">Field</A>;
157                            Typ : Field_Type'Class<A HREF="terminal_interface-curses-forms-field_types__ads.htm<48_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>
166
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>
171
172    <b>function</b> Copy_Arg (Usr<A HREF="terminal_interface-curses-forms-field_types__ads.htm<67_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>
176
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>
181
182    <b>function</b> Field_Check_Router (<FONT COLOR=red><A NAME="178_33">Fld</A></FONT> : <A HREF="system__ads.htm>3_9">Field</A>;
183                          <A HREF="terminal_interface-curses-forms-field_types__ads.htm<77_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>
189
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<85_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>
197
198    <b>function</b> Next_Router (<FONT COLOR=red><A NAME="194_26">Fld</A></FONT> : <A HREF="system__ads.htm>3_9">Field</A>;
199                          <A HREF="terminal_interface-curses-forms-field_types__ads.htm<93_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>
205
206    <b>function</b> Prev_Router (<FONT COLOR=red><A NAME="202_26">Fld</A></FONT> : <A HREF="system__ads.htm>3_9">Field</A>;
207                          <A HREF="terminal_interface-curses-forms-field_types__ads.htm>01_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>
213
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> : <A HREF="system__ads.htm>3_9">Field_Type_Access</A>;  <FONT COLOR=green><EM>--  the Field_Type creating this record</EM></FONT>
218       Usr : System.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;
222
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 (Fcheck : <A HREF="terminal_interface-curses-forms-field_types__ads.htm<08_9">Field_Check_Function</A>;
228                            Ccheck : Char_Check_Function)
229      <b>return</b> C_Field_Type;
230    <b>pragma</b> Import (C, New_Fieldtype, "new_fieldtype");
231
232    <b>function</b> Set_Fieldtype_Arg (Cft : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#92_9">C_Field_Type</A>;
233                                Mak : <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<67_13">Make_Arg</A>'<b>Access</b>;
234                                Cop : <A HREF="terminal_interface-curses-forms-field_types__ads.htm<00_9">Copyarg_Function</A> := <A HREF="terminal_interface-curses-forms-field_types__ads.htm<72_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>)
236      <b>return</b> C_Int;
237    <b>pragma</b> Import (C, Set_Fieldtype_Arg, "set_fieldtype_arg");
238
239    <b>function</b> Set_Fieldtype_Choice (Cft : C_Field_Type;
240             <A HREF="terminal_interface-curses-forms-field_types__ads.htm#46_12"> </A>                     Next, Prev : Choice_Function)
241      <b>return</b> C_Int;
242    <b>pragma</b> Import (C, Set_Fieldtype_Choice, "set_fieldtype_choice");
243
244 <b>end</b> Terminal_Interface.Curses.Forms.Field_Types;
245 </PRE></BODY></HTML>