previous chapter contents page top page next chapter


Box

February 29, 1996

Inherits from Viewable, HasBorder 




Class Description

Boxes are viewable objects that are drawn with framed borders around them. The borders are decorative, and the user can change a box's border by dropping a border coupon into the box.

Box is a popular class, with many instances in the Magic Cap software. In addition, there are many subclasses of Box, including windows, stationery, and list views. A viewable object that can be framed with a border is usually a subclass of Box.

Programming Information

Box is a simple class that's created by adding the HasBorder mixin to the class Viewable, forming a template for the simplest possible framed viewable objects. You can add boxes to your packages by getting them from the Magic Hat. Boxes are used to group objects visually. Boxes act as the superview for the objects that they contain.

Programming Information

Instantiate: often
Subclass: often
Call its methods: rarely

Class Box doesn't add any additional fields beyond those provided by its superclasses, and it only defines two methods of its own, both of them overridden from class Viewable. The methods defined by Box are the ones that determine what kinds of viewables and coupons can be dropped into boxes, CanAccept and CanAcceptCoupon.

Methods defined by class Box

Class Box defines the following methods:

Method Description
CanAccept Overridden to allow some objects to be dropped in
CanAcceptCoupon Overridden to accept all coupons except sound coupons
CanBeTransparent Overridden to return true only for class Box itself (not subclasses)

Fields defined by class Box

Class Box 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 Flags 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 Framed border drawn around object

Related Classes

The system has many subclasses of Box that provide specialized behavior. Some of these classes are shown in the class hierarchy at the beginning of this chapter. You can examine these classes and their documentation to learn more about how to create subclasses of Box.

Method Descriptions

Although you'll rarely have to call any methods of class Box, descriptions of these methods are provided here for your information. Class Box defines only two methods.

Dropping Coupons and Viewables

CanAccept

overrides CanAccept(target: Object; where: Dot): Boolean

Call: rarely
Override: sometimes

When the user drags a viewable object over the box, the system calls CanAccept to test whether the object being dragged can be dropped and can become a subview of the box. Box_CanAccept allows objects to be dropped in the following cases:

You should override CanAccept to perform other tests if you want objects of your classes to use other criteria for deciding whether to accept objects. See Viewable_CanAccept for more information.

CanAcceptCoupon

overrides CanAcceptCoupon(coupon: Object; partCode: LongInt): Boolean

Call: rarely
Override: sometimes

When the user drags a coupon over the box, the system calls CanAcceptCoupon to test whether the box can accept that coupon. Box_CanAcceptCoupon accepts all coupons accepted by its superclasses except sound coupons. See Viewable_CanAcceptCoupon for more information.