Semantics of commands

The semantics of Taligent commands are necessarily interrelated. You might find it helpful to refer to Figure 3 while reading these explanations.

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 were to use the DoIncrement member function for this curve drawing example you might:

    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.

User interface frameworks supporting indefinite incremental commands would do the following:

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.

As a compromise, the command is allowed to declare its type (and so, its abilities). There are three kinds of commands:

You set the undo type of a command at construction time with an argument to the TCommand constructor. You cannot change the undo type of a command.

If you attempt to Undo or Redo a command that is not undoable, your code will generate an exception.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker