Package wx :: Package lib :: Module docview :: Class Document

[frames | no frames]

## Type Document

    object --+
             |
        Object --+
                 |
        EvtHandler --+
                     |
                    Document

Known Subclasses:
  `ChildDocument`

The document class can be used to model an application's file-based data. It is part of the document/view framework supported by wxWindows, and cooperates with the wxView, wxDocTemplate and wxDocManager classes.

Note this wxPython version also keeps track of the modification date of the document and if it changes on disk outside of the application, we will warn the user before saving to avoid clobbering the file.

Method Summary
| ``__init__`(self, parent)` Constructor.
| ``AddView`(self, view)` If the view is not already in the list of views, adds the view and calls OnChangedViewList.
| ``Close`(self)` Closes the document, by calling OnSaveModified and then (if this true) OnCloseDocument.
| ``DeleteAllViews`(self)` Calls wxView.Close and deletes each view.
| ``DeleteContents`(self)` Deletes the contents of the document.
| ``Destroy`(self)` Destructor.
| ``Draw`(context)` Called by printing framework to draw the view.
| ``GetCommandProcessor`(self)` Returns the command processor associated with this document.
| ``GetDocumentManager`(self)` Returns the associated document manager.
| ``GetDocumentModificationDate`(self)` Returns the file's modification date when it was loaded from disk.
| ``GetDocumentName`(self)` The document type name given to the wxDocTemplate constructor, copied to this document when the document is created.
| ``GetDocumentSaved`(self)` Returns True if the document has been saved.
| ``GetDocumentTemplate`(self)` Returns the template that created the document.
| ``GetDocumentWindow`(self)` Intended to return a suitable window for using as a parent for document-related dialog boxes.
| ``GetFilename`(self)` Gets the filename associated with this document, or "" if none is associated.
| ``GetFirstView`(self)` A convenience function to get the first view for a document, because in many cases a document will only have a single view.
| ``GetPrintableName`(self)` Copies a suitable document name into the supplied name buffer.
| ``GetTitle`(self)` Gets the title for this document.
| ``GetViews`(self)` Returns the list whose elements are the views on the document.
| ``GetWriteable`(self)` Returns true if the document can be written to its accociated file path.
| ``IsDocumentModificationDateCorrect`(self)` Returns False if the file has been modified outside of the application.
| ``IsModified`(self)` Returns true if the document has been modified since the last save, false otherwise.
| ``LoadObject`(self, file)` Override this function and call it from your own LoadObject before loading your own data.
| ``Modify`(self, modify)` Call with true to mark the document as modified since the last save, false otherwise.
| ``NotifyClosing`(self)` Notifies the views that the document is going to close.
| ``OnChangedViewList`(self)` Called when a view is added to or deleted from this document.
| ``OnCloseDocument`(self)` The default implementation calls DeleteContents (an empty implementation) sets the modified flag to false.
| ``OnCreate`(self, path, flags)` The default implementation calls DeleteContents (an empty implementation) sets the modified flag to false.
| ``OnCreateCommandProcessor`(self)` Override this function if you want a different (or no) command processor to be created when the document is created.
| ``OnNewDocument`(self)` The default implementation calls OnSaveModified and DeleteContents, makes a default title for the document, and notifies the views that the filename (in fact, the title) has changed.
| ``OnOpenDocument`(self, filename)` Constructs an input file for the given filename (which must not be empty), and calls LoadObject.
| ``OnSaveDocument`(self, filename)` Constructs an output file for the given filename (which must not be empty), and calls SaveObject.
| ``OnSaveModified`(self)` If the document has been modified, prompts the user to ask if the changes should be changed.
| ``ProcessEvent`(self, event)` Processes an event, searching event tables and calling zero or more suitable event handler function(s).
| ``RemoveView`(self, view)` Removes the view from the document's list of views, and calls OnChangedViewList.
| ``Revert`(self)` Override this function to revert the document to its last saved state.
| ``Save`(self)` Saves the document by calling OnSaveDocument if there is an associated filename, or SaveAs if there is no filename.
| ``SaveAs`(self)` Prompts the user for a file to save to, and then calls OnSaveDocument.
| ``SaveObject`(self, file)` Override this function and call it from your own SaveObject before saving your own data.
| ``SetCommandProcessor`(self, processor)` Sets the command processor to be used for this document.
| ``SetDocumentModificationDate`(self)` Saves the file's last modification date.
| ``SetDocumentName`(self, name)` Sets he document type name given to the wxDocTemplate constructor, copied to this document when the document is created.
| ``SetDocumentSaved`(self, saved)` Sets whether the document has been saved.
| ``SetDocumentTemplate`(self, template)` Sets the template that created the document.
| ``SetFilename`(self, filename, notifyViews)` Sets the filename for this document.
| ``SetTitle`(self, title)` Sets the title for this document.
| ``SetWriteable`(self, writeable)` Set to False if the document can not be saved.
| ``UpdateAllViews`(self, sender, hint)` Updates all views.

Property Summary

Method Details

### __init__(self, parent=None)
(Constructor)

Constructor. Define your own default constructor to initialize application-specific data.

  Overrides:
    `wx.EvtHandler.__init__`

### AddView(self, view)

If the view is not already in the list of views, adds the view and calls OnChangedViewList.

### Close(self)

Closes the document, by calling OnSaveModified and then (if this true) OnCloseDocument. This does not normally delete the document object: use DeleteAllViews to do this implicitly.

### DeleteAllViews(self)

Calls wxView.Close and deletes each view. Deleting the final view will implicitly delete the document itself, because the wxView destructor calls RemoveView. This in turns calls wxDocument::OnChangedViewList, whose default implemention is to save and delete the document if no views exist.

### DeleteContents(self)

Deletes the contents of the document. Override this method as necessary.

### Destroy(self)

Destructor. Removes itself from the document manager.

  Overrides:
    `wx.Object.Destroy`

### Draw(context)

Called by printing framework to draw the view.

### GetCommandProcessor(self)

Returns the command processor associated with this document.

### GetDocumentManager(self)

Returns the associated document manager.

### GetDocumentModificationDate(self)

Returns the file's modification date when it was loaded from disk. This is used to check if the file has been modified outside of the application. This method has been added to wxPython and is not in wxWindows.

### GetDocumentName(self)

The document type name given to the wxDocTemplate constructor, copied to this document when the document is created. If several document templates are created that use the same document type, this variable is used in wxDocManager::CreateView to collate a list of alternative view types that can be used on this kind of document.

### GetDocumentSaved(self)

Returns True if the document has been saved. This method has been added to wxPython and is not in wxWindows.

### GetDocumentTemplate(self)

Returns the template that created the document.

### GetDocumentWindow(self)

Intended to return a suitable window for using as a parent for document-related dialog boxes. By default, uses the frame associated with the first view.

### GetFilename(self)

Gets the filename associated with this document, or "" if none is associated.

### GetFirstView(self)

A convenience function to get the first view for a document, because in many cases a document will only have a single view.

### GetPrintableName(self)

Copies a suitable document name into the supplied name buffer. The default function uses the title, or if there is no title, uses the filename; or if no filename, the string 'Untitled'.

### GetTitle(self)

Gets the title for this document. The document title is used for an associated frame (if any), and is usually constructed by the framework from the filename.

### GetViews(self)

Returns the list whose elements are the views on the document.

### GetWriteable(self)

Returns true if the document can be written to its accociated file path. This method has been added to wxPython and is not in wxWindows.

### IsDocumentModificationDateCorrect(self)

Returns False if the file has been modified outside of the application. This method has been added to wxPython and is not in wxWindows.

### IsModified(self)

Returns true if the document has been modified since the last save, false otherwise. You may need to override this if your document view maintains its own record of being modified (for example if using wxTextWindow to view and edit the document).

### LoadObject(self, file)

Override this function and call it from your own LoadObject before loading your own data. LoadObject is called by the framework automatically when the document contents need to be loaded.

Note that the wxPython version simply sends you a Python file object, so you can use pickle.

### Modify(self, modify)

Call with true to mark the document as modified since the last save, false otherwise. You may need to override this if your document view maintains its own record of being modified (for example if using xTextWindow to view and edit the document). This method has been extended to notify its views that the dirty flag has changed.

### NotifyClosing(self)

Notifies the views that the document is going to close.

### OnChangedViewList(self)

Called when a view is added to or deleted from this document. The default implementation saves and deletes the document if no views exist (the last one has just been removed).

### OnCloseDocument(self)

The default implementation calls DeleteContents (an empty implementation) sets the modified flag to false. Override this to supply additional behaviour when the document is closed with Close.

### OnCreate(self, path, flags)

The default implementation calls DeleteContents (an empty implementation) sets the modified flag to false. Override this to supply additional behaviour when the document is opened with Open.

### OnCreateCommandProcessor(self)

Override this function if you want a different (or no) command processor to be created when the document is created. By default, it returns an instance of wxCommandProcessor.

### OnNewDocument(self)

The default implementation calls OnSaveModified and DeleteContents, makes a default title for the document, and notifies the views that the filename (in fact, the title) has changed.

### OnOpenDocument(self, filename)

Constructs an input file for the given filename (which must not be empty), and calls LoadObject. If LoadObject returns true, the document is set to unmodified; otherwise, an error message box is displayed. The document's views are notified that the filename has changed, to give windows an opportunity to update their titles. All of the document's views are then updated.

### OnSaveDocument(self, filename)

Constructs an output file for the given filename (which must not be empty), and calls SaveObject. If SaveObject returns true, the document is set to unmodified; otherwise, an error message box is displayed.

### OnSaveModified(self)

If the document has been modified, prompts the user to ask if the changes should be changed. If the user replies Yes, the Save function is called. If No, the document is marked as unmodified and the function succeeds. If Cancel, the function fails.

### ProcessEvent(self, event)

Processes an event, searching event tables and calling zero or more suitable event handler function(s). Note that the ProcessEvent method is called from the wxPython docview framework directly since wxPython does not have a virtual ProcessEvent function.

  Overrides:
    `wx.EvtHandler.ProcessEvent`

### RemoveView(self, view)

Removes the view from the document's list of views, and calls OnChangedViewList.

### Revert(self)

Override this function to revert the document to its last saved state.

### Save(self)

Saves the document by calling OnSaveDocument if there is an associated filename, or SaveAs if there is no filename.

### SaveAs(self)

Prompts the user for a file to save to, and then calls OnSaveDocument.

### SaveObject(self, file)

Override this function and call it from your own SaveObject before saving your own data. SaveObject is called by the framework automatically when the document contents need to be saved.

Note that the wxPython version simply sends you a Python file object, so you can use pickle.

### SetCommandProcessor(self, processor)

Sets the command processor to be used for this document. The document will then be responsible for its deletion. Normally you should not call this; override OnCreateCommandProcessor instead.

### SetDocumentModificationDate(self)

Saves the file's last modification date. This is used to check if the file has been modified outside of the application. This method has been added to wxPython and is not in wxWindows.

### SetDocumentName(self, name)

Sets he document type name given to the wxDocTemplate constructor, copied to this document when the document is created. If several document templates are created that use the same document type, this variable is used in wxDocManager::CreateView to collate a list of alternative view types that can be used on this kind of document. Do not change the value of this variable.

### SetDocumentSaved(self, saved=True)

Sets whether the document has been saved. This method has been added to wxPython and is not in wxWindows.

### SetDocumentTemplate(self, template)

Sets the template that created the document. Should only be called by the framework.

### SetFilename(self, filename, notifyViews=False)

Sets the filename for this document. Usually called by the framework. If notifyViews is true, wxView.OnChangeFilename is called for all views.

### SetTitle(self, title)

Sets the title for this document. The document title is used for an associated frame (if any), and is usually constructed by the framework from the filename.

### SetWriteable(self, writeable)

Set to False if the document can not be saved. This will disable the ID_SAVE_AS event and is useful for custom documents that should not be saveable. The ID_SAVE event can be disabled by never Modifying the document. This method has been added to wxPython and is not in wxWindows.

### UpdateAllViews(self, sender=None, hint=None)

Updates all views. If sender is non-NULL, does not update this view. hint represents optional information to allow a view to optimize its update.

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:10:49 2007 | http://epydoc.sf.net