Examples
The following example shows the type definition of an Indicator control that displays a caption, and is used to indicate an on/off condition. This control is a subclass of the
The attributes defined for the Indicator class are listed in the following table.
Attribute Name | Primitive Type | Length |
---|---|---|
caption | String | 1000 |
value | Boolean |
The following is an example of a value mapping method.
value(set: Boolean; val: Boolean io) mapping, updating; vars tempColor : Integer; begin if set then if val <> value then // Swap the foreground and background colors to indicate // that the status has changed. This causes a paint. tempColor := backColor; backColor := foreColor; foreColor := tempColor; endif; endif; end;
The following are examples of the reimplemented
click(cntrl: Indicator) updating; begin // The following assignment causes the value mapping method // to be executed. value := not value; end;
paint(cntrl: Indicator input) updating; begin drawTextAlign := 2; drawTextIn (caption, 0, 0, width, height, foreColor); inheritMethod(cntrl); end;
The following is an example of a constructor method.
create() updating; begin value := false; end;
The following examples for an ActiveTextBox control (a subclass of the
toggleColors() updating, protected; vars tempColor : Integer; begin tempColor := foreColor; foreColor := backColor; backColor := tempColor; end; gotFocus(textbox: ActiveTextBox input) updating; begin toggleColors; inheritMethod(textbox); end; lostFocus(textbox: ActiveTextBox input) updating; begin toggleColors; inheritMethod(textbox); end;