agpl_1.0.0_b5da3320/src/agpl-drawing-buffer.ads

  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
private with Ada.Containers.Indefinite_Doubly_Linked_Lists;

package Agpl.Drawing.Buffer is

   --  This doesn't draw anything, but instead allows to keep a copy of what
   --   a drawer is supposed to do.

   pragma Preelaborate;

   --  This type is the key abstraction to be used around...
   --  It can be flushed into another drawer, or it can be passed as a drawable
   --    to another drawer (useful when a drawable is expected)
   type object is new Drawer and Drawable with private;

   overriding
   procedure Draw_Line (This   : in out Object;
                        X1, Y1,
                        X2, Y2 : Float);

   overriding
   procedure Fill_Rectangle
     (This   : in out Object;
      X1, Y1,
      X2, Y2 : Float);

   overriding
   procedure Set_Color (This  : in out Object;
                        Rgb   :        Types.Rgb_Triplet;
                        Alpha :        Types.Unsigned_8);

   overriding
   procedure Write (This : in out Object;
                    X, Y : Float;
                    Utf8 : String);

   not overriding
   procedure Flush (This  :        Object;
                    Dest  : in out Drawer'Class);

   not overriding
   procedure Clear (This : in out Object);
   --  Start afresh

   not overriding
   procedure Flush_And_Clear (This  : in out Object;
                              Dest  : in out Drawer'Class);
   --  Send to another drawer (@dest@) the buffered commands,
   --    and optionally clear them to start afresh.

   overriding
   procedure Draw (This :        Object;
                   Dest : in out Drawer'Class);
   --  Flush to Dest

private

   type Action is abstract tagged null record;

   procedure Perform (This :        Action;
                      Dest : in out Drawer'Class) is abstract;
   --  Perform for real!

   package Action_Lists is
     new Ada.Containers.Indefinite_Doubly_Linked_Lists (Action'Class);

   type Object is new Drawer and Drawable with record
      Actions : Action_Lists.List;
   end record;

   type Action_Line is new Action with record
      X1, Y1, X2, Y2 : Float;
   end record;

   overriding
   procedure Perform (This :        Action_Line;
                      Dest : in out Drawer'Class);

   type Action_Fill is new Action with record
      X1, Y1, X2, Y2 : Float;
   end record;

   overriding
   procedure Perform (This :        Action_Fill;
                      Dest : in out Drawer'Class);

   type Action_Color is new Action with record
      Rgb   : Types.Rgb_triplet;
      Alpha : Types.Unsigned_8;
   end record;

   overriding
   procedure Perform (This :        Action_Color;
                      Dest : in out Drawer'Class);

   type Action_Write (Length : Natural) is new Action with record
      X, Y : Float;
      Utf8 : String (1 .. Length);
   end record;

   overriding
   procedure Perform (This :        Action_Write;
                      Dest : in out Drawer'Class);

end Agpl.Drawing.Buffer;