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