Contents Up Previous Next

wxCommandProcessor: wxObject

Overview

wxCommandProcessor is a class that maintains a history of wxCommands, with undo/redo functionality built-in. Derive a new class from this if you want different behaviour.

wxCommandProcessor::wxCommandProcessor
wxCommandProcessor::~wxCommandProcessor
wxCommandProcessor::CanUndo
wxCommandProcessor::ClearCommands
wxCommandProcessor::Do
wxCommandProcessor::GetCommands
wxCommandProcessor::GetMaxCommands
wxCommandProcessor::GetEditMenu
wxCommandProcessor::Initialize
wxCommandProcessor::SetEditMenu
wxCommandProcessor::Submit
wxCommandProcessor::Undo


wxCommandProcessor::wxCommandProcessor

void wxCommandProcessor(int maxCommands = 100)

Constructor.

maxCommands defaults to a rather arbitrary 100, but can be set from 1 to any integer. If your wxCommand classes store a lot of data, you may wish the limit the number of commands stored to a smaller number.


wxCommandProcessor::~wxCommandProcessor

void ~wxCommandProcessor(void)

Destructor.


wxCommandProcessor::CanUndo

Bool CanUndo(void)

Returns TRUE if the currently-active command can be undone, FALSE otherwise.


wxCommandProcessor::ClearCommands

void ClearCommands(void)

Deletes all the commands in the list and sets the current command pointer to NULL.


wxCommandProcessor::Do

Bool Do(void)

Executes (redoes) the current command (the command that has just been undone if any).


wxCommandProcessor::GetCommands

wxList& GetCommands(void)

Returns the list of commands.


wxCommandProcessor::GetMaxCommands

int GetMaxCommands(void)

Returns the maximum number of commands that the command processor stores.


wxCommandProcessor::GetEditMenu

wxMenu * GetEditMenu(void)

Returns the edit menu associated with the command processor.


wxCommandProcessor::Initialize

void Initialize(void)

Initializes the command processor, setting the current command to the last in the list (if any), and updating the edit menu (if one has been specified).


wxCommandProcessor::SetEditMenu

void SetEditMenu(wxMenu *menu)

Tells the command processor to update the Undo and Redo items on this menu as appropriate. Set this to NULL if the menu is about to be destroyed and command operations may still be performed, or the command processor may try to access an invalid pointer.


wxCommandProcessor::Submit

Bool Submit(wxCommand *command, Bool storeIt)

Submits a new command to the command processor. The command processor calls wxCommand::Do to execute the command; if it succeeds, the command is stored in the history list, and the associated edit menu (if any) updated appropriately. If it fails, the command is deleted immediately. Once Submit has been called, the passed command should not be deleted directly by the application.

storeIt indicates whether the successful command should be stored in the history list.


wxCommandProcessor::Undo

Bool Undo(void)

Undoes the command just executed.