]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/command.tex
Added AdvanceSelection, ShowWindowMenu and keyboard handling
[wxWidgets.git] / docs / latex / wx / command.tex
... / ...
CommitLineData
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{Include files}
13
14<wx/cmdproc.h>
15
16\wxheading{Library}
17
18\helpref{wxCore}{librarieslist}
19
20\wxheading{See also}
21
22\overview{Overview}{wxcommandoverview}
23
24\latexignore{\rtfignore{\wxheading{Members}}}
25
26\membersection{wxCommand::wxCommand}\label{wxcommandctor}
27
28\func{}{wxCommand}{\param{bool}{ canUndo = false}, \param{const wxString\& }{name = NULL}}
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
35the criteria for undoability is context-dependent).
36
37{\it name} must be supplied for the command processor to display the command name
38in the application's edit menu.
39
40\membersection{wxCommand::\destruct{wxCommand}}\label{wxcommanddtor}
41
42\func{}{\destruct{wxCommand}}{\void}
43
44Destructor.
45
46\membersection{wxCommand::CanUndo}\label{wxcommandcanundo}
47
48\func{bool}{CanUndo}{\void}
49
50Returns true if the command can be undone, false otherwise.
51
52\membersection{wxCommand::Do}\label{wxcommanddo}
53
54\func{bool}{Do}{\void}
55
56Override this member function to execute the appropriate action when called.
57Return true to indicate that the action has taken place, false otherwise.
58Returning false will indicate to the command processor that the action is
59not undoable and should not be added to the command history.
60
61\membersection{wxCommand::GetName}\label{wxcommandgetname}
62
63\func{wxString}{GetName}{\void}
64
65Returns the command name.
66
67\membersection{wxCommand::Undo}\label{wxcommandundo}
68
69\func{bool}{Undo}{\void}
70
71Override this member function to un-execute a previous Do.
72Return true to indicate that the action has taken place, false otherwise.
73Returning false will indicate to the command processor that the action is
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