GEOS SDK TechDocs
|
|
4.1 Inclusions and Global Variables
|
4.3 UI Objects
Every GEOS application has an object called the Process object. This object is run by the application's primary thread and is an instance of a subclass of
GenProcessClass
. Because the Process is an event-driven object, there is no
main()
routine that is executed when the program is launched. Instead, the object will wait until it receives messages (events), at which time it will execute the proper methods.
Applications can be of two basic models: The procedural model puts the entire functionality of the application within the Process object, not using any other objects in the application's thread (UI objects are run by the UI thread). All messages sent to the application are handled by the Process object, and most OOP issues can be avoided. The object-oriented model allows for other objects to be run by the application's primary thread; each of these objects will have its own instance data and be located in an object block (a resource) associated with its own message queue.
There is no command or directive that determines which model is used--the distinction is inherent within the format of message handlers and therefore can be virtually ignored. Hello World, for example, is simple enough to use the procedural model, handling all functionality with the Process object.
The Process object of Hello World is shown in Hello World's Process Object .
Code Display 2-3 Hello World's Process Object
This code display is part of hello3.goc and follows the previous display directly. */
/*********************************************************************** * Class & Method Definitions * This section contains the definition of the application's Process * class and its methods. Other classes can also be defined here, * along with the message each handles. ***********************************************************************/
/* * Here we define "HelloProcessClass" as a subclass of the system-provided * "GenProcessClass". As this application is launched, an instance of this class * will be created automatically to handle application-related events (messages). * The application thread will be responsible for running this object, * meaning that whenever this object handles a message, it will be executing * in the application's thread. */
/* You will find no object in this file declared to be of this class. Instead, * this class is bound to the application thread in hello3.gp.
@class HelloProcessClass, GenProcessClass;
/* The messages HelloProcessClass objects can handle that are not * system-defined are enumerated here. Each of these messages is sent * by one of the triggers in the dialog box. This is where class- * specific messages for this application (not system-defined messages) * are defined. */
@message void MSG_HELLO_CHANGE_TO_BLUE(); /* sent by Blue trigger */ @message void MSG_HELLO_CHANGE_TO_GOLD(); /* sent by Gold trigger */ @message void MSG_HELLO_REDRAW_DOCUMENT(); /* sent by Process to itself */
@endc /* signifies end of class definition */
/* Because this class definition must be stored in memory at runtime, * we must declare it here along with a flag indicating how it should * be loaded. The "neverSaved" flag is used because Process classes * are never saved to state files and therefore no relocation tables * need be built. */ @classdecl HelloProcessClass, neverSaved;
GEOS SDK TechDocs
|
|
4.1 Inclusions and Global Variables
|
4.3 UI Objects