Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

15.5 Extending the Undo/Redo Mechanism

The Objective Grid Undo/Redo mechanism is fully extensible. You can add custom support for Undo/Redo using self-written commands.

The CGXCommand class is an abstract base class for storing Undo information for commands. If you want to support Undo/Redo for your commands, you should derive a class from CGXCommand and store all information necessary for undoing the operation into the command.

Objective Grid maintains CGXCommand objects in an Undo and Redo list. When the user wants to undo the last operation, Objective Grid removes the first CGXCommand object in the list and calls the object's Execute() method. In your CGXCommand-derived class, you should override the Execute() method and embed the necessary steps to undo the command.

Basic steps for adding Undo/Redo support for a specific command are:

  1. Derive a class from CGXCommand.

  2. Insert the GRID_DECLARE_DYNAMIC / GRID_IMPLEMENT_DYNAMIC and the GRID_DECLARE_COMMAND / GRID_IMPLEMENT_COMMAND macros (see the example).

  3. Provide a constructor.

  4. Override the Execute() method.

  5. In your command method, create the CGXCommand-derived object and add it to the Undo/Redo list. This is done by calling AddCommand().

Here is a complete example:



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.