contents up previous next

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

members

wxcommandprocessor::wxcommandprocessor
wxcommandprocessor::~wxcommandprocessor
wxcommandprocessor::canundo
wxcommandprocessor::clearcommands
wxcommandprocessor::redo
wxcommandprocessor::getcommands
wxcommandprocessor::getmaxcommands
wxcommandprocessor::geteditmenu
wxcommandprocessor::getredoaccelerator
wxcommandprocessor::getredomenulabel
wxcommandprocessor::getundoaccelerator
wxcommandprocessor::getundomenulabel
wxcommandprocessor::initialize
wxcommandprocessor::isdirty
wxcommandprocessor::markassaved
wxcommandprocessor::seteditmenu
wxcommandprocessor::setmenustrings
wxcommandprocessor::setredoaccelerator
wxcommandprocessor::setundoaccelerator
wxcommandprocessor::submit
wxcommandprocessor::undo


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()

destructor.


wxcommandprocessor::canundo

virtual bool canundo()

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


wxcommandprocessor::clearcommands

virtual void clearcommands()

deletes all commands in the list and sets the current command pointer to null.


wxcommandprocessor::redo

virtual bool redo()

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


wxcommandprocessor::getcommands

wxlist& getcommands() const

returns the list of commands.


wxcommandprocessor::getmaxcommands

int getmaxcommands() const

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


wxcommandprocessor::geteditmenu

wxmenu* geteditmenu() const

returns the edit menu associated with the command processor.


wxcommandprocessor::getredoaccelerator

const wxstring& getredoaccelerator() const

returns the string that will be appended to the redo menu item.


wxcommandprocessor::getredomenulabel

wxstring getredomenulabel() const

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


wxcommandprocessor::getundoaccelerator

const wxstring& getundoaccelerator() const

returns the string that will be appended to the undo menu item.


wxcommandprocessor::getundomenulabel

wxstring getundomenulabel() const

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


wxcommandprocessor::initialize

virtual void initialize()

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()

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()

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()

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()

undoes the command just executed.