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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
-- Programmed by Jedidiah Barber
-- Released into the public domain
with
Interfaces.C;
use type
Interfaces.C.int,
Interfaces.C.unsigned_char,
Interfaces.C.unsigned_long;
package body FLTK is
------------------------
-- Constants From C --
------------------------
fl_enum_num_red : constant Interfaces.C.int;
pragma Import (C, fl_enum_num_red);
fl_enum_num_green : constant Interfaces.C.int;
pragma Import (C, fl_enum_num_green);
fl_enum_num_blue : constant Interfaces.C.int;
pragma Import (C, fl_enum_num_blue);
fl_enum_num_gray : constant Interfaces.C.int;
pragma Import (C, fl_enum_num_gray);
------------------------
-- Functions From C --
------------------------
-- Enumerations.H --
-- Color --
function fl_enum_rgb_color2
(L : in Interfaces.C.unsigned_char)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_rgb_color2, "fl_enum_rgb_color2");
pragma Inline (fl_enum_rgb_color2);
function fl_enum_rgb_color
(R, G, B : in Interfaces.C.unsigned_char)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_rgb_color, "fl_enum_rgb_color");
pragma Inline (fl_enum_rgb_color);
function fl_enum_color_cube
(R, G, B : in Interfaces.C.int)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_color_cube, "fl_enum_color_cube");
pragma Inline (fl_enum_color_cube);
function fl_enum_gray_ramp
(L : in Interfaces.C.int)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_gray_ramp, "fl_enum_gray_ramp");
pragma Inline (fl_enum_gray_ramp);
function fl_enum_darker
(T : in Interfaces.C.unsigned)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_darker, "fl_enum_darker");
pragma Inline (fl_enum_darker);
function fl_enum_lighter
(T : in Interfaces.C.unsigned)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_lighter, "fl_enum_lighter");
pragma Inline (fl_enum_lighter);
function fl_enum_contrast
(F, B : in Interfaces.C.unsigned)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_contrast, "fl_enum_contrast");
pragma Inline (fl_enum_contrast);
function fl_enum_inactive
(T : in Interfaces.C.unsigned)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_inactive, "fl_enum_inactive");
pragma Inline (fl_enum_inactive);
function fl_enum_color_average
(T1, T2 : in Interfaces.C.unsigned;
W : in Interfaces.C.C_float)
return Interfaces.C.unsigned;
pragma Import (C, fl_enum_color_average, "fl_enum_color_average");
pragma Inline (fl_enum_color_average);
-- Box Types --
function fl_enum_box
(B : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_enum_box, "fl_enum_box");
pragma Inline (fl_enum_box);
function fl_enum_frame
(B : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_enum_frame, "fl_enum_frame");
pragma Inline (fl_enum_frame);
function fl_enum_down
(B : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_enum_down, "fl_enum_down");
pragma Inline (fl_enum_down);
-- Fl.H --
-- Versioning --
function fl_abi_check
(V : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_abi_check, "fl_abi_check");
pragma Inline (fl_abi_check);
function fl_abi_version
return Interfaces.C.int;
pragma Import (C, fl_abi_version, "fl_abi_version");
pragma Inline (fl_abi_version);
function fl_api_version
return Interfaces.C.int;
pragma Import (C, fl_api_version, "fl_api_version");
pragma Inline (fl_api_version);
function fl_version
return Interfaces.C.double;
pragma Import (C, fl_version, "fl_version");
pragma Inline (fl_version);
-- Drawing --
function fl_get_damage
return Interfaces.C.int;
pragma Import (C, fl_get_damage, "fl_get_damage");
pragma Inline (fl_get_damage);
procedure fl_set_damage
(V : in Interfaces.C.int);
pragma Import (C, fl_set_damage, "fl_set_damage");
pragma Inline (fl_set_damage);
-- Event Loop --
function fl_check
return Interfaces.C.int;
pragma Import (C, fl_check, "fl_check");
pragma Inline (fl_check);
function fl_ready
return Interfaces.C.int;
pragma Import (C, fl_ready, "fl_ready");
pragma Inline (fl_ready);
function fl_wait
return Interfaces.C.int;
pragma Import (C, fl_wait, "fl_wait");
pragma Inline (fl_wait);
function fl_wait2
(S : in Interfaces.C.double)
return Interfaces.C.double;
pragma Import (C, fl_wait2, "fl_wait2");
pragma Inline (fl_wait2);
function fl_run
return Interfaces.C.int;
pragma Import (C, fl_run, "fl_run");
pragma Inline (fl_run);
-----------------------
-- API Subprograms --
-----------------------
-- Implementation Details --
function Is_Valid
(Object : in Wrapper)
return Boolean is
begin
return Object.Void_Ptr /= Null_Pointer;
end Is_Valid;
-- Color --
function RGB_Color
(Light : in Greyscale)
return Color is
begin
case Light is
when 'A' .. 'W' => return Color (fl_enum_rgb_color2
((Greyscale'Pos (Light) - Greyscale'Pos (Greyscale'First)) * 11));
when 'X' => return Color (fl_enum_rgb_color2 (255));
end case;
end RGB_Color;
function RGB_Color
(Light : in Color_Component)
return Color is
begin
return Color (fl_enum_rgb_color2 (Interfaces.C.unsigned_char (Light)));
end RGB_Color;
function RGB_Color
(R, G, B : in Color_Component)
return Color is
begin
return Color (fl_enum_rgb_color
(Interfaces.C.unsigned_char (R),
Interfaces.C.unsigned_char (G),
Interfaces.C.unsigned_char (B)));
end RGB_Color;
function Color_Cube
(R, G, B : in Color_Component)
return Color is
begin
return Color (fl_enum_color_cube
(Interfaces.C.int (Float'Rounding (Float (R) * Float (fl_enum_num_red - 1) / 255.0)),
Interfaces.C.int (Float'Rounding (Float (G) * Float (fl_enum_num_green - 1) / 255.0)),
Interfaces.C.int (Float'Rounding (Float (B) * Float (fl_enum_num_blue - 1) / 255.0))));
end Color_Cube;
function Grey_Ramp
(Light : in Greyscale)
return Color is
begin
return Color (fl_enum_gray_ramp (Greyscale'Pos (Light) - Greyscale'Pos (Greyscale'First)));
end Grey_Ramp;
function Grey_Ramp
(Light : in Color_Component)
return Color is
begin
return Color (fl_enum_gray_ramp (Interfaces.C.int
(Float'Rounding (Float (Light) * Float (fl_enum_num_gray - 1) / 255.0))));
end Grey_Ramp;
function Darker
(Tone : in Color)
return Color is
begin
return Color (fl_enum_darker (Interfaces.C.unsigned (Tone)));
end Darker;
function Lighter
(Tone : in Color)
return Color is
begin
return Color (fl_enum_lighter (Interfaces.C.unsigned (Tone)));
end Lighter;
function Contrast
(Fore, Back : in Color)
return Color is
begin
return Color (fl_enum_contrast
(Interfaces.C.unsigned (Fore),
Interfaces.C.unsigned (Back)));
end Contrast;
function Inactive
(Tone : in Color)
return Color is
begin
return Color (fl_enum_inactive (Interfaces.C.unsigned (Tone)));
end Inactive;
function Color_Average
(Tone1, Tone2 : in Color;
Weight : in Blend := 0.5)
return Color is
begin
return Color (fl_enum_color_average
(Interfaces.C.unsigned (Tone1),
Interfaces.C.unsigned (Tone2),
Interfaces.C.C_float (Weight)));
end Color_Average;
-- Alignment --
function "+"
(Left, Right : in Alignment)
return Alignment is
begin
return Left or Right;
end "+";
function "-"
(Left, Right : in Alignment)
return Alignment is
begin
return Left and (not Right);
end "-";
-- Keyboard and Mouse Input --
function Press
(Key : in Pressable_Key)
return Keypress is
begin
return Character'Pos (Key);
end Press;
function Press
(Key : Pressable_Key)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Mod_None;
This.Keycode := Character'Pos (Key);
This.Mousecode := No_Button;
end return;
end Press;
function Press
(Key : in Keypress)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Mod_None;
This.Keycode := Key;
This.Mousecode := No_Button;
end return;
end Press;
function Press
(Key : in Mouse_Button)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Mod_None;
This.Keycode := 0;
This.Mousecode := Key;
end return;
end Press;
function "+"
(Left, Right : in Modifier)
return Modifier is
begin
return Left or Right;
end "+";
function "+"
(Left : in Modifier;
Right : in Pressable_Key)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Left;
This.Keycode := Character'Pos (Right);
This.Mousecode := No_Button;
end return;
end "+";
function "+"
(Left : in Modifier;
Right : in Keypress)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Left;
This.Keycode := Right;
This.Mousecode := No_Button;
end return;
end "+";
function "+"
(Left : in Modifier;
Right : in Mouse_Button)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Left;
This.Keycode := 0;
This.Mousecode := Right;
end return;
end "+";
function "+"
(Left : in Modifier;
Right : in Key_Combo)
return Key_Combo is
begin
return This : Key_Combo do
This.Modcode := Left or Right.Modcode;
This.Keycode := Right.Keycode;
This.Mousecode := Right.Mousecode;
end return;
end "+";
function To_C
(Key : in Key_Combo)
return Interfaces.C.int is
begin
return To_C (Key.Modcode) + To_C (Key.Keycode) + To_C (Key.Mousecode);
end To_C;
function To_Ada
(Key : in Interfaces.C.int)
return Key_Combo is
begin
return Result : Key_Combo do
Result.Modcode := To_Ada (Key);
Result.Keycode := To_Ada (Key);
Result.Mousecode := To_Ada (Key);
end return;
end To_Ada;
function To_C
(Key : in Keypress)
return Interfaces.C.int is
begin
return Interfaces.C.int (Key);
end To_C;
function To_Ada
(Key : in Interfaces.C.int)
return Keypress is
begin
return Keypress (Key mod 65536);
end To_Ada;
function To_C
(Modi : in Modifier)
return Interfaces.C.int is
begin
return Interfaces.C.int (Modi) * 65536;
end To_C;
function To_Ada
(Modi : in Interfaces.C.int)
return Modifier is
begin
return Modifier ((Modi / 65536) mod 256);
end To_Ada;
function To_C
(Button : in Mouse_Button)
return Interfaces.C.int is
begin
case Button is
when Left_Button => return 1 * (256 ** 3);
when Middle_Button => return 2 * (256 ** 3);
when Right_Button => return 4 * (256 ** 3);
when others => return 0;
end case;
end To_C;
function To_Ada
(Button : in Interfaces.C.int)
return Mouse_Button is
begin
case (Button / (256 ** 3)) is
when 1 => return Left_Button;
when 2 => return Middle_Button;
when 4 => return Right_Button;
when others => return No_Button;
end case;
end To_Ada;
-- Box Types --
function Filled
(Box : in Box_Kind)
return Box_Kind
is
Result : Interfaces.C.int := fl_enum_box (Box_Kind'Pos (Box));
begin
return Box_Kind'Val (Result);
exception
when Constraint_Error => raise Internal_FLTK_Error with
"fl_box in Enumerations.H returned unexpected int value of " &
Interfaces.C.int'Image (Result);
end Filled;
function Frame
(Box : in Box_Kind)
return Box_Kind
is
Result : Interfaces.C.int := fl_enum_frame (Box_Kind'Pos (Box));
begin
return Box_Kind'Val (Result);
exception
when Constraint_Error => raise Internal_FLTK_Error with
"fl_frame in Enumerations.H returned unexpected int value of " &
Interfaces.C.int'Image (Result);
end Frame;
function Down
(Box : in Box_Kind)
return Box_Kind
is
Result : Interfaces.C.int := fl_enum_down (Box_Kind'Pos (Box));
begin
return Box_Kind'Val (Result);
exception
when Constraint_Error => raise Internal_FLTK_Error with
"fl_down in Enumerations.H returned unexpected int value of " &
Interfaces.C.int'Image (Result);
end Down;
-- Menu Flags --
function "+"
(Left, Right : in Menu_Flag)
return Menu_Flag is
begin
return Left or Right;
end "+";
-- Versioning --
function ABI_Check
(ABI_Ver : in Version_Number)
return Boolean is
begin
return fl_abi_check (Interfaces.C.int (ABI_Ver)) /= 0;
end ABI_Check;
function ABI_Version
return Version_Number is
begin
return Version_Number (fl_abi_version);
end ABI_Version;
function API_Version
return Version_Number is
begin
return Version_Number (fl_api_version);
end API_Version;
function Version
return Version_Number is
begin
return Version_Number (fl_version);
end Version;
-- Drawing --
function Is_Damaged
return Boolean is
begin
return fl_get_damage /= 0;
end Is_Damaged;
procedure Set_Damaged
(To : in Boolean) is
begin
fl_set_damage (Boolean'Pos (To));
end Set_Damaged;
-- Event Loop --
function Check
return Boolean is
begin
return fl_check /= 0;
end Check;
function Ready
return Boolean is
begin
return fl_ready /= 0;
end Ready;
function Wait
return Integer is
begin
return Integer (fl_wait);
end Wait;
function Wait
(Seconds : in Long_Float)
return Long_Float is
begin
return Long_Float (fl_wait2 (Interfaces.C.double (Seconds)));
end Wait;
function Run
return Integer is
begin
return Integer (fl_run);
end Run;
end FLTK;
|