Pascal interface – HP SunSoft Pascal 4.0 User Manual

Page 247

Advertising
background image

The XView Toolkit

223

10

with the root being the class from which all others are descended. In the
XView toolkit, the root is the class Generic Object, which has no data fields and
no methods. Each descendant of Generic Object is specialized in some way,
perhaps with additional data fields or methods.

What gives object orientation its power is that the inherited methods of a
subclass can be reimplemented so that they take actions suited to the subclass.

For example, consider a system that has three classes: Drawable Object,
Window, and Icon. Window and Icon are subclasses of Drawable Object. This
setup creates the hierarchical relationship illustrated in Figure 10-1.

Figure 10-1 A Sample Class Hierarchy

Suppose that Drawable Object has a method that draws the object. Window
and Icon inherit that method, but each implements it in a different way.
Window defines a Draw method that draws windows; Icon defines a Draw
method that draws icons.

When you write your program, you can send a message to an object directing
it to draw itself without knowing whether, at runtime, the object is an icon or a
window. This method works because both Window and Icon are descendants
of Drawable Object. At runtime, the object that receives the method draws
itself using its class implementation of the Draw method.

Pascal Interface

To write XView applications in Pascal, you use special libraries, modules files,
object handles, and standard procedures.

Drawabl

e

Object

Icon

Window

Advertising