(*******************************************************************)
(** Release history:                                              **)
(**    17th January 1985   version 1.0.0 First port to new world  **)
(*******************************************************************)
DEFINITION MODULE GraphicsIP;
FROM Graphics    IMPORT GSTREAM, COLOUR, TEXT, MARKER, CURSOR;
FROM Polysys     IMPORT POLYGON;
FROM SYSTEM      IMPORT WORD;
FROM Strings     IMPORT String;
FROM Streams     IMPORT Stream;
EXPORT QUALIFIED gstreamIP, colourIP, textIP, markerIP, cursorIP,
                 NullDevNo, DebugDevNo, BBCDevNo, HPDevNo,
                 DeviceDriver;
CONST (* Supported to date *)
      NullDevNo = 0 * 1024;
     DebugDevNo = 1 * 1024;  (* Also used as a template for new drivers *)
       BBCDevNo = 2 * 1024;
        HPDevNo = 3 * 1024;
TYPE
  ColourIP        = PROCEDURE (GSTREAM, ARRAY OF CHAR) :COLOUR;
  TextStyleIP     = PROCEDURE (GSTREAM, ARRAY OF CHAR) :TEXT;
  MarkerIP        = PROCEDURE (GSTREAM, ARRAY OF CHAR) :MARKER;
  CursorIP        = PROCEDURE (GSTREAM, ARRAY OF CHAR) :CURSOR;
  SetLineColourIP = PROCEDURE (GSTREAM, COLOUR);
  SetAreaColourIP = PROCEDURE (GSTREAM, COLOUR);
  SetTextStyleIP  = PROCEDURE (GSTREAM, TEXT);
  SetCursorIP     = PROCEDURE (GSTREAM, CURSOR);
  SurfaceIP       = PROCEDURE (GSTREAM, INTEGER,INTEGER,INTEGER,INTEGER);
  CommandIP       = PROCEDURE (GSTREAM, ARRAY OF CHAR) :INTEGER;
  MoveToIP        = PROCEDURE (GSTREAM, INTEGER,INTEGER);
  LineToIP        = PROCEDURE (GSTREAM, INTEGER,INTEGER);
  MarkerAtIP      = PROCEDURE (GSTREAM, INTEGER,INTEGER, MARKER);
  TextAtIP        = PROCEDURE (GSTREAM, INTEGER,INTEGER, ARRAY OF CHAR);
  BoxIP           = PROCEDURE (GSTREAM, INTEGER,INTEGER,INTEGER,INTEGER);
  TextBoxIP       = PROCEDURE (GSTREAM, INTEGER,INTEGER,INTEGER,INTEGER,
                               ARRAY OF CHAR);
  DrawPolygonIP   = PROCEDURE (GSTREAM, POLYGON);
  ReadCursorIP    = PROCEDURE (GSTREAM, INTEGER,INTEGER,INTEGER,INTEGER,
                               VAR INTEGER,VAR INTEGER,
                               VAR ARRAY OF CHAR);
  DeleteIP        = PROCEDURE (GSTREAM);
  UpdateIP        = PROCEDURE (GSTREAM);

  DeviceDriver =  POINTER TO RECORD
    Colour        :ColourIP;
    TextStyle     :TextStyleIP;
    Marker        :MarkerIP;
    Cursor        :CursorIP;
    SetLineColour :SetLineColourIP;
    SetAreaColour :SetAreaColourIP;
    SetTextStyle  :SetTextStyleIP;
    SetCursor     :SetCursorIP;
    Surface       :SurfaceIP;
    Command       :CommandIP;
    MoveTo        :MoveToIP;
    LineTo        :LineToIP;
    MarkerAt      :MarkerAtIP;
    TextAt        :TextAtIP;
    Box           :BoxIP;
    TextBox       :TextBoxIP;
    DrawPolygon   :DrawPolygonIP;
    ReadCursor    :ReadCursorIP;
    Delete        :DeleteIP;
    Update        :UpdateIP;
  END ;

  gstreamIP = POINTER TO RECORD
    StreamNo  : INTEGER;
    Procedure : DeviceDriver;
    (* Every stream for a particular device points to a single copy of
       the device driver record which is set up by the device driver itself
       in its local module workspace. This is acceptable as the low-level
       device driver is necessarily a monitor.
       *)
    InStream, OutStream :Stream;
    DeviceState         :WORD
    (* DeviceState holds the current state of the device as seen in real-
       life, rather than as seen by the package. For example:
       The HP plotter may hold the red pen in its carousel, but the visible
       'LineColour' variable may be green - if the package is attempting
       to optimise redundant pen selections. (This could happen if the
       pen is changed from the current line colour to the colour needed to
       draw a polygon, and is changed back after the polygon has been drawn.
       If another polygon were drawn immediately, yet another pen would be
       selected thus making the re-selection of the current line colour
       redundant. *)
  END;

(* The device-dependents field of the following records are WORDs which point
   to an implementation specific data structure.
 *)

  colourIP  = POINTER TO RECORD
    Name        :String;
    DeviceHook  :WORD;
  END;
  textIP    = POINTER TO RECORD
    Name       :String;  (* For diagnostic assistance *)
    DeviceHook :WORD
  END;
  markerIP  = POINTER TO RECORD
    Name       :String;  (* For diagnostic assistance *)
    DeviceHook :WORD
  END;
  cursorIP  = POINTER TO RECORD
    Name       :String;  (* For diagnostic assistance *)
    DeviceHook :WORD
  END;

END GraphicsIP.
