summaryrefslogtreecommitdiff
path: root/spec/fltk-widgets-groups-tables.ads
blob: 5b526233292c2aa26623f1e253e0be5db0c5f376 (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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616


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


with

    FLTK.Widgets.Groups.Scrolls,
    FLTK.Widgets.Valuators.Sliders.Scrollbars;

private with

    Interfaces.C,
    System;


package FLTK.Widgets.Groups.Tables is


    type Table is new Group with private;

    type Table_Reference (Data : not null access Table'Class) is limited null record
        with Implicit_Dereference => Data;

    type Table_Context is
       (No_Context,    Start_Page,  End_Page,  Row_Header,
        Column_Header, Within_Cell, Dead_Zone, Row_Column_Resize);

    type Resize_Flag is (Resize_None, Column_Left, Column_Right, Row_Above, Row_Below);

    type Tab_Navigation is (Widget_Focus, Navigate_Cells);


    Range_Error : exception;




    package Forge is

        function Create
               (X, Y, W, H : in Integer;
                Text       : in String := "")
            return Table;

        function Create
               (Parent     : in out Groups.Group'Class;
                X, Y, W, H : in     Integer;
                Text       : in     String := "")
            return Table;

    end Forge;




    function H_Bar
           (This : in out Table)
        return Valuators.Sliders.Scrollbars.Scrollbar_Reference;

    function V_Bar
           (This : in out Table)
        return Valuators.Sliders.Scrollbars.Scrollbar_Reference;

    function Scroll_Area
           (This : in out Table)
        return Scrolls.Scroll_Reference;




    procedure Add
           (This : in out Table;
            Item : in out Widget'Class);

    procedure Insert
           (This  : in out Table;
            Item  : in out Widget'Class;
            Place : in     Index);

    procedure Insert
           (This   : in out Table;
            Item   : in out Widget'Class;
            Before : in     Widget'Class);

    procedure Remove
           (This : in out Table;
            Item : in out Widget'Class);

    procedure Clear
           (This : in out Table);




    function Has_Child
           (This  : in Table;
            Place : in Index)
        return Boolean;

    function Has_Child
           (Place : in Cursor)
        return Boolean;

    function Child
           (This  : in Table;
            Place : in Index)
        return Widget_Reference
    with Pre => This.Has_Child (Place);

    function Child
           (This  : in Table;
            Place : in Cursor)
        return Widget_Reference;

    function Find
           (This : in Table;
            Item : in Widget'Class)
        return Extended_Index;

    function Number_Of_Children
           (This : in Table)
        return Natural;

    function Used_As_Container
           (This : in Table)
        return Boolean;




    procedure Begin_Current
           (This : in out Table);

    procedure End_Current
           (This : in out Table);




    procedure Set_Callback
           (This : in out Table;
            Func : in     Widget_Callback);

    function Callback_Column
           (This : in Table)
        return Positive;

    function Callback_Row
           (This : in Table)
        return Positive;

    function Callback_Context
           (This : in Table)
        return Table_Context;

    procedure Do_Callback
           (This        : in out Table;
            Context     : in     Table_Context;
            Row, Column : in     Positive);

    procedure Set_When
           (This  : in out Table;
            Value : in     Callback_Flag);

    --  This is the callback used for the horizontal and vertical scrollbars
    --  inside the Table object. Assigning it to other widgets will cause errors.
    procedure Scroll_Callback
           (Item : in out Widget'Class);




    function Column_Headers_Enabled
           (This : in Table)
        return Boolean;

    procedure Set_Column_Headers
           (This  : in out Table;
            Value : in     Boolean);

    function Get_Column_Header_Color
           (This : in Table)
        return Color;

    procedure Set_Column_Header_Color
           (This  : in out Table;
            Value : in     Color);

    function Get_Column_Header_Height
           (This : in Table)
        return Positive;

    procedure Set_Column_Header_Height
           (This  : in out Table;
            Value : in     Positive);

    function Get_Column_Width
           (This   : in Table;
            Column : in Positive)
        return Positive;

    procedure Set_Column_Width
           (This   : in out Table;
            Column : in     Positive;
            Value  : in     Positive);

    procedure Set_All_Columns_Width
           (This  : in out Table;
            Value : in     Positive);

    function Get_Columns
           (This : in Table)
        return Natural;

    procedure Set_Columns
           (This  : in out Table;
            Value : in     Natural);

    function Get_Column_Position
           (This : in Table)
        return Positive;

    procedure Set_Column_Position
           (This  : in out Table;
            Value : in     Positive);

    function Get_Column_Scroll_Position
           (This   : in Table;
            Column : in Positive)
        return Long_Integer;

    function Column_Resize_Allowed
           (This : in Table)
        return Boolean;

    procedure Set_Column_Resize
           (This  : in out Table;
            Value : in     Boolean);

    function Get_Column_Resize_Minimum
           (This : in Table)
        return Positive;

    procedure Set_Column_Resize_Minimum
           (This  : in out Table;
            Value : in     Positive);




    function Row_Headers_Enabled
           (This : in Table)
        return Boolean;

    procedure Set_Row_Headers
           (This  : in out Table;
            Value : in     Boolean);

    function Get_Row_Header_Color
           (This : in Table)
        return Color;

    procedure Set_Row_Header_Color
           (This  : in out Table;
            Value : in     Color);

    function Get_Row_Header_Width
           (This : in Table)
        return Positive;

    procedure Set_Row_Header_Width
           (This  : in out Table;
            Value : in     Positive);

    function Get_Row_Height
           (This : in Table;
            Row  : in Positive)
        return Positive;

    procedure Set_Row_Height
           (This  : in out Table;
            Row   : in     Positive;
            Value : in     Positive);

    procedure Set_All_Rows_Height
           (This  : in out Table;
            Value : in     Positive);

    function Get_Rows
           (This : in Table)
        return Natural;

    procedure Set_Rows
           (This  : in out Table;
            Value : in     Natural);

    function Get_Row_Position
           (This : in Table)
        return Positive;

    procedure Set_Row_Position
           (This  : in out Table;
            Value : in     Positive);

    function Get_Row_Scroll_Position
           (This : in Table;
            Row  : in Positive)
        return Long_Integer;

    function Row_Resize_Allowed
           (This : in Table)
        return Boolean;

    procedure Set_Row_Resize
           (This  : in out Table;
            Value : in     Boolean);

    function Get_Row_Resize_Minimum
           (This : in Table)
        return Positive;

    procedure Set_Row_Resize_Minimum
           (This  : in out Table;
            Value : in     Positive);

    function Get_Top_Row
           (This : in Table)
        return Positive;

    procedure Set_Top_Row
           (This  : in out Table;
            Value : in     Positive);




    procedure Set_Cursor_Kind
           (This : in out Table;
            Kind : in     Mouse_Cursor_Kind);

    procedure Cursor_To_Row_Column
           (This        : in     Table;
            Row, Column :    out Positive;
            Context     :    out Table_Context;
            Resize      :    out Resize_Flag);

    --  Unsure if Row_Bottom and Column_Right can ever be zero, but just to be safe...
    procedure Get_Visible_Cells
           (This         : in     Table;
            Row_Top      :    out Positive;
            Column_Left  :    out Positive;
            Row_Bottom   :    out Natural;
            Column_Right :    out Natural);

    procedure Get_Selection
           (This         : in     Table;
            Row_Top      :    out Positive;
            Column_Left  :    out Positive;
            Row_Bottom   :    out Positive;
            Column_Right :    out Positive);

    procedure Set_Selection
           (This         : in out Table;
            Row_Top      : in     Positive;
            Column_Left  : in     Positive;
            Row_Bottom   : in     Positive;
            Column_Right : in     Positive);

    function Is_Selected
           (This        : in Table;
            Row, Column : in Positive)
        return Boolean;

    procedure Move_Cursor
           (This         : in out Table;
            Row, Column  : in     Positive;
            Shift_Select : in     Boolean := True);

    function Move_Cursor
           (This         : in out Table;
            Row, Column  : in     Positive;
            Shift_Select : in     Boolean := True)
        return Boolean;

    function Get_Tab_Mode
           (This : in Table)
        return Tab_Navigation;

    procedure Set_Tab_Mode
           (This  : in out Table;
            Value : in     Tab_Navigation);

    function Get_Table_Box
           (This : in Table)
        return Box_Kind;

    procedure Set_Table_Box
           (This : in out Table;
            Box  : in     Box_Kind);




    function Get_Scrollbar_Size
           (This : in Table)
        return Integer;

    procedure Set_Scrollbar_Size
           (This  : in out Table;
            Value : in     Integer);

    procedure Resize
           (This       : in out Table;
            X, Y, W, H : in     Integer);

    function Is_Interactive_Resize
           (This : in Table)
        return Boolean;

    procedure Reset_Sizes
           (This : in out Table);

    procedure Recalculate_Dimensions
           (This : in out Table);

    procedure Table_Resized
           (This : in out Table);

    procedure Table_Scrolled
           (This : in out Table);




    procedure Draw
           (This : in out Table);

    --  Derived types must override this to handle drawing cells
    procedure Draw_Cell
           (This        : in out Table;
            Context     : in     Table_Context;
            Row, Column : in     Natural := 0;
            X, Y, W, H  : in     Integer := 0);

    procedure Redraw_Range
           (This         : in out Table;
            Row_Top      : in     Positive;
            Column_Left  : in     Positive;
            Row_Bottom   : in     Positive;
            Column_Right : in     Positive);

    procedure Damage_Zone
           (This         : in out Table;
            Row_Top      : in     Positive;
            Column_Left  : in     Positive;
            Row_Bottom   : in     Positive;
            Column_Right : in     Positive;
            Reach_Row    : in     Positive := 1;
            Reach_Column : in     Positive := 1);

    procedure Cell_Dimensions
           (This        : in     Table;
            Context     : in     Table_Context;
            Row, Column : in     Positive;
            X, Y, W, H  :    out Integer);

    procedure Bounding_Region
           (This       : in     Table;
            Context    : in     Table_Context;
            X, Y, W, H :    out Integer);

    procedure Row_Column_Clamp
           (This        : in     Table;
            Context     : in     Table_Context;
            Row, Column : in out Integer);

    function Row_Column_Clamp
           (This        : in     Table;
            Context     : in     Table_Context;
            Row, Column : in out Integer)
        return Boolean;

    function Handle
           (This  : in out Table;
            Event : in     Event_Kind)
        return Event_Outcome;


private


    type Table is new Group with record
        Horizon, Vertigo : aliased Valuators.Sliders.Scrollbars.Scrollbar;
        Playing_Area     : aliased Scrolls.Scroll;
        Draw_Cell_Ptr    : System.Address;
    end record;

    overriding procedure Initialize
           (This : in out Table);

    overriding procedure Finalize
           (This : in out Table);

    procedure Extra_Init
           (This       : in out Table;
            X, Y, W, H : in     Integer;
            Text       : in     String);

    procedure Extra_Final
           (This : in out Table);


    function To_Cint
           (Context : in Table_Context)
        return Interfaces.C.int;

    function To_Context
           (Value : in Interfaces.C.int)
        return Table_Context;


    pragma Inline (H_Bar);
    pragma Inline (V_Bar);
    pragma Inline (Scroll_Area);

    pragma Inline (Add);
    pragma Inline (Insert);
    pragma Inline (Remove);

    pragma Inline (Has_Child);
    pragma Inline (Find);
    pragma Inline (Number_Of_Children);
    pragma Inline (Used_As_Container);

    pragma Inline (Begin_Current);
    pragma Inline (End_Current);

    pragma Inline (Set_Callback);
    pragma Inline (Callback_Column);
    pragma Inline (Callback_Row);
    pragma Inline (Callback_Context);
    pragma Inline (Do_Callback);
    pragma Inline (Set_When);
    pragma Inline (Scroll_Callback);

    pragma Inline (Column_Headers_Enabled);
    pragma Inline (Set_Column_Headers);
    pragma Inline (Get_Column_Header_Color);
    pragma Inline (Set_Column_Header_Color);
    pragma Inline (Get_Column_Header_Height);
    pragma Inline (Set_Column_Header_Height);
    pragma Inline (Get_Column_Width);
    pragma Inline (Set_Column_Width);
    pragma Inline (Set_All_Columns_Width);
    pragma Inline (Get_Columns);
    pragma Inline (Set_Columns);
    pragma Inline (Get_Column_Position);
    pragma Inline (Set_Column_Position);
    pragma Inline (Get_Column_Scroll_Position);
    pragma Inline (Column_Resize_Allowed);
    pragma Inline (Set_Column_Resize);
    pragma Inline (Get_Column_Resize_Minimum);
    pragma Inline (Set_Column_Resize_Minimum);

    pragma Inline (Row_Headers_Enabled);
    pragma Inline (Set_Row_Headers);
    pragma Inline (Get_Row_Header_Color);
    pragma Inline (Set_Row_Header_Color);
    pragma Inline (Get_Row_Header_Width);
    pragma Inline (Set_Row_Header_Width);
    pragma Inline (Get_Row_Height);
    pragma Inline (Set_Row_Height);
    pragma Inline (Set_All_Rows_Height);
    pragma Inline (Get_Rows);
    pragma Inline (Set_Rows);
    pragma Inline (Get_Row_Position);
    pragma Inline (Set_Row_Position);
    pragma Inline (Get_Row_Scroll_Position);
    pragma Inline (Row_Resize_Allowed);
    pragma Inline (Set_Row_Resize);
    pragma Inline (Get_Row_Resize_Minimum);
    pragma Inline (Set_Row_Resize_Minimum);
    pragma Inline (Get_Top_Row);
    pragma Inline (Set_Top_Row);

    pragma Inline (Set_Cursor_Kind);
    pragma Inline (Set_Selection);
    pragma Inline (Is_Selected);
    pragma Inline (Move_Cursor);
    pragma Inline (Get_Tab_Mode);
    pragma Inline (Set_Tab_Mode);
    pragma Inline (Get_Table_Box);
    pragma Inline (Set_Table_Box);

    pragma Inline (Get_Scrollbar_Size);
    pragma Inline (Set_Scrollbar_Size);
    pragma Inline (Resize);
    pragma Inline (Is_Interactive_Resize);
    pragma Inline (Reset_Sizes);
    pragma Inline (Recalculate_Dimensions);
    pragma Inline (Table_Resized);
    pragma Inline (Table_Scrolled);

    pragma Inline (Draw);
    pragma Inline (Redraw_Range);
    pragma Inline (Damage_Zone);
    pragma Inline (Cell_Dimensions);
    pragma Inline (Bounding_Region);
    pragma Inline (Handle);


end FLTK.Widgets.Groups.Tables;