1 \section{\class{wxCommand
}}\label{wxcommand
}
3 wxCommand is a base class for modelling an application command,
4 which is an action usually performed by selecting a menu item, pressing
5 a toolbar button or any other means provided by the application to
6 change the data or view.
8 \wxheading{Derived from
}
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
18 \helpref{wxCore
}{librarieslist
}
22 \overview{Overview
}{wxcommandoverview
}
24 \latexignore{\rtfignore{\wxheading{Members
}}}
26 \membersection{wxCommand::wxCommand
}\label{wxcommandctor
}
28 \func{}{wxCommand
}{\param{bool
}{ canUndo = false
},
\param{const wxString\&
}{name = NULL
}}
30 Constructor. wxCommand is an abstract class, so you will need to derive
31 a new class and call this constructor from your own constructor.
33 {\it canUndo
} tells the command processor whether this command is undo-able. You
34 can achieve the same functionality by overriding the CanUndo member function (if for example
35 the criteria for undoability is context-dependent).
37 {\it name
} must be supplied for the command processor to display the command name
38 in the application's edit menu.
40 \membersection{wxCommand::
\destruct{wxCommand
}}\label{wxcommanddtor
}
42 \func{}{\destruct{wxCommand
}}{\void}
46 \membersection{wxCommand::CanUndo
}\label{wxcommandcanundo
}
48 \func{bool
}{CanUndo
}{\void}
50 Returns true if the command can be undone, false otherwise.
52 \membersection{wxCommand::Do
}\label{wxcommanddo
}
54 \func{bool
}{Do
}{\void}
56 Override this member function to execute the appropriate action when called.
57 Return true to indicate that the action has taken place, false otherwise.
58 Returning false will indicate to the command processor that the action is
59 not undoable and should not be added to the command history.
61 \membersection{wxCommand::GetName
}\label{wxcommandgetname
}
63 \func{wxString
}{GetName
}{\void}
65 Returns the command name.
67 \membersection{wxCommand::Undo
}\label{wxcommandundo
}
69 \func{bool
}{Undo
}{\void}
71 Override this member function to un-execute a previous Do.
72 Return true to indicate that the action has taken place, false otherwise.
73 Returning false will indicate to the command processor that the action is
74 not redoable and no change should be made to the command history.
76 How you implement this command is totally application dependent, but typical
79 \begin{itemize
}\itemsep=
0pt
80 \item Perform an inverse operation on the last modified piece of
81 data in the
document. When redone, a copy of data stored in command
82 is pasted back or some operation reapplied. This relies on the fact that
83 you know the ordering of Undos; the user can never Undo at an arbitrary position
84 in the command history.
85 \item Restore the entire
document state (perhaps using
document transactioning).
86 Potentially very inefficient, but possibly easier to code if the user interface
87 and data are complex, and an `inverse execute' operation is hard to write.
90 The docview sample uses the first method, to remove or restore segments