NAME
Am_Main_Event_Loop, Am_Exit_Main_Event_Loop, Am_Initialize, Am_Cleanup - Amulet initialization and cleanup
SYNOPSIS
#include <amulet.h>
extern void Am_Initialize ();
extern void Am_Main_Event_Loop ();
extern void Am_Exit_Main_Event_Loop ();
extern void Am_Cleanup ();
DESCRIPTION
OpenAmulet requires a call to Am_Initialize before referencing any Opal objects or classes. This function creates the Opal prototypes and sets up bookkeeping information in OpenAmulet objects and classes. Similarly, a call to Am_Cleanup at the end of your program allows OpenAmulet to destroy the prototypes and classes, explicitly releasing memory and graphical resources that might otherwise remain occupied after the program exits.
In order for interactors to perceive input from the mouse and keyboard, the main-event-loop must be running. This loop constantly checks to see if there is an event, and processes it if there is one. The automatic redrawing of graphics also relies on the main-event-loop. Exposure events, which occur when one window is uncovered or exposed, cause OpenAmulet to refresh the window by redrawing the objects in the exposed area.
A call to Am_Main_Event_Loop should be the second-to-last instruction in your main program, just before Am_Cleanup. Your program will continue to run until you tell it otherwise. All OpenAmulet programs running Am_Main_Event_Loop can be aborted by pressing the escape sequence, which by default is META-SHIFT-F1. Most programs will have a Quit option, in the form of a button or menu item, that calls Am_Exit_Main_Event_Loop, which will cause the main event loop to terminate.
EXAMPLES
This is a simple Amulet program:
int main (void)
{
Am_Initialize ();
Am_Object my_win = Am_Window.Create ("my_win")
.Set (Am_LEFT, 20)
.Set (Am_TOP, 50);
Am_Screen.Add_Part (my_win);
// code to add widgets to the window would go here
Am_Main_Event_Loop ();
Am_Cleanup ();
return 0;
}
SEE ALSO
"OpenAmulet Reference Manual"