Important: The information in this document is obsolete and should not be used for new development.
 
  
  
  
 
Maintaining Device Independence
Whenever printing, you should use both QuickDraw and non-QuickDraw representations of an image, so that the current printer driver can render the best possible picture. If you send an image described with picture comments to a QuickDraw printer driver that does not support those picture comments, the driver ignores the comments and subsequently does not print your image; if you send only a QuickDraw image to a printer driver that supports picture comments, the driver may not render its best possible image.Printer drivers that support
TextBegin,TextCenter, andTextEndare expected to ignore calls to theCopyBits,CopyMask, andCopyDeepMaskprocedures that fall between theTextBeginandTextEndpicture comments. Between theTextBeginandTextEndpicture comments, you can useCopyBitsto draw a bitmap representation of rotated text on QuickDraw printers; this bitmap is not used if theTextBeginandTextEndpicture comments are supported, but it is used ifTextBeginandTextEndare not supported. This is illustrated in Listing B-4 on page B-23.When your application draws polygons on a PostScript printer, you can use
PolyBegin,PolySmooth, andPolyEndpicture comments to draw smoothed polygons; QuickDraw printer drivers ignore these comments. To make a PostScript printer driver ignore your QuickDraw representation of the polygons, you can use thePolyIgnorepicture comment, as illustrated in Listing B-6 on page B-29.A technique for maintaining two sets of drawing codes, described in "Rotating Graphics" beginning on page B-31 and "Drawing Dashed Lines" beginning on page B-34, makes use of a "magic pen" visible only to PostScript drivers. Graphics comments for drawing dashed lines and for rotating graphics require the use of the
PenModeprocedure to set the pattern mode to a value of 23. Normally this value is undefined, but it is handled specially by PostScript printer drivers (all QuickDraw drivers ignore it). Your application can use this pattern mode to draw objects in a picture, and if the picture is printed on a QuickDraw printer, these objects are not visible.To maintain device independence when you send routines to a PostScript printer driver, you can "hide" QuickDraw routines between the
PostScriptBeginandPostScriptEndpicture comments. ThePostScriptBegincomment is recognized only by PostScript printer drivers. When a PostScript driver receives thePostScriptBegincomment, it tells the PostScript printer to save the current state of the printer and to disable all low-level standard QuickDraw drawing procedures. Thus, the QuickDraw representation of the graphic is ignored by PostScript printer drivers.Table B-2 lists the QuickDraw low-level procedures and the affected high-level drawing routines that are disabled by the
PostScriptBeginpicture comment.
Table B-2: Low-level QuickDraw routines disabled by thePostScriptBegincommentLow-level routine Examples of affected high-level QuickDraw routines StdText QuickDraw text-drawing routines (as described in the chapter "QuickDraw Text" in Inside Macintosh: Text) StdLine MoveTo,Move,LineTo,LineStdRect FrameRect,PaintRect,FillRect,EraseRect,InvertRectStdRRect FrameRoundRect,PaintRoundRect,FillRoundRect,EraseRoundRect,InvertRoundRectStdOval FrameOval,PaintOval,FillOval,EraseOval,InvertOvalStdArc FrameArc,PaintArc,FillArc,EraseArc,InvertArcStdPoly FramePoly,PaintPoly,FillPoly,ErasePoly,InvertPolyStdRgn FrameRgn,PaintRgnStdBits CopyBits,CopyMask,CopyDeepMaskTo mark the end of a sequence of hidden QuickDraw drawing routines and to reenable QuickDraw drawing routines, you can use the picture comment
PostScriptEnd. ThePostScriptEndcomment is recognized only by PostScript printer drivers. When a PostScript driver receives thePostScriptEndcomment, it tells the PostScript printer driver to restore the previous state of the printer driver and to enable QuickDraw drawing operations.For a LaserWriter PostScript printer driver, QuickDraw routines that draw text, lines, and shapes and copy bitmaps or pixel maps have no effect when placed between the
PostScriptBeginandPostScriptEndpicture comments. Instead, the driver expects to receive imaging instructions in subsequent picture comments. On the other hand, a QuickDraw printer driver ignores thePostScriptBeginandPostScriptEndpicture comments.Only PostScript printer drivers should support the
DashedLine,DashedStop,RotateBegin,RotateCenter, andRotateEndpicture comments. Therefore, you can use thePostScriptBeginandPostScriptEndpicture comments to hide your QuickDraw implementations of these comments from the printer driver. Listing B-7 on page B-32 illustrates how to usePostScriptBeginandPostScriptEndwhen rotating graphics on PostScript printers; Listing B-9 on page B-35 illustrates how to usePostScriptBeginandPostScriptEndwhen drawing dashed lines on PostScript printers.
 
  
  
 