OWLNext 7.0
Borland's Object Windows Library for the modern age
|
View objects enable document objects to present themselves to the world.
Without a view object, you can't see or manipulate the document. But when you pair a document with a view object into a document template, you have a functional piece of data and code that provides both a graphic representation of the data stored in the document and a way to interact with and change that data. The separation between the document and view also permits flexibility in when and how the data in the document is modified. Although the data is manipulated through the view, the view only relays those changes on to the document. It is then up to the document to determine whether to change the data in the document (known as committing the changes) or discarding the changes (known as reverting back to the document).
Another advantage of using view objects instead of some sort of fixed display method (such as a word-processing program) is that view objects offer the programmer and the user a number of different ways to display and manipulate the same document. Although you might need to provide only one view for a document type, you might also want to provide three or four views.
For example, suppose you create a document class to store graphic information, such as a picture or drawing. For a basic product, you might want to provide only one type of view, such as a view that draws the picture in a window and then lets the user paint and modify the picture. For a more advanced version, you might want to provide extra views; for example, the drawing could be displayed as a color separation, as a hexadecimal file, or even as a series of equations if the drawing was mathematically generated. To access these other views, users choose the type of view desired when they open the document. In all these scenarios, the document itself never changes.
The basic functionality for a view is provided in the ObjectWindows class TView.