Output of color_draw.c
One thing to note about the program is that the callback routine for the Clear button is passed the DrawingArea
widget as the client data. This technique saves us from having to declare a global variable, while still providing a
handle to the DrawingArea in the callback routine.
11.5 Summary
The DrawingArea widget is probably most useful when it is used as a canvas for displaying raster images, animation,
or a mixture of text and graphics. It is also well−suited for tasks that require interactive user input. The widget
provides some rudimentary input mechanisms in the form of callbacks that are invoked by button events.
The translation and action tables supported by the X Toolkit Intrinsics provide a simple mechanism for notifying
applications of user events such as double−mouse clicks, keyboard events, and so on. By creatively modifying the
default translations and actions, you could build a rather intricate system of action functions that produces interesting
graphics based on various forms of user input sequences.
However, what you can do with actions is simplistic given the complexities that are involved in true paint or draw
applications. Applications that require a graphic front end should -probably dig deeper into the lower levels of Xt for
event handling and into Xlib for image -rendering.
11.6 Exercises
There are a number of different possibilities you could explore in extending the DrawingArea widget. The following
exercises are intended to shine the light down ...