summaryrefslogtreecommitdiff
path: root/src/fltk-widgets-groups-spinners.adb
blob: 476bb32f67715f72505052eba7f5f49e23616c52 (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
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


with

    Interfaces.C,
    System;

use type

    Interfaces.C.int,
    System.Address;


package body FLTK.Widgets.Groups.Spinners is


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

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




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

    procedure free_fl_spinner
           (W : in System.Address);
    pragma Import (C, free_fl_spinner, "free_fl_spinner");
    pragma Inline (free_fl_spinner);




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

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

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

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

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

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

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

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

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

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




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

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

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

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

    procedure fl_spinner_range
           (S    : in System.Address;
            A, B : in Interfaces.C.double);
    pragma Import (C, fl_spinner_range, "fl_spinner_range");
    pragma Inline (fl_spinner_range);

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

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

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

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

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

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




    procedure fl_spinner_draw
           (W : in System.Address);
    pragma Import (C, fl_spinner_draw, "fl_spinner_draw");
    pragma Inline (fl_spinner_draw);

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




    procedure Finalize
           (This : in out Spinner) is
    begin
        if  This.Void_Ptr /= System.Null_Address and then
            This in Spinner'Class
        then
            This.Clear;
            free_fl_spinner (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 Spinner is
        begin
            return This : Spinner do
                This.Void_Ptr := new_fl_spinner
                       (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));
                spinner_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
                spinner_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
            end return;
        end Create;

    end Forge;




    function Get_Background_Color
           (This : in Spinner)
        return Color is
    begin
        return Color (fl_spinner_get_color (This.Void_Ptr));
    end Get_Background_Color;


    procedure Set_Background_Color
           (This : in out Spinner;
            To   : in     Color) is
    begin
        fl_spinner_set_color (This.Void_Ptr, Interfaces.C.unsigned (To));
    end Set_Background_Color;


    function Get_Selection_Color
           (This : in Spinner)
        return Color is
    begin
        return Color (fl_spinner_get_selection_color (This.Void_Ptr));
    end Get_Selection_Color;


    procedure Set_Selection_Color
           (This : in out Spinner;
            To   : in     Color) is
    begin
        fl_spinner_set_selection_color (This.Void_Ptr, Interfaces.C.unsigned (To));
    end Set_Selection_Color;


    function Get_Text_Color
           (This : in Spinner)
        return Color is
    begin
        return Color (fl_spinner_get_textcolor (This.Void_Ptr));
    end Get_Text_Color;


    procedure Set_Text_Color
           (This : in out Spinner;
            To   : in     Color) is
    begin
        fl_spinner_set_textcolor (This.Void_Ptr, Interfaces.C.unsigned (To));
    end Set_Text_Color;


    function Get_Text_Font
           (This : in Spinner)
        return Font_Kind is
    begin
        return Font_Kind'Val (fl_spinner_get_textfont (This.Void_Ptr));
    end Get_Text_Font;


    procedure Set_Text_Font
           (This : in out Spinner;
            To   : in     Font_Kind) is
    begin
        fl_spinner_set_textfont (This.Void_Ptr, Font_Kind'Pos (To));
    end Set_Text_Font;


    function Get_Text_Size
           (This : in Spinner)
        return Font_Size is
    begin
        return Font_Size (fl_spinner_get_textsize (This.Void_Ptr));
    end Get_Text_Size;


    procedure Set_Text_Size
           (This : in out Spinner;
            To   : in     Font_Size) is
    begin
        fl_spinner_set_textsize (This.Void_Ptr, Interfaces.C.int (To));
    end Set_Text_Size;




    function Get_Minimum
           (This : in Spinner)
        return Long_Float is
    begin
        return Long_Float (fl_spinner_get_minimum (This.Void_Ptr));
    end Get_Minimum;


    procedure Set_Minimum
           (This : in out Spinner;
            To   : in     Long_Float) is
    begin
        fl_spinner_set_minimum (This.Void_Ptr, Interfaces.C.double (To));
    end Set_Minimum;


    function Get_Maximum
           (This : in Spinner)
        return Long_Float is
    begin
        return Long_Float (fl_spinner_get_maximum (This.Void_Ptr));
    end Get_Maximum;


    procedure Set_Maximum
           (This : in out Spinner;
            To   : in     Long_Float) is
    begin
        fl_spinner_set_maximum (This.Void_Ptr, Interfaces.C.double (To));
    end Set_Maximum;


    procedure Get_Range
           (This     : in     Spinner;
            Min, Max :    out Long_Float) is
    begin
        Min := Long_Float (fl_spinner_get_minimum (This.Void_Ptr));
        Max := Long_Float (fl_spinner_get_maximum (This.Void_Ptr));
    end Get_Range;


    procedure Set_Range
           (This     : in out Spinner;
            Min, Max : in     Long_Float) is
    begin
        fl_spinner_range
           (This.Void_Ptr,
            Interfaces.C.double (Min),
            Interfaces.C.double (Max));
    end Set_Range;


    function Get_Step
           (This : in Spinner)
        return Long_Float is
    begin
        return Long_Float (fl_spinner_get_step (This.Void_Ptr));
    end Get_Step;


    procedure Set_Step
           (This : in out Spinner;
            To   : in     Long_Float) is
    begin
        fl_spinner_set_step (This.Void_Ptr, Interfaces.C.double (To));
    end Set_Step;


    function Get_Type
           (This : in Spinner)
        return Spinner_Kind is
    begin
        return Spinner_Kind'Val (fl_spinner_get_type (This.Void_Ptr) - 1);
    end Get_Type;


    procedure Set_Type
           (This : in out Spinner;
            To   : in     Spinner_Kind) is
    begin
        fl_spinner_set_type (This.Void_Ptr, Spinner_Kind'Pos (To) + 1);
    end Set_Type;


    function Get_Value
           (This : in Spinner)
        return Long_Float is
    begin
        return Long_Float (fl_spinner_get_value (This.Void_Ptr));
    end Get_Value;


    procedure Set_Value
           (This : in out Spinner;
            To   : in     Long_Float) is
    begin
        fl_spinner_set_value (This.Void_Ptr, Interfaces.C.double (To));
    end Set_Value;




    procedure Draw
           (This : in out Spinner) is
    begin
        fl_spinner_draw (This.Void_Ptr);
    end Draw;


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


end FLTK.Widgets.Groups.Spinners;