]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/command.tex
add wxVector docs
[wxWidgets.git] / docs / latex / wx / command.tex
1 \section{\class{wxCommand}}\label{wxcommand}
2
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.
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
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.
32
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).
36
37 {\it name} must be supplied for the command processor to display the command name
38 in the application's edit menu.
39
40 \membersection{wxCommand::\destruct{wxCommand}}\label{wxcommanddtor}
41
42 \func{}{\destruct{wxCommand}}{\void}
43
44 Destructor.
45
46 \membersection{wxCommand::CanUndo}\label{wxcommandcanundo}
47
48 \func{bool}{CanUndo}{\void}
49
50 Returns true if the command can be undone, false otherwise.
51
52 \membersection{wxCommand::Do}\label{wxcommanddo}
53
54 \func{bool}{Do}{\void}
55
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.
60
61 \membersection{wxCommand::GetName}\label{wxcommandgetname}
62
63 \func{wxString}{GetName}{\void}
64
65 Returns the command name.
66
67 \membersection{wxCommand::Undo}\label{wxcommandundo}
68
69 \func{bool}{Undo}{\void}
70
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.
75
76 How you implement this command is totally application dependent, but typical
77 strategies include:
78
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.
88 \end{itemize}
89
90 The docview sample uses the first method, to remove or restore segments
91 in the drawing.
92
93