previous chapter contents page top page next chapter

Form

August 18, 1992
last updated January 21, 1994

Defined in Card.Def 
Inherits from Viewable, HasBorder


Class Description

When you create a package that consists of a stack of cards, you might want to have viewable objects that appear on more than one card. To do this, you can create a form, place the objects that you want to share in the form, and then make each card refer to that form. The shared objects will be drawn on every card that uses the form.

Every card uses exactly one form, but a form can be used by any number of cards.

Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Related Classes

You can find information relevant to the Form class in the sections describing classes Card and FormElement.

Using a Form Object

If your package contains a stack of cards, it must also include at least one form object. The usual way to create the stack, cards, and form is to copy an existing package that includes a stack. Using the Magic Cap software itself, you can modify the form by adding and removing objects. You can use the "put in background" and "put in foreground" coupons to move objects between the card and the form (background is an old name for form).

Each card is associated with a form. The form specifies objects that are shared by more than one card. When a card is drawn on the screen, the objects in the card's form are also drawn. Although the form objects are shared across cards, each card has its own data for the shared items. For example, a text field object in a form will be drawn with every card that uses the form, but every card can have its own text that appears in the text field object. The data for shared form items is kept in the card's extra data area.

Classes can define whether their objects store per-card data when placed in forms. Classes whose objects store per-card data should mix in the FormElement class.

A form can be associated with an image object. If a form has an image, the system draws the image in the upper left corner of the form. Usually the form's image is nil.

Programming Information

Instantiate: sometimes
Subclass: rarely
Call its methods: rarely

If your package consists of a stack of cards, you must create at least one form. As mentioned earlier, you'll probably make your stack and at least one card and form by copying an existing package. If your stack includes different logical groups of cards that share different sets of viewable objects, you can use a different form for each group of cards.

Class Form defines very few methods. The only method that you're likely to call is the one that returns the form's viewables that have different data on each card. Viewables that are on the form but have different data on each card, such as text field objects and switches, are called form items.

Most of class Form's methods are called by other parts of the system. You'll rarely have to call any methods of class Form directly.

Methods defined by class Form

The Form class has the following methods that you might call:

Method Description
FormItems Return form viewables that have per-card data
DrawCardBackground Draw the form elements on the card
GetOrMakeAgent Return an agent for a telecard

The Form class has the following methods that you might override:

Method Description
AttachToCard Initialize prior to displaying or printing
DetachFromCard Clean up after displaying or printing

Fields defined by class Form

The Form class defines the following fields:

Field Type Description
Inherited from SingleLinkable
next Object Next item in view list
Inherited from Linkable
previous Object Previous item in view list
Inherited from Viewable
superview Viewable Container for this object
subview Viewable Object contained by this object
relativeOrigin Dot Origin relative to superview
contentSize Dot Size of content rectangle
viewFlags Unsigned Property settings
labelStyle TextStyle Text style of object's label
color Color Color of object's content
shadow Shadow Shadow drawn with object
sound Sound Sound associated with object
Inherited from HasBorder
border Border Frame drawn around object
Defined by Form
image Image Image drawn in corner of form
formItems Viewable List of shared items with per-card data

Method Descriptions

FormItems

operation FormItems(): Viewable

Call: sometimes
Override: rarely

Call FormItems to get an object list that contains the items in the form that store per-card data. FormItems simply returns the value of the form's formItems field.

AttachToCard

operation AttachToCard()

Call: sometimes
Override: always

AttachToCard is available to do any initialization required your form requires before it is displayed or printed. The basic Form class does not define this method. If you want to use it, you will have to override it. This method is called by Card_SummonForm. See the section on class Card for more information.

DetachFromCard

operation DetachFromCard()

Call: sometimes
Override: sometimes

DetachFromCard is available to do any clean-up required after your form is displayed or printed. As with AttachToCard, you'll have to override this method ifyou want to use it. Card_DismissForm calls this method. See the section on class Card for more information.

DrawCardBackground

operation DrawCardBackground(canvas: Canvas; clip: Path), noFail

Call: sometimes
Override: rarely

To be written.

GetOrMakeAgent

operation GetOrMakeAgent(): Object

Call: sometimes
Override: sometimes

By default, GetOrMakeAgent returns a standard courier agent (StandardCourier_). Class Telecard calls Form_GetOrMakeAgent in its definition of GetOrMakeAgent.


Version note: More information on agents and cards will appear in future chapters on telecard-related classes. We're expanding the information highway to better serve you!