ADocumentBase
Abstract
Handles standard document-related commands.
Superclass: ACommandHandler, ANavDialogClient, ANavEventHandler
Discussion
The command-related functionality is isolated into a separate
class to simplify the ADocument template.
This class handles the Save, Save As, and Revert commands,
including the Navigation Services sheets necessary to carry
out those commands.
The default implementation of FileTypes gets its data from
the Info.plist file, similar to how Cocoa's NSDocument works.
The returned array includes all document types whose role is
"Editor", and whose type does not match the value returned by
DocumentTypeName, since that will be the item that appears
at the top of the menu.
The mTypeIndex member is an index into the array returned by
FileTypes, indicating the user's file type choice when
saving the file. A value of -1 indicates the "main" file type,
which is excluded by the default implementation of FileTypes.
Subclasses should at least override ReadFile() and WriteFile().
Member Functions
- CanSaveFileType
- Filter file types
- CompleteSaveAction
- Called after a Save or Save As operation
- DocumentTypeName
- Return the document type's name, corresponding to an
entry in the application's Info.plist file.
- FileCreator
- Return the 4-byte file creator for document files.
- FileType
- Return the 4-byte file type for document files.
- FinishSaveAs
- Handle the results of the Save As dialog
- ShouldSave
- Determine if saving is allowed
- ShowSearchText
- Display the text from a Spotlight search
Filter file types
protected
virtual bool CanSaveFileType(
const ACFString &inTypeName) const
Discussion
Determine if the given file type is currently available
for saving. Called by GenerateSaveTypes.
- function result
- False to exclude the type from the file types list.
Called after a Save or Save As operation
protected
virtual void CompleteSaveAction();
Discussion
If the document was being saved before closing,
this method finishes by deleting the document.
Return the document type's name, corresponding to an
entry in the application's Info.plist file.
public
virtual ACFString DocumentTypeName() const;
Discussion
The default implementation returns the first type listed
in the Info.plist file.
- function result
- The type name
Return the 4-byte file creator for document files.
public
virtual OSType FileCreator();
Discussion
The default implementation returns the creator type
from the Info.plist file.
Return the 4-byte file type for document files.
public
virtual OSType FileType();
Discussion
The default implementation returns the first OSType
listed in the Info.plist dictionary, using
DocumentTypeName() to look up the document info.
Handle the results of the Save As dialog
protected
virtual void FinishSaveAs(
ANavReply &inReply);
Determine if saving is allowed
protected
virtual bool ShouldSave()
Discussion
For example, an application in demo mode would return
false from this function if saving is restricted.
- function result
- True if saving is allowed.
Display the text from a Spotlight search
protected
virtual void ShowSearchText(
const std::string &inSearchText)
Discussion
This method is called from Initialize() when a document
was opened from a Spotlight search.
Parameter Descriptions
- inSearchText
- The text from the Spotlight search.
Member Data
(Last Updated October 06, 2006)