wxArt2D
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
a2dView Class Referenceabstract

Holds a view on a a2dDocument. More...

#include <docviewref.h>

Inheritance diagram for a2dView:
Inheritance graph
[legend]
Collaboration diagram for a2dView:
Collaboration graph
[legend]

Public Member Functions

 a2dView ()
 constructor More...
 
 ~a2dView ()
 destructor
 
 a2dView (const a2dView &other)
 construct with other view
 
bool IsClosed ()
 A closed flag is set when a view is closed. More...
 
void SetClosed ()
 sets closed flag to true, and calls Release() view. More...
 
bool Enable (bool enable)
 returns true if view was enabled/disabled, false if nothing done More...
 
bool GetEnabled ()
 return true if the view is enabled. See Enable()
 
virtual void SetDisplayWindow (wxWindow *display)
 Set the display window. More...
 
wxWindow * GetDisplayWindow ()
 Get the display window.
 
wxUint32 GetId ()
 Get the id of the view (used for identification in event processing.
 
a2dDocumentGetDocument () const
 get the document of the view More...
 
void SetDocument (a2dDocument *doc)
 Set the document for the view and add it to the document its viewlist. More...
 
wxString GetViewTypeName () const
 get type name of the view. More...
 
a2dViewTemplateGetViewTemplate () const
 get the a2dViewTemplate with which this view was created More...
 
void SetViewTemplate (a2dViewTemplate *viewtemplate)
 to set the view template from which this view was created.
 
void SetViewTypeName (const wxString &name)
 set type name of the view. More...
 
virtual void Update (unsigned int hint=0, wxObject *hintObject=NULL)
 force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
 
virtual bool Close (bool force=false)
 Close a view and remove the view from its document. More...
 
virtual bool ProcessEvent (wxEvent &event)
 Extend event processing to search the view's event table. More...
 
void Activate (bool activate)
 is called via ProcessEvent() when the view becomes active More...
 
bool GetActive ()
 return if the view is active/ More...
 
virtual void OnDraw (wxDC *dc)=0
 needs to be implemented to print a view, also so used for simple redrawing of views. More...
 
virtual wxPrintout * OnCreatePrintout (a2dPrintWhat typeOfPrint, const wxPageSetupDialogData &pageSetupData)
 called from the a2dDocumentCommandProcessor to create a wxPrintout are derived class More...
 
virtual void OnPrint (wxDC *dc, wxObject *info)
 called from a2dDocumentPrintout when printing a view. More...
 
- Public Member Functions inherited from a2dObject
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 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...
 
 DECLARE_PROPERTIES ()
 
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

void OnUpdate (a2dDocumentEvent &event)
 default handler for a2dDocumentEvent ::wxEVT_UPDATE_VIEWS More...
 
void OnEnableViews (a2dDocumentEvent &event)
 default handler for a2dDocumentEvent of type ::wxEVT_ENABLE_VIEWS More...
 
void OnReport (a2dDocumentEvent &event)
 handler for the ::wxEVT_REPORT_VIEWS More...
 
void OnEnable (a2dViewEvent &event)
 default handler for EVT_ENABLE_VIEW event.
 
void OnChangeFilename (a2dDocumentEvent &event)
 default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDFILENAME_DOCUMENT More...
 
void OnChangeTitle (a2dDocumentEvent &event)
 default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDTITLE_DOCUMENT More...
 
void OnCloseView (a2dCloseViewEvent &event)
 ::wxEVT_CLOSE_VIEW event handler to do cleanup/veto Close of the view. More...
 
void OnDisConnectView (a2dDocumentEvent &event)
 handler for ::wxEVT_DISCONNECT_ALLVIEWS More...
 
void OnSetFocus (wxFocusEvent &event)
 called on (de)activating (wxWindow) containing the view. More...
 
void OnKillFocus (wxFocusEvent &event)
 when a view goes out of focus ( when only one view per window More...
 
- 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

bool m_isClosed
 close flag, to indicate that the view is being closed are is closed.
 
a2dSmrtPtr< a2dDocumentm_viewDocument
 the document to which this view belongs.
 
wxString m_viewTypeName
 set via the a2dViewTemplate on generation of this view.
 
a2dViewTemplatePtr m_viewTemplate
 view was created from this view template or if not used NULL
 
bool m_active
 true if this view is activated ( its display window has the focus and recieves mouse events )
 
bool m_viewEnabled
 Is the view enabled? More...
 
wxWindow * m_display
 In case of using a window for displaying the view, this holds the window.
 
wxUint32 m_id
 This identifies the view in event processing.
 
a2dSmrtPtr< a2dViewm_keepalive
 
- 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< 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

Holds a view on a a2dDocument.

A view is able to connect your documents to the windows in an application. It knows its document or documents, and it know where (which windows) the data from the document is displayed. This makes it possible to close or disconnect all views on a document, and indirectly its windows can be closed. For instance; closing the application, will close all its documents, and via the views, will close all windows/frames on the documents. But also closing just one frame, can delete one document via the frame its view. The view is like a two way bridge between the document and the GUI.

A a2dView is indirectly used for displaying a (part of) a2dDocument its data. It may display this data in any form it wants to. Several a2dView's can exist on a a2dDocument, and they can be of different types. A a2dView organizes to display data stored in a2dDocument's. A document can be set for a view, and this will be used by the view to check if ::wxEVT_UPDATE_VIEWS events coming from the documents, are meant for the view or not. If a view wants to display the data of several documents, this can be arranged in a derived class.

The views on a document, work independent of eachother. When using a a2dDocumentCommandProcessor class, this will know the currently active view. In general this is the view which has the focus. Meaning its display window has the focus.

The a2dDocument class uses events to notify changes. The a2dView's connect themselfs to a a2dDocument to recieve specific events. Any wxEvtHandler derived class may be connected to the a2dDocument. The document does not know all this in advance, it just sents events to itself. The dynamically connected handlers, will receive those events too.

Since a2dViews connects to specific events in a a2dDocument, one could think that the same can be done with wxWindow's etc. directly. But using a2dView, makes it easy to centralize the actions needed, independent from the application its windows and dialogs. A dedicated view, used to display data from a dedicated document, can be used for a wxFrame or a wxNotebook page at the same time. The view does not need to know about your application in terms of windows. Because of this, its functionality can be made part of a library, to be used by any application.

The view may display the data from the document, directly to the device or in a delayed fashion. In which case it stores the data to display first locally, and as soon as possible this data is updated to the device ( e.g. a window. ) If the device is a window, the m_display holds a pointer to it.

Views display the data in a document, and therefore if the document data changes, the view might change because of that. The a2dDocument::UpdateAllViews() is sending ::wxEVT_UPDATE_VIEWS to the a2dDocument, and this sents the event to all connected a2dView's. a2dView::OnUpdate() will handle the event. It checks if it wants to process the event coming from that particular document, and if so updates its own data from that document. To update all views at every small change made to the document, is often not desired. Checking a "pending flag" inside the document when the program becomes idle is a better way to update the views.

Often the view is a rectangular drawing area. The view can use a wxWindow derived class to display the data for a document. But this is not a must, a view may be stored anywhere. A view might also display parts of a document(s) via wxDialogs, or it might store it in a bitmap. How and what is displayed using a view depends on the derived class.

The way to update what is displayed by the view needs to be defined in the handler for ::wxEVT_UPDATE_VIEWS event. The default OnUpdate, just calls refresh on the view its display window. Here the display window will redisplay the specific data from the document in the way it wants. Changes in the document need to result in calling OnUpdate for each view. OnUpdate may decide to directly redrawn on the device, or only store the view data locally. In the last case a flag is set to indicate that the view has changed. This flag is checked in idle time, resulting in an update of the device eventually. This is the principle behind calling m_display->Refresh() after changing a document or a view its display data. This will result in a wxPaintEvent, which will redraw the view data.

When the display device is a window, the wxPaintEvent event handled in the window, may request a redraw of certain areas within the view. The view may do this by actually redrawing directly from the document, or in case of local stored data, return/redraw only this locally stored data directly on the window. In some cases the data displayed on the window, is actually stored locally within the window, and the window handles paint events itself, without asking the view to redisplay the damaged areas ( e.g. wxTextCtrl. etc. ). Still the window will need to check if the view or document did change, to keep its contents up to date. The member a2dView::OnDraw( wxDC* ) can be used by the display window, to have the view redraw itself on the window. But of course if not using wxDC based views, any other method can be used. The important thing to understand, is that the Updating of a a2dView can happen at time X, while the display of this updated view can happen at time Y. Therefore several updates on a view might take place before they are actually redisplayed.

For printing the view in a2dView::OnPrint(wxDC *dc), you may use Ondraw to print the contents of a view to a wxDC. For that you should define a way to draw the view its data on a wxDC.

Events which are sent to a2dView:

a2dView is by default Registered to a2dDocument which is set to it. And will recieve all events from send there.

In general all wxWindow events of m_display or the wxFrame containing the a2dView

View specific events.

Definition at line 1804 of file docviewref.h.

Constructor & Destructor Documentation

a2dView::a2dView ( )

constructor

the view owns itself until Close() or SetClosed()

Definition at line 1245 of file docviewref.cpp.

Member Function Documentation

void a2dView::Activate ( bool  activate)

is called via ProcessEvent() when the view becomes active

Generates a ::wxEVT_ACTIVATE_VIEW with active == activate. When recieved by a2dDocumentCommandProcessor::OnActivateView() this way, the last will deactivate its current active view, using this same function.

The event ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD event is sent to the m_display window or frame. This is the event to catch in order to set the view in the containing frame/windows. For example a2dDocumentFrame uses this event to set the view to which it will sent window close events.

Can also be called directly to notify the view that it should go (in)active.

Normally Activate() sents the a2dViewEvent of type ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD to m_display.

See Also
a2dViewEvent.

Definition at line 1400 of file docviewref.cpp.

bool a2dView::Close ( bool  force = false)
virtual

Close a view and remove the view from its document.

IMPORTANT there are two ways/paths through which a view can be closed.

  1. by closing the frame containing the view(s).
  2. by the docmanager closing a document and this one closing the views on the document.

The first one will destroy the frames, and it must Close the view(s) it contains. The second one must make sure that the frames containing the views will be destroyed. This is why ::wxEVT_CLOSE_VIEW travels up in the hiearchy of windows, starting at m_display window.

Close() generates a ::wxEVT_CLOSE_VIEW event, which is first redirected to the a2dDocument, and if not vetod there, to the m_display wxWindow. if not vetod there, the event is sent to a2dView itself.

If not vetod in the ::wxEVT_CLOSE_VIEW handler of the view, the View Will be removed and released from the document. The view will be set Inactive. The m_display wxWindow will be disabled, to prevent it from sending more events.

When the ::wxEVT_CLOSE_VIEW is sent to the m_display window, the a2dView itself is disabled for handling events, untill the event is (not)processed by the display and return. So event coming back to the view will not be handled during that time. The ::wxEVT_CLOSE_VIEW is sent to m_display, but the event is of the type that travels up to the parent window if not handled. So if not handled in the display window, it will go to the parent window. Eventually it arives in the wxFrame holding the windows. The idea is thay you do intercept ::wxEVT_CLOSE_VIEW event somewhere in the hierarchy of windows, and make sure the a2dView is correctly detached from the windows where it is used. In case the event is not vetod by the display window, it is a good habbit that it sets the display window of this/its view to NULL, this will prevent events coming from this view to the display window for sure.

This is the clue to having view independent frames and windows. A specialized frame or window, can use different types of connectors to deal with different types of attached views.

Always be aware of dangling pointers from the display window, which normally will/should have a pointer to the view. Also other classes having somehow a pointer to this view (which will be closed and released soon), should take care of this by intercepting the ::wxEVT_CLOSE_VIEW event. Therefore the display window, in such cases should redirect the ::wxEVT_CLOSE_VIEW event to such classes. Default the event will be redirected to the parent window, if not handled or skipped.

When not vetod Close() the DisplayWindow m_display is set to NULL first. The reason for disabling the display window is to prevent it from sending more events to this view, which will be deleted soon.

In any case the ::wxEVT_CLOSE_VIEW handler should check whether the view is being deleted forcibly, using a2dCloseViewEvent::CanVeto(). If so it needs to perform the nessecary cleanup. Else it may veto.

Example:

//the next class interecepts the ::wxEVT_CLOSE_VIEW
void wxSomeClass::OnCloseView( a2dCloseViewEvent& event )
{
//test if the frame or windows where not already deleted
//
if ( event.GetForce() && GetViewFrame() )
{
event.GetView()->SetDisplayWindow( NULL );
m_display->Disable();
m_display->Destroy();
m_display = NULL;
}
}

Closing a view recursive, while its busy closing itself is not a problem. The owning objects may recursively call this function without problem, for that the m_isClosed flag is set at the beginning which prevents closing twice. the view object itself will be released only once in the end. The ::wxEVT_CLOSE_VIEW will be issued only once.

If the view has a document set, the view is first removed from that document, sending a ::wxEVT_REMOVE_VIEW event to the old document. Can be received from the a2dDocument after Registering this class. See a2dDocumentCommandProcessor::OnRemoveView() where this event is used to reset the last active view.

Remarks
a2dView is reference counted and will only be really deleted when it reaches zero
In wxWindows the handler function for ::wxEVT_CLOSE_WINDOW event is called when the user has tried to close a frame using the window manager (X) or system menu (Windows). The ::CLOSE_WINDOW event should normally be intercepted, and ask via calling a2dView::Close if it is oke to close the view. In a2dDocumentFrame this arranged.
You may call also a2dView::Close() directly, it will generate the same events.
Returns
true is view was properly closed and not vetod else false

release of itself

Definition at line 1555 of file docviewref.cpp.

bool a2dView::Enable ( bool  enable)

returns true if view was enabled/disabled, false if nothing done

Sets the view enabled or disabled, which means that no events will be processed, except ::wxEVT_ENABLE_VIEW and ::wxEVT_ENABLE_VIEWS.

The ::wxEVT_ENABLE_VIEW event is sent to the view and the display window (if available). After that the new state is set.

If the view is already in the requested state, nothing is done.

Definition at line 1320 of file docviewref.cpp.

bool a2dView::GetActive ( )
inline

return if the view is active/

a view is in general active when its m_display window has the focus or is selected.

Definition at line 2066 of file docviewref.h.

a2dDocument* a2dView::GetDocument ( ) const
inline

get the document of the view

Returns
NULL if no document is set.

Definition at line 1882 of file docviewref.h.

a2dViewTemplate* a2dView::GetViewTemplate ( ) const
inline

get the a2dViewTemplate with which this view was created

See Also
a2dViewTemplate.

Definition at line 1914 of file docviewref.h.

wxString a2dView::GetViewTypeName ( ) const
inline

get type name of the view.

This name is used to couple document types to view types. See a2dViewTemplate.

Definition at line 1908 of file docviewref.h.

bool a2dView::IsClosed ( )
inline

A closed flag is set when a view is closed.

This flag is set just before the actual closing will take place. If the close is vetod, it will be reset at the end of the closing action, else it will stay true. The flag is a handy test for associated windows, to see if their view is already closed or not.

Definition at line 1829 of file docviewref.h.

void a2dView::OnChangeFilename ( a2dDocumentEvent event)
protected

default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDFILENAME_DOCUMENT

Creates new event of type wxEVT_CHANGEDFILENAME_VIEW, which also knows the view now. Sends the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.

Definition at line 1680 of file docviewref.cpp.

void a2dView::OnChangeTitle ( a2dDocumentEvent event)
protected

default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDTITLE_DOCUMENT

Creates new event of type wxEVT_CHANGEDTITLE_VIEW, which also knows the view now. Sends the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.

Definition at line 1700 of file docviewref.cpp.

void a2dView::OnCloseView ( a2dCloseViewEvent event)
protected

::wxEVT_CLOSE_VIEW event handler to do cleanup/veto Close of the view.

The default handler does nothing yet.

The Handler for ::wxEVT_CLOSE_VIEW, resulting from view close via a2dView:Close() ( either via a2dDocument or a wxFrame containing the view)

One may intercept ::wxEVT_CLOSE_VIEW event in a derived class to Clean up and Destroy windows used for displaying the view. But it is often better to do this in a wxWindow derived class which contains the view. Therefore the ::wxEVT_CLOSE_VIEW is first sent to the m_display wxWindow of the a2dView.

The best is to use a a2dViewConnector to create frames and windows to hold a view, and a2dDocumentFrame derived class to handle Closing of a2dView's. It will recieve the ::wxEVT_CLOSE_VIEW via the wxWindow containing the a2dView which is about to be closed. This makes it easy to use the same view class in other applications.

On closing of a wxFrame, you may decide to Close the window by intercepting EVT_CLOSE, and from there call a2dView::Close. It depends on the application how the views are closed.

In any case Windows should be Destroyed, not really deleted. Destroy only flags for deletion, this means that they will really be deleted in idle time by wxWindows.

Definition at line 1510 of file docviewref.cpp.

wxPrintout * a2dView::OnCreatePrintout ( a2dPrintWhat  typeOfPrint,
const wxPageSetupDialogData &  pageSetupData 
)
virtual

called from the a2dDocumentCommandProcessor to create a wxPrintout are derived class

for printing a view If the printing framework is enabled in the library, this function returns a wxPrintout object for the purposes of printing. It should create a new object every time it is called; the framework will delete objects it creates. By default, this function returns an instance of wxDocPrintout, which prints and previews one page by calling wxView::OnDraw.

Override to return an instance of a class other than wxDocPrintout.

Parameters
typeOfPrintWhen called from a2dDocumentCommandProcessor, the a2dPrintWhat that lead to this call.

Reimplemented in a2dCanvasView.

Definition at line 1721 of file docviewref.cpp.

void a2dView::OnDisConnectView ( a2dDocumentEvent event)
protected

handler for ::wxEVT_DISCONNECT_ALLVIEWS

The ::wxEVT_DISCONNECT_ALLVIEWS is generated by the a2dDocument when it disconnects all views. This can be when closing the document, or just to attach all views to another document.

Definition at line 1516 of file docviewref.cpp.

virtual void a2dView::OnDraw ( wxDC *  dc)
pure virtual

needs to be implemented to print a view, also so used for simple redrawing of views.

Normal updating the data of a view, is via OnUpdate, called from the changed a2dDocument. Once the view its data is up to data, m_display->Refresh() results in a paint event. This in a2dDocumentViewScrolledWindow and a2dDocumentViewWindow directly leads to OnDraw(), redrawing the data of the view on the display window. In a2dDocumentViewScrolledWindow and a2dDocumentViewWindow the wxPaintEvent is intercepted and by default redirected via its OnDraw() to the view Ondraw() function here. If it is a clever implementation, the above refresh should only refresh the areas in the view which did change. In m_display->GetUpdateRegion() is where you should get those regions, while the paint event is being handled.

A more complicated situation is as follows. Paint events are generated when a wxWindow becomes visible, or when you draw something to it. The regions needing an update, or reported by the Paint event. The view does not need to do a complete re-drawn, only the damaged regions. In such a case you should Handle the paint event Your self in the m_display window, and redirect it to the a2dView. In the a2dView you can iterate over the damaged regions, and only redraw the view its data in those regions.

Implemented in a2dCanvasView.

void a2dView::OnEnableViews ( a2dDocumentEvent event)
protected

default handler for a2dDocumentEvent of type ::wxEVT_ENABLE_VIEWS

This enable or disables the view by calling Enable( event.GetEnable() ). But only if the a2dDocument from which this document was sent, is the one the a2dView is using. If the view from which the event originated is specified in the event, that view will not process the event, all others will.

Definition at line 1672 of file docviewref.cpp.

void a2dView::OnKillFocus ( wxFocusEvent &  event)
protected

when a view goes out of focus ( when only one view per window

that view goes out of focus if the window goes out of focus ) Else the window getting the focus should decide which view goes out of focus.

Definition at line 1732 of file docviewref.cpp.

void a2dView::OnPrint ( wxDC *  dc,
wxObject *  info 
)
virtual

called from a2dDocumentPrintout when printing a view.

Default calls OnDraw(wxDC *dc)

Definition at line 1635 of file docviewref.cpp.

void a2dView::OnReport ( a2dDocumentEvent event)
protected

handler for the ::wxEVT_REPORT_VIEWS

The handlers adds this a2dView to the reportlist of the event, if it depends on the document sending the event. The default simply checks that the view its document is the one sending the event, and if so adds it. In case your view displays info of several documents, you should intercept this event to implement this behaviour.

Definition at line 1657 of file docviewref.cpp.

void a2dView::OnSetFocus ( wxFocusEvent &  event)
protected

called on (de)activating (wxWindow) containing the view.

when a view gets the focus ( when only one view per window

that view gets the focus if the window gets the focus ) Else the window getting the focus should decide which view gets the focus.

Definition at line 1727 of file docviewref.cpp.

void a2dView::OnUpdate ( a2dDocumentEvent event)
protected

default handler for a2dDocumentEvent ::wxEVT_UPDATE_VIEWS

Updates the view data ( e.g the data that the view displays has changed in the document). The view may hold/display data which should change when the document(s) changes. Here this data can be updated, the internal data of the view can be updated. When the view will be redisplayed depends on the derived class. One can set a dirty flag after changing the view its data, and do the redisplay in idle time, where this flag is checked. But often there is no need to do this, since the view can directly update its Display window, or tell it that it needs to update itself. Therefore the default here simply calls m_display->Refresh(), which leads to a paint event on the display window, and that might/should call a2dView::Ondraw().

Definition at line 1651 of file docviewref.cpp.

bool a2dView::ProcessEvent ( wxEvent &  event)
virtual

Extend event processing to search the view's event table.

Some events are handled within the view as if the view is a window within a window. Therefore the wxWindow containing the view should redirect all its events to its view(s), when the view does not handle the event it will go to the window itself.

Events handled how:

  • ::wxEVT_ENABLE_VIEW & ::wxEVT_ENABLE_VIEWS always processed, sent to GetEventHandler()
  • ::wxEVT_ACTIVATE sent from a2dDocumentFrame and derived classes, calls Activate()
  • ::wxEVT_SET_FOCUS sent to GetEventHandler() and calls Activate(true)
  • ::wxEVT_KILL_FOCUS sent to GetEventHandler() and calls Activate(false)
  • ::wxEVT_CLOSE_WINDOW sent from wxWindow containing the a2dView. calls Close( !closeevent.CanVeto() )
  • ::wxEVT_IDLE sent from wxWindow containing the a2dView, sent to GetEventHandler() and to the a2dDocument.

Reimplemented from a2dObject.

Reimplemented in a2dCanvasView.

Definition at line 1438 of file docviewref.cpp.

void a2dView::SetClosed ( )

sets closed flag to true, and calls Release() view.

Normally Close() should be used, but in cases where a view is used temporarely and without a display window ( e.g using a view for rendering to bitmap ), this can be used to properly close a view without sending extra events.

Definition at line 1545 of file docviewref.cpp.

void a2dView::SetDisplayWindow ( wxWindow *  display)
virtual

Set the display window.

The display window can be used to display the view on a wxWindow. This is not a must, since a view might also be displayed into a bitmap etc. But in that case this needs to be arranged in a derived class. The default is using a display wxWindow.

The window may be set in a derived view class. But often it is better to set it from a specialized a2dViewConnector. If needed in combination with a specialized a2dViewTemplate. This makes it easier to make general view classes, which can be used in several types of applications or display windows.

Remarks
this function has only effect if the view its eventhandler is enabled. The reason is that some events like a2dCloseViewEvent are set up to the m_display window, during that time the event handler is disabled to prevent looping. But also the m_display should stay constant during that time.

Definition at line 1308 of file docviewref.cpp.

void a2dView::SetDocument ( a2dDocument doc)

Set the document for the view and add it to the document its viewlist.

Normally called by the framework.

If the view already has a document set, the view is first removed from that document, sending a ::wxEVT_REMOVE_VIEW event to the old document, Can be received from the a2dDocument after Registering this class.

See a2dDocumentCommandProcessor::OnRemoveView() where this event is used to reset the last active view.

Next the new document will be set for the view, and added to the viewlist of the new document, sending a ::wxEVT_ADD_VIEW event to the new document.

At last a a2dViewEvent event of type ::wxEVT_SET_DOCUMENT is sent to the a2dView. So if extra administrative tasks for the view are needed when setting a view to a document, intercept that event to do it.

Definition at line 1359 of file docviewref.cpp.

void a2dView::SetViewTypeName ( const wxString &  name)
inline

set type name of the view.

This name is used to couple document types to view types. See a2dViewTemplate.

Definition at line 1924 of file docviewref.h.

Member Data Documentation

a2dSmrtPtr<a2dView> a2dView::m_keepalive
protected

this is used to keep the view alive if no other references are there. This untill the view is closed by calling Close() or SetClosed()

Definition at line 2251 of file docviewref.h.

bool a2dView::m_viewEnabled
protected

Is the view enabled?

true if this view is enabled and will process all events. else only ::wxEVT_ENABLE_VIEW and ::wxEVT_ENABLE_VIEWS will be processed.

Definition at line 2241 of file docviewref.h.


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