summaryrefslogtreecommitdiff
path: root/src/fltk-widgets-groups-scrolls.adb
blob: 6ceb0cb49aad2a8ca314931e95044aa73bd1b569 (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
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


with

    Interfaces.C,
    System;

use type

    System.Address;


package body FLTK.Widgets.Groups.Scrolls is


    procedure scroll_set_draw_hook
           (S, D : in System.Address);
    pragma Import (C, scroll_set_draw_hook, "scroll_set_draw_hook");
    pragma Inline (scroll_set_draw_hook);

    procedure scroll_set_handle_hook
           (S, H : in System.Address);
    pragma Import (C, scroll_set_handle_hook, "scroll_set_handle_hook");
    pragma Inline (scroll_set_handle_hook);




    function new_fl_scroll
           (X, Y, W, H : in Interfaces.C.int;
            Text       : in Interfaces.C.char_array)
        return System.Address;
    pragma Import (C, new_fl_scroll, "new_fl_scroll");
    pragma Inline (new_fl_scroll);

    procedure free_fl_scroll
           (S : in System.Address);
    pragma Import (C, free_fl_scroll, "free_fl_scroll");
    pragma Inline (free_fl_scroll);




    procedure fl_scroll_clear
           (S : in System.Address);
    pragma Import (C, fl_scroll_clear, "fl_scroll_clear");
    pragma Inline (fl_scroll_clear);




    procedure fl_scroll_to
           (S    : in System.Address;
            X, Y : in Interfaces.C.int);
    pragma Import (C, fl_scroll_to, "fl_scroll_to");
    pragma Inline (fl_scroll_to);

    procedure fl_scroll_set_type
           (S : in System.Address;
            T : in Interfaces.C.int);
    pragma Import (C, fl_scroll_set_type, "fl_scroll_set_type");
    pragma Inline (fl_scroll_set_type);




    function fl_scroll_get_size
           (S : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_scroll_get_size, "fl_scroll_get_size");
    pragma Inline (fl_scroll_get_size);

    procedure fl_scroll_set_size
           (S : in System.Address;
            T : in Interfaces.C.int);
    pragma Import (C, fl_scroll_set_size, "fl_scroll_set_size");
    pragma Inline (fl_scroll_set_size);

    function fl_scroll_xposition
           (S : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_scroll_xposition, "fl_scroll_xposition");
    pragma Inline (fl_scroll_xposition);

    function fl_scroll_yposition
           (S : in System.Address)
        return Interfaces.C.int;
    pragma Import (C, fl_scroll_yposition, "fl_scroll_yposition");
    pragma Inline (fl_scroll_yposition);




    procedure fl_scroll_draw
           (S : in System.Address);
    pragma Import (C, fl_scroll_draw, "fl_scroll_draw");
    pragma Inline (fl_scroll_draw);

    function fl_scroll_handle
           (S : in System.Address;
            E : in Interfaces.C.int)
        return Interfaces.C.int;
    pragma Import (C, fl_scroll_handle, "fl_scroll_handle");
    pragma Inline (fl_scroll_handle);




    procedure Finalize
           (This : in out Scroll) is
    begin
        if  This.Void_Ptr /= System.Null_Address and then
            This in Scroll'Class
        then
            This.Clear;
            free_fl_scroll (This.Void_Ptr);
            This.Void_Ptr := System.Null_Address;
        end if;
        Finalize (Group (This));
    end Finalize;




    package body Forge is

        function Create
               (X, Y, W, H : in Integer;
                Text       : in String)
            return Scroll is
        begin
            return This : Scroll do
                This.Void_Ptr := new_fl_scroll
                       (Interfaces.C.int (X),
                        Interfaces.C.int (Y),
                        Interfaces.C.int (W),
                        Interfaces.C.int (H),
                        Interfaces.C.To_C (Text));
                fl_group_end (This.Void_Ptr);
                fl_widget_set_user_data
                       (This.Void_Ptr,
                        Widget_Convert.To_Address (This'Unchecked_Access));
                scroll_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
                scroll_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
            end return;
        end Create;

    end Forge;




    procedure Clear
           (This : in out Scroll) is
    begin
        fl_scroll_clear (This.Void_Ptr);
    end Clear;




    procedure Scroll_To
           (This : in out Scroll;
            X, Y : in     Integer) is
    begin
        fl_scroll_to (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y));
    end Scroll_To;


    procedure Set_Type
           (This : in out Scroll;
            Mode : in     Scroll_Kind) is
    begin
        fl_scroll_set_type (This.Void_Ptr, Scroll_Kind'Pos (Mode));
    end Set_Type;




    function Get_Scrollbar_Size
           (This : in Scroll)
        return Integer is
    begin
        return Integer (fl_scroll_get_size (This.Void_Ptr));
    end Get_Scrollbar_Size;


    procedure Set_Scrollbar_Size
           (This : in out Scroll;
            To   : in     Integer) is
    begin
        fl_scroll_set_size (This.Void_Ptr, Interfaces.C.int (To));
    end Set_Scrollbar_Size;


    function Get_Scroll_X
           (This : in Scroll)
        return Integer is
    begin
        return Integer (fl_scroll_xposition (This.Void_Ptr));
    end Get_Scroll_X;


    function Get_Scroll_Y
           (This : in Scroll)
        return Integer is
    begin
        return Integer (fl_scroll_yposition (This.Void_Ptr));
    end Get_Scroll_Y;




    procedure Draw
           (This : in out Scroll) is
    begin
        fl_scroll_draw (This.Void_Ptr);
    end Draw;


    function Handle
           (This  : in out Scroll;
            Event : in     Event_Kind)
        return Event_Outcome is
    begin
        return Event_Outcome'Val
               (fl_scroll_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
    end Handle;


end FLTK.Widgets.Groups.Scrolls;