]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/command.tex
compilation fix for wxUSE_STL==1 in DoGetSibling()
[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
954b8ae6
JS
12\wxheading{Include files}
13
d6263458 14<wx/cmdproc.h>
954b8ae6 15
a7af285d
VZ
16\wxheading{Library}
17
18\helpref{wxCore}{librarieslist}
19
a660d684
KB
20\wxheading{See also}
21
22\overview{Overview}{wxcommandoverview}
23
24\latexignore{\rtfignore{\wxheading{Members}}}
25
f510b7b2 26\membersection{wxCommand::wxCommand}\label{wxcommandctor}
a660d684 27
cc81d32f 28\func{}{wxCommand}{\param{bool}{ canUndo = false}, \param{const wxString\& }{name = NULL}}
a660d684
KB
29
30Constructor. wxCommand is an abstract class, so you will need to derive
31a new class and call this constructor from your own constructor.
32
33{\it canUndo} tells the command processor whether this command is undo-able. You
34can achieve the same functionality by overriding the CanUndo member function (if for example
2edb0bde 35the criteria for undoability is context-dependent).
a660d684
KB
36
37{\it name} must be supplied for the command processor to display the command name
38in the application's edit menu.
39
f510b7b2 40\membersection{wxCommand::\destruct{wxCommand}}\label{wxcommanddtor}
a660d684
KB
41
42\func{}{\destruct{wxCommand}}{\void}
43
44Destructor.
45
f510b7b2 46\membersection{wxCommand::CanUndo}\label{wxcommandcanundo}
a660d684
KB
47
48\func{bool}{CanUndo}{\void}
49
cc81d32f 50Returns true if the command can be undone, false otherwise.
a660d684 51
f510b7b2 52\membersection{wxCommand::Do}\label{wxcommanddo}
a660d684
KB
53
54\func{bool}{Do}{\void}
55
56Override this member function to execute the appropriate action when called.
cc81d32f
VS
57Return true to indicate that the action has taken place, false otherwise.
58Returning false will indicate to the command processor that the action is
a660d684
KB
59not undoable and should not be added to the command history.
60
f510b7b2 61\membersection{wxCommand::GetName}\label{wxcommandgetname}
a660d684
KB
62
63\func{wxString}{GetName}{\void}
64
65Returns the command name.
66
f510b7b2 67\membersection{wxCommand::Undo}\label{wxcommandundo}
a660d684
KB
68
69\func{bool}{Undo}{\void}
70
71Override this member function to un-execute a previous Do.
cc81d32f
VS
72Return true to indicate that the action has taken place, false otherwise.
73Returning false will indicate to the command processor that the action is
a660d684
KB
74not redoable and no change should be made to the command history.
75
76How you implement this command is totally application dependent, but typical
77strategies include:
78
79\begin{itemize}\itemsep=0pt
80\item Perform an inverse operation on the last modified piece of
81data in the document. When redone, a copy of data stored in command
82is pasted back or some operation reapplied. This relies on the fact that
83you know the ordering of Undos; the user can never Undo at an arbitrary position
84in the command history.
85\item Restore the entire document state (perhaps using document transactioning).
86Potentially very inefficient, but possibly easier to code if the user interface
87and data are complex, and an `inverse execute' operation is hard to write.
88\end{itemize}
89
90The docview sample uses the first method, to remove or restore segments
91in the drawing.
92
93