LAction is a PowerPlant class that helps manage the do, undo, and redo operations. It maintains the data required to restore the previous state of menu items.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation :
When you implement Undo capability in your program, you will want to modify the text of the Undo menu item of the Edit Menu in your application. For example, if the last operation of your program was to clear some text from a document window, you want to change the Undo menu item to Undo Clear. If you then chose Undo Clear from the Edit Menu, you would then want to change the menu item to Redo Clear.
See Also :
Source files:
LAction.h LAction.cp
Purpose:
Create or copy LAction objects.
Access:
Prototypes:
LAction(ResIDT inStringResID, SInt16 inStringIndex, Boolean inAlreadyDone );
LAction(ResIDT inStringResID, SInt16 inStringIndex, Boolean inAlreadyDone );
LAction( const LAction &inOriginal );Parameters:
The parameters for these constructors are:
Purpose:
Access:
Prototype:
~LAction();Parameters:
Purpose:
This method tells whether an action is currently undone.
Access:
Prototype:
virtual Boolean CanRedo() const;Parameters:
Return:
Returns a Boolean true if the action is undone, false otherwise.
Purpose:
This method tells whether an action is currently done.
Access:
Prototype:
virtual Boolean CanUndo() const;Parameters:
Return:
Returns a Boolean true if the action is done, false otherwise.
Purpose:
This method is called by the framework before deleting an action posted to an Undoer. This allows you to do something with the action before it is lost. For example, you may want to preserve the action if you are implementing multiple Undo.
Access:
Prototype:
virtual void Finalize();Parameters:
Return:
Purpose:
This method allows you to retrieve the strings for Undo and Redo menu items.
Access:
Prototype:
virtual void GetDescription( Str255 outRedoString, Str255 outUndoString) const;Parameters:
Return:
Purpose:
This method returns the value of mIsDone.
Access:
Prototype:
Boolean IsDone() const;Parameters:
Return:
A Boolean that reflects the value of mIsDone.
Purpose:
Return whether an Action is postable, meaning that it affects the Undo state. This method always returns true. Override this method to return false for actions that are not undoable.
Access:
Prototype:
virtual Boolean IsPostable() const;Parameters:
Return:
A Boolean indicating whether the Action affects the Undo state.
Purpose:
This method is a wrapper which calls RedoSelf() if the Action can be redone. Note that the first time this function
is called, "Redo" really means "Do" the Action (unless mIsDone is set to true when creating the Action).
Access:
Prototype:
virtual void Redo();Parameters:
Return:
Purpose:
This method is a pure virtual method that you must supply an implementation for in your class that inherits from LAction.
Access:
Prototype:
virtual void RedoSelf() = 0;Parameters:
Return:
Purpose:
This method is a wrapper to call UndoSelf().
Access:
Prototype:
virtual void Undo();Parameters:
Return:
Purpose:
This method is a pure virtual method that you must supply an implementation for in your class that inherits from LAction.
Access:
Prototype:
virtual void UndoSelf() = 0;Parameters:
Return:
Purpose:
The assignment operator copies the values of the mStringResID, mStringIndex and mIsDone data members to the assigned object.
Access:
Prototype:
LAction& operator=( const LAction &inOriginal );Parameters:
The parameter for this operator is a const reference to an LAction object that you wish to make a copy of.
Return:
Purpose:
This member contains the resource ID of the `STR#' resource that has the text for the redo menu items.
Access:
Prototype:
ResIDT mStringResID;
Purpose:
This member contains an index number into the `STR#' resource for the redo item related to an action.
Access:
Prototype:
SInt16 mStringIndex;
Purpose:
This member is true if an action is done, and false if an action is undone.
Access:
Prototype:
Boolean mIsDone;