CPObjectCPResponder
CPDocument
@implementation CPDocument : CPResponder
CPDocument
is used to represent a document/file in a Cappuccino application.
In a document-based application, generally multiple documents are open simutaneously
(multiple text documents, slide presentations, spreadsheets, etc.), and multiple
CPDocument
s should be used to represent this.
Method Summary | |
---|---|
-(id) | init Initializes an empty document. |
-(id) | initForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo Initializes the document from a URL. |
-(id) | initWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo Initializes a document of a specific type located at a URL. |
-(id) | initWithType:(CPString)aType error:(CPError)anError Initializes the document with a specific data type. |
-(void) | addWindowController:(CPWindowController)aWindowController Add a controller to the document's list of controllers. |
-(CPData) | dataOfType:(CPString)aType error:(CPError)anError Returns the receiver's data in a specified type. |
-(CPString) | displayName Returns the name of the document as displayed in the title bar. |
-(CPString) | fileType Returns the document's file type. |
-(CPURL) | fileURL Returns the path to the document's file. |
-(BOOL) | hasUndoManager Returns YES if the document has a
CPUndoManager . |
-(BOOL) | isDocumentEdited Returns YES if there are any unsaved changes. |
-(void) | makeWindowControllers Creates the window controller for this document. |
-(void) | readFromData:(CPData)aData ofType:(CPString)aType error:(CPError)anError Sets the content of the document by reading the provided data. |
-(void) | readFromURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo Set the document's data from a URL. |
-(void) | saveDocument:(id)aSender Saves the document. |
-(void) | saveDocumentAs:(id)aSender Saves the document to a user specified path. |
-(void) | saveToURL:(CPURL)anAbsoluteURL ofType:(CPString)aTypeName forSaveOperation:(CPSaveOperationType)aSaveOperation delegate:(id)aDelegate didSaveSelector:(SEL)aDidSaveSelector contextInfo:(id)aContextInfo Saves the document to the specified URL. |
-(void) | setFileType:(CPString)aType Sets the document's file type. |
-(void) | setFileURL:(CPURL)aFileURL Sets the path to the document's file. |
-(void) | setHasUndoManager:(BOOL)aFlag Sets whether the document should have a CPUndoManager . |
-(void) | setUndoManager:(CPUndoManager)anUndoManager Sets the document's undo manager. |
-(void) | showWindows Shows all the document's windows. |
-(CPUndoManager) | undoManager Returns the document's undo manager. |
-(void) | updateChangeCount:(CPDocumentChangeType)aChangeType Updates the number of unsaved changes to the document. |
-(CPString) | windowCibName Returns the document's Cib name. |
-(void) | windowControllerDidLoadNib:(CPWindowController)aWindowController Called after aWindowController |
-(void) | windowControllerWillLoadNib:(CPWindowController)aWindowController Called before aWindowController will load the document's Nib file. |
-(CPArray) | windowControllers Returns the document's window controllers. |
Method Detail |
---|
-(id)init
-(id)initForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
anAbsoluteURL
- the document locationabsoluteContentsURL
- the location of the document's contentsaType
- the type of the contentsaDelegate
- this object will receive a callback after the document's contents are loadedaDidReadSelector
- the message selector that will be sent to aDelegate
aContextInfo
- passed as the argument to the message sent to the aDelegate
-(id)initWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
anAbsoluteURL
- the url of the document contentaType
- the type of document located at the URLaDelegate
- the delegate to notifyaDidReadSelector
- the selector used to notify the delegateaContextInfo
- context information passed to the delegate
after initialization-(id)initWithType:(CPString)aType error:(CPError)anError
aType
- the type of document to initializeanError
- not used-(void)addWindowController:(CPWindowController)aWindowController
aWindowController
- the controller to add-(CPData)dataOfType:(CPString)aType error:(CPError)anError
aType
- the format of the dataanError
- not usedCPUnsupportedMethodException
- if this method hasn't been overriden by the subclass-(CPString)displayName
-(CPString)fileType
-(CPURL)fileURL
-(BOOL)hasUndoManager
YES
if the document has a
CPUndoManager
.-(BOOL)isDocumentEdited
YES
if there are any unsaved changes.-(void)makeWindowControllers
-(void)readFromData:(CPData)aData ofType:(CPString)aType error:(CPError)anError
aData
- the document's dataaType
- the document typeanError
- not usedCPUnsupportedMethodException
- if this method hasn't been
overridden by the subclass-(void)readFromURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
anAbsoluteURL
- the URL to the document's contentaType
- the document typeaDelegate
- delegate to notify after reading the dataaDidReadSelector
- message that will be sent to the delegateaContextInfo
- context information that gets sent to the delegate-(void)saveDocument:(id)aSender
fileURL
)
then saveDocumentAs:
will be called.aSender
- the object requesting the save-(void)saveDocumentAs:(id)aSender
aSender
- the object requesting the operation-(void)saveToURL:(CPURL)anAbsoluteURL ofType:(CPString)aTypeName forSaveOperation:(CPSaveOperationType)aSaveOperation delegate:(id)aDelegate didSaveSelector:(SEL)aDidSaveSelector contextInfo:(id)aContextInfo
anAbsoluteURL
- the url to write the document data toaTypeName
- the document typeaSaveOperation
- the type of save operationaDelegate
- the delegate to notify after savingaDidSaveSelector
- the selector to send the delegateaContextInfo
- context info that gets passed to the delegate-(void)setFileType:(CPString)aType
aType
- the document's type-(void)setFileURL:(CPURL)aFileURL
aFileURL
- the path to the document's file-(void)setHasUndoManager:(BOOL)aFlag
CPUndoManager
.aFlag
- YES
makes the document have an undo manager-(void)setUndoManager:(CPUndoManager)anUndoManager
anUndoManager
- the new undo manager for the document-(void)showWindows
-(CPUndoManager)undoManager
nil
, it
will be created and then returned.-(void)updateChangeCount:(CPDocumentChangeType)aChangeType
aChangeType
- a new document change to apply-(CPString)windowCibName
-(void)windowControllerDidLoadNib:(CPWindowController)aWindowController
aWindowController loads the document's Nib file.
aWindowController
- the controller that loaded the Nib file-(void)windowControllerWillLoadNib:(CPWindowController)aWindowController
aWindowController
will load the document's Nib file.aWindowController
- the controller that will load the Nib file-(CPArray)windowControllers
Created on Sat Sep 13 14:15:43 PDT 2008