DEFINITION MODULE IntuiCommon;

              (* * * * * * * * * * * * * * * * * * * * * * *)
              (* Common Intuition-related routines.        *)
	      (* Originally written for the TDI package,   *)
	      (* but was quickly modified for the Oxxi     *)
	      (* compiler.                                 *)
              (*                                           *)
	      (* (c) Copyright 1987 by Steve Faiwiszewski. *)
	      (* This program may be freely distributed,   *)
	      (* but it is not to be sold.                 *)
	      (* Please leave this notice intact.          *)
              (* * * * * * * * * * * * * * * * * * * * * * *)

FROM Rasters   IMPORT DrawModeSet;
FROM Views     IMPORT ViewModesSet;
FROM Intuition IMPORT Border, BorderPtr, Gadget, GadgetPtr,
		      GadgetFlagsSet, RememberPtr,
		      GadgetActivationSet, GadgetTypeSet,
                      Requester, IntuiText, ScreenPtr,
		      IDCMPFlagsSet, WindowFlagsSet, WindowPtr,
                      IntuiTextPtr, Menu, MenuPtr, MenuItem,
		      MenuItemPtr;
FROM SYSTEM    IMPORT BYTE, ADDRESS;

TYPE
    CoordinateType = RECORD
                        Left,
                        Top  : INTEGER;
                     END;    

    StandardCoordType = ARRAY [0..4] OF CoordinateType;

VAR
    RKey: RememberPtr;

PROCEDURE ReleaseAllocations;

PROCEDURE InitMenuRec (VAR Amenu : Menu;
                       left, top, width, height : INTEGER;
                       text : ADDRESS) : MenuPtr;
(* Initialize a menu record.        *)

PROCEDURE InitItemRec (VAR mi : MenuItem;
                       left, top,
		       width, height : INTEGER;
                       Cmd : CHAR;
		       ItemFillPtr : ADDRESS) : MenuItemPtr;
(* Initialize an item record.       *)

PROCEDURE InitTextRec (VAR it : IntuiText;
                       left, top : INTEGER;
                       front, back : BYTE;
		       Mode : DrawModeSet;
                       text : ADDRESS) : IntuiTextPtr;
(* Initialize menu text record.     *)


PROCEDURE InitBorder(VAR border : Border;
                     Left, Top : INTEGER;
                     Front, Back,
                     count : BYTE;
		     Mode : DrawModeSet;
                     Coords : ADDRESS;
                     Next : BorderPtr);


PROCEDURE InitReq(VAR requester : Requester;
                  Left, Top : INTEGER;
                  width, height : INTEGER;
                  gadget : GadgetPtr;
                  border : BorderPtr;
                  Text   : IntuiTextPtr;
                  Fill   : BYTE);
(* Initialize a requester *)

PROCEDURE InitCoordEntry(VAR coords : ARRAY OF CoordinateType;
                         offset : CARDINAL;
                         left, top : INTEGER);
(* Initialize coordinates *)

PROCEDURE SetUpSimpleBorder(VAR Coords: ARRAY OF CoordinateType;
                       GadWidth, GadHeight : CARDINAL;
                       VAR border : Border;
                       Left, Top : INTEGER;
                       Front, Back,
                       count : BYTE;
		       Mode : DrawModeSet;
                       NextBorder : BorderPtr);
(* Initialize a border *)

PROCEDURE AllocateStandardBorder(Width, Height : CARDINAL;
                         Front, Back : BYTE;
			 Mode : DrawModeSet): BorderPtr;
(* Create a simple rectangular border *)

PROCEDURE AllocateReqBorder(Width, Height : CARDINAL;
                         Front, Back : BYTE;
			 Mode : DrawModeSet): BorderPtr;
(* Same as AllocateStandardBorder, with minor   *)
(* variation for requesters 			*)

PROCEDURE InitGadget(VAR gadget : Gadget;
                      Left, Top : INTEGER;
                      width, height : INTEGER;
                      flags : GadgetFlagsSet;
                      Activate : GadgetActivationSet;
                      Type : GadgetTypeSet;
                      Render : ADDRESS;
                      Select : ADDRESS;
                      Special: ADDRESS;
                      ID     : CARDINAL;
                      User   : ADDRESS;
                      Text   : IntuiTextPtr) : GadgetPtr;
(* Initialize a gadget *)

PROCEDURE AddGadgetToList(VAR GadList : GadgetPtr;
                          Left, Top : INTEGER;
                          width, height : INTEGER;
                          flags : GadgetFlagsSet;
                          Activate : GadgetActivationSet;
                          Type : GadgetTypeSet;
                          Render : ADDRESS;
                          Select : ADDRESS;
                          Special: ADDRESS;
                          ID     : CARDINAL;
                          User   : ADDRESS;
                          Text   : IntuiTextPtr) : GadgetPtr;
(* Initialize a gadget and add it to a gadget list *)

PROCEDURE OpenSimpleScreen(width,height,depth : CARDINAL;
                       modeset : ViewModesSet;
		       Title : ADDRESS) : ScreenPtr;

PROCEDURE OpenSimpleWindow(width,height,left,top : CARDINAL;
			title : ADDRESS;
			flags : WindowFlagsSet;
			idcmpflags : IDCMPFlagsSet;
			gadget : GadgetPtr;
			screen : ScreenPtr) : WindowPtr;


PROCEDURE SetScreenColors(screen : ScreenPtr;
			  data : ARRAY OF CHAR);

END IntuiCommon.
