Chapter 6 Wrapped Class Reference

6.1 Activities and Application Services

The classes included in this section are used by almost every AM2 application, but the ADL user may often be unaware of their existence. MCapplication is a base class to every application class, but the user should not (indeed, can not) declare it explicitly. The ActivityManager and

AttributeManager classes are likewise abstract base classes for any wrapped class that supports activities (see "Using Activities in ADL" on page 59) or attributes (see "Member Access" on page 45), and many applications can be written using the Pressed member rather than the underlying notification request classes Nro, MouseNro, and TimerNro. On the other hand, the services provided by these classes are fundamental. For example, every ADL program should use the 'Exit message provided by the MCapplication class. Detailed documentation for the these classes are provided in the following sections:

The class inheritance tree for the Activities and Application Services (AAS) of AM2 appears in Figure 6.1. Inheritance relationships are shown by the black lines that connect the boxes. Moving from the top to the bottom of the figure, classes inherit from those where a connection exists and they become more specific as you go down the tree. Classes with more that one connection to a superclass are said to have a multiple inheritance relationship

Figure 6.1 Activities and Applications Services Wrapped Classes Inheritance Tree

6.1.1 MCapplication - Abstract

This class serves as the implicit base of every application class, but should not be used explicitly, either as the class of any member or the base of a user defined class. That is, the global level of every ADL application (theApp Class) inherits from the MCapplication wrapped class although its name never appears in the program. This class provides certain application services that do not fit naturally into any other wrapped class. These include interaction with the event loop, registration of certain error handling methods for mathematical built-in functions, and subscription for timers and idle time work procedures. In order to invoke MCapplication methods, the user should send the appropriate message to theApp, an instance of theAppClass.

Superclasses

None

Methods

on Exit

Exit the event loop and terminate the application after returning to the event loop and executing all queued asynchronous messages and propagating all constraints. This means that any statement after the method invocation in the calling method executes: 'Exit => theApp; Use the Die() built-in for emergency exits.

on Sync

Normally attribute updates take effect, asynchronous messages are delivered, and constraints propagate when an activity callback returns control to the event loop. This method forces these actions to be taken immediately.

on SetFatalErrors: list errorList

The mathematical built-ins recognize six named types of errors (see page 266). Two of these are fatal (DOMAIN, SING) and the other four (OVERFLOW, UNDERFLOW, TLOSS, PLOSS) are ignored by default. You can change this behavior by invoking this method on theApp. The single argument in the message should be a list of lists. Each sublist should be a pair consisting of a string specifying the name of an error type and a boolean constant (TRUE, FALSE) indicating whether or not the error is to be treated as fatal.

on SetBypass: integer nEvents

Normally the AM2 event loop follows a strict priority model. High priority I/O events are always processed before timer events, which are processed before normal user interface events, which are processed before idle time events (work procedure callbacks). But this strict model can lock out the processing of user interface events indefinitely, say during a long stretch of software media decompression. This method inverts the event loop for the processing of one event every nEvents events. Normally, an inverted cycle of the event loop starts with checking for a user interface event, then a timer event, and finally a high priority I/O event. If the WorkProcBypass message has been sent to theApp with an argument of TRUE, however, then the inverted cycle will start with checking for an idle time notification request (work procedure) and will only go on to check for user interface events if none is found.

on WorkProcBypass: boolean includeWorkProc

If the includeWorkProc is TRUE, then an inverted event cycle (see the previous method) includes checking for idle time notification. Otherwise, it does not. WorkProcBypass can be called repeatedly to toggle the value on and off.

Attributes

None

Activities
MCapplication Activities
ActivityKeysDescription
Tickinteger late, missedperiodic timer notification
Idlenoneapplication idle

This class supports periodic timers and idle time work procedures via a mechanism that resembles activities, although it does not use the ActivityManager base class. From the point of view of the developer there is no difference. The developer should subscribe for the Tick activity used by the Nro or TimerNro classes, which contains an Extra member that specifies the timer interval in milliseconds.

Examples

"A Simple ADL Application with a Button" page 60

6.1.2 Activity Manager - Abstract

This class is described for reference only. For further informaiton on how to use activites in ADL programs ( see Section 4.5.3, "Creating Classes That Inherit From the ActivityManager Class" page 75).

Superclasses

None

Methods

on Subscribe: handle hNro, handle hTarget return handle

Register for the activity specified in the Nro pointed to by hNro, making the object pointed to by hTarget the recipient of the future notification. This method returns a NULL handle if the subscription is refused, otherwise the value of hNro.

on Unsubscribe: handle hNro, handle hTarget return handle

Unregister the subscription for the object pointed to by hTarget for the activity specified in the Nro pointed to by hNro. Return a NULL handle if the subscription could not be removed for any reason, otherwise the value of hNro.

on TriggerNotification : string activityName, list valueList, handle hTarget

Trigger a notification for the activity activityName sent to the ADL object pointed to by hTarget. The notification message will have the selector activityName and three arguments:

1) the client data supplied in the subscribed Nro of type any;

2) a list of strings that supplies the keys for the activity, drawn from ActivityInfo member;

3) a list of values, valueList, that match the keys in 2.

The message Triggernotification is usually only sent if the programmer has defined a class with it's own, non-standard activities. See the example in section 3.4.2.

on IsAnyoneSubscribed : string activityName, handle hTarget return boolean

Check if the object pointed to by hTarget has subscribed for activity activityName. Return TRUE or FALSE.

Attributes
Activity Manager Attributes
AttributeTypeDescriptionAccess
ActivityInfoListThis member is normally read-only, unless the user has subclassed ActivityManager to define his or her own activity. See the discussion in section 3.4.2. ActivityInfo is a specially formatted list of lists in which each sublist has the form { activityName, listOfActivityKeys }.CG

Activities

None

Example

Table 4.11, "A Class Inheriting from the ActivityManager Class," on page 76

Table 4.12, "An Example Using the Movable Class," on page 77

6.1.3 Attribute Manager - Abstract

This class is an abstract class which manages attributes in the underlying operating or windowing system so that they appear to the ADL programmer as if they are members of the wrapped classes. Most of the User Interface (XF) classes inherit from AttributeManager because attributes of the window system components like width or foreground (color) are really maintained by the underlying window system code and are not stored as actual members of the wrapped user interface classes (see "Wrapped Classes" on page 44).

Superclasses

None

Methods

on Commit

Normally attributes are not updated until after an activity callback returns just before the next activity is dispatched for processing. The user can force updating of an object's attributes by sending a 'Commit to the object.

Attributes

None

Activities

None

Example

None

6.1.4 Nro

This class implements a general notification request object that is more efficient than a pure ADL version. For a general discussion of the use of this class, see Chapter 3 "Using Activities in ADL" page 59, and for a specific discussion of using a generic NRO, see Section 4.2, "Using Notification Request Objects" page 62 .

Superclasses

None

Methods

upon Create: string activity, handle client, string method, any clientData

Create a notification request object for the specified activity that invokes method on the client with the argument clientData as the first argument of the callback message.

upon CreateExtra: string activity, handle client, string method, any clientData, any extra

Same as the previous with the exception that it initializes the member Extra to the value extra.

on HandleActivity: list keys, list values

Should not be called from the ADL, although it may be overwritten in a derived NRO class. This method is called as part of the notification sequence. keys contains the string names of the attributes pertaining to this notification, and values, contains the corresponding data in the same order.

on Lookup: string key, list keys, list values return any

Lookup up key in the notification attribute-value pairs specified by keys and values and return the appropriate value. This method should become class common, when common is implemented.

Attributes
Nro Attributes
AttributeTypeDescriptionAccess
mActivitystringname of activity for which notification is requestedCG
mExtraanyextra notification request dataCG
mClienthandlenotification target objectCSG
mMethodstringnotification target methodCSG
mClientDataanyuser-supplied notification argumentCSG

Activities

None except for the actvityName? activities (see "Using Activities for Notification of Subscriptions" on page 80).

Example

Table 4.3, "An Example Using an NRO," on page 64

6.1.5 MouseNro

This class implements a special notification request object for mouse activities that is more efficient than a pure ADL version. This NRO is used with all of the supported mouse activities in widgets. For a further discussion of MouseNro, see Section 4.3.1, "Mouse NROs" page 64.

Superclasses

Section 6.1.4, "Nro" page 118

Methods

upon Create: string activity, handle client, string method, any clientData

Create a mouse notification request object for the specified activity that invokes method on the client with the argument clientData as the first argument of the callback message.

on HandleActivity: list keys, list values

Should not be called from the ADL, although it may be overwritten in a derived NRO class. This method is called as part of the notification sequence. keys contains the string names of the attributes pertaining to this notification, and values, contains the corresponding data in the same order. For the list of attributes corresponding to mouse activities see "Basic Widget Activities" on page 127.

Attributes

None

Activities

None

Example

Table 4.4, "Using MouseNro Objects," on page 66

6.1.6 TimerNro

This class implements a special notification request object for timers that is more efficient than a pure ADL version. This NRO is used with the Tick activity of MCapplication base to the application class (see "MCapplication - Abstract" on page 115). For further information about the TimerNro, see Section 4.3.2, "Timer NROs" page 67.

Superclasses

Section 6.1.4, "Nro" page 118

Methods

upon Create: integer ival, handle client, string method, any clientData

Create a notification request object for the Tick activity that invokes method on the client every ival milliseconds with the argument clientData as the first argument of the callback message.

on HandleActivity: list keys, list values

Should not be called from the ADL, although it may be overwritten in a derived NRO class. This method is called as part of the notification sequence. keys contains the string names of the attributes pertaining to this notification, and values, contains the corresponding data in the same order.

Attributes

None

Activities

None

Example

"Example Using A Timer" page 68

Figure 6.1 - Activities and Applications Services Wrapped Classes Inheritance Tree
6.1.1 - MCapplication - Abstract
Superclasses
Methods
Attributes
Activities
Examples
6.1.2 - Activity Manager - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.1.3 - Attribute Manager - Abstract
Superclasses
Methods
Attributes
Activities
Example
6.1.4 - Nro
Superclasses
Methods
Attributes
Activities
Example
6.1.5 - MouseNro
Superclasses
Methods
Attributes
Activities
Example
6.1.6 - TimerNro
Superclasses
Methods
Attributes
Activities
Example

AM2 Documentation - 19 NOV 1996

Generated with Harlequin WebMaker