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