Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Defines actions that can be undone. More...
#include <ilviews/base/command.h>
Public Member Functions | |
IlvCommand (IlvActionHistory *h=0, IlvUndoabilityReason u=notImplemented, IlBoolean ps=IlFalse, IlBoolean r=IlTrue, IlBoolean p=IlFalse) | |
Constructor. More... | |
IlBoolean | isPseudoCommand () const |
Is set to IlTrue if the command is a pseudocommand. More... | |
IlvUndoabilityReason | isUndoable () const |
Indicates whether the command can be undone, and tells why if it cannot. More... | |
virtual void | redo () |
Redoes a command that was previously undone. More... | |
virtual void | undo () |
Undoes a command. More... | |
virtual void | undoIt () |
Implements the undo behavior. More... | |
Public Member Functions inherited from IlvAction | |
IlvAction (IlvActionHistory *h=0, IlBoolean r=IlTrue, IlBoolean p=IlFalse) | |
Constructor. More... | |
IlvAction (const IlvAction &a) | |
Copy constructor used to repeat actions. More... | |
virtual IlvAction * | duplicate () const |
Must be implemented in subclasses for the action to be repeatable. More... | |
virtual IlString | errorMessage (IlUInt &severity) const |
Returns an error message. More... | |
virtual void | execute () |
Executes the action (external interface). More... | |
virtual void | executeIt ()=0 |
Executes the action (internal interface). More... | |
IlvActionHistory * | getContext () const |
Returns the action history of the action or command. More... | |
IlBoolean | isCommand () const |
Indicates whether an action is an IlvCommand object. More... | |
IlBoolean | isDone () const |
Indicates whether the execute method has already been called for this action. More... | |
IlBoolean | isRepeatable () const |
Indicates whether an action can be repeated. More... | |
virtual void | setContext (IlvActionHistory *history) |
Sets the execution context and the history of an action. More... | |
void | setDone (IlBoolean d=IlTrue) |
Specifies whether a command or action should be considered as being executed. More... | |
virtual IlString | userName () const |
Returns the name of the action in a readable form. More... | |
Additional Inherited Members | |
Public Attributes inherited from IlvAction | |
IlvActionFlags | _flags |
Action flags. Can be set directly by subclasses to change the status of the action. | |
Defines actions that can be undone.
Library: views
The class IlvCommand
defines actions that can be undone. They are generally used to implement the real changes that objects undergo in an application in response to user input.
This class cannot be directly instantiated. For a command to be executed, you must override its executeIt
and undoIt
methods in subclasses.
IlvCommand::IlvCommand | ( | IlvActionHistory * | h = 0 , |
IlvUndoabilityReason | u = notImplemented , |
||
IlBoolean | ps = IlFalse , |
||
IlBoolean | r = IlTrue , |
||
IlBoolean | p = IlFalse |
||
) |
Constructor.
h | The action history that serves as the execution context of the command. If you do not set this parameter, this will be done when the command is added to an action history. |
u | A Boolean value specifying whether the command can be undone. As a precaution, it is set by default to notImplemented . Consequently, you must not forget to set it to IlTrue when the undoIt method is implemented. |
ps | A Boolean value specifying whether the command is a pseudocommand. |
r | A Boolean value specifying whether the command can be repeated. |
p | A Boolean value specifying whether the command is persistent. The persistence of commands is not yet implemented. |
IlBoolean IlvCommand::isPseudoCommand | ( | ) | const |
Is set to IlTrue
if the command is a pseudocommand.
A pseudocommand is an action that does not actually modify the application objects, but that can be undone for practical purposes. Selection and navigation commands, such as panning and zooming, are pseudocommands. This is a flag that is statically defined for each command and not a parameter, since, depending on the application, you may consider actions, such as zooming, to be real commands. (A real command is one whose result is to be saved with the file.)
Typically, this flag is used by IlvModifiedFlagObserver
to determine whether the document corresponding to a given command history should be considered as modified or not.
IlvUndoabilityReason IlvCommand::isUndoable | ( | ) | const |
Indicates whether the command can be undone, and tells why if it cannot.
undoable
if the command can be undone. It can also return another value, that indicates why this command cannot be undone.
|
virtual |
Redoes a command that was previously undone.
By default, its implementation calls the execute
method. However, for efficiency reasons, you may wish to implement a specific version that performs less checks by assuming that executeIt
has already been called once.
|
virtual |
Undoes a command.
Usually, this method is invoked by the command history and does not have to be called or redefined. In addition to calling undoIt
, this method sets the done
flag to IlFalse
and informs its class observers that the command has been undone.
|
virtual |
Implements the undo behavior.
This method should be redefined in subclasses to cancel the executeIt
method.
Reimplemented in IlvChangeValueCommand, and IlvMacroCommand.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.