wxArt2D
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
a2dToolContr Class Reference

The a2dToolContr is the base class for Tool controller classes. More...

#include <tools.h>

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

Public Member Functions

 a2dToolContr (a2dDrawingPart *drawingPart)
 
virtual ~a2dToolContr ()
 destructor
 
void SetDrawingPart (a2dDrawingPart *drawingPart)
 sets the a2dDrawingPart on which the controller will work. More...
 
a2dDrawingPartGetDrawingPart ()
 Get the a2dDrawingPart object that the controller is plugged into.
 
void StopAllTools (bool abort=true)
 all tools currently on the tool stack will be terminated and poped ( forced ) More...
 
virtual void ReStart ()
 Toolcontroller can be re-initialized. More...
 
void Disable ()
 can be used by a2dCanvas or a2dDrawingPart to disable this class More...
 
a2dBaseToolGetFirstTool () const
 get currently used eventhandler (always the first in the list)
 
const a2dToolListGetToolList () const
 return reference to tool list
 
bool ProcessEvent (wxEvent &event)
 process an event for the object, if the event is not handled by More...
 
virtual bool PushTool (a2dBaseTool *handler)
 push/pop tool: More...
 
virtual bool PopTool (a2dBaseToolPtr &poped, bool force=true)
 remove first tool on the tool stack More...
 
void AppendTool (a2dBaseTool *handler)
 append a tool to the list, this tool will recieve an event if the other skipped the event to process. */
 
bool EnableTool (const wxString &tool, bool disableothers)
 enable the tool with the given name More...
 
bool EnableTool (a2dBaseTool *tool, bool disableothers)
 enable the given tool More...
 
bool DisableTool (const wxString &tool)
 disable the tool with the given name More...
 
bool DisableTool (a2dBaseTool *tool)
 disable the tool with the given name More...
 
a2dBaseToolSearchTool (const wxString &tool)
 search for the tools in the tool list with the given name. More...
 
void ActivateTop (bool active)
 (de)activate the first tool in the list. More...
 
bool Activate (const wxString &tool, bool disableothers)
 Activate the tool with the given name. More...
 
virtual bool StartEditingObject (a2dCanvasObject *objectToEdit)
 start editing object using existing corridor to object More...
 
virtual bool StartEditingObject (a2dCanvasObject *objectToEdit, a2dIterC &ic)
 start editing object using iteration context to define corridor. More...
 
virtual bool TriggerReStartEdit (wxUint16 editmode)
 trigger restart editing (after undo event or when changing editing mode ) More...
 
bool SetCorridor (const a2dCorridor &corridor)
 define corridor for the controller its first tool
 
virtual void Render ()
 render the tool chain More...
 
void SetSnap (bool doSnap)
 set snap on or off. More...
 
bool GetSnap ()
 get current snap setting ( true or false ).
 
void SetDefaultToolEvtHandler (a2dObject *handler)
 see m_eventHandler
 
a2dObjectGetDefaultToolEventHandler ()
 see m_eventHandler
 
void SetDefaultToolEvtHandlerFixedStyle (a2dObject *handler)
 see m_defaultEventHandlerFixedStyle
 
a2dObjectGetDefaultToolEventHandlerFixedStyle ()
 see m_defaultEventHandlerFixedStyle
 
- 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

bool ToolsProcessEvent (wxEvent &event)
 Event not handled in this class are redirected to the chain of tools. More...
 
void OnEnter (wxMouseEvent &event)
 sets the focus to the display window.
 
void OnPaint (wxPaintEvent &event)
 window Onpaint is received here before the window Onpaint where this controller is plugged into. More...
 
void OnIdle (wxIdleEvent &event)
 
- 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

a2dToolList m_tools
 tool list
 
a2dDrawingPartm_drawingPart
 a2dDrawingPart where tool is plugged into
 
bool m_bussyPoping
 
bool m_snap
 snap is on or off
 
a2dSmrtPtr< a2dObjectm_defaultEventHandler
 use to define default handlers in tools. More...
 
a2dSmrtPtr< a2dObjectm_defaultEventHandlerFixedStyle
 use to define default handlers in tools. More...
 
- 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
 

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

The a2dToolContr is the base class for Tool controller classes.

A tool controller handles redirection of events from the a2dCanvas/a2dDrawingPart Events to the tools that are maintained by a controller. The controller is derived from wxEvtHandler, and there for can be (un)plugged into a a2dDrawingPart window. It then intercepts all events on the canvas window, and sents them to the active tool. The controller has a list of tools, only the active tool will react on the events. More then one tool may be active, in which case skipped events will be handled by later tools in the tool list. In the end skipped events in all tools are handled by a2dDrawingPart itself.

See Also
a2dBaseTool
a2dDrawingPart
a2dCanvas

Definition at line 87 of file tools.h.

Constructor & Destructor Documentation

a2dToolContr::a2dToolContr ( a2dDrawingPart drawingPart)
Parameters
viewview where the controller takes events from

Definition at line 70 of file tools.cpp.

Member Function Documentation

bool a2dToolContr::Activate ( const wxString &  tool,
bool  disableothers 
)

Activate the tool with the given name.

Remarks
DIS activating a tool means it will skip mouse events
it will still receive other events like Onpaint Onchar.
Parameters
tool,:pointer to the tool
disableothers,:if true other tools in the tool list are made inactive

Definition at line 154 of file tools.cpp.

void a2dToolContr::ActivateTop ( bool  active)

(de)activate the first tool in the list.

(de)activates the first tool on the stack, and deactivates all others

Definition at line 141 of file tools.cpp.

void a2dToolContr::Disable ( )

can be used by a2dCanvas or a2dDrawingPart to disable this class

for events, and also pops all tools from the tool stack.

Definition at line 134 of file tools.cpp.

bool a2dToolContr::DisableTool ( const wxString &  tool)

disable the tool with the given name

Disabling a tool means that it will not receive any events.

Parameters
tool,:classname of the tool

Definition at line 208 of file tools.cpp.

bool a2dToolContr::DisableTool ( a2dBaseTool tool)

disable the tool with the given name

Disabling a tool means that it will not receive any events.

Parameters
tool,:pointer to the tool

Definition at line 223 of file tools.cpp.

bool a2dToolContr::EnableTool ( const wxString &  tool,
bool  disableothers 
)

enable the tool with the given name

Parameters
tool,:classname of the tool
disableothers,:if true other tools in the tool list are disabled

Definition at line 172 of file tools.cpp.

bool a2dToolContr::EnableTool ( a2dBaseTool tool,
bool  disableothers 
)

enable the given tool

Parameters
tool,:pointer to the tool
disableothers,:if true other tools in the tool list are disabled

Definition at line 191 of file tools.cpp.

void a2dToolContr::OnPaint ( wxPaintEvent &  event)
protected

window Onpaint is received here before the window Onpaint where this controller is plugged into.

In general a flag is set to do the job in Onidle time after the window itself is repainted

Definition at line 406 of file tools.cpp.

bool a2dToolContr::PopTool ( a2dBaseToolPtr poped,
bool  force = true 
)
virtual

remove first tool on the tool stack

Calls first the tool its StopTool() which prepares the tool for stopping. Calling StopTool() within a tool, automatically result in the tool to be poped by the controller, using this function. This happens within the event processing chain.

Parameters
popedthe tool which is poped from the stack.
forceIf AllowPop() return false, the PopTool is not done, unless force is true.
Remarks
the tool is removed from the stack, tools are reference counted so if you want to preserve it, you can.
Returns
true if a tool was available for poping.

Reimplemented in a2dStToolContr.

Definition at line 364 of file tools.cpp.

bool a2dToolContr::ProcessEvent ( wxEvent &  event)
virtual

process an event for the object, if the event is not handled by

the class itself through a static event table, it will be sent to the first tool via ToolsProcessEvent().

Reimplemented from a2dObject.

Definition at line 249 of file tools.cpp.

bool a2dToolContr::PushTool ( a2dBaseTool handler)
virtual

push/pop tool:

add a tool on top of the already existing ones Calls first tools start, and if this returned true the tool will be pushed.

Returns
true if tool its ToolStart() returned true;

Reimplemented in a2dStToolContr.

Definition at line 335 of file tools.cpp.

void a2dToolContr::Render ( )
virtual

render the tool chain

A tool chain gets rendered when a2dDrawingPart is updating areas that are changed in a document.

Definition at line 440 of file tools.cpp.

void a2dToolContr::ReStart ( )
virtual

Toolcontroller can be re-initialized.

After changing a document on a view, and StopAllTools() was called, this function can be used to bring the controller back into a wanted state. The default does nothing.

Reimplemented in a2dStToolContr.

Definition at line 119 of file tools.cpp.

a2dBaseTool * a2dToolContr::SearchTool ( const wxString &  tool)

search for the tools in the tool list with the given name.

Parameters
tool,:classname of the tool

Definition at line 238 of file tools.cpp.

void a2dToolContr::SetDrawingPart ( a2dDrawingPart drawingPart)

sets the a2dDrawingPart on which the controller will work.

\param view the new canvas view to work on, if NULL this a2dToolContr

will be disabled, and the controller will be popped out of a previous a2dCanvas.

Definition at line 96 of file tools.cpp.

void a2dToolContr::SetSnap ( bool  doSnap)

set snap on or off.

When snapping is on, tools will respect this, and drawing will be on the snap grid.

Definition at line 453 of file tools.cpp.

bool a2dToolContr::StartEditingObject ( a2dCanvasObject objectToEdit)
virtual

start editing object using existing corridor to object

Start editing the object within the coordinate system defined by the corridor set by for instance a2dIterC::SetCorridorPath() Parent of startobject is defined as last object in corridor.

The corridor is used to calculate the editworld matrix, meaning relative to what coordinates system the editing takes place. This becomes important when editing children of objects directly.

Remarks
if a corridor is not set in the a2dCanvasDocument, the ShowObject() of the a2dDrawingPart is used.
at the top level (ShowObject of view) the editorWorld is always a2dIDENTITY_MATRIX else it depends on the structure of the document.

Reimplemented in a2dStToolContr.

Definition at line 425 of file tools.cpp.

bool a2dToolContr::StartEditingObject ( a2dCanvasObject objectToEdit,
a2dIterC ic 
)
virtual

start editing object using iteration context to define corridor.

The editcopy created of the objectToEdit is used to capture the corridor to that object.

Reimplemented in a2dStToolContr.

Definition at line 430 of file tools.cpp.

void a2dToolContr::StopAllTools ( bool  abort = true)

all tools currently on the tool stack will be terminated and poped ( forced )

Use this when the document of the view of this controller is changed.

Definition at line 123 of file tools.cpp.

bool a2dToolContr::ToolsProcessEvent ( wxEvent &  event)
protected

Event not handled in this class are redirected to the chain of tools.

When there are tools in the tools chain, the first tools receives the event first.

If you derive a class from this controller class here, you might not want to use the base event handling for some type of events, even if you do not handle it yourself in your static event callback. Normally handling an event in the baseclass is achieved with event.Skip(). ( e.g in OnMouse or OnChar ). But by calling ToolsProcessEvent() function here directly, skipping is not needed, and the event will directly go to the first available tool.

Remarks
If new tools are pushed while handling the event in the currently available tools, and the event itself was skipped ( not handled ), it will be redirect to the pushed tools. This is in a recursive manner, so there may be a chain of extra pushed tools.
If a tool is stopped (
See Also
GetStopTool() ), it is poped from the Objects used for interactive manipulation. stack. And if the event is not processed yet, it is sent to the next/new first tool. More Objects used for interactive manipulation. can be stopped in a chain of Objects used for interactive manipulation. as a respons to one and the same event.
ProcessEvent
Parameters
eventthe event which will be sent to the tools.
Returns
true if the event was processed and event.Skip() was not called.

Definition at line 289 of file tools.cpp.

bool a2dToolContr::TriggerReStartEdit ( wxUint16  editmode)
virtual

trigger restart editing (after undo event or when changing editing mode )

An editing tool on a a2dCanvasObject can be restarted in derived controller.

Reimplemented in a2dStToolContr.

Definition at line 435 of file tools.cpp.

Member Data Documentation

bool a2dToolContr::m_bussyPoping
protected

set when poping a tool is in progress. This is used to prevent recursive calls from event sent around in the poping process.

Definition at line 310 of file tools.h.

a2dSmrtPtr<a2dObject> a2dToolContr::m_defaultEventHandler
protected

use to define default handlers in tools.

Several tools use a centralized defaultEventHandler, which is called to process events before handling it in the tool itself. Here the default one in those tools can be set.

Definition at line 321 of file tools.h.

a2dSmrtPtr<a2dObject> a2dToolContr::m_defaultEventHandlerFixedStyle
protected

use to define default handlers in tools.

Several tools use a centralized defaultEventHandler, which is called to process events before handling it in the tool itself. Here the default one in those tools can be set, for tools having a fixed style.

Definition at line 329 of file tools.h.


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