/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    PDriver.h
    Author:  Copyright  1993, 1994 Jason Howat (and a bit by Jason Williams)
    Version: 1.11 (22 Oct 1994)
    Purpose: SWI veneers for using printer drivers (the PDriver module)
*/



#ifndef __dl_pdriver_h
#define __dl_pdriver_h

#ifdef __cplusplus
extern "C" {
#endif


#ifndef __dl_core_h
#include "Core.h"
#endif

#ifndef __dl_wimp_h
#include "Wimp.h"
#endif



typedef int print_job;                  /* actually a RISC OS file handle */

typedef struct
{
  int xx;
  int xy;
  int yx;
  int yy;
} print_transformation;                 /* See pg 1554 of the RISC OS 2 PRMs */

                                        /* Values for the drivertype field
                                           of printer_info                 */
#define printdriver_POSTSCRIPT          0
#define printdriver_FX80                1
#define printdriver_LASERJET            2
#define printdriver_INTEGREX            3   
#define printdriver_FAXMODEM            4
#define printdriver_DIRECTDRIVELASER    5
#define printdriver_CASPELGRAPHLANG     6
#define printdriver_PDUMPER             7
#define printdriver_EPSONJX             99
#define printdriver_STARLC10            99
#define printdriver_PAINTJET            99


        /* These #defines represent the bits of the 'features' word */
#define printfeat_COLOUR         0x00000001
#define printfeat_LIMITED        0x00000002
#define printfeat_DISCRETE       0x00000004
#define printfeat_NOFILL         0x00000100
#define printfeat_NOTHICKNESS    0x00000200
#define printfeat_NOOVERWRITE    0x00000400
#define printfeat_TRANSSPRITE    0x00000800
#define printfeat_NEWFONTMANAGER 0x00001000
#define printfeat_SCREENDUMP     0x01000000
#define printfeat_TRANSFORMS     0x02000000
#define printfeat_ILLUSTRATIONS  0x04000000
#define printfeat_MISCOP         0x08000000
#define printfeat_SETDRIVER      0x10000000
#define printfeat_DECLAREFONT    0x20000000


        /* The 'features' word represented as a structure. */
typedef union
{
  int value;
  struct
  {
    unsigned int colour         : 1;
    unsigned int limited        : 1;
    unsigned int discrete       : 1;
    unsigned int filler1        : 5;   /* reserved */
    unsigned int nofill         : 1;
    unsigned int nothickness    : 1;
    unsigned int nooverwrite    : 1;
    unsigned int transsprite    : 1;
    unsigned int newfontmanager : 1;
    unsigned int filler2        : 3;   /* reserved */
    unsigned int filler3        : 8;   /* reserved */
    unsigned int screendump     : 1;
    unsigned int transforms     : 1;
    unsigned int illustrations  : 1;
    unsigned int miscop         : 1;
    unsigned int setdriver      : 1;
    unsigned int declarefont    : 1;
    unsigned int filler4        : 2;   /* reserved */
  } data;
} print_features;


typedef struct
{
  unsigned int     version    : 16;
  int              drivertype : 16;
  wimp_point       resolution;
  print_features   features;
  char             *description;
  wimp_point       halftone_res;
  int              id_number;
} printer_info;                  /* info returned by PDriver_Info (pg 1539) */



os_error *PDriver_Info(printer_info *block);
/*
 * Reads information on the printer driver.
 */


extern char *PDriver_PrinterName(void);
/*
 * This function calls PDriver_Info, and returns the Printer name returned
 * by that SWI. If no Printer Driver is installed, it returns NULL.
 *
 * NOTE that the returned string should be treated as READ ONLY, as it
 * is a pointer into the PDriver's RMA workspace!
 */


os_error *PDriver_CheckFeatures(print_features mask, print_features value);
/*
 * Checks the features of a printer and generates an error if appropriate.
 */


os_error *PDriver_PageSize(wimp_point *size, wimp_rect *printable);
/*
 * Find how large the paper and print area are.
 */


os_error *PDriver_SelectJob(print_job newjob, char *title, print_job *oldjob);
/*
 * Make a given print job the current one.
 */


os_error *PDriver_CurrentJob(print_job *current);
/*
 * Get the handle of the current job.
 */


os_error *PDriver_EndJob(print_job job);
/*
 * End a print job normally.
 */


os_error *PDriver_AbortJob(print_job job);
/*
 * End a print job without any further output.
 */


os_error *PDriver_GiveRectangle(int rectangle_id, wimp_rect *rectangle,
                                print_transformation *matrix,
                                wimp_point *position, int background_colour);
/*
 * Specify a rectangle to be printed.
 */


os_error *PDriver_DrawPage(int copies, wimp_rect *rectangle_to_print,
                           int sequence_no, char *page,
                           int *finished, int *rectangle_id);
/*
 * Called to draw the page after all the rectangles have been specified.
 */


os_error *PDriver_GetRectangle(wimp_rect *rectangle_to_print,
                               int *finished, int *rectangle_id);
/*
 * Get the next print rectangle
 */


os_error *PDriver_CancelJob(print_job job);
/*
 * Stop the print job from printing.
 */


os_error *PDriver_ScreenDump(print_job job);
/*
 * Output a screen dump to the printer.
 */


os_error *PDriver_EnumerateJobs(print_job *handle);
/*
 * List existing print jobs.
 */


os_error *PDriver_CancelJobWithError(print_job job, os_error *error);
/*
 * Cancels a print job - future attempts to output to it generate an error.
 */


os_error *PDriver_SelectIllustration(print_job newjob, char *title,
                                     print_job *oldjob);
/*
 * Makes the given print job the current one, and treats it as an
 * illustration.
 */


os_error *PDriver_InsertIllustration(int illustration_handle, void *drawpath,
                                     wimp_point *bottom_left,
                                     wimp_point *bottom_right,
                                     wimp_point *top_left);
/*
 * Inserts a file containing an illustration into the current job's output.
 *
 * NOTE - the drawpath will be changed from a void * when drawfile support is
 * added to DeskLib.
 */

#ifdef __cplusplus
}
#endif


#endif
