wxArt2D
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
a2dCommand Class Referenceabstract

a base command for the a2dCommandProcessor More...

#include <comevt.h>

Inherits a2dObject.

Inherited by a2dCommand_AddObject, a2dCommand_AddObjects, a2dCommand_AddObjectToGroup, a2dCommand_AddPoint, a2dCommand_BandCurveMovePoint, a2dCommand_ChangeCanvasObjectStyle, a2dCommand_ChangeText, a2dCommand_CloneCameleonFromInstMask, a2dCommand_ConnectPins, a2dCommand_ConvertMask, a2dCommand_CopyMask, a2dCommand_CreateCameleonMask, a2dCommand_DisConnectPins, a2dCommand_EliminateMatrix, a2dCommand_FlattenCameleonMask, a2dCommand_GdsIoSaveFromView, a2dCommand_GdsIoSaveTextAsPolygon, a2dCommand_GetEnvVariable, a2dCommand_GetVariable, a2dCommand_GroupAB, a2dCommand_GroupMask, a2dCommand_ImagesToRectMask, a2dCommand_JoinAtPin, a2dCommand_KeyIoSaveFromView, a2dCommand_KeyIoSaveTextAsPolygon, a2dCommand_MergeMask, a2dCommand_MoveMask, a2dCommand_MoveMidSegment, a2dCommand_MoveObject, a2dCommand_MovePoint, a2dCommand_MoveSegment, a2dCommand_NewGroup, a2dCommand_NewPin, a2dCommand_OffsetMask, a2dCommand_PolygonToSurfaceMask, a2dCommand_PushInto, a2dCommand_ReleaseObject, a2dCommand_ReleaseObjectFromGroup, a2dCommand_RemoveSegment, a2dCommand_RemoveZeroWire, a2dCommand_ReplaceObject, a2dCommand_Select, a2dCommand_SetCursor, a2dCommand_SetEnvironmentVariable, a2dCommand_SetFill, a2dCommand_SetFillColour, a2dCommand_SetFillStrokeMask, a2dCommand_SetFlag, a2dCommand_SetFlags, a2dCommand_SetInternalBoundaries, a2dCommand_SetLayerGroup, a2dCommand_SetLayerMask, a2dCommand_SetLayersProperty, a2dCommand_SetPinFlags, a2dCommand_SetProperty, a2dCommand_SetSegments, a2dCommand_SetSelect2Flag, a2dCommand_SetSelectFlag, a2dCommand_SetShowObject, a2dCommand_SetStroke, a2dCommand_SetStrokeColour, a2dCommand_SetVariable, a2dCommand_ShowDlg, a2dCommand_SplitAtPin, a2dCommand_SurfaceToPolygonMask, a2dCommand_SweepCurveMovePoint, a2dCommand_UnGroupMask, a2dCommand_UrlOnMask, a2dCommand_VertexCurveMovePoint, a2dCommand_VertexListCurveMovePoint, a2dCommand_ViewAsImage, a2dCommand_ViewAsSvg, a2dCommand_VirtWire, and a2dCommandGroup.

Collaboration diagram for a2dCommand:
Collaboration graph
[legend]

Public Member Functions

 a2dCommand (bool canUndo=false, const a2dCommandId &commandId=sm_noCommandId, const a2dCommandId &commandTypeId=sm_noCommandTypeId, const wxString &menuString=wxEmptyString)
 constructor More...
 
 ~a2dCommand (void)
 destructor
 
a2dCommandTClone (CloneOptions options=clone_deep, a2dRefMap *refs=NULL)
 
virtual wxString GetName () const
 
const a2dCommandIdGetCommandId ()
 a specific id for this command. More...
 
const a2dCommandIdGetCommandTypeId ()
 used to identify groups of simular commands
 
virtual a2dCommandCloneAndBind (a2dObject *object)
 Copy and instantiate the command. More...
 
virtual bool Do ()=0
 Override this to perform a command.
 
virtual bool Undo ()=0
 Override this to undo a command.
 
virtual bool PreDo ()
 Override this to perform a dependency action before command is done.
 
virtual bool PostDo ()
 Override this to perform a dependency action after command is done.
 
virtual bool CanUndo () const
 
virtual bool Redo ()
 
bool Modifies ()
 
void SetCommandProcessor (a2dCommandProcessor *cmp)
 set when submitting this command via a2dCommandProcessor
 
a2dCommandProcessorGetCommandProcessor ()
 
virtual bool ClearAfterCurrentCommand (a2dCommand *current)
 Hierarchically clear all commands after current command. More...
 
virtual class a2dCommandGroupIsCommandGroup ()
 This is like a wxDynamicCast, but much faster.
 
virtual a2dCommandFindPrevious (a2dCommand *current) const
 Find the previous command of the given command.
 
virtual a2dCommandFindNext (a2dCommand *current) const
 Find the next command of the given command.
 
virtual bool Remove (a2dCommand *command)
 Remove the given command.
 
virtual bool ContainsCommand (a2dCommand *command)
 return true if this command/group are nested group contains the given command
 
virtual void DistributeEvent (wxEventType eventType)
 
- 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 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 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...
 

Static Public Attributes

static const a2dCommandId sm_noCommandId = a2dCommandId( wxT( "NoCommandId" ) )
 property for command id
 
static const a2dCommandId sm_noCommandTypeId = a2dCommandId( wxT( "NoCommandTypeId" ) )
 property for type of command id
 
static const a2dCommandId sm_groupCommandId = a2dCommandId( wxT( "GroupCommandId" ) )
 property for group command id
 
- 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 Member Functions

virtual a2dObjectDoClone (CloneOptions options, a2dRefMap *refs) const
 Clone this object and return a pointer to the new object.
 
void DoSave (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
 Save settings.
 
void DoLoad (wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
 Load settings.
 
 a2dCommand (const a2dCommand &other)
 this is a not implemented copy constructor that avoids automatic creation of one
 
- 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

bool m_canUndo
 can this command be undone
 
bool m_modifies
 
const a2dCommandIdm_commandId
 can be used to identify the command
 
const a2dCommandIdm_commandTypeId
 if set can be used to identify groups of commands
 
a2dCommandProcessorm_cmp
 allows commands to get to the command processor that submitted the command.
 
wxString m_menuString
 if set this will be used for menu Undo/Redo labels, else the m_commandId its name is used.
 
- 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
 
- Protected Types inherited from a2dObject
enum  { refcount_nondynamic = 0x76543210 }
 special refcount value for non-dynamic objects
 

Detailed Description

a base command for the a2dCommandProcessor

When a2dCommandProcessor gets this command submitted, it will set itself to the command. The command will be added to the undo stack, and if it can be undone, the information to make this happen is part of the this command stored on the undo stack. So normally for each command one derives from a2dCommand, in order to have the derived command class store the right information for undoing an action, and define how to Do() and Undo() this action.

To makes things a bit more flexible, this class is derived from a2dObject, therefore it can have a2dProperty's. This can be used to add extra information on a command.

Definition at line 140 of file comevt.h.

Constructor & Destructor Documentation

a2dCommand::a2dCommand ( bool  canUndo = false,
const a2dCommandId commandId = sm_noCommandId,
const a2dCommandId commandTypeId = sm_noCommandTypeId,
const wxString &  menuString = wxEmptyString 
)

constructor

Parameters
canUndocan this command be undone
commandIdId of the command
commandTypeIdType Id of the command belong to a group of commands
menuStringcommand is associated with a menu string

Definition at line 103 of file comevt.cpp.

Member Function Documentation

bool a2dCommand::ClearAfterCurrentCommand ( a2dCommand current)
virtual

Hierarchically clear all commands after current command.

When storing commands, normally when no undo or redo is done yet, the command will be stored at the end of the undo stack. But if several Undo have bin done, the currentcommand is not pointing to the end of the stack. When at that moment a new command is submitted, this will be added after the current command, BUT first all commands after the current command will be cleared. As a result on can Redo all Undo's sofar as long as no new command is submitted yet.

Reimplemented in a2dCommandGroup.

Definition at line 160 of file comevt.cpp.

a2dCommand * a2dCommand::CloneAndBind ( a2dObject object)
virtual

Copy and instantiate the command.

This is usefull for commands that are used as command templates in widgets. The widget owns a command template, that is not bound to an object. This function clones the command object and binds it to the given object.

\param object for which the command is to be generated.

Reimplemented in a2dCommand_SetCanvasProperty, a2dCommand_SetSelect2Flag, a2dCommand_SetSelectFlag, a2dCommand_SetPinFlags, and a2dCommand_SetFlag.

Definition at line 149 of file comevt.cpp.

const a2dCommandId* a2dCommand::GetCommandId ( )
inline

a specific id for this command.

A command can have an id set to it, to easily identify it. This can be done by m_commandName comparison, but id's are saver.

Definition at line 179 of file comevt.h.

wxString a2dCommand::GetName ( ) const
virtual

return command name if m_menuName is set this will be used for menu Undo/Redo labels, else the m_commandId its name is used.

Reimplemented from a2dObject.

Definition at line 138 of file comevt.cpp.

bool a2dCommand::Modifies ( )
inline

If this command changes the object such that it needs to flagged as modified (e.g. document ) Some command like selecting objects on the canvas, do not need to be saved to the document. and in such a situation the command action can be undone, but the document is not flagged modified.

Definition at line 214 of file comevt.h.

bool a2dCommand::Redo ( void  )
virtual

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