summaryrefslogtreecommitdiff
path: root/src/windows-jump.adb
blob: f19315e49fb78fefdbe73de6f636838bdc8b231d (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
80
81
82
83
84
85
86
87


package body Windows.Jump is


    package W renames FLTK.Widgets.Groups.Windows;
    package WD renames FLTK.Widgets.Groups.Windows.Double;
    package BU renames FLTK.Widgets.Buttons;
    package EN renames FLTK.Widgets.Buttons.Enter;
    package IT renames FLTK.Widgets.Inputs.Integer;




    procedure Jump_M
           (Item : in out FLTK.Widgets.Widget'Class)
    is
        type Jump_Window_Access is access all Jump_Window;
        Dialog : access Jump_Window := Jump_Window_Access (Item.Parent);

        Line : Integer := Dialog.To_Line.Get_Value;
    begin
        if Dialog.Callback /= null and Line > 0 then
            Dialog.Callback.all (Line);
        end if;
    end Jump_M;




    function Create
        return Jump_Window
    is
        My_Width  : constant Integer := 350;
        My_Height : constant Integer := 110;

        Button_Width  : constant Integer := 140;
        Button_Height : constant Integer := 40;

        Input_Line  : constant Integer := 10;
        Button_Line : constant Integer := 60;

        Input_Width  : constant Integer := 240;
        Input_Height : constant Integer := 25;
        Input_Margin_Right : constant Integer := 10;
    begin
        return This : Jump_Window :=
               (WD.Double_Window'(WD.Forge.Create (0, 0, My_Width, My_Height, "Jump")) with

                    To_Line => IT.Integer_Input'(IT.Forge.Create
                        (My_Width - Input_Width - Input_Margin_Right,
                         Input_Line, Input_Width, Input_Height, "Jump to:")),
                    Cancel => BU.Button'(BU.Forge.Create
                        ((My_Width - 2 * Button_Width) / 3,
                         Button_Line, Button_Width, Button_Height, "Cancel")),
                    Go_Jump => EN.Enter_Button'(EN.Forge.Create
                        ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
                         Button_Line, Button_Width, Button_Height, "Jump")),

                    Callback => null) do

            This.Add (This.To_Line);
            This.Add (This.Cancel);
            This.Cancel.Set_Callback (Hide_CB'Access);
            This.Add (This.Go_Jump);
            This.Go_Jump.Set_Callback (Jump_M'Access);

            This.Set_Icon (Logo);

            This.Set_Callback (Hide_CB'Access);
            This.Set_Modal_State (W.Modal);
        end return;
    end Create;




    procedure Set_Jump_Callback
           (This : in out Jump_Window;
            Func : in     Jump_Callback) is
    begin
        This.Callback := Func;
    end Set_Jump_Callback;


end Windows.Jump;