Previous: Some Examples, Up: Part I Getting Started [Contents][Index]

### 2.3 Programming Model

To summarize, every Forms Library application program must perform several basic steps. These are

Initialize the Forms Library

  This step establishes a connection to the X server, allocates resources and otherwise initializes the Forms Library’s internal structures, which include visual selection, font initialization and command line parsing.

Defining forms

  Every program creates one or more forms and all the objects on them to construct the user interface. This step may also include callback registration and per object initialization such as setting bounds for sliders etc.

Showing forms

  This step makes the designed user interface visible by creating and mapping the window (and subwindows) used by the forms.

Main loop

  Most Forms Library applications are completely event-driven and are designed to respond to user events indefinitely. The Forms Library main loop, usually invoked by calling `fl_do_forms()`, retrieves events from the X event queue, dispatches them to the appropriate objects and notifies the application of what action, if any, should be taken. The actual notification method depends on how the interaction is set up, which could be done by calling an object callback or by returning the object whose status has changed to the application program.

The following chapters will lead you through each step of the process with more details.