
In addition to a destructor TDocument also provides a CanClose function to,
make sure that it’ OK to close. CanClose first checks whether all its childrens
can close. If any child returns FALSE, CanClose returns FALSE and aborts. If
all child documents return TRUE, CanClose calls the document manager
function FlushDoc, which checks to see if the document is dirty If the.
document is clean, FlushDoc and CanClose return TRUE. If the document is
dirty FlushDoc opens a message box that prompts the user to either save,
the data, discard any changes, or cancel the close operation.
The functions described in this section include most of what you need to
Expanding
know to make a functioning document class. It is up to you to expand the
document
functionality of your document class. Y ur class needs special functions foro
functionality
manipulating data, understanding and acting on the information obtained
from the user through the document’ associated view and so on. All thiss ,
functionality goes into your TDocument-derived class.
Because the Doc/View model is so flexible, there are no requirements or
rules as to how you should approach this task. A document can handle
almost any type of data because the Doc/View data-handling mechanism is
a primitive framework, intended to be extended by derived classes. The
base classes provided in ObjectWindows provide the functionality to
support your extensions to the Doc/View model.
TDocument provides two functions for accessing the document manager,
W rking with theo
GetDocManager and SetDocManager. GetDocManager returns a pointer to the
document
current document manager Y u can then use this pointer to access the data. o
manager
and function members of the document manager SetDocManager lets you.
assign the document to a different document manager All other document.
manager functionality is contained in the document manager itself.
TDocument provides two functions for working with views, NotifyViews
W rking witho
and QueryViews. Both functions take three parameters, an int
views
corresponding to an event, a long item, and a TView *. The meaning of the
long item is dependent on the event and is essentially a parameter to the
event. The TView * lets you exclude a view from your query or notification
by passing a pointer to that view to the function. These two functions are
your primary means of communicating information between your
document and its views.
Both functions call views through the views’ response tables. The general-
purpose macro used for ObjectWindows notification events is
EV_OWLNOTIFY The response functions for EV_OWLNOTIFY events.
have the following signature:
212
OWL P ogrammer’ Guider s