|
wxArt2D
|
The a2dDocumentTemplate class is used to model the relationship between a document class and files. More...
#include <docviewref.h>


Public Member Functions | |
| a2dDocumentTemplate (const wxString &descr, const wxString &filter, const wxString &dir, const wxString &ext, const wxString &docTypeName, wxClassInfo *docClassInfo=(wxClassInfo *) NULL, a2dViewConnector *connector=(a2dViewConnector *) NULL, long flags=a2dTemplateFlag::DEFAULT, a2dIOHandlerStrIn *handlerIn=NULL, a2dIOHandlerStrOut *handlerOut=NULL) | |
| Associate document and view types. They're for identifying what view is associated with what template/document type. More... | |
| ~a2dDocumentTemplate () | |
| Destructor. | |
| virtual a2dDocument * | CreateDocument (const wxFileName &path, a2dDocumentFlagMask flags=a2dREFDOC_NON) |
| Creates a new document. More... | |
| a2dDocument * | SentPreAddCreatedDocumentEvent (a2dDocument *newDoc, a2dDocumentFlagMask flags) |
| sents a wxEVT_PRE_ADD_DOCUMENT event to m_connector if available. More... | |
| bool | SentPostCreateDocumentEvent (a2dDocument *newDoc, a2dDocumentFlagMask flags) |
| sents a wxEVT_POST_CREATE_DOCUMENT called in general from a2dDocumentCommandProcessor() when a new document was created. More... | |
| wxString | GetDefaultExtension () const |
| Returns the default file extension for the document data, as passed to the document template constructor. | |
| wxString | GetDescription () const |
| Returns the text description of this template, as passed to the document template constructor. | |
| wxString | GetDirectory () const |
| Returns the default directory, as passed to the document template constructor. | |
| wxString | GetFileFilter () const |
| Returns the file filter, as passed to the document template constructor. | |
| const a2dTemplateFlag & | GetFlags () const |
| Returns the flags, as passed to the document template constructor. | |
| void | SetFlags (a2dTemplateFlagMask flags) |
| Sets the internal document template flags (see the constructor description for more details). | |
| void | SetFlags (a2dTemplateFlag flags) |
| Sets the internal document template flags (see the constructor description for more details). | |
| bool | CheckMask (a2dTemplateFlagMask mask) |
| does template mask match | |
| wxString | GetDocumentTypeName () const |
| Returns the document type name, as passed to the document template constructor. | |
| void | SetFileFilter (const wxString &filter) |
| Sets the file filter. | |
| void | SetDirectory (const wxString &dir) |
| Sets the default directory. | |
| void | SetDescription (const wxString &descr) |
| Sets the template description. | |
| void | SetDefaultExtension (const wxString &ext) |
| Sets the default file extension. | |
| void | SetVisible (bool value) |
| Returns true if the document template can be shown in user dialogs, false otherwise. | |
| void | SetMarked (bool value) |
| Returns true if the document template is marked , false otherwise. | |
| bool | IsVisible () const |
| Returns true if the document template can be shown in user dialogs, false otherwise. | |
| bool | IsMarked () const |
| Returns true if the document template is marked , false otherwise. | |
| virtual bool | FileMatchesTemplate (const wxString &path) |
| to test if a file that needs to be loaded, is suitable for this template. More... | |
| virtual a2dIOHandlerStrIn * | GetDocumentIOHandlerStrIn () |
| Get Input handler used to store the document using this template. | |
| virtual a2dIOHandlerStrOut * | GetDocumentIOHandlerStrOut () |
| Get output handler used to save the document using this template. | |
| virtual a2dIOHandlerStrIn * | GetDocumentIOHandlerForLoad (a2dDocumentInputStream &stream, a2dDocument *document) |
| if there is an io handler, and it can load the document of this template, return it | |
| virtual a2dIOHandlerStrOut * | GetDocumentIOHandlerForSave (const wxString &filename, a2dDocument *document) |
| if there is an io handler, and it can save the document of this template, return it More... | |
| virtual void | SetDocumentIOHandlerStrIn (a2dIOHandlerStrIn *handler) |
| Set Inputhandler used to load the document using this template. | |
| virtual void | SetDocumentIOHandlerStrOut (a2dIOHandlerStrOut *handler) |
| Set output handler used to save the document using this template. | |
| a2dViewConnector * | GetViewConnector () |
| return the a2dViewConnector that is used for sending the ::wxEVT_POST_CREATE_DOCUMENT too. | |
| wxPageSetupDialogData * | GetPageSetupData (void) const |
| void | SetPageSetupData (const wxPageSetupDialogData &pageSetupData) |
| void | SetPageSetupData (wxPageSetupDialogData *pageSetupData) |
| wxClassInfo * | GetDocumentClassInfo () const |
| a2dDocument * | GetDocumentCreate () |
| if set this will be used instead of m_docClassInfo to initiate new documents | |
| void | SetDocumentCreate (a2dDocument *documentCreate) |
| if set this will be used instead of m_docClassInfo to initiate new documents More... | |
Public Member Functions inherited from a2dObject | |
| virtual bool | ProcessEvent (wxEvent &event) |
| bool | SearchDynamicEventTable (wxEvent &event) |
| void | Connect (int winid, int lastId, int eventType, wxObjectEventFunction func, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL) |
| bool | Disconnect (int winid, int lastId, wxEventType eventType, wxObjectEventFunction func=NULL, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL) |
| void | ProcessConnectedEvent (wxEvent &event) |
| wxCHECK_VERSION(2,9,0) More... | |
| void | ConnectEvent (wxEventType type, wxEvtHandler *eventSink) |
| bool | DisconnectEvent (wxEventType type, wxEvtHandler *eventSink) |
| bool | DisconnectEventAll (wxEvtHandler *eventSink) |
| Remove all dynamic events in classA, going to classB (eventSink) More... | |
| a2dObject () | |
| constructor | |
| virtual | ~a2dObject () |
| destructor | |
| void | operator= (const a2dObject &other) |
| assignment operator | |
| int | GetOwnedBy () |
| like it to be protected, but this does not work with wxList macros More... | |
| virtual a2dObject * | SetNonDynamic () |
| Call to mark this object as non-dynamic (static/local/auto) More... | |
| void | CheckReferences () |
| Check zero reference count and delete if count is 0. More... | |
| a2dObject * | Clone (CloneOptions options, a2dRefMap *refs=NULL) const |
| create an exact copy of this property | |
| a2dObject (const a2dObject &other, CloneOptions options, a2dRefMap *refs) | |
| virtual wxString | GetName () const |
| Returns the name of this object, if no name is given the internal id will be returned. More... | |
| virtual void | SetName (const wxString &name) |
| Creates the a2dStringProperty PROPID_Name. More... | |
| virtual bool | IsTemporary_DontSave () const |
| Check if this is a temporary object, which should not be saved. | |
| void | SaveAsDocument (a2dIOHandlerXmlSerOut &out) |
| Save this object and all below as an XML document. More... | |
| virtual void | Save (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite) |
| write all needed to an XML type of file called the CVG format More... | |
| void | LoadFromDocument (a2dIOHandlerXmlSerIn &parser) |
| Load this object and all below from an XML document. More... | |
| virtual void | Load (wxObject *parent, a2dIOHandlerXmlSerIn &parser) |
| load object from CVG file More... | |
| wxInt64 | GetUniqueSerializationId () const |
| return a unique id for this object More... | |
| virtual bool | AlwaysWriteSerializationId () const |
| If true, always write an id. More... | |
| virtual bool | LinkReference (a2dObject *other) |
| link a reference in the object to the given value More... | |
| virtual void | ResolveInform () |
| inform an object that reference resolution was done More... | |
| void | Walker (wxObject *parent, a2dWalkerIOHandler &handler) |
| This is used to recursively walk through an object tree. | |
| void | SetCheck (bool check) |
| general flag use at will. More... | |
| bool | GetCheck () const |
| general flag use at will. | |
| void | SetRelease (bool value) |
| set release flag More... | |
| bool | GetRelease () const |
| get release flag More... | |
| a2dAutoZeroPtr< a2dObject > ** | GetAutoZeroPtrList () |
| return the list head pointer for autozero pointers to this object More... | |
| DECLARE_PROPERTIES () | |
| a2dNamedProperty * | GetProperty (const a2dPropertyId *propertyId, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const |
| get property on this object More... | |
| void | SetProperty (a2dNamedProperty *propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none) |
| Set the property to the this object. More... | |
| void | SetProperty (const a2dNamedProperty &propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none) |
| Set the property to the this object and if enabled, to all childs and object members. More... | |
| virtual a2dNamedProperty * | FindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) |
| Find a dynamic property with given id in the property list. More... | |
| virtual const a2dNamedProperty * | FindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const |
| Find a dynamic property with given id in the property list. More... | |
| virtual bool | HasProperty (const a2dPropertyId *id, const wxString &stringvalue=wxEmptyString) const |
| Check if the object has a property with given id and string representation. More... | |
| virtual void | OnPropertyChanged (const a2dPropertyId *id) |
| This function is called after a property changed. More... | |
| virtual bool | EditProperties (const a2dPropertyId *id, bool withUndo=true) |
| edit properties of the object More... | |
| void | TakeOverProperties (a2dObject *from, a2dPropertyIdList *listOfIds) |
| Properties in the id list are taken from the given object, en set to this. More... | |
| wxURI | GetURI () const |
| quick way to get to PROPID_URI property More... | |
| void | SetURI (const wxURI &url) |
| quickly set a property PROPID_URI More... | |
| const a2dNamedPropertyList & | GetPropertyList () const |
| Get the Property List. More... | |
| bool | HasDynamicProperties () const |
| test if there are dynamic properties in the m_propertylist | |
| virtual bool | RemoveProperty (const a2dPropertyId *id, bool all=true) |
| This function is called by a2dPropertyId to remove a property from the list. More... | |
| void | RemoveTemporaryProperties () |
| remove all temporary properties | |
| virtual bool | AddProperty (a2dNamedProperty *property) |
| This function is called by a2dPropertyId to add a property to the list. More... | |
Protected Member Functions | |
| a2dObject * | DoClone (a2dObject::CloneOptions options, a2dRefMap *refs) const |
| virtual void | DoSave (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite) |
| Save settings. | |
| virtual void | DoLoad (wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts) |
| Load settings. | |
Protected Member Functions inherited from a2dObject | |
| virtual bool | DoIgnoreIfNotMember (const a2dPropertyId *id) const |
| used to decide if a property shall be ignored, if it is not a member More... | |
| virtual void | DoWalker (wxObject *parent, a2dWalkerIOHandler &handler) |
| iterate over this object and its children More... | |
Protected Attributes | |
| a2dTemplateFlag | m_flags |
| The flags passed to the constructor. | |
| wxString | m_fileFilter |
| The file filter (such as *.txt) to be used in file selector dialogs. | |
| wxString | m_directory |
| The default directory for files of this type. | |
| wxString | m_description |
| A short description of this template. | |
| wxString | m_defaultExt |
| The default extension for files of this type. | |
| wxString | m_docTypeName |
| The named type of the document associated with this template. | |
| wxClassInfo * | m_docClassInfo |
| Run-time class information that allows document instances to be constructed dynamically. | |
| a2dDocumentPtr | m_documentCreate |
| if set this will be used instead of m_docClassInfo to initiate new documents | |
| a2dSmrtPtr< a2dIOHandlerStrIn > | m_ioHandlerStrIn |
| used for reading the document from streams. | |
| a2dSmrtPtr< a2dIOHandlerStrOut > | m_ioHandlerStrOut |
| used for writing the document to streams. | |
| a2dSmrtPtr< a2dViewConnector > | m_connector |
| class used to connect new views with Frames and windows. | |
| wxPageSetupDialogData * | m_pageSetupData |
| this is the printer page setup data for all documents with this template | |
Protected Attributes inherited from a2dObject | |
| a2dNamedPropertyList | m_propertylist |
| properties | |
| int | m_refcount |
| how many references to this object do exist | |
| bool | m_check: 1 |
| used for linking multiple referenced objects when serializing | |
| bool | m_release: 1 |
| when set object is treated as being deleted, and wil be deleted in idle time. | |
| bool | m_recursion_active: 1 |
| this is used as a recursion stopper | |
| bool | m_pendingDisconnects: 1 |
| unsigned int | m_iteratorCount |
| a2dAutoZeroPtr< a2dObject > * | m_autozeroptrlist |
| this is a list of all a2dAutoZeroPtr object pointing to this object | |
Friends | |
| class | a2dSmrtPtrBase |
Additional Inherited Members | |
Public Types inherited from a2dObject | |
| enum | CloneOptions { clone_members = 0x00000001, clone_properties = 0x00000002, clone_childs = 0x00000004, clone_unused = 0x00000008, clone_setoriginal = 0x00000010, clone_seteditcopy = 0x00000020, clone_noReference = 0x00000040, clone_noCameleonRef = 0x00000080, clone_toDrag = 0x00000100, clone_flat = 0x00000000, clone_deep = clone_members | clone_properties | clone_childs } |
| options for cloning More... | |
| typedef a2dAutoZeroPtr< a2dObject > | TAutoZeroPtrListClass |
| this is needed inside the smart pointer template code | |
Static Public Attributes inherited from a2dObject | |
| static a2dPropertyIdBool * | PROPID_Check = NULL |
| used for linking multiple referenced objects when serializing | |
| static a2dPropertyIdUri * | PROPID_URI = NULL |
| attach an URL to the object | |
| static a2dPropertyIdString * | PROPID_Name = NULL |
| Name property, to return name of this object. | |
| static a2dPropertyIdVoidPtr * | PROPID_autozeroptrlist = NULL |
| static const a2dSignal | sm_Edit_properties = wxNewId() |
| edit properties event, see EditProperties() | |
Protected Types inherited from a2dObject | |
| enum | { refcount_nondynamic = 0x76543210 } |
| special refcount value for non-dynamic objects | |
The a2dDocumentTemplate class is used to model the relationship between a document class and files.
Next to that, a a2dViewConnector class pointer is used to generate new views for new documents, or whatever the a2dViewConnector finds appropriate to do when a new document is created by the a2dDocumentCommandProcessor via a a2dDocumentTemplate.
Normally new views are created by the a2dViewConnector class via a a2dViewTemplate. When and where this new view will be displayed, is up to the a2dViewConnector.
After CreateDocument created a new document, it sents a ::wxEVT_POST_CREATE_DOCUMENT event to the a2dViewConnector class m_connector. The a2dViewConnector derived class may intercept the event to created new a2dView's for the new a2dDocument. This is what the default handler ::wxEVT_POST_CREATE_DOCUMENT in a2dViewConnector::OnPostCreateDocument() does do. It first uses the a2dDocumentCommandProcessor to display the available a2dViewTemplate's for the new created document type. The user chooses one, and that a2dViewTemplate will be used to create the first view on the document with a2dViewTemplate::CreateView(). But in other situations, one might prefer to hook the new document into an existing view. The existing view its current document is disconnected from the view, and the new one is connected to the view. a2dViewTemplate::CreateView() is what generates the ::wxEVT_POST_CREATE_VIEW which is also redirected to a a2dViewConnector. This event may or may no be handled by a connector. It depends on the application, how a connector wants to connect new views into the application.
Definition at line 2297 of file docviewref.h.
| a2dDocumentTemplate::a2dDocumentTemplate | ( | const wxString & | descr, |
| const wxString & | filter, | ||
| const wxString & | dir, | ||
| const wxString & | ext, | ||
| const wxString & | docTypeName, | ||
| wxClassInfo * | docClassInfo = ( wxClassInfo* ) NULL, |
||
| a2dViewConnector * | connector = ( a2dViewConnector* ) NULL, |
||
| long | flags = a2dTemplateFlag::DEFAULT, |
||
| a2dIOHandlerStrIn * | handlerIn = NULL, |
||
| a2dIOHandlerStrOut * | handlerOut = NULL |
||
| ) |
Associate document and view types. They're for identifying what view is associated with what template/document type.
Constructor. Create instances dynamically near the start of your application after creating a a2dDocumentCommandProcessor instance, and before doing any document or view operations.
| descr | is a short description of what the template is for. This string will be displayed in the file filter list of Windows file selectors. |
| filter | is an appropriate file filter such as *.txt OR "*.cal;*.gds" for more the one. |
| dir | is the default directory to use for file selectors. |
| ext | is the default file extension (such as txt). |
| docTypeName | is a name that should be unique for a given type of document, used for gathering a list of views relevant to a particular document. |
| docClassInfo | is a pointer to the run-time document class information as returned by the CLASSINFO macro, e.g. CLASSINFO(MyDocumentClass). If this is not supplied, you will need to derive a new a2dDocumentTemplate class and override the CreateDocument member to return a new document instance on demand. |
| connector | connector to use to attach this type of template to GUI. |
| flags | is a bit list of the following: - a2dTemplateFlag::VISIBLE The template may be displayed to the user in dialogs. - wxREFTEMPLATE_INVISIBLE The template may not be displayed to the user in dialogs. - a2dTemplateFlag::DEFAULT Defined as a2dTemplateFlag::VISIBLE. |
| handlerIn | IO handler needed to read this type of files into the document. |
| handlerOut | IO handler needed to write this type of files from the document. |
Definition at line 1740 of file docviewref.cpp.
|
virtual |
Creates a new document.
Creates a new instance of the associated document class. If you have not supplied a wxClassInfo parameter to the template constructor, you will need to override this function to return an appropriate document instance.
After creating a new document two event are generated:
- a2dDocumentEvent of type ::wxEVT_CREATE_DOCUMENT sent to document - a2dDocumentTemplateEvent of type ::wxEVT_POST_CREATE_DOCUMENT sent to a2dViewConnector.
Definition at line 1841 of file docviewref.cpp.
|
virtual |
to test if a file that needs to be loaded, is suitable for this template.
The default implementation is testing the file extension of the template against the file extension in the path. When no extension is given in the file and a m_ioHandlerStrIn is set, the a2dIOHandler::CanLoad() is used to test the file contents for that io handler. At last the m_fileFilter is search for the path extension, if found return true.
Definition at line 1904 of file docviewref.cpp.
|
virtual |
if there is an io handler, and it can save the document of this template, return it
| filename | when not empty, it is/can be used to choose io handler also based on the extension of the filename. |
| document | the document that needs to be saved. |
Reimplemented in a2dDocumentTemplateAuto.
Definition at line 1819 of file docviewref.cpp.
| bool a2dDocumentTemplate::SentPostCreateDocumentEvent | ( | a2dDocument * | newDoc, |
| a2dDocumentFlagMask | flags | ||
| ) |
sents a wxEVT_POST_CREATE_DOCUMENT called in general from a2dDocumentCommandProcessor() when a new document was created.
This event is sent to the m_connector a2dViewConnector of the template, and the sender/eventObject is this template. The a2dViewConnector can react in several ways to this action:
The default implementation see a2dViewConnector::OnPostCreateDocument().
In a derived a2dViewConnector you can implement your own handler, to treat the new document in ways more appropriate to your application.
| newDoc | the new document which was created |
| flags | some flags telling for what purpose the new document was created. e.g a2dREFDOC_NEW |
Definition at line 1887 of file docviewref.cpp.
| a2dDocument * a2dDocumentTemplate::SentPreAddCreatedDocumentEvent | ( | a2dDocument * | newDoc, |
| a2dDocumentFlagMask | flags | ||
| ) |
sents a wxEVT_PRE_ADD_DOCUMENT event to m_connector if available.
This event is sent to the m_connector a2dViewConnector of the template, and the sender/eventObject is this template. It is sent just before a new created document is added to the framework. The a2dViewConnector can react to this action by closings existing documents and disconnect frames and views. At this stage the a2dDocumentCommandProcessor() its current document has not changed yet.
| newDoc | the new document which was created |
| flags | some flags telling for what purpose the new document was created. e.g a2dREFDOC_NEW |
Definition at line 1870 of file docviewref.cpp.
|
inline |
if set this will be used instead of m_docClassInfo to initiate new documents
Id set a clone of this document will be used to create new documents through this a2dDocumentTemplate. This is handy when a document has a lot of initial settings which can now be set once here. So for each document type/purpose you can have unique settings.
Definition at line 2506 of file docviewref.h.