GnuDOS library version 1.0: Fog

Next: GNU Free Documentation License, Previous: Strings, Up: Top [Contents][Index]

## 8 Fog: The console Form Designer

Using the utilities of the GnuDOS library will ease the life of console programmers very much, but still though, putting it all together to design a complete user interface (or a form) can be a tedious job. The FOG (Form Designer) helps with this aspect of programming. It provides a development environment that will make it easy to design an application interface for a program using the console-utils library under the console.

Fog is installed as part of the GnuDOS library package. It can be invoked by running:

    $ fog

from the command line. The user interface is very simple:

- Toolbox: Contains the set of ’tools’ that can be added to a form, such as option items and bulleted items
- Form design: Displays the form under design
- Menu bar: Contains the menus File, Edit and Help

Fog saves the form design typically in the same working directory from which it was invoked. This can be changed by specifying another path and file name in the Save dialog box. Fog design files have the extension ’.fog’, to be distinct from other programs’ files. These files should not be edited by hand. Instead, open Fog and edit the form design and re-save the form. After finishing the form design, Fog can create a skeleton project that has most components pre-written for the programmer, mainly the parts that deal with the user interface and getting input from the user.

Select ’Write Project’ from the File menu, or just press CTRL+W. Fog will write three files in the same project directory:

- main.c: Contains the main() program function. If the form contains any buttons, it will contain a function event handler which is called whenever a button is clicked (or the user presses ENTER on it).
- fog_header.h: Contains global variable declarations and function prototypes.
- form_design.c: Contains the following function definitions:
  - - void init_form(): Initializes the form and fills global variables
  - - void refresh_form(): Redraws the form into the screen
  - - void input_loop(): Catches user input on the form
  - - void close_form(): Restores the terminal and clears the screen before exiting

A program designed with Fog can be compiled as following (if using gcc compiler):

    $ gcc -o myprog main.c form_design.c -lGnuDOS

Next: GNU Free Documentation License, Previous: Strings, Up: Top [Contents][Index]