contents up previous next

wxcommand

wxcommand is a base class for modelling an application command, which is an action usually performed by selecting a menu item, pressing a toolbar button or any other means provided by the application to change the data or view.

derived from

wxobject

include files

<wx/cmdproc.h>

see also

overview

members

wxcommand::wxcommand
wxcommand::~wxcommand
wxcommand::canundo
wxcommand::do
wxcommand::getname
wxcommand::undo


wxcommand::wxcommand

wxcommand(bool canundo = false, const wxstring& name = null)

constructor. wxcommand is an abstract class, so you will need to derive a new class and call this constructor from your own constructor.

canundo tells the command processor whether this command is undo-able. you can achieve the same functionality by overriding the canundo member function (if for example the criteria for undoability is context-dependent).

name must be supplied for the command processor to display the command name in the application's edit menu.


wxcommand::~wxcommand

~wxcommand()

destructor.


wxcommand::canundo

bool canundo()

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


wxcommand::do

bool do()

override this member function to execute the appropriate action when called. return true to indicate that the action has taken place, false otherwise. returning false will indicate to the command processor that the action is not undoable and should not be added to the command history.


wxcommand::getname

wxstring getname()

returns the command name.


wxcommand::undo

bool undo()

override this member function to un-execute a previous do. return true to indicate that the action has taken place, false otherwise. returning false will indicate to the command processor that the action is not redoable and no change should be made to the command history.

how you implement this command is totally application dependent, but typical strategies include:

the docview sample uses the first method, to remove or restore segments in the drawing.