[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LAction



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:

 

LAction()  
~LAction()  
CanRedo()  
CanUndo()  
Finalize()  
GetDescription()  
IsDone()  
IsPostable()  
Redo()  
RedoSelf()  
Undo()  
UndoSelf()  
operator=()  
 

Data Members:

The data members in this class are:

 

mStringResID  
mStringIndex  
mIsDone  
 

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 :

LUndoer

Source files:

(Action Classes)


  LAction.h   LAction.cp

LAction()

Purpose:

Create or copy LAction objects.

Access:

Public

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:

 

ResIDT  
inStringResID  
The resource ID of the Redo menu item text (a`STR#' resource). The Undo text menu item must have a STR# resource ID that is one higher.  
SInt16  
inStringIndex  
The index number in the STR# resource for the Redo menu item.  
Boolean  
inAlreadyDone  
A value indicating whether the action is already done.  
const LAction&  
inOriginal  
A reference to an LAction object.  

~LAction()

Purpose:

Destroy LAction objects.

Access:

Public

Prototype:

~LAction();
Parameters:

None

CanRedo()

Purpose:

This method tells whether an action is currently undone.

Access:

Virtual, Public

Prototype:

virtual Boolean CanRedo() const;
Parameters:

None

Return:

Returns a Boolean true if the action is undone, false otherwise.

CanUndo()

Purpose:

This method tells whether an action is currently done.

Access:

Virtual, Public

Prototype:

virtual Boolean CanUndo() const;
Parameters:

None

Return:

Returns a Boolean true if the action is done, false otherwise.

Finalize()

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:

Virtual, Public

Prototype:

virtual void Finalize();
Parameters:

None

Return:

None

GetDescription()

Purpose:

This method allows you to retrieve the strings for Undo and Redo menu items.

Access:

Virtual, Public

Prototype:

virtual void GetDescription( Str255 outRedoString, 
Str255 outUndoString) const;
Parameters:

None

Return:

None

IsDone()

Purpose:

This method returns the value of mIsDone.

Access:

Public

Prototype:

Boolean IsDone() const;
Parameters:

None

Return:

A Boolean that reflects the value of mIsDone.

IsPostable()

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:

Virtual, Public

Prototype:

virtual Boolean IsPostable() const;
Parameters:

None

Return:

A Boolean indicating whether the Action affects the Undo state.

Redo()

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:

Virtual, Public

Prototype:

virtual void Redo();
Parameters:

None

Return:

None

RedoSelf()

Purpose:

This method is a pure virtual method that you must supply an implementation for in your class that inherits from LAction.

Access:

Virtual, Public

Prototype:

virtual void RedoSelf() = 0;
Parameters:

None

Return:

None

Undo()

Purpose:

This method is a wrapper to call UndoSelf().

Access:

Virtual, Public

Prototype:

virtual void Undo();
Parameters:

None

Return:

None

UndoSelf()

Purpose:

This method is a pure virtual method that you must supply an implementation for in your class that inherits from LAction.

Access:

Virtual, Public

Prototype:

virtual void UndoSelf() = 0;
Parameters:

None

Return:

None

operator=()

Purpose:

The assignment operator copies the values of the mStringResID, mStringIndex and mIsDone data members to the assigned object.

Access:

Public

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:

Returns an LAction reference.

mStringResID

Purpose:

This member contains the resource ID of the `STR#' resource that has the text for the redo menu items.

Access:

Protected

Prototype:

ResIDT mStringResID;

mStringIndex

Purpose:

This member contains an index number into the `STR#' resource for the redo item related to an action.

Access:

Protected

Prototype:

SInt16 mStringIndex;

mIsDone

Purpose:

This member is true if an action is done, and false if an action is undone.

Access:

Protected

Prototype:

Boolean mIsDone;

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ TOC ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000