ncurses 5.4
[ncurses.git] / doc / html / ada / terminal_interface-curses-forms-field_types-user__adb.htm
1 <HTML><HEAD><TITLE>terminal_interface-curses-forms-field_types-user.adb</TITLE></HEAD>
2 <BODY>
3 <HR><DIV ALIGN="center"><H1> File : terminal_interface-curses-forms-field_types-user.adb </H1></DIV><HR>
4 <PRE>
5 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
6 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
7 <FONT COLOR=green><EM>--                           <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding                           --</EM></FONT>
8 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
9 <FONT COLOR=green><EM>--              Terminal_Interface.Curses.Forms.Field_Types.User            --</EM></FONT>
10 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
11 <FONT COLOR=green><EM>--                                 B O D Y                                  --</EM></FONT>
12 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
13 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
14 <FONT COLOR=green><EM>-- Copyright (c) 1998 Free Software Foundation, Inc.                        --</EM></FONT>
15 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
16 <FONT COLOR=green><EM>-- Permission is hereby granted, free of charge, to any person obtaining a  --</EM></FONT>
17 <FONT COLOR=green><EM>-- copy of this software and associated documentation files (the            --</EM></FONT>
18 <FONT COLOR=green><EM>-- "Software"), to deal in the Software without restriction, including      --</EM></FONT>
19 <FONT COLOR=green><EM>-- without limitation the rights to use, copy, modify, merge, publish,      --</EM></FONT>
20 <FONT COLOR=green><EM>-- distribute, distribute with modifications, sublicense, and/or sell       --</EM></FONT>
21 <FONT COLOR=green><EM>-- copies of the Software, and to permit persons to whom the Software is    --</EM></FONT>
22 <FONT COLOR=green><EM>-- furnished to do so, subject to the following conditions:                 --</EM></FONT>
23 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
24 <FONT COLOR=green><EM>-- The above copyright notice and this permission notice shall be included  --</EM></FONT>
25 <FONT COLOR=green><EM>-- in all copies or substantial portions of the Software.                   --</EM></FONT>
26 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
27 <FONT COLOR=green><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --</EM></FONT>
28 <FONT COLOR=green><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --</EM></FONT>
29 <FONT COLOR=green><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --</EM></FONT>
30 <FONT COLOR=green><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --</EM></FONT>
31 <FONT COLOR=green><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --</EM></FONT>
32 <FONT COLOR=green><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --</EM></FONT>
33 <FONT COLOR=green><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --</EM></FONT>
34 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
35 <FONT COLOR=green><EM>-- Except as contained in this notice, the name(s) of the above copyright   --</EM></FONT>
36 <FONT COLOR=green><EM>-- holders shall not be used in advertising or otherwise to promote the     --</EM></FONT>
37 <FONT COLOR=green><EM>-- sale, use or other dealings in this Software without prior written       --</EM></FONT>
38 <FONT COLOR=green><EM>-- authorization.                                                           --</EM></FONT>
39 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
40 <FONT COLOR=green><EM>--  Author:  Juergen Pfeifer, 1996</EM></FONT>
41 <FONT COLOR=green><EM>--  Version Control:</EM></FONT>
42 <FONT COLOR=green><EM>--  @Revision: 1.10 @</EM></FONT>
43 <FONT COLOR=green><EM>--  Binding Version 01.00</EM></FONT>
44 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
45 <b>with</b> Ada.Unchecked_Conversion;
46 <b>with</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C;
47 <b>with</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#50_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#50_35">Aux</A>;
48
49 <b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-forms__ads.htm#48_35">Forms</A>.<A HREF="terminal_interface-curses-forms-field_types__ads.htm#43_41">Field_Types</A>.<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#43_53">User</A> <b>is</b>
50
51    <b>use</b> <b>type</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C.int;
52
53    <b>procedure</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#70_14">Set_Field_Type</A><FONT COLOR=red><A NAME="49_14"></A></FONT> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#70_30">Fld</A> : <b>in</b> <A HREF="terminal_interface-curses-forms__ads.htm#55_9">Field</A>;
54                              <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#71_30">Typ</A> : <b>in</b> User_Defined_Field_Type)
55    <b>is</b>
56       <b>function</b> <FONT COLOR=red><A NAME="52_16">Allocate_Arg</A></FONT> (T : User_Defined_Field_Type'Class)
57                              <b>return</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#216_9">Argument_Access</A>;
58
59       <b>function</b> <FONT COLOR=red><A NAME="55_16">Set_Fld_Type</A></FONT> (<FONT COLOR=red><A NAME="55_30">F</A></FONT>    : <A HREF="terminal_interface-curses-forms__ads.htm#55_9">Field</A> := <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#70_30">Fld</A>;
60                              <FONT COLOR=red><A NAME="56_30">Cft</A></FONT>  : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#132_9">C_Field_Type</A> := <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#81_13">C_Generic_Type</A>;
61                              <FONT COLOR=red><A NAME="57_30">Arg1</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#216_9">Argument_Access</A>)
62                              <b>return</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A>;
63       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#55_16">Set_Fld_Type</A>, "set_field_type");
64
65       <FONT COLOR=red><A NAME="61_7">Res</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#78_12">Eti_Error</A>;
66
67       <b>function</b> <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#52_16">Allocate_Arg</A> (T : <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">User_Defined_Field_Type</A>'Class)
68                              <b>return</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#216_9">Argument_Access</A>
69       <b>is</b>
70          <FONT COLOR=red><A NAME="66_10">Ptr</A></FONT> : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#63_9">Field_Type_Access</A> := <b>new</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">User_Defined_Field_Type</A>'Class'(T);
71       <b>begin</b>
72          <b>return</b> <b>new</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#211_9">Argument</A>'(Usr =&gt; System.Null_Address,
73                               Typ =&gt; <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#66_10">Ptr</A>,
74                               Cft =&gt; <A HREF="terminal_interface-curses-forms-field_types__ads.htm#134_4">Null_Field_Type</A>);
75       <b>end</b> <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#52_16">Allocate_Arg</A><A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#52_16">;</A>
76
77    <b>begin</b>
78       <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#61_7">Res</A> := <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#55_16">Set_Fld_Type</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#57_30">Arg1</A> =&gt; <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#52_16">Allocate_Arg</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#71_30">Typ</A>));
79       <b>if</b> <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#61_7">Res</A> /= <A HREF="terminal_interface-curses-aux__ads.htm#80_4">E_Ok</A> <b>then</b>
80          <A HREF="terminal_interface-curses-aux__ads.htm#96_14">Eti_Exception</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#61_7">Res</A>);
81       <b>end</b> <b>if</b>;
82    <b>end</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#70_14">Set_Field_Type</A><A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#70_14">;</A>
83
84    <b>function</b> <FONT COLOR=red><A NAME="80_13">To_Argument_Access</A></FONT> <b>is</b> <b>new</b> Ada.Unchecked_Conversion
85      (System.Address, <A HREF="terminal_interface-curses-forms-field_types__ads.htm#216_9">Argument_Access</A>);
86
87    <b>function</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_13">Generic_Field_Check</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_34">Fld</A> : <A HREF="terminal_interface-curses-forms__ads.htm#55_9">Field</A>;
88                                  <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#84_34">Usr</A> : System.Address) <b>return</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A>
89    <b>is</b>
90       <FONT COLOR=red><A NAME="86_7">Result</A></FONT> : Boolean;
91       <FONT COLOR=red><A NAME="87_7">Udf</A></FONT>    : <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#53_9">User_Defined_Field_Type_Access</A> :=
92         <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#53_9">User_Defined_Field_Type_Access</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#80_13">To_Argument_Access</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#84_34">Usr</A>).<A HREF="terminal_interface-curses-forms-field_types__ads.htm#212_7">Typ</A>);
93    <b>begin</b>
94       <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#86_7">Result</A> := <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#56_13">Field_Check</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_34">Fld</A>, <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#87_7">Udf</A>.<b>all</b>);
95       <b>return</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A> (Boolean'Pos (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#86_7">Result</A>));
96    <b>end</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_13">Generic_Field_Check</A><A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_13">;</A>
97
98    <b>function</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_13">Generic_Char_Check</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_33">Ch</A>  : <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A>;
99                                 <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#91_33">Usr</A> : System.Address) <b>return</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A>
100    <b>is</b>
101       <FONT COLOR=red><A NAME="97_7">Result</A></FONT> : Boolean;
102       <FONT COLOR=red><A NAME="98_7">Udf</A></FONT>    : <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#53_9">User_Defined_Field_Type_Access</A> :=
103         <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#53_9">User_Defined_Field_Type_Access</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#80_13">To_Argument_Access</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#91_33">Usr</A>).<A HREF="terminal_interface-curses-forms-field_types__ads.htm#212_7">Typ</A>);
104    <b>begin</b>
105       <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#97_7">Result</A> := <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#63_13">Character_Check</A> (Character'Val (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_33">Ch</A>), <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#98_7">Udf</A>.<b>all</b>);
106       <b>return</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#46_12">C_Int</A> (Boolean'Pos (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#97_7">Result</A>));
107    <b>end</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_13">Generic_Char_Check</A><A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_13">;</A>
108
109    <FONT COLOR=green><EM>--  -----------------------------------------------------------------------</EM></FONT>
110    <FONT COLOR=green><EM>--</EM></FONT>
111    <b>function</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#81_13">C_Generic_Type</A> <b>return</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#132_9">C_Field_Type</A>
112    <b>is</b>
113       <FONT COLOR=red><A NAME="109_7">Res</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#78_12">Eti_Error</A>;
114       <FONT COLOR=red><A NAME="110_7">T</A></FONT>   : <A HREF="terminal_interface-curses-forms-field_types__ads.htm#132_9">C_Field_Type</A>;
115    <b>begin</b>
116       <b>if</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#141_4">M_Generic_Type</A> = <A HREF="terminal_interface-curses-forms-field_types__ads.htm#134_4">Null_Field_Type</A> <b>then</b>
117          <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#110_7">T</A> := <A HREF="terminal_interface-curses-forms-field_types__ads.htm#222_13">New_Fieldtype</A> (<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#83_13">Generic_Field_Check</A>'<b>Access</b>,
118                              <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#90_13">Generic_Char_Check</A>'<b>Access</b>);
119          <b>if</b> <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#110_7">T</A> = <A HREF="terminal_interface-curses-forms-field_types__ads.htm#134_4">Null_Field_Type</A> <b>then</b>
120             <b>raise</b> <A HREF="terminal_interface-curses-forms__ads.htm#288_4">Form_Exception</A>;
121          <b>else</b>
122             <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#109_7">Res</A> := <A HREF="terminal_interface-curses-forms-field_types__ads.htm#227_13">Set_Fieldtype_Arg</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#110_7">T</A>,
123                                       <A HREF="terminal_interface-curses-forms-field_types__ads.htm#162_13">Make_Arg</A>'<b>Access</b>,
124                                       <A HREF="terminal_interface-curses-forms-field_types__ads.htm#167_13">Copy_Arg</A>'<b>Access</b>,
125                                       <A HREF="terminal_interface-curses-forms-field_types__ads.htm#172_14">Free_Arg</A>'<b>Access</b>);
126             <b>if</b> <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#109_7">Res</A> /= <A HREF="terminal_interface-curses-aux__ads.htm#80_4">E_Ok</A> <b>then</b>
127                <A HREF="terminal_interface-curses-aux__ads.htm#96_14">Eti_Exception</A> (<A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#109_7">Res</A>);
128             <b>end</b> <b>if</b>;
129          <b>end</b> <b>if</b>;
130          <A HREF="terminal_interface-curses-forms-field_types__ads.htm#141_4">M_Generic_Type</A> := <A HREF="terminal_interface-curses-forms-field_types-user__adb.htm#110_7">T</A>;
131       <b>end</b> <b>if</b>;
132       <b>pragma</b> Assert (<A HREF="terminal_interface-curses-forms-field_types__ads.htm#141_4">M_Generic_Type</A> /= <A HREF="terminal_interface-curses-forms-field_types__ads.htm#134_4">Null_Field_Type</A>);
133       <b>return</b> <A HREF="terminal_interface-curses-forms-field_types__ads.htm#141_4">M_Generic_Type</A>;
134    <b>end</b> <A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#81_13">C_Generic_Type</A><A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#81_13">;</A>
135
136 <b>end</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-forms__ads.htm#48_35">Forms</A>.<A HREF="terminal_interface-curses-forms-field_types__ads.htm#43_41">Field_Types</A>.<A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#43_53">User</A><A HREF="terminal_interface-curses-forms-field_types-user__ads.htm#43_53">;</A>
137 </PRE></BODY></HTML>