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
, andTextEnd
are expected to ignore calls to theCopyBits
,CopyMask
, andCopyDeepMask
procedures that fall between theTextBegin
andTextEnd
picture comments. Between theTextBegin
andTextEnd
picture comments, you can useCopyBits
to draw a bitmap representation of rotated text on QuickDraw printers; this bitmap is not used if theTextBegin
andTextEnd
picture comments are supported, but it is used ifTextBegin
andTextEnd
are 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
, andPolyEnd
picture 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 thePolyIgnore
picture 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
PenMode
procedure 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
PostScriptBegin
andPostScriptEnd
picture comments. ThePostScriptBegin
comment is recognized only by PostScript printer drivers. When a PostScript driver receives thePostScriptBegin
comment, 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
PostScriptBegin
picture comment.
Table B-2: Low-level QuickDraw routines disabled by thePostScriptBegin
commentLow-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
,Line
StdRect FrameRect
,PaintRect
,FillRect
,EraseRect
,InvertRect
StdRRect FrameRoundRect
,PaintRoundRect
,FillRoundRect
,EraseRoundRect
,InvertRoundRect
StdOval FrameOval
,PaintOval
,FillOval
,EraseOval
,InvertOval
StdArc FrameArc
,PaintArc
,FillArc
,EraseArc
,InvertArc
StdPoly FramePoly
,PaintPoly
,FillPoly
,ErasePoly
,InvertPoly
StdRgn FrameRgn
,PaintRgn
StdBits CopyBits
,CopyMask
,CopyDeepMask
To mark the end of a sequence of hidden QuickDraw drawing routines and to reenable QuickDraw drawing routines, you can use the picture comment
PostScriptEnd
. ThePostScriptEnd
comment is recognized only by PostScript printer drivers. When a PostScript driver receives thePostScriptEnd
comment, 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
PostScriptBegin
andPostScriptEnd
picture comments. Instead, the driver expects to receive imaging instructions in subsequent picture comments. On the other hand, a QuickDraw printer driver ignores thePostScriptBegin
andPostScriptEnd
picture comments.Only PostScript printer drivers should support the
DashedLine
,DashedStop
,RotateBegin
,RotateCenter
, andRotateEnd
picture comments. Therefore, you can use thePostScriptBegin
andPostScriptEnd
picture comments to hide your QuickDraw implementations of these comments from the printer driver. Listing B-7 on page B-32 illustrates how to usePostScriptBegin
andPostScriptEnd
when rotating graphics on PostScript printers; Listing B-9 on page B-35 illustrates how to usePostScriptBegin
andPostScriptEnd
when drawing dashed lines on PostScript printers.