summaryrefslogtreecommitdiff
path: root/src/windows-jump.adb
blob: 13f9cd0902b453a89436dfe1db8624f0cf8c5b9f (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


with FLTK.Widgets.Groups.Windows.Double;
with FLTK.Widgets.Buttons.Enter;
with FLTK.Widgets.Inputs.Integer;


package body Windows.Jump is


    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  : Integer := 350;
        My_Height : Integer := 110;

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

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

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

                    To_Line => IT.Integer_Input'(IT.Create
                        (My_Width - Input_Width - Input_Margin_Right,
                         Input_Line, Input_Width, Input_Height, "Jump to:")),
                    Cancel => BU.Button'(BU.Create
                        ((My_Width - 2 * Button_Width) / 3,
                         Button_Line, Button_Width, Button_Height, "Cancel")),
                    Go_Jump => EN.Enter_Button'(EN.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_Callback (Hide_CB'Access);
            This.Set_Icon (Logo);
            This.Set_Modal;
        end return;
    end Create;




    function Create
           (X, Y, W, H : in Integer;
            Label_Text : in String)
        return Jump_Window is
    begin
        return Create;
    end Create;




    function Create
           (W, H : in Integer)
        return Jump_Window is
    begin
        return Create;
    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;