(*
 * Title: print.h
 * Purpose: access to printer driver facilities
 *
 *)

#ifndef print__h
#define print__h

const
  print_PostScript     = 0;
  print_FX80compatible = 1;

type print_identity_ptr = ^print_identity;
     print_identity = integer;


const
  print_colour      = $0000001;    (* colour                               *)
  print_limited     = $0000002;    (* if print_COLOUR bit set, full colour *)
                                   (* range not available                  *)
  print_discrete    = $0000004;    (* only a discrete colour set supported *)

  print_NOFILL      = $0000100;    (* cannot handle filled shapes well     *)
  print_NOTHICKNESS = $0000200;    (* cannot handle thick lines well       *)
  print_NOOVERWRITE = $0000400;    (* cannot overwrite colours properly    *)

(* const print_SCREENDUMP clashes with function print_screendump *)
#define print_SCREENDUMP $1000000  (* supports PDriver_ScreenDump          *)
  print_TRANSFORM   = $2000000;    (* supports arbitrary transformations   *)
                                   (* (else only axis-preserving ones).    *)
type print_features_ptr = ^print_features;
     print_features = integer;


type print_infostr_ptr = ^print_infostr;
     print_infostr =
       record
         version : short;        (* version number *100                   *)
         identity : short;   (* driver identity (eg 0=Postscript,1=FX80)  *)
         xres, yres : integer;   (* x, y resolution (pixels/inch)         *)
         features : integer;     (* see print_features                    *)
         description : string;   (* printers supported, <=20chars + null  *)
         xhalf, yhalf : integer; (* halftone resolution (repeats/inch)    *)
         number : integer        (* configured printer number             *)
       end;


type print_box_ptr = ^print_box;
     print_box =
       record
         x0, y0, x1, y1 : integer
       end;


type print_pagesizestr_ptr = ^print_pagesizestr;
     print_pagesizestr =
       record
         xsize, ysize : integer;
                      (* size of page, including margins (1/72000 inch)   *)
         bbox : print_box
                      (* bounding box of printable portion (1/72000 inch) *)
       end;


type print_transmatstr_ptr = ^print_transmatstr;
     print_transmatstr =
       record
         xx, xy, yx, yy : integer
       end;

type print_positionstr_ptr = ^print_positionstr;
     print_positionstr =
       record
         dx, dy : integer
       end;

(* ----------------------------- print_info ----------------------------
 * Description:  Read details of current printer driver (version, 
 *               resolution, features etc).
 *               
 * Parameters:   Pointer to print_infostr structure to be filled in.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_info(i : print_infostr_ptr) : os_error; extern;


(* ----------------------------- print_setinfo -------------------------
 * Description:  Reconfigure current printer driver.
 *               
 * Parameters:   Pointer to the print_infostr structure to be used to 
 *               update the printer driver configuration.
 * Returns:      Any error returned from the system call.
 * Other Info:   The version, identity and description fields are not 
 *               used. Leave bit 0 clear in the features field for 
 *               monochrome, set bit 0 for colour.
 *)
function print_setinfo(i : print_infostr_ptr) : os_error; extern;


(* ----------------------------- print_checkfeatures -------------------
 * Description:  Checks the features of a printer, returning an error if 
 *               the current printer does not have the specified 
 *               features.
 *               
 * Parameters:   int mask  -- set bits correspond to the features
 *                            of interest (bits as print_features)
 *               int value -- required values of the bits of interest
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_checkfeatures(mask, value : integer) : os_error; extern;


(* ----------------------------- print_pagesize ------------------------
 * Description:  Find how large paper and print area is.
 *               
 * Parameters:   Pointer to the print_pagesizestr structure to be
 *               filled in.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_pagesize(p : print_pagesizestr_ptr) : os_error; extern;


(* ----------------------------- print_setpagesize ---------------------
 * Description:  Set how large paper and print size is.
 *               
 * Parameters:   Pointer to the print_pagesizestr structure to be
 *               used to update the printer driver.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_setpagesize(p : print_pagesizestr_ptr) : os_error; extern;


(* ----------------------------- print_selectjob -----------------------
 * Description:  Make a given print job the current one.
 *               
 * Parameters:   int job      -- file handle for selected job, or 0
 *                               to leave no print job selected
 *               char *title  -- title string for job
 *               int *oldjobp -- pointer to integer to fill in with
 *                               file handle of previously active job
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_selectjob(job : integer;
                title : string;
                var oldjobp : integer) : os_error; extern;


(* ----------------------------- print_currentjob ----------------------
 * Description:  Get the file handle of the current print job.
 *               
 * Parameters:   Pointer to integer to be filled in with the
 *               file handle of the current print job.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_currentjob(var curjobp : integer) : os_error; extern;


(* ----------------------------- print_endjob --------------------------
 * Description:  End a print job normally.
 *               
 * Parameters:   File handle of print job to be ended.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_endjob(job : integer) : os_error; extern;


(* ----------------------------- print_abortjob ------------------------
 * Description:  End a print job without any further output.
 *               
 * Parameters:   File handle of print job to be aborted.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_abortjob(job : integer) : os_error; extern;


(* ----------------------------- print_canceljob -----------------------
 * Description:  Stops a specified print job from printing.
 *               
 * Parameters:   File handle of print job to be cancelled.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_canceljob(job : integer) : os_error; extern;


(* ----------------------------- print_reset ---------------------------
 * Description:  Abort all print jobs.
 *               
 * Parameters:   void
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_reset : os_error; extern;

(* ----------------------------- print_selectillustration --------------
 * Description:  Makes the specified print job the current one, 
 *               and treats it as an illustration.
 *               
 * Parameters:   int job      -- file handle for selected job, or 0
 *                               to leave no print job selected
 *               char *title  -- title string for job
 *               int *oldjobp -- pointer to integer to fill in with
 *                               file handle of previously active job
 * Returns:      Any error returned from the system call.
 * Other Info:   The difference with print_selectjob is that an 
 *               error is generated if the job does not contain 
 *               one page, and certain printer drivers (such as 
 *               the PostScript printer driver) generate 
 *               different output for illustrations.
 *)
function print_selectillustration(job : integer;
                title : string;
                var oldjobp : integer) : os_error; extern;


(* ----------------------------- print_giverectangle -------------------
 * Description:  Specify a rectangle to be printed.
 *               
 * Parameters:   ident -- rectangle identification word
 *               Pointer to structure specifying rectangle to be
 *                   plotted (OS coordinates)
 *               Pointer to structure specifying transformation
 *                   matrix (fixed point, 16 binary places)
 *               Pointer to structure containing  the position of
 *                   bottom left of rectangle on page (1/72000 inch)
 *               bgcol -- background colour for this rectangle, &BBGGRRXX
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_giverectangle(ident : integer;
                r : print_box_ptr;
                m : print_transmatstr_ptr;
                p : print_positionstr_ptr) : os_error; extern;


(* ----------------------------- print_drawpage ------------------------
 * Description:  This should be called after specifying all rectangles 
 *               to be plotted on the current page with 
 *               print_giverectangle.
 *               
 * Parameters:   copies -- number of copies
 *               sequ   -- zero or pages sequence number within document
 *               page   -- zero or a string containing a textual page number
 *                         (no spaces)
 *               Pointer to structure to be filled in with the rectangle 
 *               to print
 *               more   -- pointer to integer to be filled in with the 
 *                         number of copies left to print
 *               ident  -- pointer to integer to be filled in with the 
 *                         rectangle identification word
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_drawpage(copies : integer;
                sequ : integer;
                page : string;
                clip : print_box_ptr;
                var more : integer;
                var ident : integer) : os_error; extern;


(* ----------------------------- print_getrectangle --------------------
 * Description:  Get the next print rectangle.
 *               
 * Parameters:   Pointer to the structure to be filled in with the clip
 *                   rectangle
 *               more  -- pointer to integer to be filled in with the number
 *                        of rectangles left to print
 *               ident -- pointer to integer to be filled in with the 
 *                        rectangle identification word
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_getrectangle(clib : print_box_ptr;
                var more : integer;
                var ident : integer) : os_error; extern;


(* ----------------------------- print_screendump ----------------------
 * Description:  Output a screen dump to the printer.
 *               
 * Parameters:   File handle of file to receive the dump.
 * Returns:      Any error returned from the system call.
 * Other Info:   none.
 *)
function print_screendump(job : integer) : os_error; extern;

#endif
