Class Fox::FXUndoList
In: lib/fox16/undolist.rb
Parent: FXObject

The undo list manages a list of undoable (and redoable) commands for a FOX application; it works hand-in-hand with subclasses of FXCommand and is an application of the well-known Command pattern. Your application code should implement any number of command classes and then add then to an FXUndoList instance. For an example of how this works, see the textedit example program from the FXRuby distribution.

Class Constants

FXUndoList::ID_UNDO
Message identifier for the undo method. When a SEL_COMMAND message with this identifier is sent to an undo list, it undoes the last command. FXUndoList also provides a SEL_UPDATE handler for this identifier, that enables or disables the sender depending on whether it‘s possible to undo.
FXUndoList::ID_UNDO_ALL
Message identifier for the "undo all" method. FXUndoList handles both the SEL_COMMAND and SEL_UPDATE messages for this message identifier.
FXUndoList::ID_REDO
Message identifier for the redo method. When a SEL_COMMAND message with this identifier is sent to an undo list, it redoes the last command. FXUndoList also provides a SEL_UPDATE handler for this identifier, that enables or disables the sender depending on whether it‘s possible to redo.
FXUndoList::ID_REDO_ALL
Message identifier for the "redo all" method. FXUndoList handles both the SEL_COMMAND and SEL_UPDATE messages for this message identifier.
FXUndoList::ID_CLEAR
Message identifier for the "clear" method. FXUndoList handles both the SEL_COMMAND and SEL_UPDATE messages for this message identifier.
FXUndoList::ID_REVERT
Message identifier for the "revert" method. FXUndoList handles both the SEL_COMMAND and SEL_UPDATE messages for this message identifier.

Methods

add   canRedo?   canRevert?   canUndo?   clear   current   cut   mark   marked?   new   redo   redoAll   redoName   revert   trimCount   trimSize   undo   undoAll   undoCount   undoName   undoSize   unmark  

Included Modules

Responder

Constants

ID_LAST = enum(0, 7)

Public Class methods

Returns an initialized FXUndoList instance.

Public Instance methods

Add new command (an FXCommand instance) to the list. If doit is true, the command is also executed.

Return true if we can still redo some commands (i.e. the redo list is not empty).

Return true if there is a previously marked state that we can revert to.

Return true if we can still undo some commands (i.e. the undo list is not empty).

Clear the list

Returns the current undo command.

Cut the redo list

Mark current state

Return true if the undo list is marked.

Redo next command

Redo all commands

Return the name of the first available redo command. If no redo command is available, returns nil.

Revert to marked

Trim undo list down to at most nc commands.

Trim undo list down to at most size.

Undo last command.

Undo all commands

Returns the number of undo records.

Return the name of the first available undo command. If no undo command is available, returns nil.

Returns the total size of undo information.

Unmark undo list

[Validate]