X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12f5e1e78fe906050ff2fee9529476db332633f0..1b7751aaa9a86d76a850b9267bc0c201e3cea30f:/interface/wx/cmdproc.h diff --git a/interface/wx/cmdproc.h b/interface/wx/cmdproc.h index 55970df404..5d948d6c27 100644 --- a/interface/wx/cmdproc.h +++ b/interface/wx/cmdproc.h @@ -3,7 +3,7 @@ // Purpose: interface of wxCommandProcessor and wxCommand // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @@ -35,17 +35,17 @@ public: Must be supplied for the command processor to display the command name in the application's edit menu. */ - wxCommand(bool canUndo = false, const wxString& name = NULL); + wxCommand(bool canUndo = false, const wxString& name = wxEmptyString); /** Destructor. */ - ~wxCommand(); + virtual ~wxCommand(); /** Returns @true if the command can be undone, @false otherwise. */ - bool CanUndo(); + virtual bool CanUndo() const; /** Override this member function to execute the appropriate action when @@ -56,26 +56,26 @@ public: processor that the action is not undoable and should not be added to the command history. */ - bool Do(); + virtual bool Do() = 0; /** Returns the command name. */ - wxString GetName(); + virtual wxString GetName() const; /** Override this member function to un-execute a previous Do. How you implement this command is totally application dependent, but typical strategies include: - + - Perform an inverse operation on the last modified piece of data in the document. When redone, a copy of data stored in command is pasted back or some operation reapplied. This relies on the fact that you know the ordering of Undos; the user can never Undo at an arbitrary position in the command history. - Restore the entire document state (perhaps using document - transactioning). Potentially very inefficient, but possibly easier to + transacting). Potentially very inefficient, but possibly easier to code if the user interface and data are complex, and an "inverse execute" operation is hard to write. The docview sample uses the first method, to remove or restore segments in the drawing. @@ -85,7 +85,7 @@ public: processor that the action is not redoable and no change should be made to the command history. */ - bool Undo(); + virtual bool Undo() = 0; }; @@ -118,13 +118,19 @@ public: /** Destructor. */ - ~wxCommandProcessor(); + virtual ~wxCommandProcessor(); /** Returns @true if the currently-active command can be undone, @false otherwise. */ - virtual bool CanUndo(); + virtual bool CanUndo() const; + + /** + Returns @true if the currently-active command can be redone, @false + otherwise. + */ + virtual bool CanRedo() const; /** Deletes all commands in the list and sets the current command pointer @@ -135,7 +141,12 @@ public: /** Returns the list of commands. */ - wxList& GetCommands() const; + wxList& GetCommands(); + + /** + Returns the current command. + */ + wxCommand *GetCurrentCommand() const; /** Returns the edit menu associated with the command processor. @@ -180,13 +191,13 @@ public: the last save operation. This only works if MarkAsSaved() is called whenever the project is saved. */ - virtual bool IsDirty(); + virtual bool IsDirty() const; /** You must call this method whenever the project is saved if you plan to use IsDirty(). */ - virtual void MarkAsSaved(); + void MarkAsSaved(); /** Executes (redoes) the current command (the command that has just been @@ -206,7 +217,7 @@ public: Sets the menu labels according to the currently set menu and the current command state. */ - void SetMenuStrings(); + virtual void SetMenuStrings(); /** Sets the string that will be appended to the Redo menu item. @@ -219,19 +230,28 @@ public: void SetUndoAccelerator(const wxString& accel); /** - 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. + 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. + @param command + The command to submit @param storeIt Indicates whether the successful command should be stored in the history list. */ virtual bool Submit(wxCommand* command, bool storeIt = true); + /** + Just store the command without executing it. The command is stored in the + history list, and the associated edit menu (if any) updated appropriately. + */ + virtual void Store(wxCommand *command); + /** Undoes the last command executed. */