/*
    ####             #    #     # #
    #   #            #    #       #          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 __Desk_PDriver_h
#define __Desk_PDriver_h

#ifdef __cplusplus
	extern "C" {
#endif


#ifndef __Desk_Core_h
#include "Desk.Core.h"
#endif

#ifndef __Desk_Wimp_h
#include "Desk.Wimp.h"
#endif



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

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

                                        /* Values for the drivertype field
                                           of Desk_printer_info                 */
#define Desk_printdriver_POSTSCRIPT          0
#define Desk_printdriver_FX80                1
#define Desk_printdriver_LASERJET            2
#define Desk_printdriver_INTEGREX            3   
#define Desk_printdriver_FAXMODEM            4
#define Desk_printdriver_DIRECTDRIVELASER    5
#define Desk_printdriver_CASPELGRAPHLANG     6
#define Desk_printdriver_PDUMPER             7
#define Desk_printdriver_EPSONJX             99
#define Desk_printdriver_STARLC10            99
#define Desk_printdriver_PAINTJET            99


        /* These #defines represent the bits of the 'features' word */
#define Desk_printfeat_COLOUR         0x00000001
#define Desk_printfeat_LIMITED        0x00000002
#define Desk_printfeat_DISCRETE       0x00000004
#define Desk_printfeat_NOFILL         0x00000100
#define Desk_printfeat_NOTHICKNESS    0x00000200
#define Desk_printfeat_NOOVERWRITE    0x00000400
#define Desk_printfeat_TRANSSPRITE    0x00000800
#define Desk_printfeat_NEWFONTMANAGER 0x00001000
#define Desk_printfeat_SCREENDUMP     0x01000000
#define Desk_printfeat_TRANSFORMS     0x02000000
#define Desk_printfeat_ILLUSTRATIONS  0x04000000
#define Desk_printfeat_MISCOP         0x08000000
#define Desk_printfeat_SETDRIVER      0x10000000
#define Desk_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;
} Desk_print_features;


typedef struct
{
  unsigned int     version    : 16;
  int              drivertype : 16;
  Desk_wimp_point       resolution;
  Desk_print_features   features;
  char             *description;
  Desk_wimp_point       Desk_halftone_res;
  int              Desk_id_number;
} Desk_printer_info;                  /* info returned by Desk_PDriver_Info (pg 1539) */



void	Desk_PDriver_Info(Desk_printer_info *block);
/*
 * Reads information on the printer driver.
 */


extern char *Desk_PDriver_PrinterName(void);
/*
 * This function calls Desk_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!
 */


Desk_os_error *Desk_PDriver_CheckFeatures(Desk_print_features mask, Desk_print_features value);
/*
 * Checks the features of a printer and generates an error if appropriate.
 */


void	Desk_PDriver_PageSize(Desk_wimp_point *size, Desk_wimp_rect *printable);
/*
 * Find how large the paper and print area are.
 */


void	Desk_PDriver_SelectJob(Desk_print_job newjob, char *title, Desk_print_job *oldjob);
/*
 * Make a given print job the current one.
 */


void	Desk_PDriver_CurrentJob(Desk_print_job *current);
/*
 * Get the handle of the current job.
 */


void	Desk_PDriver_EndJob(Desk_print_job job);
/*
 * End a print job normally.
 */


void	Desk_PDriver_AbortJob(Desk_print_job job);
/*
 * End a print job without any further output.
 */


void	Desk_PDriver_GiveRectangle(int Desk_rectangle_id, Desk_wimp_rect *rectangle,
                                Desk_print_transformation *matrix,
                                Desk_wimp_point *position, int Desk_background_colour);
/*
 * Specify a rectangle to be printed.
 */


void	Desk_PDriver_DrawPage(int copies, Desk_wimp_rect *Desk_rectangle_to_print,
                           int Desk_sequence_no, char *page,
                           int *finished, int *Desk_rectangle_id);
/*
 * Called to draw the page after all the rectangles have been specified.
 */


void	Desk_PDriver_GetRectangle(Desk_wimp_rect *Desk_rectangle_to_print,
                               int *finished, int *Desk_rectangle_id);
/*
 * Get the next print rectangle
 */


void	Desk_PDriver_CancelJob(Desk_print_job job);
/*
 * Stop the print job from printing.
 */


void	Desk_PDriver_ScreenDump(Desk_print_job job);
/*
 * Output a screen dump to the printer.
 */


void	Desk_PDriver_EnumerateJobs(Desk_print_job *handle);
/*
 * List existing print jobs.
 */


void	Desk_PDriver_CancelJobWithError(Desk_print_job job, Desk_os_error *error);
/*
 * Cancels a print job - future attempts to output to it generate an error.
 */


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


void	Desk_PDriver_InsertIllustration(int Desk_illustration_handle, void *drawpath,
                                     Desk_wimp_point *Desk_bottom_left,
                                     Desk_wimp_point *Desk_bottom_right,
                                     Desk_wimp_point *Desk_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
