1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
with Interfaces.C;
with System;
use type System.Address;
with Ada.Containers.Vectors;
use type Ada.Containers.Count_Type;
package body FLTK.Widgets.Groups is
function new_fl_group
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_group, "new_fl_group");
procedure free_fl_group
(G : in System.Address);
pragma Import (C, free_fl_group, "free_fl_group");
procedure fl_group_end
(G : in System.Address);
pragma Import (C, fl_group_end, "fl_group_end");
procedure fl_group_add
(G, W : in System.Address);
pragma Import (C, fl_group_add, "fl_group_add");
procedure fl_group_clear
(G : in System.Address);
pragma Import (C, fl_group_clear, "fl_group_clear");
procedure fl_group_insert
(G, W : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_group_insert, "fl_group_insert");
procedure fl_group_remove
(G, W : in System.Address);
pragma Import (C, fl_group_remove, "fl_group_remove");
procedure fl_group_remove2
(G : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_group_remove2, "fl_group_remove2");
procedure Initialize
(This : in out Group) is
begin
Initialize (Widget (This));
This.Widget_List := Widget_Vectors.Empty_Vector;
end Initialize;
procedure Finalize
(This : in out Group) is
begin
Finalize (Widget (This));
if This.Void_Ptr /= System.Null_Address then
while This.Widget_List.Length > 0 loop
This.Remove (This.Widget_List.Last_Index);
end loop;
if This in Group then
free_fl_group (This.Void_Ptr);
end if;
end if;
end Finalize;
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Group is
begin
return This : Group do
This.Void_Ptr := new_fl_group
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_group_end (This.Void_Ptr);
end return;
end Create;
procedure Add
(This : in out Group;
Item : in out Widget'Class) is
begin
if Item.Parent /= null then
Item.Parent.Remove (Item);
end if;
This.Widget_List.Append (Item'Unchecked_Access);
Item.Parent := This'Unchecked_Access;
fl_group_add (This.Void_Ptr, Item.Void_Ptr);
end Add;
function Child
(This : in Group;
Place : in Index)
return Widget_Cursor is
begin
return Ref : Widget_Cursor (This.Widget_List.Element (Place));
end Child;
procedure Clear
(This : in out Group) is
begin
while This.Widget_List.Length > 0 loop
This.Remove (This.Widget_List.Last_Index);
end loop;
fl_group_clear (This.Void_Ptr);
end Clear;
function Find
(This : in Group;
Item : in out Widget'Class)
return Index is
begin
return This.Widget_List.Find_Index (Item'Unchecked_Access);
end Find;
procedure Insert
(This : in out Group;
Item : in out Widget'Class;
Place : in Index) is
begin
if Item.Parent /= null then
Item.Parent.Remove (Item);
end if;
This.Widget_List.Insert (Place, Item'Unchecked_Access);
Item.Parent := This'Unchecked_Access;
fl_group_insert
(This.Void_Ptr,
Item.Void_Ptr,
Interfaces.C.int (Place));
end Insert;
procedure Remove
(This : in out Group;
Item : in out Widget'Class) is
begin
Item.Parent := null;
This.Widget_List.Delete (This.Find (Item));
fl_group_remove (This.Void_Ptr, Item.Void_Ptr);
end Remove;
procedure Remove
(This : in out Group;
Place : in Index) is
begin
This.Widget_List.Element (Place).Parent := null;
This.Widget_List.Delete (Place);
fl_group_remove2 (This.Void_Ptr, Interfaces.C.int (Place));
end Remove;
end FLTK.Widgets.Groups;
|