[comp.windows.x] X Graphics Widget

jonm@syma.sussex.ac.uk (Jonathan Meyer) (12/14/89)

(Fairly long - and only of general interest)

We wanted a simple graphics widget here - that allowed users to draw lines and
text on a window without worrying about expose events. We couldn't find one,
so wrote our own. It provides the user with copious resources that can be set.
For example if the user doesn't specify a graphics context, then the widget
gets a shared default graphics context for drawing operations. Any changes to
the graphics context's elements cause the creation of a non-shared graphics
context that is specific to that widget.

Has anyone else done this, or would others find such a widget useful? Here is
more info:

The widget has a set of graphics operations which are basically a copy of the
Xlib graphics ops, except that they perform the graphics operation on both the
window and a pixmap copy of the window that is used to restore the window in
cases of exposure/resize events (resource expensive, I know, but also very
easy to implement).

The Widget also does several other operations to make life easier for the
programmer. We mainly use the widget for an interactive programming
environment called Poplog. In such an environment, it is possible to issue
Xlib and Xtoolkit commands interactively, and see the results immediately.
(This makes developing UI's very easy).

The ability to just create a widget and draw on it, without worrying about all
of those (complex) matters like events, graphics contexts, colourmaps,
pixmaps, resources, size, shape... is very useful to people that don't want to
write X applications, but do want to view the results of their programs
without investing loads of time learning about a whole programming interface.
To create a window and draw a graph, he just types something like:

 xt_create_widget(PopGraphic, [[width 100][height 100][background blue]]) ->w;

 xt_drawline(w,50,0,50,100); xt_drawline(w,0,50,100,50) ...

Does anyone know of widget sets which include such a basic widget? It is
useful to have such a generic widget, which doesn't have loads of bells and
whistles, or try to be too clever. We would rather not have to support such
widgets if another widget set provides us with the functionality that we
need. The (HP/Athena) widget sets that we have seen don't have such a low
level widget. Do others agree that such widgets are a good idea, or do people
think that the programmer ought to create such simple widgets himself?


Jon.

PS. Poplog/X Windows still under developement. Everything said here is my own
opinion, and won't necessarily reflect the views of anyone else at all.