A normal document is the one created without parent document and is associated with a disk file. Since version 2.9.2 wxWidgets also supports a special kind of documents called child documents which are virtual in the sense that they do not correspond to a file but rather to a part of their parent document. Because of this, the child documents can't be created directly by user but can only be created by the parent document (usually when it's being created itself). They also can't be independently saved. A child document has its own view with the corresponding window. This view can be closed by user but, importantly, is also automatically closed when its parent document is closed. Thus, child documents may be convenient for creating additional windows which need to be closed when the main document is. The docview sample demonstrates this use of child documents by creating a child document containing the information about the parameters of the image opened in the main document.

Processes the pending events previously queued using QueueEvent() or AddPendingEvent(); you must call this function only if you are sure there are pending events for this handler, otherwise a wxCHECK will fail. More...

Unbinds the given function, functor or method dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed. More...

Constructor & Destructor Documentation

Specifying a non-NULL parent document here makes this document a special child document, see their description in the class documentation. Notice that this parameter exists but is ignored in wxWidgets versions prior to 2.9.1.

virtual wxDocument::~wxDocument

(

)

virtual

Destructor.

Removes itself from the document manager.

Member Function Documentation

void wxDocument::Activate

(

)

const

Activate the first view of the document if any.

This function simply calls the Raise() method of the frame of the first view. You may need to override the Raise() method to get the desired effect if you are not using a standard wxFrame for your view. For instance, if your document is inside its own notebook tab you could implement Raise() like this:

Returns true if the document hasn't been modified since the last time it had been saved.

Notice that this function returns false if the document had been never saved at all, so it may be also used to test whether it makes sense to save the document: if it returns true, there is nothing to save but if false is returned, it can be saved, even if it might be not modified (this can be used to create an empty document file by the user).

Deleting the final view will implicitly delete the document itself, because the wxView destructor calls RemoveView(). This in turns calls OnChangedViewList(), whose default implementation is to save and delete the document if no views exist.

The default implementation calls DeleteContents() (which may be overridden to perform additional cleanup) and sets the modified flag to false. You can override it to supply additional behaviour when the document is closed with Close().

Notice that previous wxWidgets versions used to call this function also from OnNewDocument(), rather counter-intuitively. This is no longer the case since wxWidgets 2.9.0.

Called just after the document object is created to give it a chance to initialize itself.

The default implementation uses the template associated with the document to create an initial view.

For compatibility reasons, this method may either delete the document itself if its initialization fails or not do it in which case it is deleted by caller. It is recommended to delete the document explicitly in this function if it can't be initialized.

Constructs an input file stream 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.

Normally there is no need to call this function as the document-view framework does it itself as the documents are loaded from and saved to the files. However it may be useful in some particular cases, for example it may be called with false argument to prevent the user from saving the just opened document into the same file if this shouldn't be done for some reason (e.g. file format version changes and a new extension should be used for saving).

The document type name given to the wxDocTemplate constructor, copied to this variable 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.