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
|
with
FLTK.Widgets,
Squares;
private with
Ada.Containers.Vectors;
package Grids is
type Grid is new FLTK.Widgets.Widget with private;
-- Don't use this.
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Grid;
-- Use this instead.
function Create
(X, Y : in Integer)
return Grid;
procedure Draw
(This : in out Grid);
-- Meant for Displays to adjust the Grid.
procedure Set_Cols
(This : in out Grid;
To : in Natural);
-- Meant for Displays to adjust the Grid.
procedure Set_Rows
(This : in out Grid;
To : in Natural);
function In_Bounds
(This : in Grid;
X, Y : in Integer)
return Boolean;
function Get_Square
(This : in Grid;
X, Y : in Integer)
return Squares.Square;
procedure Set_Square
(This : in out Grid;
X, Y : in Integer;
Item : in Squares.Square)
with Pre => This.In_Bounds (X, Y);
private
Empty_Square : aliased Squares.Square := Squares.Void;
Step : constant Natural := 40;
package Square_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Squares.Square,
"=" => Squares."=");
package Square_Vector_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Square_Vectors.Vector,
"=" => Square_Vectors."=");
type Grid is new FLTK.Widgets.Widget with record
Cells : Square_Vector_Vectors.Vector;
Rows, Cols : Integer;
end record;
end Grids;
|