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