QuickDraw GX Printing and Messages
----------------------------------
Printing with QuickDraw GX is based on a message-passing architecture. QuickDraw GX sends printing messages when certain printing-related tasks need to be accomplished or when certain printing-related conditions arise. A printing message is a notice that a certain part of the printing process is in progress or that a certain printing task needs to be accomplished.
QuickDraw GX sends a large number of printing messages during the printing process, and a printing extension or printer driver might need to respond to make available its features or functionality. For example, a printing extension could respond to a particular printing message called GXDespoolPage to add a date/time stamp to each page. Or a printer driver could respond to the GXOpenConnection message to verify that the corresponding printing device is working properly. This response of intercepting a specific printing message and taking some action is called a message override, which is performed by an override function that is defined in the extension or driver.
Before learning more about how message overrides work, it is important to have an overview of what happens when QuickDraw GX sends a printing message. Because the printing extension or printer driver may respond to a printing message, it is called a message handler. A number of message handlers, including an extension or driver, an application, and QuickDraw GX itself, can respond to printing messages.
Each message handler is part of the message chain, which links the handlers in a hierarchical sequence. Each handler in the hierarchy receives the message and decides whether to respond to the message and whether to forward the message to the handler below it in the hierarchy.
In most cases, when the printing extension or printer driver overrides a printing message, it performs some operations and forwards the message to the next handler in the message chain. This is called a partial override. (A total override occurs when the message is not forwarded.) Because QuickDraw GX provides a default implementation for most of the printing messages, a partial override is used to add to the response of, or change the result of, the default implementation before or after forwarding the message. For those printing messages that require forwarding, a partial override can be used. If the messages are not forwarded, their default implementation is not invoked, which means that a vital operation might be neglected, potentially resulting in serious errors.
Depending on the nature of a message, a partial override can forward it to the other handlers and then perform the tasks, or it can perform the tasks and then forward it to other handlers. For example, if a printing extension is created that combines eight pages of a document into one page of thumbnail sketches, it needs to override the GXCountPages message, which QuickDraw GX sends to count the pages in the spool file. It forwards this message to let the default implementation count the pages, and the override would then modifies this value. On the other hand, if the extension created adds a background picture to each page as it gets printed, it needs to override the GXDespoolPage message. It adds the background picture to the page after forwarding the message to the default implementation, which would reads the page from the spool file.
QuickDraw GX also provides a number of printing functions that can only be called from within the message overrides that are implemented in the driver or extension. These functions perform a variety of operations, including:
* Displaying status information and printing alert boxes
* Interfacing with the paper trays
* Communicating imaging options between a driver and an application
* Gracefully handling errors that arise during the processing of certain
printing messages
The message-passing architecture used for QuickDraw GX printing is supported by the Message Manager, which is a general-purpose software component of QuickDraw GX that can be used when programming for message passing.
Article Change History:
14 Feb 1995 - Reviewed for technical accuracy.
Support Information Services