background image
Functional specification
12
CDE/Motif PST
CDEnext
A simple X application supplemented with some of the libXp routines might look like:
/*
* Connect to the X Print Server
*/
pdpy =
XOpenDisplay( printServerName );
/*
* See if the printer "myLaser" is available
*/
plist =
XpGetPrinterList( pdpy, "myLaser", &plistCnt );
/*
* Initialize a print context representing "mylaser"
*/
pcontext =
XpCreateContext( pdpy, plist[0].name );
XpFreePrinterList( plist );
/*
* Possibly modify attributes in the print context
*/
attrPool =
XpGetAttributes( pdpy, pcontext, poolType );
/* twiddle attributes */
XpSetAttributes( pdpy, pcontext, poolType, attrPool, XPAttrMerge );
/*
* Set a print context, then start a print job against it
*/
XpSetContext( pdpy, pcontext );
XpStartJob( pdpy, XPSpool );
/*
* Generate the first page
*/
pscreen =
XpGetScreenOfContext( pdpy, pcontext );
pwin =
XCreateWindow( pdpy, pscreen, ..... );
XpStartPage( pdpy, pwin, True );
usual_rendering_stuff( pdpy, pscreen, pwin );
XpEndPage( pdpy );
/*
* Generate more pages, and so on...
*/
XpStartPage( pdpy, pwin, True );
more_rendering_stuff( pdpy, pscreen, pwin );
XpEndPage( pdpy );
/*
* End the print job - the final results are sent by the
* X Print Server to the spooler subsystem
*/
XpEndJob( pdpy );
XpDestroyContext( pdpy, pcontext );