[comp.windows.open-look] NeWS graphics in X11 program

steve@hekla.stanford.edu (Steve Cole) (01/23/91)

I want to display NeWS graphics in an X11 program. With the X11/NeWS
server that comes with OpenWindows, this should be possible. The
most difficult part is telling NeWS which X11 window to display in.

In my OpenWindows version 2: X11/NeWS server guide, there are some
hints as to how to do this. Unfortunately the hints are brief, and
the reader is referred to a demo program included in the OpenWindows
source distribution ($OPENWINHOME/share/src/xnews/client/X11/logo.c)
for more details. Apparently this is a program that mixes X11 and
NeWS graphics in just the way I'd like.

The problem is that my source distribution has no such example (at
least not the source). Probably my manual is out of date and that
program was included in some pre-release version of OpenWindows.

Does anyone have any advice - code that shows how to tell the NeWS
server to draw in a particular X11 window, the source to the
program I mentioned, a pointer to better advice in a newer manual,
etc? Thanks for any replies. 
-----------------------------------------------------------------
Steve Cole  (steve@hanauma.stanford.edu, apple!hanauma!steve)
Department of Geophysics, Stanford University, Stanford, CA 94305

jmck@norge.Eng.Sun.COM (John McKernan) (01/23/91)

steve@hekla.stanford.edu (Steve Cole) writes:
>I want to display NeWS graphics in an X11 program.

Examples of News rendering in an xview canvas are included in the xview
source distribution, available in the contrib directory of the MIT X11R4
source. I don't personally know of any pure X11 example programs that
do News rendering.

John McKernan.                                              jmck@sun.com
Windows and Graphics Software, XView Development Group, Sun Microsystems.

mike@ste.dyn.bae.co.uk (Mike Heley) (01/23/91)

In response to Steve Cole's request for advice on using NeWS graphics
from an X11 program -

I am in the process of changing the canvas graphics output portion of an
XView program from xlib to the NeWS extended postscript. Since I have most
of it working now, I can tell you where I started looking and a few of
the problems I found.

In my OpenWindows 2.0 there was a document ($OPENWINHOME/share/xvps.ps) which
describes the PSCANVAS package. I found the package itself pretty limited,
compared to the normal XView canvas, in particular, there seemed to be
no support for split views or event procs. My application also couldn't
cope with the fact that the repaint/resize procs got called with a changing
xview object handle.

However, there are a couple of cps macros which allow NeWS graphics on
any X11 window. I used these in combination with the normal XView canvas
object to get full canvas functionality + NeWS on the paintwindows.

I couldn't find the cps source file for the macros, but working back from the
tokenised macros, I found they do something like

#define CANVAS_TOKEN_TAG 51
cdef ps_token_from_xid(xid, canvastoken)
        => CANVAS_TOKEN_TAG (canvastoken)
        xid /XLookupID XResource send dup type
        /canvastype ne
        {pop -1}
        {currentfile countfileinputtoken dup 3 -2 roll setfileinputtoken}
        ifelse
        CANVAS_TOKEN_TAG tagprint
        typedprint

cdef ps_setcanvas(token canvastoken)
        canvastoken setcanvas

which seems to work okay.

One thing I would like to know. How do you go about debugging applications
which use cps macros, and how on earth to you handle error conditions
which occur on the server side?

--
  Mike Heley 					mike@ste.dyn.bae.co.uk
  British Aerospace Dynamics			+44 438 752432
  Stevenage, UK

  "Schizophrenic? I'm bleedin' Quadrophenic!" - The Who, 1973.
--

mh@roger.imsd.contel.com (Mike Hoegeman) (01/25/91)

In article <1991Jan23.103329.11656@ste.dyn.bae.co.uk> mike@ste.dyn.bae.co.uk (Mike Heley) writes:
>
>One thing I would like to know. How do you go about debugging applications
>which use cps macros, and how on earth to you handle error conditions
>which occur on the server side?
>
>--
>  Mike Heley 					mike@ste.dyn.bae.co.uk
>  British Aerospace Dynamics			+44 438 752432
>  Stevenage, UK

There is a PostScript debugging package that comes with NeWS. See the
NeWS 2.1 Programmers guide. You can use this to debug rour cps macros.

-mike