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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
-- Programmed by Jedidiah Barber
-- Released into the public domain
with
Interfaces.C.Strings;
package body FLTK.Labels is
------------------------
-- Functions From C --
------------------------
function new_fl_label
(V : in Interfaces.C.Strings.chars_ptr;
F : in Interfaces.C.int;
S : in Interfaces.C.int;
H : in Interfaces.C.unsigned;
K : in Interfaces.C.int;
P : in Interfaces.C.unsigned)
return Storage.Integer_Address;
pragma Import (C, new_fl_label, "new_fl_label");
pragma Inline (new_fl_label);
procedure free_fl_label
(L : in Storage.Integer_Address);
pragma Import (C, free_fl_label, "free_fl_label");
pragma Inline (free_fl_label);
procedure fl_label_set_value
(L : in Storage.Integer_Address;
V : in Interfaces.C.Strings.chars_ptr);
pragma Import (C, fl_label_set_value, "fl_label_set_value");
pragma Inline (fl_label_set_value);
function fl_label_get_font
(L : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, fl_label_get_font, "fl_label_get_font");
pragma Inline (fl_label_get_font);
procedure fl_label_set_font
(L : in Storage.Integer_Address;
F : in Interfaces.C.int);
pragma Import (C, fl_label_set_font, "fl_label_set_font");
pragma Inline (fl_label_set_font);
function fl_label_get_size
(L : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, fl_label_get_size, "fl_label_get_size");
pragma Inline (fl_label_get_size);
procedure fl_label_set_size
(L : in Storage.Integer_Address;
S : in Interfaces.C.int);
pragma Import (C, fl_label_set_size, "fl_label_set_size");
pragma Inline (fl_label_set_size);
function fl_label_get_color
(L : in Storage.Integer_Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_label_get_color, "fl_label_get_color");
pragma Inline (fl_label_get_color);
procedure fl_label_set_color
(L : in Storage.Integer_Address;
H : in Interfaces.C.unsigned);
pragma Import (C, fl_label_set_color, "fl_label_set_color");
pragma Inline (fl_label_set_color);
function fl_label_get_type
(L : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, fl_label_get_type, "fl_label_get_type");
pragma Inline (fl_label_get_type);
procedure fl_label_set_type
(L : in Storage.Integer_Address;
K : in Interfaces.C.int);
pragma Import (C, fl_label_set_type, "fl_label_set_type");
pragma Inline (fl_label_set_type);
function fl_label_get_align
(L : in Storage.Integer_Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_label_get_align, "fl_label_get_align");
pragma Inline (fl_label_get_align);
procedure fl_label_set_align
(L : in Storage.Integer_Address;
P : in Interfaces.C.unsigned);
pragma Import (C, fl_label_set_align, "fl_label_set_align");
pragma Inline (fl_label_set_align);
procedure fl_label_set_image
(L, I : in Storage.Integer_Address);
pragma Import (C, fl_label_set_image, "fl_label_set_image");
pragma Inline (fl_label_set_image);
procedure fl_label_set_deimage
(L, I : in Storage.Integer_Address);
pragma Import (C, fl_label_set_deimage, "fl_label_set_deimage");
pragma Inline (fl_label_set_deimage);
procedure fl_label_draw
(L : in Storage.Integer_Address;
X, Y, W, H : in Interfaces.C.int;
P : in Interfaces.C.unsigned);
pragma Import (C, fl_label_draw, "fl_label_draw");
pragma Inline (fl_label_draw);
procedure fl_label_measure
(L : in Storage.Integer_Address;
W, H : out Interfaces.C.int);
pragma Import (C, fl_label_measure, "fl_label_measure");
pragma Inline (fl_label_measure);
-----------------------------------
-- Controlled Type Subprograms --
-----------------------------------
procedure Finalize
(This : in out Label) is
begin
if This.Void_Ptr /= Null_Pointer and This.Needs_Dealloc then
free_fl_label (This.Void_Ptr);
Interfaces.C.Strings.Free (This.My_Text);
end if;
end Finalize;
-----------------
-- Label API --
-----------------
package body Forge is
function Create
(Value : in String;
Font : in Font_Kind := Helvetica;
Size : in Font_Size := Normal_Size;
Hue : in Color := Foreground_Color;
Kind : in Label_Kind := Normal_Label;
Place : in Alignment := Align_Center;
Active : access FLTK.Images.Image'Class := null;
Inactive : access FLTK.Images.Image'Class := null)
return Label is
begin
return This : Label do
This.My_Text := Interfaces.C.Strings.New_String (Value);
This.Void_Ptr := new_fl_label
(This.My_Text, -- Interfaces.C.Strings.chars_ptr
Font_Kind'Pos (Font), -- Interfaces.C.int
Interfaces.C.int (Size),
Interfaces.C.unsigned (Hue),
Label_Kind'Pos (Kind), -- Interfaces.C.int
Interfaces.C.unsigned (Place));
This.Set_Active (Active);
This.Set_Inactive (Inactive);
end return;
end Create;
end Forge;
function Get_Value
(This : in Label)
return String is
begin
return Interfaces.C.Strings.Value (This.My_Text);
end Get_Value;
procedure Set_Value
(This : in out Label;
Text : in String) is
begin
Interfaces.C.Strings.Free (This.My_Text);
This.My_Text := Interfaces.C.Strings.New_String (Text);
fl_label_set_value (This.Void_Ptr, This.My_Text);
end Set_Value;
function Get_Font
(This : in Label)
return Font_Kind is
begin
return Font_Kind'Val (fl_label_get_font (This.Void_Ptr));
end Get_Font;
procedure Set_Font
(This : in out Label;
Font : in Font_Kind) is
begin
fl_label_set_font (This.Void_Ptr, Font_Kind'Pos (Font));
end Set_Font;
function Get_Size
(This : in Label)
return Font_Size is
begin
return Font_Size (fl_label_get_size (This.Void_Ptr));
end Get_Size;
procedure Set_Size
(This : in out Label;
Size : in Font_Size) is
begin
fl_label_set_size (This.Void_Ptr, Interfaces.C.int (Size));
end Set_Size;
function Get_Color
(This : in Label)
return Color is
begin
return Color (fl_label_get_color (This.Void_Ptr));
end Get_Color;
procedure Set_Color
(This : in out Label;
Hue : in Color) is
begin
fl_label_set_color (This.Void_Ptr, Interfaces.C.unsigned (Hue));
end Set_Color;
function Get_Kind
(This : in Label)
return Label_Kind is
begin
return Label_Kind'Val (fl_label_get_type (This.Void_Ptr));
end Get_Kind;
procedure Set_Kind
(This : in out Label;
Kind : in Label_Kind) is
begin
fl_label_set_type (This.Void_Ptr, Label_Kind'Pos (Kind));
end Set_Kind;
function Get_Alignment
(This : in Label)
return Alignment is
begin
return Alignment (fl_label_get_align (This.Void_Ptr));
end Get_Alignment;
procedure Set_Alignment
(This : in out Label;
Place : in Alignment) is
begin
fl_label_set_align (This.Void_Ptr, Interfaces.C.unsigned (Place));
end Set_Alignment;
function Get_Active
(This : in Label)
return access FLTK.Images.Image'Class is
begin
return This.My_Active;
end Get_Active;
procedure Set_Active
(This : in out Label;
Pic : access FLTK.Images.Image'Class) is
begin
if Pic /= null then
fl_label_set_image (This.Void_Ptr, Wrapper (Pic.all).Void_Ptr);
else
fl_label_set_image (This.Void_Ptr, Null_Pointer);
end if;
This.My_Active := Pic;
end Set_Active;
function Get_Inactive
(This : in Label)
return access FLTK.Images.Image'Class is
begin
return This.My_Inactive;
end Get_Inactive;
procedure Set_Inactive
(This : in out Label;
Pic : access FLTK.Images.Image'Class) is
begin
if Pic /= null then
fl_label_set_deimage (This.Void_Ptr, Wrapper (Pic.all).Void_Ptr);
else
fl_label_set_deimage (This.Void_Ptr, Null_Pointer);
end if;
This.My_Inactive := Pic;
end Set_Inactive;
procedure Draw
(This : in out Label;
X, Y, W, H : in Integer;
Place : in Alignment) is
begin
fl_label_draw
(This.Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.unsigned (Place));
end Draw;
procedure Measure
(This : in Label;
W, H : out Integer) is
begin
fl_label_measure
(This.Void_Ptr,
Interfaces.C.int (W),
Interfaces.C.int (H));
end Measure;
end FLTK.Labels;
|