[comp.windows.x] Drawing in Widgets

jlf@earth.cray.COM (John Freeman) (02/03/89)

People here have had problems trying to draw inside widgets
using Xlib type calls.  One of these involved the Viewport
widget - it seems impossible to draw in it.  However, if a
Form widget is created within the Viewport, one can draw
in the Form widget.

So the question arose, which widgets can be drawn in with
Xlib calls, and which can't?

swick@ATHENA.MIT.EDU (Ralph R. Swick) (02/03/89)

> So the question arose, which widgets can be drawn in with
> Xlib calls, and which can't?

Widgets that are intended to be used for client drawing purposes
should be so documented.  In general, a widget does not have to
guarantee that any (or all) of the window returned by XtWindow()
can be manipulated in any way by clients other than by the Xt
interfaces (for configuring it) or by class-specific methods.
Of course, the widget itself knows exactly what's going on and
is free to use any Xlib calls it wants, (within the constraints
of the Xt geometry management architecture).

In the case of the Xaw Viewport widget, the window returned by
XtWindow() is completely occluded by subwindows managed by
the Viewport private methods, thus your inability to see what
you tried to draw.  Viewport could offer you an interface to
retrieve the visible window, however it's semantics aren't
really intended to be the DrawingSurface widget.

If you are trying to write a better widget that has prettier
graphics, then the correct approach is to subclass the existing
widget & replace the expose method.  If you are trying to do
other hackery, then you'll have to consult the documentation
(or the code :-) for the particular widget implementation to
see what might be "supported" by that widget.

tom@ICASE.EDU (Tom Crockett) (05/17/89)

>I am having trouble displaying a pseudocolor or greyscale image in the
>Xaw Viewport.  Is the Xaw Viewport color capable?  Does anyone have a
>code fragment describing how to display a color zpixmap in this widget?

The Xaw Viewport widget does not allow you to do graphics within it.
Create a child widget of the Viewport widget and do the graphics in the
child widget.  Try using a core widget, whose class is widgetClass.


Donna Converse