a2dDocument Class Reference
[Objects in docview frame work.]

The document class can be used to model an application's file-based data. More...

#include <docviewref.h>

Inheritance diagram for a2dDocument:

Inheritance graph
[legend]
Collaboration diagram for a2dDocument:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 a2dDocument (a2dDocument *parent=(a2dDocument *) NULL)
 Constructor.
 ~a2dDocument ()
 destructor
 a2dDocument (const a2dDocument &other)
 constructor with other document
a2dObjectClone (a2dObject::CloneOptions options) const
 Clone document.
void SetFilename (const wxFileName &filename, bool notifyViews=false)
 Sets the filename for this document. Usually called by the framework.
wxFileName GetFilename () const
 Get the file name in use for this document.
void SetTitle (const wxString &title, bool notifyViews=false)
 Sets the title for this document.
wxString GetTitle () const
 Returns the title for this document.
void SetDocumentTypeName (const wxString &name)
 Sets the document type name for this document. See the comment for documentTypeName.
wxString GetDocumentTypeName () const
 Gets the document type name of this document. See the comment for documentTypeName.
bool GetDocumentSaved () const
 Returns if the document was saved after a modification.
bool IsDocumentSaved () const
 Alias for a2dDocument::GetDocumentSaved.
void SetDocumentSaved (bool saved=true)
 Sets the document saved flag.
bool IsClosed ()
 returns true when document is closed or busy closing.
bool Close (bool force)
 Closes the document if not vetod.
bool Save ()
 Saves the document by sending a a2dDocumentEvent wxEVT_SAVE_DOCUMENT event.
bool SaveAs (const wxFileName &fileTosaveTo=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
 Tries to save the document by sending a a2dDocumentEvent wxEVT_SAVEAS_DOCUMENT event.
bool Export (a2dDocumentTemplate *doctemplate, const wxFileName &fileTosaveTo=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
 Tries to save the document by sending a a2dDocumentEvent wxEVT_EXPORT_DOCUMENT event.
bool Import (a2dDocumentTemplate *doctemplate, const wxFileName &fileToImport=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
 Tries to read a file into the document by sending a a2dDocumentEvent wxEVT_IMPORT_DOCUMENT event.
virtual bool Revert ()
 Normally should undo all changes by rereading the file again.
virtual a2dDocumentInputStreamLoadObject (a2dDocumentInputStream &stream, a2dIOHandlerStrIn *handler)
 handling loading of the document from a stream
virtual a2dDocumentOutputStreamSaveObject (a2dDocumentOutputStream &stream, a2dIOHandlerStrOut *handler)
 handling saving and exporting of the document to a stream
void SetLastError (a2dError lastError)
 can be set by a2dIOHandler's by e.g LoadObject().
a2dError GetLastError ()
 is set by a2dIOHandler's and is tested by LoadObject().
void Load (wxObject *parent, a2dIOHandlerXmlSerIn &parser)
 used by CVG parser
void Save (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
 called from a2dIOHandlerXmlSerOut after a SaveObject.
void Save (a2dIOHandlerXmlSerOut &out, wxObject *start=NULL)
 called from a2dIOHandlerXmlSerOut after a SaveObject.
virtual int SaveModifiedDialog (bool canCancel=true)
 dialog when the user needs to confirm saving a document
virtual void CreateCommandProcessor ()
 create a command processor and set it for the document.
a2dCommandProcessorGetCommandProcessor () const
 Returns a pointer to the command processor associated with this document.
void SetCommandProcessor (a2dCommandProcessor *proc)
 Sets the command processor to be used for this document.
virtual void DeleteContents ()
 called when there is a need to clear the contents of the document.
virtual bool Draw (wxDC &context)
 Might be used to draw the contents of a document to a a2dView using a wxDc as the drawing context.
bool IsModified () const
 Has the document been modified.
void Modify (bool mod)
 set the docuent as modified or not
void AskSaveWhenOwned (bool askSaveWhenOwned)
 Ask to save when document is modified and last view is closed?
virtual void UpdateAllViews (a2dView *sender=(a2dView *) NULL, unsigned int hint=a2dVIEW_UPDATE_ALL, wxObject *objecthint=(wxObject *) NULL)
 sent Update events to all a2dView which display or use this document.
void ReportViews (a2dViewList *allviews)
 sents a wxEVT_REPORT_VIEWS to all views, via the a2dDocumentCommandProcessor.
void EnableAllViews (bool enable, a2dView *sender=(a2dView *) NULL)
 calls Enable( true/false ) for each view.
void DisConnectAllViews ()
 Disconnect a2dView's using this document.
a2dDocumentTemplateGetDocumentTemplate () const
 Gets a2dDocumentTemplate pointer which was used to create the a2dView.
void SetDocumentTemplate (a2dDocumentTemplate *temp)
 Set a2dDocumentTemplate pointer.
wxString GetPrintableName () const
 Get title, or filename if no title, else [unnamed].
virtual wxWindow * GetAssociatedWindow () const
 Returns a window that can be used as a parent for document-related dialogs. Override if necessary.

Protected Member Functions

void OnCreateDocument (a2dDocumentEvent &event)
 default handler for wxEVT_CREATE_DOCUMENT, Called after creation of document from a template.
void OnSaveDocument (a2dDocumentEvent &event)
 Called by wxWindows when a file needs to be saved.
void OnSaveAsDocument (a2dDocumentEvent &event)
 default handler for a2dDocumentEvent of type wxEVT_SAVEAS_DOCUMENT
void OnOpenDocument (a2dDocumentEvent &event)
 load a document from a file into this document
void OnNewDocument (a2dDocumentEvent &event)
 called after creating a new document from a template , in order to initialize it.
void OnCloseDocument (a2dCloseDocumentEvent &event)
 called when document is closed
void OnCloseView (a2dCloseViewEvent &event)
 Intercept to do cleanup/veto closing of a view.
void OnRemoveView (a2dDocumentEvent &event)
 what to do when a view using this document will stop using it.
void OnAddView (a2dDocumentEvent &event)
 what to do when a view starts using this document
void OnExportDocument (a2dDocumentEvent &event)
 The default handler for wxEVT_EXPORT_DOCUMENT.
void OnImportDocument (a2dDocumentEvent &event)
 The default handler for wxEVT_IMPORT_DOCUMENT.

Protected Attributes

bool m_askSaveWhenOwned
 Set when Owners become zero and document will be deleted. May also be overruled by user.
wxFileName m_documentFile
 Filename associated with this document ("" if none).
wxString m_documentTitle
 Document title.
wxString m_documentTypeName
 The document type name given to the a2dDocumentTemplate constructor,.
a2dDocumentTemplatePtr m_documentTemplate
 A pointer to the template from which this document was created.
bool m_documentModified
 modified flag
a2dDocumentm_documentParent
 parant document if set.
a2dSmrtPtr< a2dCommandProcessorm_commandProcessor
 A pointer to the command processor associated with this document.
bool m_savedYet
 saved flag
bool m_isClosed
 set true when document is closed or when busy closing document.
wxUint32 m_id
 This identifies the document in event processing.
a2dError m_lastError
 error code used when LoadObject is returning.

Friends

class a2dSmrtPtrBase


Detailed Description

The document class can be used to model an application's file-based data.

It is part of the document/view framework, and cooperates with the a2dView, a2dDocumentTemplate, a2dViewTemplate, a2dEventDistributer and a2dDocumentCommandProcessor classes.

a2dDocument can also be used in a setting with just a2dView's and/or templates, so without a a2dDocumentCommandProcessor controlling most tasks. But events coming from the document meant for the a2dView (e.g. Update events), will be sent to a wxEvtHandler that is set with SetDistributer(). If not set, events are sent to a2dDocviewGlobals->GetEventDistributer(). Therefore if you just want to display the fixed data in the a2dDocument, a a2dDocumentCommandProcessor is not really needed. In the general case with several view and documents, it is best to use a a2dDocumentCommandProcessor.

Events types which can be/are intercepted:

Definition at line 1264 of file docviewref.h.


Constructor & Destructor Documentation

a2dDocument::a2dDocument ( a2dDocument parent = (a2dDocument*) NULL  ) 

Constructor.

The document may have a parent, so a hierachically structure of documents is possible.

Remarks:
Current implementation doesn't support a nice access to parent/child docs.
Parameters:
parent The document's parent

Definition at line 457 of file docviewref.cpp.


Member Function Documentation

void a2dDocument::SetFilename ( const wxFileName &  filename,
bool  notifyViews = false 
)

Sets the filename for this document. Usually called by the framework.

If notifyViews is true, a a2dDocumentEvent of type wxEVT_CHANGEDFILENAME_DOCUMENT is sent to the event distributer. DistributeEvent()

Definition at line 1398 of file docviewref.cpp.

void a2dDocument::SetTitle ( const wxString &  title,
bool  notifyViews = false 
)

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. The title may be changed by the programmer or set by an IOHandler

Parameters:
title The title of the document.
notifyViews If true a a2dDocumentEvent of type wxEVT_CHANGEDTITLE_DOCUMENT is send to all views via DistributeEvent()

Definition at line 1412 of file docviewref.cpp.

void a2dDocument::SetDocumentSaved ( bool  saved = true  )  [inline]

Sets the document saved flag.

The document saved flag is normally set by the framework,

Definition at line 1337 of file docviewref.h.

bool a2dDocument::IsClosed (  )  [inline]

returns true when document is closed or busy closing.

Closing a document in general includes closing its views too. When busy closing a document, this function here can be used to prevent recursive calls elsewhere. You can savely call Close() anyway, but if other actions depends on the document being closed or not, you can check it with this here. A typical example is a closing a document and also releasing it from some higher order class.

See also:
Close() for more.

Definition at line 1348 of file docviewref.h.

bool a2dDocument::Close ( bool  force  ) 

Closes the document if not vetod.

Closing a document means that the application does not want the the document in memory anymore in order to view or modify it. This function prepares the document for deletion.

Sents a wxEVT_CLOSE_DOCUMENT event. The default handler is OnCloseDocument( a2dCloseDocumentEvent& event ).

Default calls SaveModifiedDialog(), to give the user a change to save his changes.

This does not normally delete the document object, which only happens if the reference count reaches zero, indicating no more Owners do exist.

See also:
OnCloseDocument

SaveModifiedDialog

Definition at line 578 of file docviewref.cpp.

bool a2dDocument::Save (  ) 

Saves the document by sending a a2dDocumentEvent wxEVT_SAVE_DOCUMENT event.

The method first tests if the document is modified and not saved yet. If it is modified and not saved, the event is sent.

See also:
OnSaveDocument
Returns:
true if the document could be saved

Definition at line 637 of file docviewref.cpp.

bool a2dDocument::SaveAs ( const wxFileName &  fileTosaveTo = wxFileName( wxT("") ),
a2dDocumentFlagMask  flags = a2dREFDOC_NON 
)

Tries to save the document by sending a a2dDocumentEvent wxEVT_SAVEAS_DOCUMENT event.

The default handler asks for a file, to save the document into.

See also:
OnSaveAsDocument
Returns:
true if the document could be saved

Definition at line 650 of file docviewref.cpp.

bool a2dDocument::Export ( a2dDocumentTemplate doctemplate,
const wxFileName &  fileTosaveTo = wxFileName( wxT("") ),
a2dDocumentFlagMask  flags = a2dREFDOC_NON 
)

Tries to save the document by sending a a2dDocumentEvent wxEVT_EXPORT_DOCUMENT event.

See also:
OnExportDocument
Returns:
true if the document could be saved

Definition at line 813 of file docviewref.cpp.

bool a2dDocument::Import ( a2dDocumentTemplate doctemplate,
const wxFileName &  fileToImport = wxFileName( wxT("") ),
a2dDocumentFlagMask  flags = a2dREFDOC_NON 
)

Tries to read a file into the document by sending a a2dDocumentEvent wxEVT_IMPORT_DOCUMENT event.

See also:
OnImportDocument
Returns:
true if the document could be read

Definition at line 947 of file docviewref.cpp.

bool a2dDocument::Revert (  )  [virtual]

Normally should undo all changes by rereading the file again.

Todo:
make a default implementation which does do it ( unless already saved the changes sofar )

Definition at line 1283 of file docviewref.cpp.

a2dDocumentInputStream & a2dDocument::LoadObject ( a2dDocumentInputStream stream,
a2dIOHandlerStrIn handler 
) [virtual]

handling loading of the document from a stream

The given handler is used to load the document from the stream.

Override this function to implement your own version. LoadObject is called by the framework automatically when the document contents needs to be loaded.

Note:
only one of these forms exists, depending on how wxWindows was configured.

Reimplemented in a2dCanvasDocument.

Definition at line 1147 of file docviewref.cpp.

a2dDocumentOutputStream & a2dDocument::SaveObject ( a2dDocumentOutputStream stream,
a2dIOHandlerStrOut handler 
) [virtual]

handling saving and exporting of the document to a stream

The a2dIOHandler given is used to save the document to the stream.

Override this function to implement your own version. SaveObject is called by the framework automatically when the document contents need to be saved.

Note:
only one of these forms exists, depending on how wxWindows was configured.

Reimplemented in a2dCanvasDocument.

Definition at line 1242 of file docviewref.cpp.

void a2dDocument::SetLastError ( a2dError  lastError  )  [inline]

can be set by a2dIOHandler's by e.g LoadObject().

If parsing a document from the stream is incorrect due to formating errors, the handler or LoadObject itself can set this error code, which result in veto-ing the event.

Definition at line 1442 of file docviewref.h.

a2dError a2dDocument::GetLastError (  )  [inline]

is set by a2dIOHandler's and is tested by LoadObject().

If parsing a document from the stream is incorrect due to formating errors, the handler or LoadObject itself can set this error code.

Definition at line 1449 of file docviewref.h.

void a2dDocument::Load ( wxObject *  parent,
a2dIOHandlerXmlSerIn parser 
) [virtual]

used by CVG parser

Remarks:
do not use directly

Reimplemented from a2dObject.

Reimplemented in a2dCanvasDocument.

Definition at line 1197 of file docviewref.cpp.

void a2dDocument::Save ( wxObject *  parent,
a2dIOHandlerXmlSerOut out,
a2dObjectList towrite 
) [virtual]

called from a2dIOHandlerXmlSerOut after a SaveObject.

Parameters:
parent parent object from which Save was called
out CVG io handler
towrite object to write later

Reimplemented from a2dObject.

Reimplemented in a2dCanvasDocument.

Definition at line 1213 of file docviewref.cpp.

void a2dDocument::Save ( a2dIOHandlerXmlSerOut out,
wxObject *  start = NULL 
)

called from a2dIOHandlerXmlSerOut after a SaveObject.

Parameters:
out CVG io handler
start start wrting from this object

Definition at line 1227 of file docviewref.cpp.

int a2dDocument::SaveModifiedDialog ( bool  canCancel = true  )  [virtual]

dialog when the user needs to confirm saving a document

If the document has been modified, prompts the user to ask if the changes should be saved. If the user replies Yes, the Save function is called and return is wxYES. If No, the document is marked as unmodified and return is wxNO If Cancel return is wxCANCEL. If document was not modified, also wxYES is returned.

Definition at line 1317 of file docviewref.cpp.

void a2dDocument::CreateCommandProcessor (  )  [virtual]

create a command processor and set it for the document.

If available the existing commandprocessor will be deleted. A new CommandProcessor will be created and set for the document.

Override if you need a more application specific commandhandler.

Reimplemented in a2dCanvasDocument.

Definition at line 1312 of file docviewref.cpp.

void a2dDocument::SetCommandProcessor ( a2dCommandProcessor proc  )  [inline]

Sets the command processor to be used for this document.

Use in case you need one a2dCommandProcessor to be used for several a2dDocument's, Make sure you set it to NULL before deleting the document itself, else the a2dDocument destructor will delete it ( leaving the others with dangling pointers ).

Definition at line 1505 of file docviewref.h.

void a2dDocument::DeleteContents (  )  [virtual]

called when there is a need to clear the contents of the document.

Override this function to define the way to do this.

Reimplemented in a2dCanvasDocument.

Definition at line 492 of file docviewref.cpp.

bool a2dDocument::Draw ( wxDC &  context  )  [virtual]

Might be used to draw the contents of a document to a a2dView using a wxDc as the drawing context.

You need to override this method in derived class to do something usefull.

Returns:
default only returns true

Definition at line 1353 of file docviewref.cpp.

void a2dDocument::Modify ( bool  mod  ) 

set the docuent as modified or not

If the modified status changes an wxEVT_CHANGEDMODIFY_DOCUMENT event will be send.

Parameters:
mod true to set document modified, else false

Definition at line 1363 of file docviewref.cpp.

void a2dDocument::AskSaveWhenOwned ( bool  askSaveWhenOwned  )  [inline]

Ask to save when document is modified and last view is closed?

When there are still owners of the document, and the last view is closed it can either be saved or delayed until the application closes. Setting AskSaveWhenOwned delayes the saving of the data until later.

Definition at line 1539 of file docviewref.h.

void a2dDocument::UpdateAllViews ( a2dView sender = (a2dView *) NULL,
unsigned int  hint = a2dVIEW_UPDATE_ALL,
wxObject *  objecthint = (wxObject *) NULL 
) [virtual]

sent Update events to all a2dView which display or use this document.

This function is typicaly called when the document its contents has changed, this in general will result in the a2dView displaying this new information. Understand that this only informs the views to update themselfs, how and what the view needs to update can be indicated by the hints, or in more complex situations the views will read the document contents to see what did change, and only update what changed in its view.

Parameters:
sender which view did calls this function ( Non = NULL ).
hint update will differ on the hint given and the implementation
objecthint more complex way to deliver hints

Reimplemented in a2dCanvasDocument.

Definition at line 1382 of file docviewref.cpp.

void a2dDocument::ReportViews ( a2dViewList allviews  ) 

sents a wxEVT_REPORT_VIEWS to all views, via the a2dDocumentCommandProcessor.

The a2dView's using this document will report themself by adding itself to the allviews list.

Definition at line 1375 of file docviewref.cpp.

void a2dDocument::EnableAllViews ( bool  enable,
a2dView sender = (a2dView *) NULL 
)

calls Enable( true/false ) for each view.

Enables or disables all views. If sender is non-NULL, does NOT call it for this view. The disabling a a2dView means that it will not process any events, until enabled again.

Definition at line 1391 of file docviewref.cpp.

void a2dDocument::DisConnectAllViews (  ) 

Disconnect a2dView's using this document.

It depends on the application if a disconnected view will be closed or not. In case the views will be resused for another document after disconnecting them, obviously they should not be closed. Typically thsi will be the case in a one frame application, where the frame has one or more fixed views, which will be used for the currently open document.

Before starting to disconnect the views, a a2dDocumentEvent type wxEVT_DISCONNECT_ALLVIEWS is sent to this a2dDocument, which can be intercepted to do some general cleanup on the document.

In case the a2dView::Close() is called on disconnection, . this generates a a2dCloseViewEvent (type wxEVT_CLOSE_VIEW ) sent to the document and the view. The event can not be vetod for this action.

Definition at line 568 of file docviewref.cpp.

void a2dDocument::OnCreateDocument ( a2dDocumentEvent event  )  [protected]

default handler for wxEVT_CREATE_DOCUMENT, Called after creation of document from a template.

Called by framework if the documemt is created automatically by the default document manager (via a document template). This gives the document a chance to initialise.

This Default handler does Nothing Yet.

Definition at line 1358 of file docviewref.cpp.

void a2dDocument::OnSaveDocument ( a2dDocumentEvent event  )  [protected]

Called by wxWindows when a file needs to be saved.

Default handler for a2dDocumentEvent of type wxEVT_SAVE_DOCUMENT.

Save in the file filename of the document, or call SaveAs if the filename is not set.

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

event is set Allowed if the file could be opened and the document was saved.

Remarks:
the document its a2dDocumentTemplate is used to find the right a2dIOHandlerStrOut via a2dDocumentTemplate::GetDocumentIOHandlerForSave().

Definition at line 748 of file docviewref.cpp.

void a2dDocument::OnSaveAsDocument ( a2dDocumentEvent event  )  [protected]

default handler for a2dDocumentEvent of type wxEVT_SAVEAS_DOCUMENT

Prompts the user for a file to save to.

Notifies the views that the filename has changes by sending wxEVT_CHANGEDFILENAME_DOCUMENT to the event distributer DistributeEvent().

Remarks:
the document its a2dDocumentTemplate is used to find the right a2dIOHandlerStrOut via a2dDocumentTemplate::GetDocumentIOHandlerForSave().

Definition at line 664 of file docviewref.cpp.

void a2dDocument::OnOpenDocument ( a2dDocumentEvent event  )  [protected]

load a document from a file into this document

Default handler for a2dDocumentEvent of type wxEVT_OPEN_DOCUMENT.

In the default handler SaveModifiedDialog() is called first, and if the document is modified the user is asked to save the changes. Cancel will not open the file into the document.

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.

Remarks:
m_documentTemplate must be set for the default handler to work.
Note:
only one of these forms exists, depending on how wxWindows was configured.

Reimplemented in a2dCanvasDocument.

Definition at line 1080 of file docviewref.cpp.

void a2dDocument::OnNewDocument ( a2dDocumentEvent event  )  [protected]

called after creating a new document from a template , in order to initialize it.

called by: a2dDocumentCommandProcessor::CreateDocument() a2dDocumentCommandProcessor::AddCreatedDocument()

Default handler for a2dDocumentEvent of type wxEVT_NEW_DOCUMENT.

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

The user can intercept the event to fill new documents if empty, but do Skip() the event for the base implementation to be called.

Understand that views might already by open on the document.

Definition at line 622 of file docviewref.cpp.

void a2dDocument::OnCloseDocument ( a2dCloseDocumentEvent event  )  [protected]

called when document is closed

Default handler for a2dDocumentEvent of type wxEVT_CLOSE_DOCUMENT.

The default implementation, calls SaveModifiedDialog(), and if not canceled, disconnects and/or closes all views using DisconnectAllViews(). This leads to sending wxEVT_DISCONNECT_ALLVIEWS to the document and wxEVT_CLOSE_VIEW to each view. This enables the program to delete or detach views etc. Next empties the document by calling DeleteContents setting modified flag to false.

Override this to supply additional behaviour when the document is closed with Close.

e.g. In a single document and view approach, you very likely want to call DeleteContents and set the modified flag to false.

Emptying a document while views are using it, is dangerous. Views may refer to or use objects in the document. Therefore the default:

  • closes all views ( holding and display parts of the document, else maybe dangling pointers )
  • clears the undo stack ( which may hold references to objects within the document )
  • empty the document

Remarks:
Remember a view also Owns a reference to a document, so certainly all views need to be gone to really get a document deleted.

Definition at line 600 of file docviewref.cpp.

void a2dDocument::OnCloseView ( a2dCloseViewEvent event  )  [protected]

Intercept to do cleanup/veto closing of a view.

The handler function for EVT_CLOSE_VIEW, it is called when the program tries to close a View.

The frame or window containing the view sent a EVT_CLOSE_WINDOW, this results in a EVT_CLOSE_VIEW being sent to the document and to the view. OR The a2dDocumentCommandProcessor is closing all documents plus views.

The a2dCloseViewEvent is generated via the a2dView::Close function, so that the application can also invoke the handler programmatically.

See also:
a2dCloseViewEvent for the way the event is propegated to the several classes in the Objects in docview frame work. framework. If OnCloseView does not veto the close event, the a2dView will futher propegate the event.
The Default implementation: Checks if the view is the last reference for the document; if so, asks user to confirm save data. If AskSaveWhenOwned() == true it will always ask to save the data.

Definition at line 532 of file docviewref.cpp.

void a2dDocument::OnRemoveView ( a2dDocumentEvent event  )  [protected]

what to do when a view using this document will stop using it.

When a view is switching its document to another document, or when a view is closed, this event is sent to the document just before a2dView releases the document. The default implementation asks to save the document if it was modified, but only if m_askSaveWhenOwned is true or m_refcount has reached 1, which is when only the view itself Own the document. In an application where this document is also controlled by a a2dDocumentCommandProcessor, the refcount would by two. When an application has a fixed set of views (per Frame) used by any document that is shown, it of course makes no sence to automatically close a document when the refcount reaches 1. In a standard "multi child frame+view + document", one can automatically close the document when a refcount of < 2 is reached. Which means when a document its last view is closed, and the document is only owned by the controlling a2dDocumentCommandProcessor. To make this happen intercept the wxEVT_REMOVE_VIEW, and implement whatever you need. In this case you should call a2dDocviewGlobals->GetDocviewCommandProcessor()->FileClose() in order to Close the document, which leads to the a2dDocumentCommandProcessor releasing the document. The very last release and therefore deletion will be done in a2dView after returning from the wxEVT_REMOVE_VIEW event.

Definition at line 548 of file docviewref.cpp.

void a2dDocument::OnExportDocument ( a2dDocumentEvent event  )  [protected]

The default handler for wxEVT_EXPORT_DOCUMENT.

This method asks for a file, to export/save the document into, using the handler of the event its a2dDocumentTemplate. If a a2dDocumentTemplate was not given as part of the event, the document template of this document is used to search for possible templates to be used for exporting this document. The selection is based on GetDocumentTemplate()->GetDocumentTypeName(). Next a file dialog is presented to select a file to export.

If a filename is part of the event, this is used as initial file to export to in the save dialog. If a2dDocumentFlagMask contains a2dREFDOC_SILENT, no dialog will be presented.

Definition at line 826 of file docviewref.cpp.

void a2dDocument::OnImportDocument ( a2dDocumentEvent event  )  [protected]

The default handler for wxEVT_IMPORT_DOCUMENT.

This method asks for a file, to read the document from, using the handler of the event its a2dDocumentTemplate. If a a2dDocumentTemplate was not given as part of the event, the document template of this document is used to search for possible templates to be used for importing into this document. The selection is based on GetDocumentTemplate()->GetDocumentTypeName(). Next a file dialog is presented to select a file to import.

If as part of the event a path+path was already provided, that will be used. If a2dREFDOC_SILENT was set as flag in the event, no dialogs will appear, when a file+path is available.

Definition at line 960 of file docviewref.cpp.


Member Data Documentation

wxString a2dDocument::m_documentTitle [protected]

Document title.

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

Definition at line 1797 of file docviewref.h.

wxString a2dDocument::m_documentTypeName [protected]

The document type name given to the a2dDocumentTemplate constructor,.

is copied to this variable when the document is created.

In a2dDocumentCommandProcessor::AddCreatedDocument() first set this, to search an appropriate template.

It is used later on to select Views from the a2dViewTemplate's. a2dViewTemplate uses the same documentTypeName as a2dDocumentTemplate's.

The same a2dDocument derived class instances, can have a different m_documentTypeName.

If several view templates are created that use the same document type, this variable is used in a2dDocumentCommandProcessor::CreateView to collate a list of alternative view types that can be used on this kind of document.

Definition at line 1814 of file docviewref.h.

wxUint32 a2dDocument::m_id [protected]

This identifies the document in event processing.

Not sure, if this is really used for something

Definition at line 1836 of file docviewref.h.


The documentation for this class was generated from the following files:
a2dDocument Class Reference -- Tue Aug 31 18:22:37 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation