# 2 Using The EZ Widget Library

This chapter is a tutorial of the EZ widget library.

There are two classes of widgets in the EZ widget library: a class of simple widgets each of which is implemented using exactly one X window; and a class of composite widgets which are made from a group of simple widgets. Label, frame, buttons, menu-items, entry and sliders are examples of simple widgets while text widget, list box, notebook and notebook-page are composite widgets.

EZ widgets are event-driven. Interaction between an application and the EZ widget library is achieved via callbacks and event handlers. Typically, an EZwgl application contains five components. \it initialization, creating and configuring widgets, registering widget callbacks and/or event handlers, mapping widgets and handling events.

For some applications, especially interactive graphical applications, it may be desirable to use a "polling" style programming. The EZ widget library also provides an event "polling" routine, `EZ_ServiceEvents()`, which does no-waiting event processing.

The EZ widget library implements a simple geometry manager (rectangle packer). The size and location of EZ widgets are computed semi-automatically by the geometry manager, in the sense that applications specify some controlling information about how to arrange a set of widgets, the geometry manager assigns a size and location to each widget.

The EZwgl also supports a more advanced grid bag geometry management. The grid bag geometry manager is implemented through the row-column container widget.

There are some subtle differences between simple widgets and composite widgets.

- For a simple widget, events are dispatched to the widget event handler; callbacks, event handlers and client data are registered to the widget data structure. For a composite widget, however, events are dispatched to whatever children widgets that are involved; Callbacks, eventHandlers and client data, if set, are attached to the most relevent widget. For example, in a ListBox widget, these information are automatically registered to the Internal ListBox widget.

- For a simple widget, children widgets are the direct descendants of the widget; for a composite widget, children widgets are arranged as the children of the top-most frame of the composite widget.

HTML Documentation Maintainance:`Arturo Espinosa <arturo@nuclecu.unam.mx>`