OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Designing Document Template Classes

You create a document template class using the DEFINE_DOC_TEMPLATE_CLASS macro.

This macro takes three arguments:

  • Document class
  • View class
  • Template class name

The document class should be the document class you want to use for data containment. The view class should be the view class you want to use to display the data contained in the document class. The template class name should be indicative of the function of the template. It cannot be a C++ keyword (such as int, switch, and so on) or the name of any other type in the application. For example, suppose you have two document classes–one called TPlotDocument, which contains graphics data, and another called TDataDocument, which contains numerical data. Now suppose you have four view classes, two for each document class. For TPlotDocument, you have TPlotView, which displays the data in a TPlotDocument object as a drawing, and THexView, which displays the data in a TPlotDocument object as arrays of hexadecimal numbers. For TDataDocument, you have TSpreadView, which displays the data in a TDataDocument object much like a spreadsheet, and TCalcView, which displays the data in a TDataDocument object after performing a series of calculations on the data.

To associate the document classes with their views, you would use the DEFINE_DOC_TEMPLATE_CLASS macro. The code would look something like this:

As you can see from the first line, the existing document class TPlotDocument and the existing view class TPlotView are brought together and associated in a new class called TPlotTemplate. The same thing happens in all the other lines, so that you have four new classes, TPlotTemplate, THexTemplate, TSpreadTemplate, and TCalcTemplate. The next section describes how to use these new classes you have created.

See Also