Class Fox::FXUndoList

In: | ../lib/fox/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 revert trimCount trimSize undo undoAll undoCount undoSize unmark

Included modules

Responder

Public Class methods

new()

Returns an initialized FXUndoList instance.

Public Instance methods

cut()

Cut the redo list

add(command, doit=false)

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

undo()

Undo last command.

redo()

Redo next command

undoAll()

Undo all commands

redoAll()

Redo all commands

revert()

Revert to marked

canUndo?()

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

canRedo?()

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

canRevert?()

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

current()

Returns the current undo command.

undoCount()

Returns the number of undo records.

undoSize()

Returns the total size of undo information.

clear()

Clear the list

trimCount(nc)

Trim undo list down to at most nc commands.

trimSize(sz)

Trim undo list down to at most size.

mark()

Mark current state

unmark()

Unmark undo list

marked?()

Return `true` if the undo list is marked.