summaryrefslogtreecommitdiff
path: root/test/adjuster_test.adb
blob: 6b05b96c5ea00dc85755aa340a7ab41886eb41b9 (plain)
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


--  Programmed by Jedidiah Barber
--  Released into the public domain


--  Adjuster test program functionality duplicated in Ada


with

    Ada.Command_Line,
    FLTK.Widgets.Boxes,
    FLTK.Widgets.Groups.Windows.Double,
    FLTK.Widgets.Valuators.Adjusters;


function Adjuster_Test
    return Integer
is


    package ACom renames Ada.Command_Line;
    package BX renames FLTK.Widgets.Boxes;
    package DW renames FLTK.Widgets.Groups.Windows.Double;
    package AD renames FLTK.Widgets.Valuators.Adjusters;


    type My_Adjuster is new AD.Adjuster with record
        Rect : access BX.Box;
    end record;


    procedure Adjust_Callback
           (This : in out FLTK.Widgets.Widget'Class)
    is
        Just : My_Adjuster renames My_Adjuster (This);
    begin
        Just.Rect.Set_Label (Just.Format);
        Just.Rect.Redraw;
    end Adjust_Callback;


    The_Window : DW.Double_Window :=
        DW.Forge.Create (320, 100, ACom.Command_Name);

    Box_One : aliased BX.Box :=
        BX.Forge.Create (The_Window, FLTK.Down_Box, 20, 30, 80, 25);
    Just_One : My_Adjuster :=
       (AD.Forge.Create (The_Window, 20 + 80, 30, 3 * 25, 25)
        with Rect => Box_One'Access);

    Box_Two : aliased BX.Box :=
        BX.Forge.Create (The_Window, FLTK.Down_Box, 20 + 80 + 4 * 25, 30, 80, 25);
    Just_Two : My_Adjuster :=
       (AD.Forge.Create (The_Window, Box_Two.Get_X + Box_Two.Get_W, 10, 25, 3 * 25)
        with Rect => Box_Two'Access);


begin


    Box_One.Set_Background_Color (FLTK.White_Color);
    Just_One.Set_Callback (Adjust_Callback'Unrestricted_Access);
    Just_One.Do_Callback;

    Box_Two.Set_Background_Color (FLTK.White_Color);
    Just_Two.Set_Callback (Adjust_Callback'Unrestricted_Access);
    Just_Two.Do_Callback;

    The_Window.Set_Resizable (The_Window);
    The_Window.Show_With_Args;

    return FLTK.Run;


end Adjuster_Test;