]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/command.tex
* Someone destroy a part of my previous work. Redocumenting ...
[wxWidgets.git] / docs / latex / wx / command.tex
CommitLineData
a660d684
KB
1\section{\class{wxCommand}}\label{wxcommand}
2
3wxCommand is a base class for modelling an application command,
4which is an action usually performed by selecting a menu item, pressing
5a toolbar button or any other means provided by the application to
6change the data or view.
7
8\wxheading{Derived from}
9
10\helpref{wxObject}{wxobject}
11
12\wxheading{See also}
13
14\overview{Overview}{wxcommandoverview}
15
16\latexignore{\rtfignore{\wxheading{Members}}}
17
18\membersection{wxCommand::wxCommand}
19
20\func{}{wxCommand}{\param{bool}{ canUndo = FALSE}, \param{const wxString\& }{name = NULL}}
21
22Constructor. wxCommand is an abstract class, so you will need to derive
23a new class and call this constructor from your own constructor.
24
25{\it canUndo} tells the command processor whether this command is undo-able. You
26can achieve the same functionality by overriding the CanUndo member function (if for example
27the criteria for undoability is context-dependant).
28
29{\it name} must be supplied for the command processor to display the command name
30in the application's edit menu.
31
32\membersection{wxCommand::\destruct{wxCommand}}
33
34\func{}{\destruct{wxCommand}}{\void}
35
36Destructor.
37
38\membersection{wxCommand::CanUndo}
39
40\func{bool}{CanUndo}{\void}
41
42Returns TRUE if the command can be undone, FALSE otherwise.
43
44\membersection{wxCommand::Do}
45
46\func{bool}{Do}{\void}
47
48Override this member function to execute the appropriate action when called.
49Return TRUE to indicate that the action has taken place, FALSE otherwise.
50Returning FALSE will indicate to the command processor that the action is
51not undoable and should not be added to the command history.
52
53\membersection{wxCommand::GetName}
54
55\func{wxString}{GetName}{\void}
56
57Returns the command name.
58
59\membersection{wxCommand::Undo}
60
61\func{bool}{Undo}{\void}
62
63Override this member function to un-execute a previous Do.
64Return TRUE to indicate that the action has taken place, FALSE otherwise.
65Returning FALSE will indicate to the command processor that the action is
66not redoable and no change should be made to the command history.
67
68How you implement this command is totally application dependent, but typical
69strategies include:
70
71\begin{itemize}\itemsep=0pt
72\item Perform an inverse operation on the last modified piece of
73data in the document. When redone, a copy of data stored in command
74is pasted back or some operation reapplied. This relies on the fact that
75you know the ordering of Undos; the user can never Undo at an arbitrary position
76in the command history.
77\item Restore the entire document state (perhaps using document transactioning).
78Potentially very inefficient, but possibly easier to code if the user interface
79and data are complex, and an `inverse execute' operation is hard to write.
80\end{itemize}
81
82The docview sample uses the first method, to remove or restore segments
83in the drawing.
84
85