Chapter 16:
Undo Functions
 

Anytime a graph is modified by one of the set graph attribute functions (i.e., SetGraphAttr(), SetGraphAttrSI(), or SetGraphAttrSL()), the change is added to the undo list. These functions are used to manipulate the undo list.

 

ClearUndo(); Clear the Undo List

 

GetUndoStatus(); Get Undo Status

 

IsUndoListEmpty(); Is the Undo List empty?

 

PerformUndo(); Perform Undo

 

SetUndoMode(); Set Undo Mode

 

SetUndoStatus(); Set Undo Status

 

UndoSelListMove(); Undo Selection List Move

   

ClearUndo()

 

This function clears the UNDO buffer associated with the graph. Anytime a graph is modified by one of the set graph attribute functions (i.e., SetGraphAttr(), SetGraphAttrSI(), or SetGraphAttrSL()), the change is added to the undo list. This function clears the contents of this list.

Syntax:

void PUBLIC
ClearUndo (
     GraphPtr pGraph
);

Input:

pGraph: Pointer to a graph object created by AllocGraphPtr()

Return:

None

Notes:

The PerformUndo() function which restores all of the graph attribute changes also clears the undo list.

Example:

if(pGraph->pUndoList)
{
     ClearUndo
(pGraph);
     
pGraph->pUndoList = NULL;
}

Also See:

GetUndoStatus(), PerformUndo(), SetUndoMode, SetUndoStatus(),

   

GetUndoStatus()

 

This function returns the status of the UNDO buffer for the graph identified by pGraph.

Syntax:

INT16 PUBLIC
GetUndoStatus (
     GraphPtr pGraph
);

Input:

pGraph: Pointer to the graph object created by AllocGraphPtr()

Return:

INT16:

 

Value

Description

 

CANNOT_UNDO_OR_REDO

Cannot be undone or redone

 

CAN_UNDO

Can be undone

 

CAN_REDO

Can be redone

Example:

/* Toggle the Undo Flag */
If ( GetUndoStatus (
     gpGraph ) == CAN_UNDO )
     SetUndoStatus ( gpGraph, CAN_REDO );
if ( GetUndoStatus ( gpGraph ) == CAN_REDO )
     SetUndoStatus ( gpGraph, CAN_UNDO );

Also See:

SetUndoStatus()

IsUndoListEmpty()

 

This function returns a BOOLEAN16 indicating whether or not the undo list is empty.

Syntax:

BOOLEAN16 PUBLIC
IsUndoListEmpty(
     GraphPtr pGraph
);

Input:

pGraph: Pointer to a valid graph

Return:

BOOLEAN16; TRUE/FALSE

 

TRUE=

Undo list is empty

 

FALSE=

Undo list is not empty

Also See:

ClearUndo(), GetUndoStatus(), PerformUndo(), SetUndoMode(), SetUndoStatus()

   

PerformUndo

 

This function uses the information in the UNDO buffer to return to the previous state of the graph. When a graph is modified by one of the set graph attribute functions (i.e., SetGraphAttr(), SetGraphAttrSI(), or SetGraphAttrSL()), the function is added to the undo list. This function processes the entire contents of the undo list and performs the undo. This effectively clears the undo list and then adds each undo operation back to the list. For example if the user changes three attributes, this function restores the attributes to their original values. Calling PerformUndo() a second time will redo the changes so they are again implemented in the graph. This provides undo/redo capability.

Syntax:

BOOLEAN16 PUBLIC
PerformUndo (
     DrawEnvPtr pDE,
     GraphPtr pGraph
);

Input:

pDE: Pointer to a draw environment created by AllocDrawEnvPtr()

 

pGraph: Pointer to the graph object created by AllocGraphPtr()

Return:

BOOLEAN16: TRUE/FALSE

 

TRUE=

Undo successful

 

FALSE=

Error/Unsuccessful

Notes:

Your application is responsible for clearing the undo list using ClearUndo().

Also See:

ClearUndo(), GetUndoStatus(), SetUndoMode()

   

SetUndoMode()

 

This function sets the Undo Mode for this instance of the library.

Syntax:

void PUBLIC SetUndoMode (INT16 nUndoMode );

Input:

nUndoMode: 0...2

 

0=

No Undo information saved

 

1=

Last attribute change only saved (default)

 

2=

All attribute changes saved (create Undo Stack)

Return:

None

Notes:

If your program will not be using the undo/redo features, you can enhance performance by using SetUndoMode(0);

Also See:

GetUndoStatus(), PerformUndo(), SetUndoStatus()

SetUndoStatus()

 

This function sets the undo status in pGraph to the value identified by newValue.

Syntax:

void PUBLIC
SetUndoStatus (
     GraphPtr pGraph,
     INT16 newValue
);

Input:

pGraph: Pointer to the graph object created by AllocGraphPtr()

 

newValue: INT16 value identifying the new Undo Status.

 

Possible Values

Description

 

CANNOT_UNDO_OR_REDO

Cannot undo or redo

 

CAN_UNDO

Can undo

 

CAN_REDO

Can redo

Return:

None

Example:

SetUndoStatus ( gpGraph, CAN_UNDO );

Also See:

GetUndoStatus(), PerformUndo(), SetUndoMode()

   

UndoSelListMove()

 

This function can be used to undo a move of a list of selected items. It takes a list of items (pointed to by pSelList) and moves them back to the position recorded in the pCurr->rcLastBounds field.

Syntax:

void PUBLIC
UndoSelListMove (
     DrawEnvPtr pDE,
     GraphPtr pGraph,
     SelListPtr pSelList
);

Input:

pDE: Pointer to a draw environment

 

pGraph: Pointer to the graph object created by AllocGraphPtr()

 

pSelList: Pointer to a selection list. See the SelListRec in Appendix A.

Return:

None