wxCommandProcessor

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.

Derived from

wxObject

Include files

<wx/cmdproc.h>

See also

wxCommandProcessor overview, wxCommand



wxCommandProcessor::wxCommandProcessor



wxCommandProcessor(int maxCommands = $-1$)

Constructor.

maxCommands may be set to a positive integer to limit the number of commands stored to it, otherwise (and by default) the list of commands can grow arbitrarily.



wxCommandProcessor::~wxCommandProcessor



~wxCommandProcessor(void)

Destructor.



wxCommandProcessor::CanUndo



virtual bool CanUndo(void)

Returns true if the currently-active command can be undone, false otherwise.



wxCommandProcessor::ClearCommands



virtual void ClearCommands(void)

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



wxCommandProcessor::Redo



virtual bool Redo(void)

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



wxCommandProcessor::GetCommands

wxList& GetCommands(void) const

Returns the list of commands.



wxCommandProcessor::GetMaxCommands

int GetMaxCommands(void) const

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



wxCommandProcessor::GetEditMenu

wxMenu* GetEditMenu(void) const

Returns the edit menu associated with the command processor.



wxCommandProcessor::GetRedoAccelerator

const wxString& GetRedoAccelerator(void) const

Returns the string that will be appended to the Redo menu item.



wxCommandProcessor::GetRedoMenuLabel

wxString GetRedoMenuLabel(void) const

Returns the string that will be shown for the redo menu item.



wxCommandProcessor::GetUndoAccelerator

const wxString& GetUndoAccelerator(void) const

Returns the string that will be appended to the Undo menu item.



wxCommandProcessor::GetUndoMenuLabel

wxString GetUndoMenuLabel(void) const

Returns the string that will be shown for the undo menu item.



wxCommandProcessor::Initialize



virtual 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::IsDirty



virtual bool IsDirty(void)

Returns a boolean value that indicates if changes have been made since the last save operation. This only works if wxCommandProcessor::MarkAsSaved is called whenever the project is saved.



wxCommandProcessor::MarkAsSaved



virtual void MarkAsSaved(void)

You must call this method whenever the project is saved if you plan to use wxCommandProcessor::IsDirty.



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::SetMenuStrings



void SetMenuStrings(void)

Sets the menu labels according to the currently set menu and the current command state.



wxCommandProcessor::SetRedoAccelerator



void SetRedoAccelerator(const wxString& accel)

Sets the string that will be appended to the Redo menu item.



wxCommandProcessor::SetUndoAccelerator



void SetUndoAccelerator(const wxString& accel)

Sets the string that will be appended to the Undo menu item.



wxCommandProcessor::Submit



virtual bool Submit(wxCommand * command, bool storeIt = true)

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



virtual bool Undo(void)

Undoes the command just executed.

ymasuda 平成17年11月19日