[comp.windows.x] rendering into widgets

clyne@redcloud.ucar.edu (John Clyne) (03/16/89)

Could someone please either send me some code demonstrating how to use
the Xlib primitives to render into a Widget's window or simply explain
to me how it is done. I've had no success by myself. Thanks in advance

John


	John Clyne 	(clyne@bierstadt.ucar.edu)
	c/o
	National Center for Atmospheric Research
	P.O. Box 3000
	Boulder, Colorado 80307
	(303) 497-1236

	
		%%% Its a small world. But I wouldn't want to paint it %%%
						S. Wright
		%%%						       %%%

converse@EXPO.LCS.MIT.EDU (Donna Converse) (03/16/89)

> Could someone please either send me some code demonstrating how to use
> the Xlib primitives to render into a Widget's window or simply explain
> to me how it is done.

Chris Peterson's test of drawing into a Box widget upon exposure events,
posted a few days ago, is an example of using the Xlib interface to do
graphics within a widget.  

After initializing the toolkit and creating your widget(s), you should
wait for the first exposure event before using any Xlib calls to draw in the
window.  You can do this at the Xlib level (with XSelectInput on exposure
events, XNextEvent, and your own loop to handle them), or, at the Xt level,
by registering a callback procedure with XtAddEventHandler, as Chris did.
Create and initialize your graphic contexts, realize the widget tree,
and get the 2 or 3 ubiquitous arguments for the Xlib level: display from
XtDisplay(widget), window from XtWindow(widget), perhaps the screen.
Now, in your exposure procedure, or upon whatever events you have selected
to be notified of, your code can be entirely at the Xlib level.  

Suppose you choose to write your own event handling loop at the Xlib level.
You would sit in this loop after rendering was complete, waiting to be
notified of a keyboard event or a mouse event.  When you get some indication
of the user wanting to see the next frame, control can pass back up to the
cgm parser.  

During initialization, a separate block on the first expose event must 
occur, either through a widget callback, or by selecting for expose events
on the widgets window.  After the first expose event, then the cgm parser
can start throwing primitives at your driver code.

Good luck to the graphics project at NCAR!