Documents: 4.2 Advanced DC Usage: Multiple Document Model

Up: GEOS SDK TechDocs | Up | Prev: 4.1 Document Protocols | Next: 4.3 Working with DOS files

The Object model of document control makes it easy to manage several documents at once. Effectively, each document object acts as a special-purpose application dedicated to handling one file. The display control lets the user change documents at will. The document control and display control take care of most of the nuts and bolts of file switching, so the application doesn't have to worry about them.

Subclassing GenDocumentClass

Under the object model of document control, a document's functionality is implemented as methods in the document class. Much of the switching between documents is thus transparent to the application. When the target changes, all user actions will result in messages being sent to the new target document; whenever a document gets a message, it knows the message pertains to itself, not some other document (and thus knows that it is the target document).

In order to implement this functionality, the application must declare a subclass of GenDocumentClass . This subclass will have its own methods for application-handled messages.

Using the Display Group

The simplest way to manage multiple documents is to use the display control. The display control lets the user change documents transparently to the application. In order to do this, the application must define a resource of objects which should be copied each time a document is opened or created. The GenDocumentGroup object's GDGI_genDisplay attribute should be set to point to a GenDisplay object in that resource; the GenDisplay should be set "not usable" and should be the head of a tree of objects. Also, the application should define an object of GenDisplayGroupClass , and the GenDocumentGroup's GDGI_genDisplayGroup attribute should be set to point to it. The display control will then automatically switch displays whenever the user chooses an entry from the display control.


Up: GEOS SDK TechDocs | Up | Prev: 4.1 Document Protocols | Next: 4.3 Working with DOS files