]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxUpdateUIEvent}}\label{wxupdateuievent} |
2 | ||
fc2171bd | 3 | This class is used for pseudo-events which are called by wxWidgets |
a660d684 KB |
4 | to give an application the chance to update various user interface elements. |
5 | ||
6 | \wxheading{Derived from} | |
7 | ||
2b5f62a0 | 8 | \helpref{wxCommandEvent}{wxcommandevent}\\ |
a660d684 KB |
9 | \helpref{wxEvent}{wxevent}\\ |
10 | \helpref{wxObject}{wxobject} | |
11 | ||
954b8ae6 JS |
12 | \wxheading{Include files} |
13 | ||
14 | <wx/event.h> | |
15 | ||
a660d684 KB |
16 | \wxheading{Event table macros} |
17 | ||
631f1bfe | 18 | To process an update event, use these event handler macros to direct input to member |
a660d684 KB |
19 | functions that take a wxUpdateUIEvent argument. |
20 | ||
21 | \twocolwidtha{7cm} | |
22 | \begin{twocollist}\itemsep=0pt | |
3ca6a5f0 BP |
23 | \twocolitem{{\bf EVT\_UPDATE\_UI(id, func)}}{Process a wxEVT\_UPDATE\_UI event for the command with the given id.} |
24 | \twocolitem{{\bf EVT\_UPDATE\_UI\_RANGE(id1, id2, func)}}{Process a wxEVT\_UPDATE\_UI event for any command with id included in the given range.} | |
d2c2afc9 | 25 | \end{twocollist} |
a660d684 KB |
26 | |
27 | \wxheading{Remarks} | |
28 | ||
29 | Without update UI events, an application has to work hard to check/uncheck, enable/disable, | |
a3a4105d | 30 | show/hide, and set the text for elements such as menu items and toolbar buttons. |
a660d684 KB |
31 | The code for doing this has to be mixed up with the code that is invoked when |
32 | an action is invoked for a menu item or button. | |
33 | ||
34 | With update UI events, you define an event handler to look at the state of | |
fc2171bd | 35 | the application and change UI elements accordingly. wxWidgets will call your |
a660d684 KB |
36 | member functions in idle time, so you don't have to worry where to call this code. |
37 | In addition to being a clearer and more declarative method, it also means you | |
38 | don't have to worry whether you're updating a toolbar or menubar identifier. | |
39 | The same handler can update a menu item and toolbar button, if the identifier is the same. | |
40 | ||
41 | Instead of directly manipulating the menu or button, you call functions in the event | |
fc2171bd | 42 | object, such as \helpref{wxUpdateUIEvent::Check}{wxupdateuieventcheck}. wxWidgets |
a660d684 KB |
43 | will determine whether such a call has been made, and which UI element to update. |
44 | ||
631f1bfe JS |
45 | These events will work for popup menus as well as menubars. Just before a menu is popped |
46 | up, \helpref{wxMenu::UpdateUI}{wxmenuupdateui} is called to process any UI events for | |
47 | the window that owns the menu. | |
48 | ||
e39af974 JS |
49 | If you find that the overhead of UI update processing is affecting |
50 | your application, you can do one or both of the following: | |
51 | ||
52 | \begin{enumerate} | |
53 | \item Call \helpref{wxUpdateUIEvent::SetMode}{wxupdateuieventsetmode} with | |
54 | a value of wxUPDATE\_UI\_PROCESS\_SPECIFIED, and set the extra style | |
c9854321 | 55 | wxWS\_EX\_PROCESS\_UI\_UPDATES for every window that should receive update events. |
e39af974 JS |
56 | No other windows will receive update events. |
57 | \item Call \helpref{wxUpdateUIEvent::SetUpdateInterval}{wxupdateuieventsetupdateinterval} with | |
58 | a millisecond value to set the delay between updates. You may need | |
59 | to call \helpref{wxWindow::UpdateWindowUI}{wxwindowupdatewindowui} at critical | |
60 | points, for example when a dialog is about to be shown, in case the user | |
61 | sees a slight delay before windows are updated. | |
62 | \end{enumerate} | |
63 | ||
64 | Note that although events are sent in idle time, defining a wxIdleEvent | |
65 | handler for a window does not affect this because the events are sent from \helpref{wxWindow::OnInternalIdle}{wxwindowoninternalidle} | |
66 | which is {\bf always} called in idle time. | |
67 | ||
fc2171bd | 68 | wxWidgets tries to optimize update events on some platforms. On Windows |
e39af974 JS |
69 | and GTK+, events for menubar items are only sent when the menu is about |
70 | to be shown, and not in idle time. | |
71 | ||
a660d684 KB |
72 | \wxheading{See also} |
73 | ||
74 | \helpref{Event handling overview}{eventhandlingoverview} | |
75 | ||
76 | \latexignore{\rtfignore{\wxheading{Members}}} | |
77 | ||
15d83f72 | 78 | \membersection{wxUpdateUIEvent::wxUpdateUIEvent}\label{wxupdateuieventctor} |
a660d684 KB |
79 | |
80 | \func{}{wxUpdateUIEvent}{\param{wxWindowID }{commandId = 0}} | |
81 | ||
82 | Constructor. | |
83 | ||
e39af974 JS |
84 | \membersection{wxUpdateUIEvent::CanUpdate}\label{wxupdateuieventcanupdate} |
85 | ||
86 | \func{static bool}{CanUpdate}{\param{wxWindow*}{ window}} | |
87 | ||
88 | Returns {\tt true} if it is appropriate to update (send UI update events to) | |
89 | this window. | |
90 | ||
91 | This function looks at the mode used (see \helpref{wxUpdateUIEvent::SetMode}{wxupdateuieventsetmode}), | |
c9854321 | 92 | the wxWS\_EX\_PROCESS\_UI\_UPDATES flag in {\it window}, |
e39af974 JS |
93 | the time update events were last sent in idle time, and |
94 | the update interval, to determine whether events should be sent to | |
95 | this window now. By default this will always return {\tt true} because | |
96 | the update mode is initially wxUPDATE\_UI\_PROCESS\_ALL and | |
97 | the interval is set to 0; so update events will be sent as | |
98 | often as possible. You can reduce the frequency that events | |
99 | are sent by changing the mode and/or setting an update interval. | |
100 | ||
101 | \wxheading{See also} | |
102 | ||
103 | \helpref{wxUpdateUIEvent::ResetUpdateTime}{wxupdateuieventresetupdatetime}, | |
104 | \helpref{wxUpdateUIEvent::SetUpdateInterval}{wxupdateuieventsetupdateinterval}, | |
105 | \helpref{wxUpdateUIEvent::SetMode}{wxupdateuieventsetmode} | |
106 | ||
a660d684 KB |
107 | \membersection{wxUpdateUIEvent::Check}\label{wxupdateuieventcheck} |
108 | ||
109 | \func{void}{Check}{\param{bool}{ check}} | |
110 | ||
111 | Check or uncheck the UI element. | |
112 | ||
113 | \membersection{wxUpdateUIEvent::Enable}\label{wxupdateuieventenable} | |
114 | ||
115 | \func{void}{Enable}{\param{bool}{ enable}} | |
116 | ||
117 | Enable or disable the UI element. | |
118 | ||
a3a4105d VZ |
119 | \membersection{wxUpdateUIEvent::Show}\label{wxupdateuieventshow} |
120 | ||
121 | \func{void}{Show}{\param{bool}{ show}} | |
122 | ||
123 | Show or hide the UI element. | |
124 | ||
a660d684 KB |
125 | \membersection{wxUpdateUIEvent::GetChecked}\label{wxupdateuieventgetchecked} |
126 | ||
127 | \constfunc{bool}{GetChecked}{\void} | |
128 | ||
cc81d32f | 129 | Returns true if the UI element should be checked. |
a660d684 KB |
130 | |
131 | \membersection{wxUpdateUIEvent::GetEnabled}\label{wxupdateuieventgetenabled} | |
132 | ||
133 | \constfunc{bool}{GetEnabled}{\void} | |
134 | ||
cc81d32f | 135 | Returns true if the UI element should be enabled. |
a660d684 | 136 | |
a3a4105d VZ |
137 | \membersection{wxUpdateUIEvent::GetShown}\label{wxupdateuieventgetshown} |
138 | ||
139 | \constfunc{bool}{GetShown}{\void} | |
140 | ||
141 | Returns true if the UI element should be shown. | |
142 | ||
a660d684 KB |
143 | \membersection{wxUpdateUIEvent::GetSetChecked}\label{wxupdateuieventgetsetchecked} |
144 | ||
145 | \constfunc{bool}{GetSetChecked}{\void} | |
146 | ||
05994861 | 147 | Returns true if the application has called \helpref{wxUpdateUIEvent::Check}{wxupdateuieventcheck}. For wxWidgets internal use only. |
a660d684 KB |
148 | |
149 | \membersection{wxUpdateUIEvent::GetSetEnabled}\label{wxupdateuieventgetsetenabled} | |
150 | ||
151 | \constfunc{bool}{GetSetEnabled}{\void} | |
152 | ||
05994861 | 153 | Returns true if the application has called \helpref{wxUpdateUIEvent::Enable}{wxupdateuieventenable}. For wxWidgets internal use only. |
a660d684 | 154 | |
a3a4105d VZ |
155 | \membersection{wxUpdateUIEvent::GetSetShown}\label{wxupdateuieventgetsetshown} |
156 | ||
157 | \constfunc{bool}{GetSetShown}{\void} | |
158 | ||
159 | Returns true if the application has called \helpref{wxUpdateUIEvent::Show}{wxupdateuieventshow}. For wxWidgets internal use only. | |
160 | ||
a660d684 KB |
161 | \membersection{wxUpdateUIEvent::GetSetText}\label{wxupdateuieventgetsettext} |
162 | ||
163 | \constfunc{bool}{GetSetText}{\void} | |
164 | ||
05994861 | 165 | Returns true if the application has called \helpref{wxUpdateUIEvent::SetText}{wxupdateuieventsettext}. For wxWidgets internal use only. |
a660d684 KB |
166 | |
167 | \membersection{wxUpdateUIEvent::GetText}\label{wxupdateuieventgettext} | |
168 | ||
169 | \constfunc{wxString}{GetText}{\void} | |
170 | ||
171 | Returns the text that should be set for the UI element. | |
172 | ||
e39af974 JS |
173 | \membersection{wxUpdateUIEvent::GetMode}\label{wxupdateuieventgetmode} |
174 | ||
175 | \func{static wxUpdateUIMode}{GetMode}{\void} | |
176 | ||
fc2171bd | 177 | Static function returning a value specifying how wxWidgets |
e39af974 JS |
178 | will send update events: to all windows, or only to those which specify that they |
179 | will process the events. | |
180 | ||
181 | See \helpref{wxUpdateUIEvent::SetMode}{wxupdateuieventsetmode}. | |
182 | ||
183 | \membersection{wxUpdateUIEvent::GetUpdateInterval}\label{wxupdateuieventgetupdateinterval} | |
184 | ||
185 | \func{static long}{GetUpdateInterval}{\void} | |
186 | ||
187 | Returns the current interval between updates in milliseconds. | |
188 | -1 disables updates, 0 updates as frequently as possible. | |
189 | ||
190 | See \helpref{wxUpdateUIEvent::SetUpdateInterval}{wxupdateuieventsetupdateinterval}. | |
191 | ||
192 | \membersection{wxUpdateUIEvent::ResetUpdateTime}\label{wxupdateuieventresetupdatetime} | |
193 | ||
194 | \func{static void}{ResetUpdateTime}{\void} | |
195 | ||
196 | Used internally to reset the last-updated time to the | |
197 | current time. It is assumed that update events are | |
198 | normally sent in idle time, so this is called at the end of | |
199 | idle processing. | |
200 | ||
201 | \wxheading{See also} | |
202 | ||
203 | \helpref{wxUpdateUIEvent::CanUpdate}{wxupdateuieventcanupdate}, | |
204 | \helpref{wxUpdateUIEvent::SetUpdateInterval}{wxupdateuieventsetupdateinterval}, | |
205 | \helpref{wxUpdateUIEvent::SetMode}{wxupdateuieventsetmode} | |
206 | ||
207 | \membersection{wxUpdateUIEvent::SetMode}\label{wxupdateuieventsetmode} | |
208 | ||
9a75ba66 | 209 | \func{static void}{SetMode}{\param{wxUpdateUIMode }{mode}} |
e39af974 | 210 | |
fc2171bd | 211 | Specify how wxWidgets will send update events: to |
e39af974 JS |
212 | all windows, or only to those which specify that they |
213 | will process the events. | |
214 | ||
215 | {\it mode} may be one of the following values. | |
216 | The default is wxUPDATE\_UI\_PROCESS\_ALL. | |
217 | ||
218 | \begin{verbatim} | |
219 | enum wxUpdateUIMode | |
220 | { | |
221 | // Send UI update events to all windows | |
222 | wxUPDATE_UI_PROCESS_ALL, | |
223 | ||
224 | // Send UI update events to windows that have | |
225 | // the wxWS_EX_PROCESS_UI_UPDATES flag specified | |
226 | wxUPDATE_UI_PROCESS_SPECIFIED | |
227 | }; | |
228 | \end{verbatim} | |
229 | ||
a660d684 KB |
230 | \membersection{wxUpdateUIEvent::SetText}\label{wxupdateuieventsettext} |
231 | ||
232 | \func{void}{SetText}{\param{const wxString\&}{ text}} | |
233 | ||
234 | Sets the text for this UI element. | |
235 | ||
e39af974 JS |
236 | \membersection{wxUpdateUIEvent::SetUpdateInterval}\label{wxupdateuieventsetupdateinterval} |
237 | ||
238 | \func{static void}{SetUpdateInterval}{\param{long }{updateInterval}} | |
239 | ||
240 | Sets the interval between updates in milliseconds. | |
241 | Set to -1 to disable updates, or to 0 to update as frequently as possible. | |
242 | The default is 0. | |
243 | ||
244 | Use this to reduce the overhead of UI update events if your application | |
245 | has a lot of windows. If you set the value to -1 or greater than 0, | |
246 | you may also need to call \helpref{wxWindow::UpdateWindowUI}{wxwindowupdatewindowui} | |
247 | at appropriate points in your application, such as when a dialog | |
248 | is about to be shown. | |
249 |