DEFINITION Graphics; (* portable *)

 IMPORT Files, Modules, Fonts, Texts;

  NameLen = 16;

  Graph = POINTER TO GraphDesc;
  Object = POINTER TO ObjectDesc;
  Method = POINTER TO MethodDesc;
  Line = POINTER TO LineDesc;
  Caption = POINTER TO CaptionDesc;
  Macro = POINTER TO MacroDesc;
  ObjectDesc = RECORD
   x, y, w, h, col: INTEGER;
   selected, marked: BOOLEAN;
   do: Method;


  WidMsg = RECORD ( Msg ) 

  ColorMsg = RECORD ( Msg ) 
   col: INTEGER END;

  FontMsg = RECORD ( Msg ) 
   fnt: Fonts.Font END;

  Name = ARRAY NameLen OF CHAR;
  GraphDesc = RECORD
   time: LONGINT;
   sel: Object

  MacHead = POINTER TO MacHeadDesc;
  MacExt = POINTER TO MacExtDesc;
  Library = POINTER TO LibraryDesc;
  MacHeadDesc = RECORD
   name: Name;
   w, h: INTEGER;
   ext: MacExt;
   lib: Library;

  LibraryDesc = RECORD
   name: Name;

  MacExtDesc = RECORD END;

  Context = RECORD

  MethodDesc = RECORD
   module, allocator: Name;
   new: Modules.Command;
   copy: PROCEDURE (from, to: Object);
   draw, handle: PROCEDURE (obj: Object; VAR msg: Msg);
   selectable: PROCEDURE (obj: Object; x, y: INTEGER): BOOLEAN;
   read: PROCEDURE (obj: Object; VAR R: Files.Rider; VAR C: Context);
   write: PROCEDURE (obj: Object; cno: SHORTINT; VAR R: Files.Rider; VAR C: Context);
   print: PROCEDURE (obj: Object; x, y: INTEGER)

  LineDesc = RECORD ( ObjectDesc ) 

  CaptionDesc = RECORD ( ObjectDesc ) 
   pos, len: INTEGER

  MacroDesc = RECORD ( ObjectDesc ) 
   mac: MacHead

  new: Object;
  width, res: INTEGER;
  T: Texts.Text;
  LineMethod, CapMethod, MacMethod: Method;
  scale: INTEGER;
 PROCEDURE Add (G: Graph; obj: Object);
 PROCEDURE Draw (G: Graph; VAR M: Msg);
 PROCEDURE ThisObj (G: Graph; x, y: INTEGER): Object;
 PROCEDURE SelectObj (G: Graph; obj: Object);
 PROCEDURE SelectArea (G: Graph; x0, y0, x1, y1: INTEGER);
 PROCEDURE Enumerate (G: Graph; handle: PROCEDURE (obj: Object; VAR done: BOOLEAN));
 PROCEDURE Deselect (G: Graph);
 PROCEDURE DrawSel (G: Graph; VAR M: Msg);
 PROCEDURE Handle (G: Graph; VAR M: Msg);
 PROCEDURE Move (G: Graph; dx, dy: INTEGER);
 PROCEDURE Copy (Gs, Gd: Graph; dx, dy: INTEGER);
 PROCEDURE Delete (G: Graph);
 PROCEDURE FontNo (VAR W: Files.Rider; VAR C: Context; fnt: Fonts.Font): SHORTINT;
 PROCEDURE Store (G: Graph; VAR W: Files.Rider);
 PROCEDURE WriteObj (VAR W: Files.Rider; cno: SHORTINT; obj: Object);
 PROCEDURE WriteFile (G: Graph; name: ARRAY OF CHAR);
 PROCEDURE Print (G: Graph; x0, y0: INTEGER);
 PROCEDURE ThisClass (VAR module, allocator: ARRAY OF CHAR): Modules.Command;
 PROCEDURE Font (VAR R: Files.Rider; VAR C: Context): Fonts.Font;
 PROCEDURE Load (G: Graph; VAR R: Files.Rider);
 PROCEDURE Open (G: Graph; name: ARRAY OF CHAR);
 PROCEDURE ThisLib (VAR name: ARRAY OF CHAR; replace: BOOLEAN): Library;
 PROCEDURE NewLib (VAR Lname: ARRAY OF CHAR): Library;
 PROCEDURE StoreLib (L: Library; VAR Fname: ARRAY OF CHAR);
 PROCEDURE RemoveLibraries;
 PROCEDURE ThisMac (L: Library; VAR Mname: ARRAY OF CHAR): MacHead;
 PROCEDURE OpenMac (mh: MacHead; G: Graph; x, y: INTEGER);
 PROCEDURE DrawMac (mh: MacHead; VAR M: Msg);
 PROCEDURE MakeMac (G: Graph; x, y, w, h: INTEGER; VAR Mname: ARRAY OF CHAR): MacHead;
 PROCEDURE InsertMac (mh: MacHead; L: Library; VAR new: BOOLEAN);
END Graphics.