home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / macintosh technotes and q&as / technotes / tn / samplecode.sit.hqx / Sample Code / PrintingLibrary.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-22  |  7.8 KB  |  234 lines

  1. /*
  2.     File:        PrintingLibrary.h
  3.  
  4.     Contains:    Graphics library for printing QuickDraw GX data.
  5.                 
  6.                 This library supports the basic job, format, dialog, and
  7.                 spooling functions of the QuickDraw GX Printing Manager. It
  8.                 provides an abstraction layer to handle printing through the
  9.                 QuickDraw GX and classic QuickDraw printing architectures,
  10.                 depending on which environment is available when the library
  11.                 is initialized. Only the basic features of QuickDraw GX
  12.                 printing are supported; i.e., the library does not handle
  13.                 application message overrides, custom dialog panels, or custom
  14.                 page formatting.
  15.                 
  16.                 For classic QuickDraw printing, the library uses QuickTime
  17.                 compression and decompression to image QuickDraw GX data. The
  18.                 basic technique is to encapsulate the QuickDraw GX image in a
  19.                 compressed data format using the object flattening functions
  20.                 from QuickDraw GX. Once the compressed image data is created,
  21.                 it may be passed to the QuickDraw GX codec and drawn using the
  22.                 QuickTime image compression functions or embedded within a
  23.                 QuickDraw picture and drawn using the DrawPicture function. In
  24.                 either case, the compressed data is passed to the the
  25.                 low-level QuickDraw drawing routines through the StdPix
  26.                 bottleneck routine. StdPix decompresses the data using the
  27.                 QuickDraw GX codec and passes the decompressed data to the
  28.                 bitsProc bottleneck routine when rendering the image.
  29.  
  30.                 LaserWriter drivers starting with version 8.3 recognize
  31.                 compressed data that may be drawn using QuickTime, like
  32.                 QuickDraw GX flattened objects. For version 8.4.3, the
  33.                 LaserWriter driver has been modified to render the QuickDraw
  34.                 GX data at the device resolution of the printer. When
  35.                 despooling, the printer driver changes the resolution of the
  36.                 offscreen drawing port and uses the QuicDraw GX codec to
  37.                 rasterize the compressed data. The QuickDraw printer drivers
  38.                 from Apple render the compressed data during spooling and use
  39.                 the resolution of the active graphics port. The library uses
  40.                 the device resolution commands of the PrGeneral routine to
  41.                 improve the quality of their printed images as described in
  42.                 “Meet PrGeneral, the Trap That Makes the Most of the Printing
  43.                 Manager,” in develop 3 (July 1990).
  44.  
  45.     Written by:    Daniel Lipton
  46.  
  47.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  48.  
  49.     Writers:
  50.  
  51.         (DIL)    Daniel Lipton
  52.         (IK)    Ingrid Kelly
  53.  
  54.     Change History (most recent first):
  55.  
  56.          <1>      6/1/97    IK        First created.
  57. */
  58.  
  59. #ifndef __PRINTINGLIBRARY__
  60. #define __PRINTINGLIBRARY__
  61.  
  62. #ifndef __FILES__
  63. #include <Files.h>
  64. #endif
  65.  
  66. #ifndef __GXENVIRONMENT__
  67. #include <GXEnvironment.h>
  68. #endif
  69.  
  70. #ifndef __GXGRAPHICS__
  71. #include <GXGraphics.h>
  72. #endif
  73.  
  74. #ifndef __GXPRINTING__
  75. #include <GXPrinting.h>
  76. #endif
  77.  
  78. #ifndef __PRINTING__
  79. #include <Printing.h>
  80. #endif
  81.  
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85.  
  86. #if PRAGMA_ALIGN_SUPPORTED
  87. #pragma options align=mac68k
  88. #endif
  89.  
  90. #if PRAGMA_IMPORT_SUPPORTED
  91. #pragma import on
  92. #endif
  93.  
  94. /* ---------------------------------------------------------------------------
  95.     Constants 
  96.   --------------------------------------------------------------------------- */
  97.  
  98. enum {
  99.     rJobObjectRsrcType        = (ResType)'pjob',
  100.     rPrintRecordRsrcType    = (ResType)'PREC',
  101.     rJobObjectRsrcID        = 1,
  102.     rPrintRecordRsrcID        = 1,
  103.     noPrinterChosenErr        = 42
  104. };
  105.  
  106. /* ---------------------------------------------------------------------------
  107.     Type definitions 
  108.   --------------------------------------------------------------------------- */
  109.  
  110. typedef short PrintingArchitecture;
  111.  
  112. enum {
  113.     kAnyPrArch            = (PrintingArchitecture)0,
  114.     kQDPrArch            = (PrintingArchitecture)1,
  115.     kGXPrArch            = (PrintingArchitecture)2
  116. };
  117.  
  118. typedef OptionBits PrintingOptions;
  119.  
  120. enum {
  121.     /*    Force the spooling functions of the PrintingLibrary to convert each
  122.         page shape to a QuickDraw picture before passing the compressed
  123.         QuickDraw GX data to QuickTime for decompression.
  124.     */
  125.     kUseShapeToQuickDrawPictureConversion    = 0x00000001
  126. };
  127.  
  128. struct vpContextRecord {
  129.     gxViewPort                viewport;
  130.     gxUserViewPortFilter    viewportFilter;
  131.     long                    refcon;
  132. };
  133.  
  134. typedef struct vpContextRecord vpContextRecord;
  135.  
  136. struct gxprViewportContextRecord {
  137.     gxShape                    shape;
  138.     long                    vpCount;
  139.     vpContextRecord            vpContextArray[kVariableLengthArray];
  140. };
  141.  
  142. typedef struct gxprViewportContextRecord gxprViewportContextRecord, *gxprViewportContextPtr, **gxprViewportContextHdl;
  143.  
  144. struct gxprJobRecord {
  145.     PrintingArchitecture    architecture;
  146.     OSErr                    error;
  147.     gxJob                    job;
  148.     gxprViewportContextHdl    vpContextHdl;
  149.     THPrint                 prRecHdl;
  150.     short                    prResFile;
  151.     TPPrPort                prPort;
  152.     short                    prResolution;
  153.     short                    savedVRes;
  154.     short                    savedHRes;
  155.     GrafPtr                    savedPort;
  156. };
  157.  
  158. typedef struct gxprJobRecord gxprJobRecord, *gxprJobPtr, **gxprJobHdl;
  159.  
  160. struct gxprFormatRecord {
  161.     gxprJobHdl                gxprJob;
  162.     gxFormat                format;
  163. };
  164.  
  165. typedef struct gxprFormatRecord gxprFormatRecord, *gxprFormatPtr, **gxprFormatHdl;
  166.  
  167. /* ---------------------------------------------------------------------------
  168.     Function prototypes 
  169.   --------------------------------------------------------------------------- */
  170.  
  171. extern OSErr                GXPrInitPrinting(void);
  172. extern OSErr                GXPrExitPrinting(void);
  173. extern PrintingArchitecture    GXPrGetPrintingArchitecture(void);
  174. extern PrintingOptions        GXPrGetPrintingOptions(void);
  175. extern void                    GXPrSetPrintingOptions(PrintingOptions options);
  176.  
  177. /*    Error handling routines */
  178.  
  179. extern OSErr                GXPrGetJobError(gxprJobHdl gxprJob);
  180. extern void                    GXPrSetJobError(gxprJobHdl gxprJob, OSErr error);
  181.  
  182. /*    Job routines */
  183.  
  184. extern OSErr                GXPrNewJob(gxprJobHdl *gxprJob);
  185. extern OSErr                GXPrDisposeJob(gxprJobHdl gxprJob);
  186. extern void                    GXPrFlattenJobToFile(gxprJobHdl gxprJob, FSSpecPtr fileSpec);
  187. extern gxprJobHdl            GXPrUnflattenJobFromFile(gxprJobHdl gxprJob, FSSpecPtr fileSpec);
  188. extern void                    GXPrInstallApplicationOverride(gxprJobHdl gxprJob, short messageID, void *override);
  189. extern Boolean                GXPrUpdateJob(gxprJobHdl gxprJob);
  190.  
  191. /*    Format routines */
  192.  
  193. extern gxprFormatHdl        GXPrNewFormat(gxprJobHdl gxprJob);
  194. extern void                    GXPrDisposeFormat(gxprFormatHdl gxprFormat);
  195. extern gxprJobHdl            GXPrGetFormatJob(gxprFormatHdl gxprFormat);
  196. extern void                    GXPrGetFormatDimensions(gxprFormatHdl gxprFormat, gxRectangle *pageSize, gxRectangle *paperSize);
  197. extern Collection            GXPrGetFormatCollection(gxprFormatHdl gxprFormat);
  198.  
  199. /*    Dialog routines */
  200.  
  201. extern gxDialogResult        GXPrJobDefaultFormatDialog(gxprJobHdl gxprJob, gxEditMenuRecord *anEditMenuRec);
  202. extern gxDialogResult        GXPrJobPrintDialog(gxprJobHdl gxprJob, gxEditMenuRecord *anEditMenuRec);
  203. extern gxDialogResult        GXPrFormatDialog(gxprFormatHdl gxprFormat, gxEditMenuRecord *anEditMenuRec, StringPtr title);
  204.  
  205. /*    Spooling routines */
  206.  
  207. extern void                    GXPrGetJobPageRange(gxprJobHdl gxprJob, long *firstPage, long *lastPage);
  208. extern void                    GXPrStartJob(gxprJobHdl gxprJob, StringPtr docName, long pageCount);
  209. extern void                    GXPrStartPage(gxprJobHdl gxprJob, long pageNumber, gxprFormatHdl gxprFormat, long numViewPorts, gxViewPort *viewPortList);
  210. extern void                    GXPrDrawPicture(gxprJobHdl gxprJob, gxShape theShape, Fixed hScale, Fixed vScale);
  211. extern void                    GXPrPrintPage(gxprJobHdl gxprJob, long pageNumber, gxprFormatHdl gxprFormat, gxShape thePage);
  212. extern void                    GXPrFinishPage(gxprJobHdl gxprJob);
  213. extern void                    GXPrFinishJob(gxprJobHdl gxprJob);
  214.  
  215. /*    Utility routines */
  216.  
  217. extern OSErr                GXPrSetJobCopies(gxprJobHdl gxprJob, gxCopiesInfo *newData, gxCopiesInfo **oldDataPtr);
  218. extern OSErr                GXPrSetJobFileDestination(gxprJobHdl gxprJob, gxFileDestinationInfo *newData, gxFileDestinationInfo **oldDataPtr);
  219. extern OSErr                GXPrSetJobPageRange(gxprJobHdl gxprJob, long newDataSize, gxPageRangeInfo *newData, long *oldDataSize, gxPageRangeInfo **oldDataPtr);
  220.  
  221. #if PRAGMA_IMPORT_SUPPORTED
  222. #pragma import off
  223. #endif
  224.  
  225. #if PRAGMA_ALIGN_SUPPORTED
  226. #pragma options align=reset
  227. #endif
  228.  
  229. #ifdef __cplusplus
  230. }
  231. #endif
  232.  
  233. #endif /* __PRINTINGLIBRARY__ */
  234.