Important for all Apple Printing and Graphics Developers:
The information in this Technical Q & A is still relevant up to and including
Mac OS 7.6
with QuickDraw GX 1.1.5. Beginning with the release of Mac OS 8.0,
however, Apple plans to deliver a system which incorporates QuickDraw GX
graphics and typography only. QuickDraw GX printer drivers and GX printing
extensions will not be supported in Mac OS 8.0 or in future Mac OS releases. Apple's
goal is to simplify the user experience of printing by unifying the Macintosh
graphic and printing architectures and standardizing on the classic Printing
Manager.
For details on Apple's official announcement, refer to
</dev/technotes/gxchange.html>
|
Q:
How can I create a new GX papertype on the fly within my QuickDraw GX
application? I use GXNewPaperType , but for some reason the new papertype
doesn't show up in the page set-up dialog.
A:
This is actually related to a known bug in QuickDraw GX. If an
application uses GXNewPaperType to create an application-defined paper
type, GX doesn't find it in the page set-up dialog as it should. This is
because GX is setting up the paper type flags incorrectly. But there is a
workaround....
You need to create a job and custom paperType and flatten it to a file
within the extensions folder. GXNewPaperType will create a valid
paperType , but it does not set up the creator and the paperType flags
correctly. Therefore, after calling GXNewPaperType to set up the new
custom paperType , you'll need to set the paperTypeFlags and the creator.
The following code fragments will do the trick.
The globals used to set up the creator and paperType flags:
OSErr collectionErr = noErr;
Str255 paperTypeName;
gxRectangle paperDims;
gxRectangle pageDims;
Collection paperTypeCollection;
gxFlagsInfo paperTypeFlags;
gxCreatorInfo paperTypeCreator;
//
// We use this information to check to make sure that our
// new paperType was set up as we thought after calling GXNewPaperType
//
GXGetPaperTypeName( theNewPaperType, paperTypeName );
GXGetPaperTypeDimensions( theNewPaperType, &pageDims, &paperDims);
//
// We need to set our new paperType's flags and creator to allow
// GX to recognize it.
//
paperTypeCollection = GXGetPaperTypeCollection( theNewPaperType );
paperTypeFlags.flags = gxOldAndNewPaperTypeFlag;
collectionErr = AddCollectionItem( paperTypeCollection, gxFlagsTag,
gxPrintingTagID, sizeof(gxFlagsInfo),
&paperTypeFlags );
paperTypeCreator.creator = gxUserPaperType;
collectionErr = AddCollectionItem( paperTypeCollection, gxCreatorTag,
gxPrintingTagID, sizeof(gxCreatorInfo),
&paperTypeCreator );
|
At this point, when a print dialog is displayed, the paperType list is
recreated each time. This behavior ensures that any newly created
paperType will be found from within a running app which is creating
paperTypes .
After you have created the custom paperType and valid job, you'll need to
call GXFlattenJob and GXFlattenPaperType and save this info into a file
within the extension folder. Then it should show up in your page setup
paper type list.
|