Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
a2dViewConnector Class Referenceabstract

This class is used to connect newly created a2dView's to a wxFrame and/or wxWindow. More...

#include <docviewref.h>

Inheritance diagram for a2dViewConnector:
Inheritance graph
Collaboration diagram for a2dViewConnector:
Collaboration graph

Public Member Functions

 a2dViewConnector ()
virtual ~a2dViewConnector ()=0
 a2dViewConnector (const a2dViewConnector &other)
void SetInitialPosition (const wxPoint &position)
 set position to use for new created views or frames or windows
void SetInitialSize (const wxSize &size)
 set size to use for new created views or frames or windows
void SetInitialStyle (long style)
 set style to use for new created frames or windows
wxPoint & GetInitialPosition ()
 Get position used for new created views or frames or windows.
wxSize & GetInitialSize ()
 GGet size used for new created views or frames or windows.
long GetInitialStyle ()
 Get style used for new created a2dDocumentFrame.
a2dViewTemplateListGetViewTemplates ()
void AssociateViewTemplate (a2dViewTemplate *temp)
 add a reference to a a2dViewTemplate to the wxViewTemplateReflist More...
void DisassociateViewTemplate (a2dViewTemplate *temp)
 remove a reference to a a2dViewTemplate from the wxViewTemplateReflist
void DisassociateViewTemplates ()
 remove All references to a a2dViewTemplate from the wxViewTemplateReflist
virtual a2dViewCreateView (a2dDocument *doc, const wxString &viewTypeName=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON, a2dTemplateFlagMask mask=a2dTemplateFlag::DEFAULT)
 create a new view from a list of a2dViewTemplate's More...
void OnDisConnectView (a2dTemplateEvent &event)
 handler for ::wxEVT_DISCONNECT_VIEW More...
void SetOnlyDisconnect (bool OnlyDisconnect)
bool GetOnlyDisconnect ()
 When true, a2dView::OnDisConnectView() only disconnects view from document, and does not close it.
- 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 ()
virtual ~a2dObject ()
void operator= (const a2dObject &other)
 assignment operator
int GetOwnedBy ()
 like it to be protected, but this does not work with wxList macros More...
virtual a2dObjectSetNonDynamic ()
 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...
a2dObjectClone (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...
a2dNamedPropertyGetProperty (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 a2dNamedPropertyFindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none)
 Find a dynamic property with given id in the property list. More...
virtual const a2dNamedPropertyFindProperty (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 a2dNamedPropertyListGetPropertyList () 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

a2dObjectDoClone (a2dObject::CloneOptions options, a2dRefMap *refs) const
- 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...
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 Attributes

wxPoint m_initialPos
 position for new frames
wxSize m_initialSize
 size for new frames
long m_initialStyle
 style for new frames
a2dViewTemplateList m_viewTemplates
 templates for views
bool m_OnlyDisconnect
 see SetOnlyDisconnect()
- Protected Attributes inherited from a2dObject
a2dNamedPropertyList m_propertylist
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

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< a2dObjectTAutoZeroPtrListClass
 this is needed inside the smart pointer template code
- Static Public Attributes inherited from a2dObject
static a2dPropertyIdBoolPROPID_Check = NULL
 used for linking multiple referenced objects when serializing
static a2dPropertyIdUriPROPID_URI = NULL
 attach an URL to the object
static a2dPropertyIdStringPROPID_Name = NULL
 Name property, to return name of this object.
static a2dPropertyIdVoidPtrPROPID_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

Detailed Description

This class is used to connect newly created a2dView's to a wxFrame and/or wxWindow.

a2dDocumentTemplate generates new documents and a2dViewTemplate generate new views on a document. The new documents and views use the a2dViewConnector to link themselfs to the windows and/or frames of the application. The a2dViewConnector is an abstract class, so a new connector class needs to be derived. This derived class has complete freedom on how to organize new views into the application. It may decide to use existing frame or windows, or generate new frames and/or windows. In the end it must set one wxWindow pointer in the a2dView, which will be used by the view to display itself. The a2dViewConnector may also decide to use existing views for connecting the new document to. In that case no new views will be created.

The approach to have a a2dViewConnector decide how to connect views to frames/windows, is good for making a2dView independent classes. In such clases, the views can be switched with other views. Think here of a complete graphical editor wxFrame derived class, which edits the view which has the focus. It has all the menu's and tools to do it, but does not know yet if there is one or many views inside itself. It only knows how to edit one a2dView which is part of the editor frame. Different types of views can be switched into the editor frame, where each view type can define a different manner of rendering a drawing. One might use the standard wxDC based API for drawing in one view type, and another using an antialiasing rendering engine. The editor does not need to know what view is used internal.

The a2dViewConnector class is created before setting up a2dDocumentTemplate, and given as a pointer to a2dDocumentTemplate and a2dViewTemplate.

a2dDocumentTemplate sents a ::wxEVT_POST_CREATE_DOCUMENT event after it created a new a2dDocument. This event should be catched by the a2dViewConnector. The default handler calls CreateView on a choosen a2dViewTemplate from a list, leading to a ::wxEVT_POST_CREATE_VIEW being sent to this or another a2dViewConnector class. The connector receives this event, and the new view can be plugged into/attached to a window etc.

WxViewTemplateRef sents a ::wxEVT_POST_CREATE_VIEW event after it created a new a2dView. This event may be catched by the a2dViewConnector. One can handle this event in a derived a2dViewConnector class, and connect the new a2dView somehow into the application its wxFrame's or wxWindow's. The normal action should be to plug the new view into a wxFrame, and/or create a wxWindow for the a2dView to use as DisplayWindow. The wxFrame and DisplayWindow may already exist or will be created each time. This depends on the application and what a2dViewConnector is used.

The new a2dView in the end will have a pointer set to its display window. It is up to the type of a2dViewConnector ( which the application uses ), to decide what to do with new a2dView's and/or new a2dDocument's.

A different approach to connect new documents into the application, is to not intercept ::wxEVT_POST_CREATE_VIEW. The connector will either directly use newly created views or already existing views to connect the new document to. This should all be arranged in the handler for ::wxEVT_POST_CREATE_DOCUMENT. In a one wxFrame application with one or more subwindows containing a view, this is the better way to connect new documents into the application.

The a2dView uses its DisplayWindow to redirect events ( e.g. ::wxEVT_CLOSE_VIEW ) to the window(s) and frame containing the view. A special a2dDocumentFrame can be used to interecept such events, and handle them correctly. But you can decide to use your own frame class.

Events sent to this class:

- ::wxEVT_POST_CREATE_DOCUMENT from template just after creation of a document
- ::wxEVT_POST_CREATE_VIEW from template just after creation of a view

Definition at line 2857 of file docviewref.h.

Member Function Documentation

void a2dViewConnector::AssociateViewTemplate ( a2dViewTemplate temp)

add a reference to a a2dViewTemplate to the wxViewTemplateReflist

When Associating a a2dViewTemplate, you are responsible for Disassociating that ViewTemplateRef. Not doing this will result in a memory leak, since instances of this class will not be deleted. The reason is that the ViewTemplateRef itself also Owns the connector, and therefore the reference count will never reach zero, if still associated ViewTemplateRef templates to exist.

Definition at line 2148 of file docviewref.cpp.

a2dView * a2dViewConnector::CreateView ( a2dDocument doc,
const wxString &  viewTypeName = wxT( "" ),
a2dDocumentFlagMask  flags = a2dREFDOC_NON,
a2dTemplateFlagMask  mask = a2dTemplateFlag::DEFAULT 

create a new view from a list of a2dViewTemplate's

Creates a a2dDocumentTemplateEvent of type ::wxEVT_POST_CREATE_DOCUMENT to be processed by this connector. This is handy when one already created/has a document, and wants to create a view for it. In general document are created via a2dDocumentTemplate.

Definition at line 2191 of file docviewref.cpp.

void a2dViewConnector::OnDisConnectView ( a2dTemplateEvent event)

handler for ::wxEVT_DISCONNECT_VIEW

The ::wxEVT_DISCONNECT_ALLVIEWS is generated by the a2dDocument when it wants to disconnects all views. This can be when closing the document, or just to attach all views to another document. a2dView does intercept this event, and sents a ::wxEVT_DISCONNECT_VIEW via its a2dViewTemplate member to the a2dViewConnector of that specific template. In short the a2dViewTemplate and a2dViewConnetor which were used to generate the a2dView and connect the view into the GUI of the application, is also used to disconnect it later.

Here the view connector is responsible for disconnecting view from documents, and if wanted to destroy the a2dView and/or the a2dDocumentFrame, a2dDocumentViewWindow, a2dDocumentViewScrolledWindow or whatever GUI interface was used to contain the view.

Definition at line 2220 of file docviewref.cpp.

void a2dViewConnector::SetOnlyDisconnect ( bool  OnlyDisconnect)

when view is disconnected is called, the document is only disconnected from the document and kept alive

Definition at line 2936 of file docviewref.h.

The documentation for this class was generated from the following files:
a2dViewConnector Class Reference -- Sun Oct 12 2014 17:04:52 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation