GenView: 5.3 The GenViewControl: GenViewControl Example

Up: GEOS SDK TechDocs | Up | Prev: 5.2 Notification Received | Next: 5.4 Messages Handled

An example of the use of a GenViewControl is shown in An Example of GenViewControl . This example is built on the Hello World application, and only the differences between Hello World and the example are shown. As an exercise, try adding a GenToolControl to Hello World as well.

Code Display 9-9 An Example of GenViewControl

/* This display builds on the Hello World sample application. You should make the
 * changes shown here to that program, compile it, and run it to get a solid feel
 * for how the GenViewControl works and the features it provides.
 * Only the alterations to Hello World are shown here; the basic code can be found
 * in the Hello World chapter. */
/* Add the GenViewControl definition file. */
@include <Objects/gViewCC.goh>
/* HelloApp changes
 * Add a new GCN list type to the application object, and add the HelloViewControl
 * object to the list. This list is typical of system-provided controllers. */
@object GenApplicationClass HelloApp = {
    GI_visMoniker = list { @HelloTextMoniker };
    GI_comp = @HelloPrimary;
    gcnList(MANUFACTURER_ID_GEOWORKS, GAGCNLT_WINDOWS) =							@HelloPrimary;
    gcnList(MANUFACTURER_ID_GEOWORKS, GAGCNLT_SELF_LOAD_OPTIONS) =									/* add */
							@HelloViewControl;
}
/* HelloPrimary changes
 * Add a new menu to the Primary's list of children. This new menu is called
 * HelloViewMenu and is declared below. */
@object GenPrimaryClass HelloPrimary = {
    GI_visMoniker = "Hello Sample Application";							/* unchanged */
    GI_comp = @HelloView, @HelloMenu, @HelloViewMenu;							/* add @HelloViewMenu */
    ATTR_GEN_DISPLAY_NOT_MINIMIZABLE;							/* unchanged */
    HINT_SIZE_WINDOW_AS_DESIRED;							/* unchanged */
}
/* HelloViewMenu declaration
 * Declare a new menu, HelloViewMenu. The GenViewControl object will add its
 * features to this menu. */
@object GenInteractionClass HelloViewMenu = {
    GII_visibility = GIV_POPUP;				/* This makes the GenInteraction a menu */
    GI_comp = @HelloViewControl;				/* Add the GenViewControl as the menu's child */
    ATTR_GEN_INTERACTION_GROUP_TYPE = (GIGT_VIEW_MENU);
				/* Give this menu the default characteristics
				 * of the standard View menu. */
}
/* HelloViewControl declaration
 * Declare the GenViewControl object, HelloViewControl. This needs no extra
 * settings; we will use all the defaults. */
@object GenViewControlClass HelloViewControl = {
}
/* HelloView changes
 * The only change necessary to the GenView itself is to mark it controlled.
 * This entails setting the GVA_CONTROLLED flag in GVI_attrs. */
@object GenViewClass HelloView = {
    GVI_attrs = @default | GVA_CONTROLLED;						/* set the controlled attr */
    GVI_horizAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT;
						/* unchanged */
    GVI_vertAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT;
						/* unchanged */
    GVI_content = process;						/* unchanged */
}

Up: GEOS SDK TechDocs | Up | Prev: 5.2 Notification Received | Next: 5.4 Messages Handled