Generic UI Controllers: 1.2 Controller Features and Functions: How Controllers Work

Up: GEOS SDK TechDocs | Up | Prev: 1.1 Controller Features | Next: 1.3 Using Controllers

When you use a controller object, you are really using three different types of objects: The controller itself, the UI gadgetry it creates and manages, and the controlled object (sometimes called a "data item") it acts on. For the most part, you will not have to understand these relationships unless you are creating your own controllers with GenControlClass .

To explain how a controller works with both of these other objects, this section uses a simple application that uses a single controller. The controller used is a PointSizeControl object, exported by the text library and used with the GenText and VisText objects; in this example, it interacts with two GenText objects. The entire source code of the application's psctext.goc file is given in A Sample Controller Application (psctext.goc) . This code display does not show the psctext.gp file because it is similar to Hello World's parameters file.

A screen dump of the application is shown below and the entire object tree declared in the application is shown above. The controller object (PSCTSizeControl) declares and sets up the entire menu structure of the Sizes menu, so the menu items do not need to be declared in the application's .goc file.

The interaction between the controller, the text objects, and the controller's UI objects is simple. When the controller is first loaded in from the application's Interface resource block, it also loads in the associated UI gadgetry for the Sizes menu. The menu items are added as children of the controller without the programmer having to do anything extra.

The data item objects (in this example the GenText objects), when loaded or created, create and set up special General Change Notification (GCN) lists. In the PSCText sample application, the text library sets up a GCN list for the notification type GAGCNLT_APP_TARGET_NOTIFY_CHAR_ATTR_CHANGE. When changes to the text object occur, the text object will send a message to this GCN list.

The controller object knows inherently which GCN lists it should be added to. When it is loaded, it adds itself to these lists. In the sample application, the PSCTSizeControl object will add itself automatically to the GCN list for GAGCNLT_APP_TARGET_NOTIFY_CHAR_ATTR_CHANGE.

The interactions between the three components are summarized in the figure below. The application programmer needs to know very little about the interactions of these components; in fact, unless you are creating your own controller objects, you can get away with knowing only a very few things. Building your own controller is detailed in Creating Your Own Controllers , and the basics of controller use, along with the source code for psctext.goc , are shown in Using Controllers .


Up: GEOS SDK TechDocs | Up | Prev: 1.1 Controller Features | Next: 1.3 Using Controllers