home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PrintingLibrary.h
-
- Contains: Graphics library for printing QuickDraw GX data.
-
- This library supports the basic job, format, dialog, and
- spooling functions of the QuickDraw GX Printing Manager. It
- provides an abstraction layer to handle printing through the
- QuickDraw GX and classic QuickDraw printing architectures,
- depending on which environment is available when the library
- is initialized. Only the basic features of QuickDraw GX
- printing are supported; i.e., the library does not handle
- application message overrides, custom dialog panels, or custom
- page formatting.
-
- For classic QuickDraw printing, the library uses QuickTime
- compression and decompression to image QuickDraw GX data. The
- basic technique is to encapsulate the QuickDraw GX image in a
- compressed data format using the object flattening functions
- from QuickDraw GX. Once the compressed image data is created,
- it may be passed to the QuickDraw GX codec and drawn using the
- QuickTime image compression functions or embedded within a
- QuickDraw picture and drawn using the DrawPicture function. In
- either case, the compressed data is passed to the the
- low-level QuickDraw drawing routines through the StdPix
- bottleneck routine. StdPix decompresses the data using the
- QuickDraw GX codec and passes the decompressed data to the
- bitsProc bottleneck routine when rendering the image.
-
- LaserWriter drivers starting with version 8.3 recognize
- compressed data that may be drawn using QuickTime, like
- QuickDraw GX flattened objects. For version 8.4.3, the
- LaserWriter driver has been modified to render the QuickDraw
- GX data at the device resolution of the printer. When
- despooling, the printer driver changes the resolution of the
- offscreen drawing port and uses the QuicDraw GX codec to
- rasterize the compressed data. The QuickDraw printer drivers
- from Apple render the compressed data during spooling and use
- the resolution of the active graphics port. The library uses
- the device resolution commands of the PrGeneral routine to
- improve the quality of their printed images as described in
- “Meet PrGeneral, the Trap That Makes the Most of the Printing
- Manager,” in develop 3 (July 1990).
-
- Written by: Daniel Lipton
-
- Copyright: © 1997 by Apple Computer, Inc., all rights reserved.
-
- Writers:
-
- (DIL) Daniel Lipton
- (IK) Ingrid Kelly
-
- Change History (most recent first):
-
- <1> 6/1/97 IK First created.
- */
-
- #ifndef __PRINTINGLIBRARY__
- #define __PRINTINGLIBRARY__
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- #ifndef __GXENVIRONMENT__
- #include <GXEnvironment.h>
- #endif
-
- #ifndef __GXGRAPHICS__
- #include <GXGraphics.h>
- #endif
-
- #ifndef __GXPRINTING__
- #include <GXPrinting.h>
- #endif
-
- #ifndef __PRINTING__
- #include <Printing.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- /* ---------------------------------------------------------------------------
- Constants
- --------------------------------------------------------------------------- */
-
- enum {
- rJobObjectRsrcType = (ResType)'pjob',
- rPrintRecordRsrcType = (ResType)'PREC',
- rJobObjectRsrcID = 1,
- rPrintRecordRsrcID = 1,
- noPrinterChosenErr = 42
- };
-
- /* ---------------------------------------------------------------------------
- Type definitions
- --------------------------------------------------------------------------- */
-
- typedef short PrintingArchitecture;
-
- enum {
- kAnyPrArch = (PrintingArchitecture)0,
- kQDPrArch = (PrintingArchitecture)1,
- kGXPrArch = (PrintingArchitecture)2
- };
-
- typedef OptionBits PrintingOptions;
-
- enum {
- /* Force the spooling functions of the PrintingLibrary to convert each
- page shape to a QuickDraw picture before passing the compressed
- QuickDraw GX data to QuickTime for decompression.
- */
- kUseShapeToQuickDrawPictureConversion = 0x00000001
- };
-
- struct vpContextRecord {
- gxViewPort viewport;
- gxUserViewPortFilter viewportFilter;
- long refcon;
- };
-
- typedef struct vpContextRecord vpContextRecord;
-
- struct gxprViewportContextRecord {
- gxShape shape;
- long vpCount;
- vpContextRecord vpContextArray[kVariableLengthArray];
- };
-
- typedef struct gxprViewportContextRecord gxprViewportContextRecord, *gxprViewportContextPtr, **gxprViewportContextHdl;
-
- struct gxprJobRecord {
- PrintingArchitecture architecture;
- OSErr error;
- gxJob job;
- gxprViewportContextHdl vpContextHdl;
- THPrint prRecHdl;
- short prResFile;
- TPPrPort prPort;
- short prResolution;
- short savedVRes;
- short savedHRes;
- GrafPtr savedPort;
- };
-
- typedef struct gxprJobRecord gxprJobRecord, *gxprJobPtr, **gxprJobHdl;
-
- struct gxprFormatRecord {
- gxprJobHdl gxprJob;
- gxFormat format;
- };
-
- typedef struct gxprFormatRecord gxprFormatRecord, *gxprFormatPtr, **gxprFormatHdl;
-
- /* ---------------------------------------------------------------------------
- Function prototypes
- --------------------------------------------------------------------------- */
-
- extern OSErr GXPrInitPrinting(void);
- extern OSErr GXPrExitPrinting(void);
- extern PrintingArchitecture GXPrGetPrintingArchitecture(void);
- extern PrintingOptions GXPrGetPrintingOptions(void);
- extern void GXPrSetPrintingOptions(PrintingOptions options);
-
- /* Error handling routines */
-
- extern OSErr GXPrGetJobError(gxprJobHdl gxprJob);
- extern void GXPrSetJobError(gxprJobHdl gxprJob, OSErr error);
-
- /* Job routines */
-
- extern OSErr GXPrNewJob(gxprJobHdl *gxprJob);
- extern OSErr GXPrDisposeJob(gxprJobHdl gxprJob);
- extern void GXPrFlattenJobToFile(gxprJobHdl gxprJob, FSSpecPtr fileSpec);
- extern gxprJobHdl GXPrUnflattenJobFromFile(gxprJobHdl gxprJob, FSSpecPtr fileSpec);
- extern void GXPrInstallApplicationOverride(gxprJobHdl gxprJob, short messageID, void *override);
- extern Boolean GXPrUpdateJob(gxprJobHdl gxprJob);
-
- /* Format routines */
-
- extern gxprFormatHdl GXPrNewFormat(gxprJobHdl gxprJob);
- extern void GXPrDisposeFormat(gxprFormatHdl gxprFormat);
- extern gxprJobHdl GXPrGetFormatJob(gxprFormatHdl gxprFormat);
- extern void GXPrGetFormatDimensions(gxprFormatHdl gxprFormat, gxRectangle *pageSize, gxRectangle *paperSize);
- extern Collection GXPrGetFormatCollection(gxprFormatHdl gxprFormat);
-
- /* Dialog routines */
-
- extern gxDialogResult GXPrJobDefaultFormatDialog(gxprJobHdl gxprJob, gxEditMenuRecord *anEditMenuRec);
- extern gxDialogResult GXPrJobPrintDialog(gxprJobHdl gxprJob, gxEditMenuRecord *anEditMenuRec);
- extern gxDialogResult GXPrFormatDialog(gxprFormatHdl gxprFormat, gxEditMenuRecord *anEditMenuRec, StringPtr title);
-
- /* Spooling routines */
-
- extern void GXPrGetJobPageRange(gxprJobHdl gxprJob, long *firstPage, long *lastPage);
- extern void GXPrStartJob(gxprJobHdl gxprJob, StringPtr docName, long pageCount);
- extern void GXPrStartPage(gxprJobHdl gxprJob, long pageNumber, gxprFormatHdl gxprFormat, long numViewPorts, gxViewPort *viewPortList);
- extern void GXPrDrawPicture(gxprJobHdl gxprJob, gxShape theShape, Fixed hScale, Fixed vScale);
- extern void GXPrPrintPage(gxprJobHdl gxprJob, long pageNumber, gxprFormatHdl gxprFormat, gxShape thePage);
- extern void GXPrFinishPage(gxprJobHdl gxprJob);
- extern void GXPrFinishJob(gxprJobHdl gxprJob);
-
- /* Utility routines */
-
- extern OSErr GXPrSetJobCopies(gxprJobHdl gxprJob, gxCopiesInfo *newData, gxCopiesInfo **oldDataPtr);
- extern OSErr GXPrSetJobFileDestination(gxprJobHdl gxprJob, gxFileDestinationInfo *newData, gxFileDestinationInfo **oldDataPtr);
- extern OSErr GXPrSetJobPageRange(gxprJobHdl gxprJob, long newDataSize, gxPageRangeInfo *newData, long *oldDataSize, gxPageRangeInfo **oldDataPtr);
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __PRINTINGLIBRARY__ */
-