Some hints on Display PostScript, CCB, 23-Aug-1994

* VAX/VMS source code

Found in LSL$SOURCE_ROOT:[LSLMAINT.GKSMOTIFLIB.SRC]
GKS2.SRC contains the routines for setting things up
GTX2.SRC contains the routines which draw text
WRAPS.PSW are the PS wraps which are used

* Drawable

Does displib draw things into a window, a backing pixmap, or both?
Whichever it does, you will need to do the same. If writing into a backing
pixmap, then perhaps it needs to be copied to the window periodically
to show users what is happening.

If you need to draw into more than one drawable, then the PostScript
operator setXgcdrawable can be used. This resets the coordinate system,
so it needs to be set afterwards.

* Coordinate System

Everything else is presumably drawing in X pixels so it is probably
as well to set up the PostScript coordinate system to do the same.
This can be done by specifying the pixel height of the drawable as the
y-offset in XDPSCreateContext or setXgcdrawable, and then executing
[1 0 0 -1 0 0] setmatrix.

* Graphical Context

The DPS system should probably have a GC of its own, as we are not certain
what changes will be made to it. So XCreateGC a new one, and free it where
appropriate. The Plane Mask is the only component of the GC that needs
setting, as far as I can remember. After using XChangeGC, you need to do
FlushGC, or _XFlushGCCache, or something in order to make sure that the
change is sent to the server.

* Synchronization

If drawing order is important, then you need to make sure that DPS drawing
is completed before doing X drawing (using DPSWaitContext), and perhaps also
the other way round although I haven't had any trouble here (XFlush).

* Colours

We cannot let DPS allocate or use pixel values of its own - it must be made
to use the same ones that our X drawing already uses. This is so that the
ability to manipulate overlays by changing the colour map works. DPS only
allows colour to be set using the standard PostScript operators (unless I
am missing something). displib will already have a set of pixel values
allocated in a colour map. On VAX/VMS, I pretend that these pixel
values represent a gray ramp (even though they do not), set up an
XStandardColormap structure to represent it, and pass it as the gray_ramp
argument to XDPSCreateContext. Then if I want the first pixel value,
I do 0.0 setgray, the top pixel value is obtained by 1.0 setgray, and
everything in between with intermediate values for setgray.
