11 The DrawingArea Widget
This chapter describes the Motif DrawingArea widget, which provides a canvas for interactive drawing. The chapter
does not try to teach Xlib drawing, but rather it highlights, with numerous code examples, the difficulties that may be
encountered when working with this widget. The chapter assumes some knowledge of Xlib. See Volume One, Xlib
Programming Manual, for additional information.
The DrawingArea widget provides a blank canvas for interactive drawing using basic Xlib drawing primitives. The
widget does no drawing of its own, nor does it define or support any Motif user−interface design style. Since it is
subclassed from the Manager widget class, the DrawingArea widget may also contain other widgets as children,
although there is no regimented layout policy. In short, the DrawingArea is a free−form widget that you can use for
interactive drawing or object placement when conventional user−interface rules do not apply.
The most intuitive use of the DrawingArea is for a drawing or painting program. Here, the user can interactively draw
geometric objects and paint arbitrary colors. Another interesting application demonstrated at a recent trade show used
a DrawingArea widget to display a map of the United States with dynamically−drawn line segments representing the
flight paths taken by airplanes. The actual airplanes were represented by PushButton widgets displaying pixmaps.
Each airplane icon moved dynamically along its flight path unless the user grabbed and moved ...