]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/cmdproc.tex
no changes, just come cleanup and more comments
[wxWidgets.git] / docs / latex / wx / cmdproc.tex
CommitLineData
a660d684
KB
1\section{\class{wxCommandProcessor}}\label{wxcommandprocessor}
2
3wxCommandProcessor is a class that maintains a history of wxCommands,
4with undo/redo functionality built-in. Derive a new class from this
5if you want different behaviour.
6
7\wxheading{Derived from}
8
9\helpref{wxObject}{wxobject}
10
954b8ae6
JS
11\wxheading{Include files}
12
d6263458 13<wx/cmdproc.h>
954b8ae6 14
a7af285d
VZ
15\wxheading{Library}
16
17\helpref{wxCore}{librarieslist}
18
a660d684
KB
19\wxheading{See also}
20
21\helpref{wxCommandProcessor overview}{wxcommandprocessoroverview}, \helpref{wxCommand}{wxcommand}
22
23\latexignore{\rtfignore{\wxheading{Members}}}
24
f260c476 25
f510b7b2 26\membersection{wxCommandProcessor::wxCommandProcessor}\label{wxcommandprocessorctor}
a660d684 27
84023968 28\func{}{wxCommandProcessor}{\param{int}{ maxCommands = $-1$}}
a660d684
KB
29
30Constructor.
31
84023968
VZ
32{\it maxCommands} may be set to a positive integer to limit the number of
33commands stored to it, otherwise (and by default) the list of commands can grow
34arbitrarily.
a660d684 35
f260c476 36
f510b7b2 37\membersection{wxCommandProcessor::\destruct{wxCommandProcessor}}\label{wxcommandprocessordtor}
a660d684
KB
38
39\func{}{\destruct{wxCommandProcessor}}{\void}
40
41Destructor.
42
f260c476 43
f510b7b2 44\membersection{wxCommandProcessor::CanUndo}\label{wxcommandprocessorcanundo}
a660d684
KB
45
46\func{virtual bool}{CanUndo}{\void}
47
cc81d32f 48Returns true if the currently-active command can be undone, false otherwise.
a660d684 49
f260c476 50
f510b7b2 51\membersection{wxCommandProcessor::ClearCommands}\label{wxcommandprocessorclearcommands}
a660d684
KB
52
53\func{virtual void}{ClearCommands}{\void}
54
4e43c815 55Deletes all commands in the list and sets the current command pointer to \NULL.
a660d684 56
f260c476 57
f510b7b2 58\membersection{wxCommandProcessor::Redo}\label{wxcommandprocessorredo}
a660d684 59
fc9a9b2a 60\func{virtual bool}{Redo}{\void}
a660d684
KB
61
62Executes (redoes) the current command (the command that has just been undone if any).
63
f260c476 64
f510b7b2 65\membersection{wxCommandProcessor::GetCommands}\label{wxcommandprocessorgetcommands}
a660d684
KB
66
67\constfunc{wxList\&}{GetCommands}{\void}
68
69Returns the list of commands.
70
f260c476 71
f510b7b2 72\membersection{wxCommandProcessor::GetMaxCommands}\label{wxcommandprocessorgetmaxcommands}
a660d684
KB
73
74\constfunc{int}{GetMaxCommands}{\void}
75
76Returns the maximum number of commands that the command processor stores.
77
f260c476 78
f510b7b2 79\membersection{wxCommandProcessor::GetEditMenu}\label{wxcommandprocessorgeteditmenu}
a660d684
KB
80
81\constfunc{wxMenu*}{GetEditMenu}{\void}
82
83Returns the edit menu associated with the command processor.
84
f260c476 85
5e0e6ceb
JS
86\membersection{wxCommandProcessor::GetRedoAccelerator}\label{wxcommandprocessorgetredoaccelerator}
87
88\constfunc{const wxString\&}{GetRedoAccelerator}{\void}
89
90Returns the string that will be appended to the Redo menu item.
91
f260c476 92
d863ed83
JS
93\membersection{wxCommandProcessor::GetRedoMenuLabel}\label{wxcommandprocessorgetredomenulabel}
94
95\constfunc{wxString}{GetRedoMenuLabel}{\void}
96
97Returns the string that will be shown for the redo menu item.
98
f260c476 99
5e0e6ceb
JS
100\membersection{wxCommandProcessor::GetUndoAccelerator}\label{wxcommandprocessorgetundoaccelerator}
101
102\constfunc{const wxString\&}{GetUndoAccelerator}{\void}
103
104Returns the string that will be appended to the Undo menu item.
105
f260c476 106
d863ed83
JS
107\membersection{wxCommandProcessor::GetUndoMenuLabel}\label{wxcommandprocessorgetundomenulabel}
108
109\constfunc{wxString}{GetUndoMenuLabel}{\void}
110
111Returns the string that will be shown for the undo menu item.
112
f260c476 113
f510b7b2 114\membersection{wxCommandProcessor::Initialize}\label{wxcommandprocessorinitialize}
a660d684
KB
115
116\func{virtual void}{Initialize}{\void}
117
118Initializes the command processor, setting the current command to the
119last in the list (if any), and updating the edit menu (if one has been
120specified).
121
f260c476
VZ
122
123\membersection{wxCommandProcessor::IsDirty}\label{wxcommandprocessorisdirty}
124
125\func{virtual bool}{IsDirty}{\void}
126
127Returns a boolean value that indicates if changes have been made since
128the last save operation. This only works if
129\helpref{wxCommandProcessor::MarkAsSaved}{wxcommandprocessormarkassaved}
130is called whenever the project is saved.
131
132
133\membersection{wxCommandProcessor::MarkAsSaved}\label{wxcommandprocessormarkassaved}
134
135\func{virtual void}{MarkAsSaved}{\void}
136
137You must call this method whenever the project is saved if you plan to use
138\helpref{wxCommandProcessor::IsDirty}{wxcommandprocessorisdirty}.
139
140
f510b7b2 141\membersection{wxCommandProcessor::SetEditMenu}\label{wxcommandprocessorseteditmenu}
a660d684
KB
142
143\func{void}{SetEditMenu}{\param{wxMenu* }{menu}}
144
145Tells the command processor to update the Undo and Redo items on this
146menu as appropriate. Set this to NULL if the menu is about to be
147destroyed and command operations may still be performed, or the command
148processor may try to access an invalid pointer.
149
f260c476 150
f510b7b2 151\membersection{wxCommandProcessor::SetMenuStrings}\label{wxcommandprocessorsetmenustrings}
d863ed83
JS
152
153\func{void}{SetMenuStrings}{\void}
154
155Sets the menu labels according to the currently set menu and the current
156command state.
157
f260c476 158
5e0e6ceb
JS
159\membersection{wxCommandProcessor::SetRedoAccelerator}\label{wxcommandprocessorsetredoaccelerator}
160
161\func{void}{SetRedoAccelerator}{\param{const wxString\&}{accel}}
162
163Sets the string that will be appended to the Redo menu item.
164
f260c476 165
5e0e6ceb
JS
166\membersection{wxCommandProcessor::SetUndoAccelerator}\label{wxcommandprocessorsetundoaccelerator}
167
168\func{void}{SetUndoAccelerator}{\param{const wxString\&}{accel}}
169
170Sets the string that will be appended to the Undo menu item.
171
f260c476 172
f510b7b2 173\membersection{wxCommandProcessor::Submit}\label{wxcommandprocessorsubmit}
a660d684 174
cc81d32f 175\func{virtual bool}{Submit}{\param{wxCommand *}{command}, \param{bool}{ storeIt = true}}
a660d684
KB
176
177Submits a new command to the command processor. The command processor
178calls wxCommand::Do to execute the command; if it succeeds, the command
179is stored in the history list, and the associated edit menu (if any) updated
180appropriately. If it fails, the command is deleted
181immediately. Once Submit has been called, the passed command should not
182be deleted directly by the application.
183
184{\it storeIt} indicates whether the successful command should be stored
185in the history list.
186
f260c476 187
f510b7b2 188\membersection{wxCommandProcessor::Undo}\label{wxcommandprocessorundo}
a660d684
KB
189
190\func{virtual bool}{Undo}{\void}
191
192Undoes the command just executed.
193
194