summaryrefslogtreecommitdiff
path: root/src/grids.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/grids.ads')
-rw-r--r--src/grids.ads91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/grids.ads b/src/grids.ads
new file mode 100644
index 0000000..af2971b
--- /dev/null
+++ b/src/grids.ads
@@ -0,0 +1,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;
+