]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/html/terminal_interface-curses-forms-field_types_s.html
ncurses 4.2
[ncurses.git] / Ada95 / html / terminal_interface-curses-forms-field_types_s.html
1 <HTML>
2 <HEAD>
3 <TITLE></TITLE>
4 </HEAD>
5 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
6 <PRE>
7
8 <I>------------------------------------------------------------------------------</I>
9 <I>--                                                                          --</I>
10 <I>--                           <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding                           --</I>
11 <I>--                                                                          --</I>
12 <I>--                 Terminal_Interface.Curses.Forms.Field_Types              --</I>
13 <I>--                                                                          --</I>
14 <I>--                                 S P E C                                  --</I>
15 <I>--                                                                          --</I>
16 <I>------------------------------------------------------------------------------</I>
17 <I>-- Copyright (c) 1998 Free Software Foundation, Inc.                        --</I>
18 <I>--                                                                          --</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>
26 <I>--                                                                          --</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>
29 <I>--                                                                          --</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>
37 <I>--                                                                          --</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&uuml;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>;
48
49 <B>package</B> Terminal_Interface.Curses.Forms.Field_Types <B>is</B>
50
51    <I>--  |=====================================================================</I>
52    <I>--  | Man page <A HREF="form_fieldtype.3x.html">form_fieldtype.3x</A></I>
53    <I>--  |=====================================================================</I>
54
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>
65
66    type Field_Type_Access <B>is</B> <B>access</B> <B>all</B> Field_Type'Class;
67
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>
74
75    <I>--  ---------------------------------------------------------------------</I>
76
77    <I>--  |=====================================================================</I>
78    <I>--  | Man page <A HREF="form_field_validation.3x.html">form_field_validation.3x</A></I>
79    <I>--  |=====================================================================</I>
80
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>
88
89    <I>--  +----------------------------------------------------------------------</I>
90    <I>--  | Private Part.</I>
91    <I>--  | Most of this is used by the implementations of the child packages.</I>
92    <I>--  |</I>
93 <B>private</B>
94    <B>use</B> Terminal_Interface.Curses.<A HREF="terminal_interface-curses-aux_s.html#32:35">Aux</A>;
95
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);
99
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);
103
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);
107
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);
111
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);
115
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);
119
120    <I>--  +----------------------------------------------------------------------</I>
121    <I>--  | This must be in sync with the FIELDTYPE structure in form.h</I>
122    <I>--  |</I>
123    type Low_Level_Field_Type <B>is</B>
124       <B>record</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;
137
138    Null_Field_Type   : <B>constant</B> C_Field_Type := <B>null</B>;
139
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>
144    <I>--  |</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;
149
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>
160
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>
165
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>
170
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>
175
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>
182    <I>--  function.</I>
183
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>
190    <I>--  function.</I>
191
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>
198    <I>--  function.</I>
199
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>
206    <I>--  function.</I>
207
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;
216
217    <I>--  +----------------------------------------------------------------------</I>
218    <I>--  |</I>
219    <I>--  | Some Imports of libform routines to deal with low-level fieldtypes.</I>
220    <I>--  |</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");
225
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");
232
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");
237
238 <B>end</B> Terminal_Interface.Curses.Forms.Field_Types;
239
240 </PRE>
241
242 <P><HR><P>
243 <P>
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>
248 </BODY>
249 </HTML>
250