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

Chapter 15. Widget Printing

Because only a subset of the X protocol is supported by most X print servers (some GC functions, like GXxor, or things like CopyArea, GetImage, may not be supported), a widget implementation may run into problems when it is connected to a print server.

The list of requests that are guaranteed to be supported are documented in the X Print documentation. In addition, a fallback behavior is provided for those requests that are not fully supported (GXor drawing can resolve to GXcopy, XGetImage can return a white image, and so on). At the widget method level, one simple way to check whether or not a particular instance is running on a print server is to check if its shell root is an XmPrintShell.

Widget writers should bear these remarks in mind when writing or adapting their code. They should provide new resources to turn off visual characteristics that are appropriate for the screen representation of the widget, but usually inappropriate when the widget is printed on paper (for example, blinking and highlighting). Alternatively, they may turn off such resources automatically in the case where the widget is to be printed. (For information on scaling bitmaps and pixmaps for printing purposes, refer to the discussion of the XmRBitmap and XmRDynamicPixmap converters in Chapter 6.)

The knowledge of the XmPrintShell can also be used to optimize the widget code for printing only. In such cases, there is no need for drag-and-drop contexts, scrollbars, and the like.

The application printing model assumes that the application developer duplicates some widget instances for use in displaying them on the screen and printing them on paper (refer to Motif Programmer's Guide for a discussion of this subject). Widget writers are therefore encouraged to provide and document such resources as best define the content of their widgets for the benefit of application developers who use them.

In the following example, a simple widget Initialize method wants to know it is creating a widget for printing or video.

            Widget parent = widget;
    do {
                if (XmIsPrintShell(parent)) break;
    } while (parent = XtParent(parent));
    if (!parent) {
              /* not printing case, create our DragIcon */
    } else {
      /* use GXcopy instad of GXxor in the graphics */

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