If you were to use the DoIncrement member function for this curve drawing example you might:
User interface frameworks supporting indefinite incremental commands would do the following:
As a compromise, the command is allowed to declare its type (and so, its abilities). There are three kinds of commands:
If you attempt to Undo or Redo a command that is not undoable, your code will generate an exception.
Do
The Do member function changes the target. It can also save information to enable the Undo of the command later. To simplify your use of incremental and non-incremental commands, you can call the Do member function instead of calling DoBegin followed by DoEnd. Incremental Do
Some commands are executed incrementally, for example, a command for drawing a freehand curve. The command has a beginning, which creates the curve; a number of incremental steps, adding to the curve; and an end, to complete the curve.
If you require additional information (for example, the new point to add into the curve), call a subclass-specific method to gather this information before calling DoIncrement.
Most incremental commands provide a subclass-specific protocol to set the parameters for the increment (for example, SetDragPosition(TGPoint&)). DoEnd
Calling the DoEnd member function ends an incremental command as does calling Undo and Commit. Undo
The Undo member function allows changes to the target to be undone. Not all commands can be undone. In the best of all possible worlds, all commands would be undoable. However, in the real world, it is often difficult for developers to write all commands so that they can be undone.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker