DEFINITION MODULE Icon;

   (* This module defines types and procedures used for manipulating *)
   (* GEM graphic icon structures.                                   *)


   FROM SYSTEM IMPORT ADDRESS;
   IMPORT Screen;


   CONST
      Selectable  = 0;   (* Object Flags *)
      Default     = 1;
      Exit        = 2;
      Editable    = 3;
      RadioButton = 4;
      LastObject  = 5;
      TouchExit   = 6;
      HideTree    = 7;
      Indirect    = 8;

      Selected    = 0;   (* Object States *)
      Crossed     = 1;
      Checked     = 2;
      Disabled    = 3;
      Outlined    = 4;
      Shadowed    = 5;


   TYPE Object = RECORD
      Next   : CARDINAL;
      Head   : CARDINAL;
      Tail   : CARDINAL;
      Type   : CARDINAL;
      Flags  : BITSET;
      State  : BITSET;
      Spec   : ADDRESS;
      X      : CARDINAL;
      Y      : CARDINAL;
      Width  : CARDINAL;
      Height : CARDINAL;
   END;

   TYPE ObjectPtr = POINTER TO Object;

   TYPE Tedinfo = RECORD
      Text           : ADDRESS;
      Template       : ADDRESS;
      Valid          : ADDRESS;
      Font           : CARDINAL;
      Reserved1      : CARDINAL;
      Justification  : CARDINAL;
      Color          : CARDINAL;
      Reserved2      : CARDINAL;
      Thickness      : CARDINAL;
      TextLength     : CARDINAL;
      TemplateLength : CARDINAL;
   END;

   TYPE Iconblk = RECORD
      Mask       : ADDRESS;
      Data       : ADDRESS;
      Text       : ADDRESS;
      Char       : CARDINAL;
      CharX      : CARDINAL;
      CharY      : CARDINAL;
      IconX      : CARDINAL;
      IconY      : CARDINAL;
      IconWidth  : CARDINAL;
      IconHeight : CARDINAL;
      TextX      : CARDINAL;
      TextY      : CARDINAL;
      TextWidth  : CARDINAL;
      TextHeight : CARDINAL;
      Reserved   : CARDINAL;
   END;

   TYPE Bitblk = RECORD
      Data     : ADDRESS;
      Width    : CARDINAL;
      Height   : CARDINAL;
      X        : CARDINAL;
      Y        : CARDINAL;
      Color    : CARDINAL;
      Reserved : CARDINAL;
   END;

   TYPE Applblk = RECORD
      DrawRoutine : PROC;
      Parameters  : ADDRESS;
   END;

   TYPE Parmblk = RECORD
      ObjectTree    : ADDRESS;
      ObjectIndex   : CARDINAL;
      PreviousState : CARDINAL;
      CurrentState  : CARDINAL;
      ObjectX       : CARDINAL;
      ObjectY       : CARDINAL;
      ObjectWidth   : CARDINAL;
      ObjectHeight  : CARDINAL;
      ClipX         : CARDINAL;
      ClipY         : CARDINAL;
      ClipWidth     : CARDINAL;
      ClipHeight    : CARDINAL;
      Parameters    : ADDRESS;
   END;


   PROCEDURE GetAddress ( ObjectTree  : INTEGER;
                          ObjectIndex : INTEGER ) : ObjectPtr;

      (* Return a pointer to the specified object in a graphic *)
      (* icon tree.                                            *)


   PROCEDURE GetRegion ( Tree       : INTEGER;
                         Object     : INTEGER;
                         VAR Region : Screen.Box );

      (* Get the coordinates and size of the specified object. *)


   PROCEDURE SetOrigin ( Tree   : INTEGER;
                         Object : INTEGER;
                         Origin : Screen.PixelCoordinate );

      (* Set the origin of the object to the specified coordinate. *)


   PROCEDURE SetSize ( Tree    : INTEGER;
                       Object  : INTEGER;
                       NewSize : Screen.Area );

      (* Set the size of the object. *)


   PROCEDURE Enable (
      Tree    : (* IN *) INTEGER;
      Object  : (* IN *) INTEGER;
      ClipBox : (* IN *) Screen.Box );


   PROCEDURE Disable (
      Tree    : (* IN *) INTEGER;
      Object  : (* IN *) INTEGER;
      ClipBox : (* IN *) Screen.Box );


   PROCEDURE Select (
      Tree    : (* IN *) INTEGER;
      Object  : (* IN *) INTEGER;
      ClipBox : (* IN *) Screen.Box );


   PROCEDURE Deselect (
      Tree    : (* IN *) INTEGER;
      Object  : (* IN *) INTEGER;
      ClipBox : (* IN *) Screen.Box );


   PROCEDURE Find ( Tree            : INTEGER;
                    MouseCoordinate : Screen.PixelCoordinate;
                    VAR Object      : INTEGER ) : BOOLEAN;

      (* Search the tree for an object located under the mouse *)
      (* coordinate.  This routine returns "true" if an object *)
      (* was located, or "false" otherwise.                    *)


   PROCEDURE Display ( Tree    : INTEGER;
                       Object  : INTEGER;
                       ClipBox : Screen.Box );

      (* Display the specified object on the screen.  The object *)
      (* will be clipped to the size specified by "ClipBox".     *)


END Icon.

        GEMDOS.Read ( SourceId, Count, Buffer );
            IF Co