[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide

Chapter 19. Printing

This chapter describes how application developers can use the X Print Service and printing-related APIs to achieve printing from their applications.

The X printing architecture is fundamentally concerned with reusing most of the X Protocol and X library APIs with an X Server that generates such printer languages as PostScript and PCL (refer to the specification, X Printing Architecture). Correspondingly, the model chosen for widget printing is to re-use the code that renders the widgets on the video side (through their expose method) for the X Print Server side.

An application therefore needs only to create new instances of widgets using a Shell widget created on the X Print Server and to set resources according to what it is to be printed on paper. In addition, depending on the programming model chosen for rendering, the application may instruct the widgets to render themselves manually or use callbacks to change the state of the widget content between pages.

As a result of that design choice, there is no clear boundary between printing only the content of the widgets and printing high-resolution screen dumps of the widget's visual representation. The separation between current content and current visual is left to the programmer, and so widget printing becomes mostly a matter of the programmer deciding which widget resources need to be copied from the video widget instance to the print widget instance. A section in this chapter is intended to help the programmer answer this question for the Motif XmText and XmLabel widget classes.

As far as rendering the widget on the print side is concerned, two models of programming are supported:

  1. Synchronous, where the application directs the widget to print itself (using the XmRedisplayWidget API)

  2. Asynchronous, where all drawing/printing happens as a result of Exposure and other Print events being generated by the X Print Server and automatically dispatched through the XmPrintShell callback mechanism (XmNpageSetUpCallback).

    In addition, a convenience function to set up the X Print Server connection and a top-level Print shell widget are provided, as well as a convenience function supporting a print-to-file service. Both APIs are also usable from Motif/CDE applications that do not print using widgets but print by means of direct rendering via Xlib.

  3. [ Previous | Next | Contents | Glossary | Home | Search ]