1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
9 ------------------------------------------------------------------------------
10 -- Copyright 2020 Thomas E. Dickey --
11 -- Copyright 1998-2006,2011 Free Software Foundation, Inc. --
13 -- Permission is hereby granted, free of charge, to any person obtaining a --
14 -- copy of this software and associated documentation files (the --
15 -- "Software"), to deal in the Software without restriction, including --
16 -- without limitation the rights to use, copy, modify, merge, publish, --
17 -- distribute, distribute with modifications, sublicense, and/or sell --
18 -- copies of the Software, and to permit persons to whom the Software is --
19 -- furnished to do so, subject to the following conditions: --
21 -- The above copyright notice and this permission notice shall be included --
22 -- in all copies or substantial portions of the Software. --
24 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
25 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
26 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
27 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
28 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
29 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
30 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
32 -- Except as contained in this notice, the name(s) of the above copyright --
33 -- holders shall not be used in advertising or otherwise to promote the --
34 -- sale, use or other dealings in this Software without prior written --
36 ------------------------------------------------------------------------------
37 -- Author: Juergen Pfeifer, 1996
40 -- $Date: 2020/02/02 23:34:34 $
41 -- Binding Version 01.00
42 ------------------------------------------------------------------------------
43 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
44 with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
45 with Terminal_Interface.Curses.Forms.Field_User_Data;
46 with Sample.My_Field_Type; use Sample.My_Field_Type;
47 with Sample.Explanation; use Sample.Explanation;
48 with Sample.Form_Demo.Aux; use Sample.Form_Demo.Aux;
49 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
50 with Sample.Form_Demo.Handler;
52 with Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada;
53 with Terminal_Interface.Curses.Forms.Field_Types.Enumeration;
54 use Terminal_Interface.Curses.Forms.Field_Types.Enumeration;
55 with Terminal_Interface.Curses.Forms.Field_Types.IntField;
56 use Terminal_Interface.Curses.Forms.Field_Types.IntField;
58 package body Sample.Form_Demo is
64 type User_Access is access User_Data;
67 Terminal_Interface.Curses.Forms.Field_User_Data (User_Data,
70 type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday,
73 package Weekday_Enum is new
74 Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada (Weekday);
76 Enum_Field : constant Enumeration_Field :=
82 Mft : constant My_Data := (Ch => 'X');
84 FA : Field_Array_Access := new Field_Array'
85 (Make (0, 14, "Sample Entry Form"),
86 Make (2, 0, "WeekdayEnumeration"),
87 Make (2, 20, "Numeric 1-10"),
88 Make (2, 34, "Only 'X'"),
89 Make (5, 0, "Multiple Lines offscreen(Scroll)"),
90 Make (Width => 18, Top => 3, Left => 0),
91 Make (Width => 12, Top => 3, Left => 20),
92 Make (Width => 12, Top => 3, Left => 34),
93 Make (Width => 46, Top => 6, Left => 0, Height => 4, Off_Screen => 2),
97 Frm : Terminal_Interface.Curses.Forms.Form := Create (FA);
99 I_F : constant Integer_Field := (Precision => 0,
103 F1, F2 : User_Access;
105 package Fh is new Sample.Form_Demo.Handler (Default_Driver);
108 Push_Environment ("FORM00");
109 Notepad ("FORM-PAD00");
112 Set_Field_Type (FA.all (6), Enum_Field);
113 Set_Field_Type (FA.all (7), I_F);
114 Set_Field_Type (FA.all (8), Mft);
116 F1 := new User_Data'(Data => 4711);
117 Fld_U.Set_User_Data (FA.all (1), F1);
121 Fld_U.Get_User_Data (FA.all (1), F2);
122 pragma Assert (F1 = F2);
123 pragma Assert (F1.Data = F2.Data);
131 end Sample.Form_Demo;