(*$ Implementation- *)
DEFINITION MODULE Printer;
(* 4-Sep-96/Stefan Tiemann for Cyclone *)
(* Converted from C-include: printer.h 1.7 (26.7.90), Includes Release 40.15 *)

IMPORT ED: ExecD;
IMPORT GD: GraphicsD;

CONST
  rawWrite= ED.nonstd+0;
  prtCommand= ED.nonstd+1;
  dumpRPort= ED.nonstd+2;
  query= ED.nonstd+3;

  printerName= "printer.device";

(* printer command definitions *)

 ris=	 0;  (* ESCc  reset		      ISO *)
 rin=	 1;  (* ESC#1 initialize	      +++ *)
 ind=	 2;  (* ESCD  lf		      ISO *)
 nel=	 3;  (* ESCE  return,lf		      ISO *)
 ri=	 4;  (* ESCM  reverse lf	      ISO *)
 asgr0=	 5;  (* ESC[0m normal char set	      ISO *)
 sgr3=	 6;  (* ESC[3m italics on	      ISO *)
 sgr23=	 7;  (* ESC[23m italics off	      ISO *)
 sgr4=	 8;  (* ESC[4m underline on	      ISO *)
 sgr24=	 9;  (* ESC[24m underline off	      ISO *)
 sgr1=	10;  (* ESC[1m boldface on	      ISO *)
 sgr22=	11;  (* ESC[22m boldface off	      ISO *)
 sfc=	12;  (* SGR30-39  set foreground color ISO *)
 sbc=	13;  (* SGR40-49  set background color ISO *)

 shorp0= 14;  (* ESC[0w normal pitch	      DEC *)
 shorp2= 15;  (* ESC[2w elite on		      DEC *)
 shorp1= 16;  (* ESC[1w elite off	      DEC *)
 shorp4= 17;  (* ESC[4w condensed fine on       DEC *)
 shorp3= 18;  (* ESC[3w condensed off	      DEC *)
 shorp6= 19;  (* ESC[6w enlarged on	      DEC *)
 shorp5= 20;  (* ESC[5w enlarged off	      DEC *)

 den6=	21;  (* ESC[6"z shadow print on	      DEC (sort of) *)
 den5=	22;  (* ESC[5"z shadow print off       DEC *)
 den4=	23;  (* ESC[4"z doublestrike on	      DEC *)
 den3=	24;  (* ESC[3"z doublestrike off       DEC *)
 den2=	25;  (* ESC[2"z	NLQ on		      DEC *)
 den1=	26;  (* ESC[1"z	NLQ off	      DEC *)

 sus2=	27;  (* ESC[2v superscript on	      +++ *)
 sus1=	28;  (* ESC[1v superscript off	      +++ *)
 sus4=	29;  (* ESC[4v subscript on	      +++ *)
 sus3=	30;  (* ESC[3v subscript off	      +++ *)
 sus0=	31;  (* ESC[0v normalize the line      +++ *)
 plu=	32;  (* ESCL  partial line up	      ISO *)
 pld=	33;  (* ESCK  partial line down	      ISO *)

 fnt0=	34;  (* ESC(B US char set	or Typeface  0 (default) *)
 fnt1=	35;  (* ESC(R French char set	or Typeface  1 *)
 fnt2=	36;  (* ESC(K German char set	or Typeface  2 *)
 fnt3=	37;  (* ESC(A UK char set	or Typeface  3 *)
 fnt4=	38;  (* ESC(E Danish I char set	or Typeface  4 *)
 fnt5=	39;  (* ESC(H Sweden char set	or Typeface  5 *)
 fnt6=	40;  (* ESC(Y Italian char set	or Typeface  6 *)
 fnt7=	41;  (* ESC(Z Spanish char set	or Typeface  7 *)
 fnt8=	42;  (* ESC(J Japanese char set	or Typeface  8 *)
 fnt9=	43;  (* ESC(6 Norweign char set	or Typeface  9 *)
 fnt10=	44;  (* ESC(C Danish II char set or Typeface 10 *)

(*
	Suggested typefaces are:

	 0 - default typeface.
	 1 - Line Printer or equiv.
	 2 - Pica or equiv.
	 3 - Elite or equiv.
	 4 - Helvetica or equiv.
	 5 - Times Roman or equiv.
	 6 - Gothic or equiv.
	 7 - Script or equiv.
	 8 - Prestige or equiv.
	 9 - Caslon or equiv.
	10 - Orator or equiv.
*)

 prop2=	45;  (* ESC[2p  proportional on	      +++ *)
 prop1=	46;  (* ESC[1p  proportional off       +++ *)
 prop0=	47;  (* ESC[0p  proportional clear     +++ *)
 tss=	48;  (* ESC[n E set proportional offset ISO *)
 jfy5=	49;  (* ESC[5 F auto left justify      ISO *)
 jfy7=	50;  (* ESC[7 F auto right justify     ISO *)
 jfy6=	51;  (* ESC[6 F auto full justify      ISO *)
 jfy0=	52;  (* ESC[0 F auto justify off       ISO *)
 jfy3=	53;  (* ESC[3 F letter space (justify) ISO (special) *)
 jfy1=	54;  (* ESC[1 F word fill(auto center) ISO (special) *)

 verp0=	55;  (* ESC[0z  1/8" line spacing      +++ *)
 verp1=	56;  (* ESC[1z  1/6" line spacing      +++ *)
 slpp=	57;  (* ESC[nt  set form length n      DEC *)
 perf=	58;  (* ESC[nq  perf skip n (n>0)      +++ *)
 perf0=	59;  (* ESC[0q  perf skip off	      +++ *)

 lms=	60;  (* ESC#9   Left margin set	      +++ *)
 rms=	61;  (* ESC#0   Right margin set       +++ *)
 tms=	62;  (* ESC#8   Top margin set	      +++ *)
 bms=	63;  (* ESC#2   Bottom marg set	      +++ *)
 stbm=	64;  (* ESC[Pn1;Pn2r  T&B margins      DEC *)
 slrm=	65;  (* ESC[Pn1;Pn2s  L&R margin       DEC *)
 cam=	66;  (* ESC#3   Clear margins	      +++ *)

 hts=	67;  (* ESCH    Set horiz tab	      ISO *)
 vts=	68;  (* ESCJ    Set vertical tabs      ISO *)
 tbc0=	69;  (* ESC[0g  Clr horiz tab	      ISO *)
 tbc3=	70;  (* ESC[3g  Clear all h tab	      ISO *)
 tbc1=	71;  (* ESC[1g  Clr vertical tabs      ISO *)
 tbc4=	72;  (* ESC[4g  Clr all v tabs	      ISO *)
 tbcall= 73;  (* ESC#4   Clr all h & v tabs     +++ *)
 tbsall= 74;  (* ESC#5   Set default tabs       +++ *)
 extend= 75;  (* ESC[Pn"x extended commands     +++ *)

 raw=	76;	(* ESC[Pn"r	Next 'Pn' chars are raw +++ *)

TYPE
 Error= (noErr,			(* clean exit, no errors *)
         cancel,			(* user cancelled print *)
         notGraphics,		(* printer cannot output graphics *)
         invertHam,			(* OBSOLETE *)
         badDimension,		(* print dimensions illegal *)
         dimensionOvflow,	(* OBSOLETE *)
         internalMemory,		(* no memory for internal variables *)
         bufferMemory,		(* no memory for print buffer *)
(*
	Note : this is an internal error that can be returned from the render
	function to the printer device.  It is NEVER returned to the user.
	If the printer device sees this error it converts it 'PDERR_NOERR'
	and exits gracefully.  Refer to the document on
	'How to Write a Graphics Printer Driver' for more info.
*)
         tookControl	(* Took control in case 0 of render *)
        );
TYPE
 IOPrtCmdReq= RECORD
    message: ED.Message;
    device : ED.DevicePtr;     (* device node pointer  *)
    unit: ED.UnitPtr;	    (* unit (driver private)*)
    command: CARDINAL;	    (* device command *)
    flags: ED.IOFlagSet;
    error: Error;		    (* error or warning num *)
    prtCommand: CARDINAL;	    (* printer command *)
    parm0: SHORTCARD;		    (* first command parameter *)
    parm1: SHORTCARD;		    (* second command parameter *)
    parm2: SHORTCARD;		    (* third command parameter *)
    parm3: SHORTCARD;		    (* fourth command parameter *)
 END;
 IOPrtCmdReqPtr= POINTER TO IOPrtCmdReq;


 Special= (milCols,	(* DestCols specified in 1/1000" *)
           milRows,	(* DestRows specified in 1/1000" *)
           fullCols,	(* make DestCols maximum possible *)
           fullRows,	(* make DestRows maximum possible *)
           fracCols, (* DestCols is fraction of FULLCOLS *)
           fracRows,	(* DestRows is fraction of FULLROWS *)
           center,	(* center image on paper *)
           aspect,	(* ensure correct aspect ratio *)
           density1,	(* lowest resolution (dpi) *)
           density2,	(* next res *)
           density4,	(* next res *)
           noFormFeed,	(* don't eject paper on gfx prints *)
           trustMe,	(* don't reset on gfx prints *)
(*
	Compute print size, set 'io_DestCols' and 'io_DestRows' in the calling
	program's 'IODRPReq' structure and exit, DON'T PRINT.  This allows the
	calling program to see what the final print size would be in printer
	pixels.  Note that it modifies the 'io_DestCols' and 'io_DestRows'
	fields of your 'IODRPReq' structure.  Also, set the print density and
	update the 'MaxXDots', 'MaxYDots', 'XDotsInch', and 'YDotsInch' fields
	of the 'PrinterExtendedData' structure.
*)
           noPrint,	(* see above *)
           s14,s15
          );
 SpecialSet= SET OF Special;
(* internal use *)
CONST
 density3= SpecialSet{density1,density2};
 density5= SpecialSet{density1,density4};
 density6= SpecialSet{density2,density4};
 density7= SpecialSet{density1..density4};
 densityMask= SpecialSet{density1..density4};	(* masks out density values *)
 dimensionMask= SpecialSet{milCols..fracRows,aspect};

TYPE
 IODRPReq= RECORD
    message: ED.Message;
    device: ED.DevicePtr;     (* device node pointer  *)
    unit: ED.UnitPtr;	    (* unit (driver private)*)
    command: CARDINAL;	    (* device command *)
    flags: ED.IOFlagSet;
    error: Error;		    (* error or warning num *)
    rastPort: GD.RastPortPtr;  (* raster port *)
    colorMap: GD.ColorMapPtr;  (* color map *)
    modesHi: CARDINAL;		    (* graphics viewport modes *) // must be set to 0!!!
    modes: GD.ViewModeSet;
    srcX: CARDINAL;		    (* source x origin *)
    srcY: CARDINAL;		    (* source y origin *)
    srcWidth: CARDINAL;	    (* source x width *)
    srcHeight: CARDINAL;	    (* source x height *)
    destCols: LONGINT;	    (* destination x width *)
    destRows: LONGINT;	    (* destination y height *)
    special: SpecialSet;	    (* option flags *)
 END;
 IODRPReqPtr= POINTER TO IODRPReq;


 // M2Amiga compatibility
 PrinterIO = RECORD
  CASE :INTEGER OF
  | 0: ios: ED.IOStdReq;
  | 1: iodrp: IODRPReq;
  | 2: iopc: IOPrtCmdReq;
  END;
 END;
 PrinterIOPtr= POINTER TO PrinterIO;

 IOPrinter= IOPrtCmdReq;
 IOPrinterPtr= IOPrtCmdReqPtr;


END Printer.

