1 \section{\class{wxUpdateUIEvent
}}\label{wxupdateuievent
}
3 This class is used for pseudo-events which are called by wxWidgets
4 to give an application the chance to update various user interface elements.
6 \wxheading{Derived from
}
8 \helpref{wxCommandEvent
}{wxcommandevent
}\\
9 \helpref{wxEvent
}{wxevent
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
18 \helpref{wxCore
}{librarieslist
}
20 \wxheading{Event table macros
}
22 To process an update event, use these event handler macros to direct input to member
23 functions that take a wxUpdateUIEvent argument.
26 \begin{twocollist
}\itemsep=
0pt
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.
}
33 Without update UI events, an application has to work hard to check/uncheck, enable/disable,
34 show/hide, and set the text for elements such as menu items and toolbar buttons.
35 The code for doing this has to be mixed up with the code that is invoked when
36 an action is invoked for a menu item or button.
38 With update UI events, you define an event handler to look at the state of
39 the application and change UI elements accordingly. wxWidgets will call your
40 member functions in idle time, so you don't have to worry where to call this code.
41 In addition to being a clearer and more declarative method, it also means you
42 don't have to worry whether you're updating a toolbar or menubar identifier.
43 The same handler can update a menu item and toolbar button, if the identifier is the same.
45 Instead of directly manipulating the menu or button, you call functions in the event
46 object, such as
\helpref{wxUpdateUIEvent::Check
}{wxupdateuieventcheck
}. wxWidgets
47 will determine whether such a call has been made, and which UI element to update.
49 These events will work for popup menus as well as menubars. Just before a menu is popped
50 up,
\helpref{wxMenu::UpdateUI
}{wxmenuupdateui
} is called to process any UI events for
51 the window that owns the menu.
53 If you find that the overhead of UI update processing is affecting
54 your application, you can do one or both of the following:
57 \item Call
\helpref{wxUpdateUIEvent::SetMode
}{wxupdateuieventsetmode
} with
58 a value of wxUPDATE
\_UI\_PROCESS\_SPECIFIED, and set the extra style
59 wxWS
\_EX\_PROCESS\_UI\_UPDATES for every window that should receive update events.
60 No other windows will receive update events.
61 \item Call
\helpref{wxUpdateUIEvent::SetUpdateInterval
}{wxupdateuieventsetupdateinterval
} with
62 a millisecond value to set the delay between updates. You may need
63 to call
\helpref{wxWindow::UpdateWindowUI
}{wxwindowupdatewindowui
} at critical
64 points, for example when a dialog is about to be shown, in case the user
65 sees a slight delay before windows are updated.
68 Note that although events are sent in idle time, defining a wxIdleEvent
69 handler for a window does not affect this because the events are sent from
\helpref{wxWindow::OnInternalIdle
}{wxwindowoninternalidle
}
70 which is
{\bf always
} called in idle time.
72 wxWidgets tries to optimize update events on some platforms. On Windows
73 and GTK+, events for menubar items are only sent when the menu is about
74 to be shown, and not in idle time.
78 \helpref{Event handling overview
}{eventhandlingoverview
}
80 \latexignore{\rtfignore{\wxheading{Members
}}}
82 \membersection{wxUpdateUIEvent::wxUpdateUIEvent
}\label{wxupdateuieventctor
}
84 \func{}{wxUpdateUIEvent
}{\param{wxWindowID
}{commandId =
0}}
88 \membersection{wxUpdateUIEvent::CanUpdate
}\label{wxupdateuieventcanupdate
}
90 \func{static bool
}{CanUpdate
}{\param{wxWindow*
}{ window
}}
92 Returns
{\tt true
} if it is appropriate to update (send UI update events to)
95 This function looks at the mode used (see
\helpref{wxUpdateUIEvent::SetMode
}{wxupdateuieventsetmode
}),
96 the wxWS
\_EX\_PROCESS\_UI\_UPDATES flag in
{\it window
},
97 the time update events were last sent in idle time, and
98 the update interval, to determine whether events should be sent to
99 this window now. By default this will always return
{\tt true
} because
100 the update mode is initially wxUPDATE
\_UI\_PROCESS\_ALL and
101 the interval is set to
0; so update events will be sent as
102 often as possible. You can reduce the frequency that events
103 are sent by changing the mode and/or setting an update interval.
107 \helpref{wxUpdateUIEvent::ResetUpdateTime
}{wxupdateuieventresetupdatetime
},
108 \helpref{wxUpdateUIEvent::SetUpdateInterval
}{wxupdateuieventsetupdateinterval
},
109 \helpref{wxUpdateUIEvent::SetMode
}{wxupdateuieventsetmode
}
111 \membersection{wxUpdateUIEvent::Check
}\label{wxupdateuieventcheck
}
113 \func{void
}{Check
}{\param{bool
}{ check
}}
115 Check or uncheck the UI element.
117 \membersection{wxUpdateUIEvent::Enable
}\label{wxupdateuieventenable
}
119 \func{void
}{Enable
}{\param{bool
}{ enable
}}
121 Enable or disable the UI element.
123 \membersection{wxUpdateUIEvent::Show
}\label{wxupdateuieventshow
}
125 \func{void
}{Show
}{\param{bool
}{ show
}}
127 Show or hide the UI element.
129 \membersection{wxUpdateUIEvent::GetChecked
}\label{wxupdateuieventgetchecked
}
131 \constfunc{bool
}{GetChecked
}{\void}
133 Returns true if the UI element should be checked.
135 \membersection{wxUpdateUIEvent::GetEnabled
}\label{wxupdateuieventgetenabled
}
137 \constfunc{bool
}{GetEnabled
}{\void}
139 Returns true if the UI element should be enabled.
141 \membersection{wxUpdateUIEvent::GetShown
}\label{wxupdateuieventgetshown
}
143 \constfunc{bool
}{GetShown
}{\void}
145 Returns true if the UI element should be shown.
147 \membersection{wxUpdateUIEvent::GetSetChecked
}\label{wxupdateuieventgetsetchecked
}
149 \constfunc{bool
}{GetSetChecked
}{\void}
151 Returns true if the application has called
\helpref{wxUpdateUIEvent::Check
}{wxupdateuieventcheck
}. For wxWidgets internal use only.
153 \membersection{wxUpdateUIEvent::GetSetEnabled
}\label{wxupdateuieventgetsetenabled
}
155 \constfunc{bool
}{GetSetEnabled
}{\void}
157 Returns true if the application has called
\helpref{wxUpdateUIEvent::Enable
}{wxupdateuieventenable
}. For wxWidgets internal use only.
159 \membersection{wxUpdateUIEvent::GetSetShown
}\label{wxupdateuieventgetsetshown
}
161 \constfunc{bool
}{GetSetShown
}{\void}
163 Returns true if the application has called
\helpref{wxUpdateUIEvent::Show
}{wxupdateuieventshow
}. For wxWidgets internal use only.
165 \membersection{wxUpdateUIEvent::GetSetText
}\label{wxupdateuieventgetsettext
}
167 \constfunc{bool
}{GetSetText
}{\void}
169 Returns true if the application has called
\helpref{wxUpdateUIEvent::SetText
}{wxupdateuieventsettext
}. For wxWidgets internal use only.
171 \membersection{wxUpdateUIEvent::GetText
}\label{wxupdateuieventgettext
}
173 \constfunc{wxString
}{GetText
}{\void}
175 Returns the text that should be set for the UI element.
177 \membersection{wxUpdateUIEvent::GetMode
}\label{wxupdateuieventgetmode
}
179 \func{static wxUpdateUIMode
}{GetMode
}{\void}
181 Static function returning a value specifying how wxWidgets
182 will send update events: to all windows, or only to those which specify that they
183 will process the events.
185 See
\helpref{wxUpdateUIEvent::SetMode
}{wxupdateuieventsetmode
}.
187 \membersection{wxUpdateUIEvent::GetUpdateInterval
}\label{wxupdateuieventgetupdateinterval
}
189 \func{static long
}{GetUpdateInterval
}{\void}
191 Returns the current interval between updates in milliseconds.
192 -
1 disables updates,
0 updates as frequently as possible.
194 See
\helpref{wxUpdateUIEvent::SetUpdateInterval
}{wxupdateuieventsetupdateinterval
}.
196 \membersection{wxUpdateUIEvent::ResetUpdateTime
}\label{wxupdateuieventresetupdatetime
}
198 \func{static void
}{ResetUpdateTime
}{\void}
200 Used internally to reset the last-updated time to the
201 current time. It is assumed that update events are
202 normally sent in idle time, so this is called at the end of
207 \helpref{wxUpdateUIEvent::CanUpdate
}{wxupdateuieventcanupdate
},
208 \helpref{wxUpdateUIEvent::SetUpdateInterval
}{wxupdateuieventsetupdateinterval
},
209 \helpref{wxUpdateUIEvent::SetMode
}{wxupdateuieventsetmode
}
211 \membersection{wxUpdateUIEvent::SetMode
}\label{wxupdateuieventsetmode
}
213 \func{static void
}{SetMode
}{\param{wxUpdateUIMode
}{mode
}}
215 Specify how wxWidgets will send update events: to
216 all windows, or only to those which specify that they
217 will process the events.
219 {\it mode
} may be one of the following values.
220 The default is wxUPDATE
\_UI\_PROCESS\_ALL.
225 // Send UI update events to all windows
226 wxUPDATE_UI_PROCESS_ALL,
228 // Send UI update events to windows that have
229 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
230 wxUPDATE_UI_PROCESS_SPECIFIED
234 \membersection{wxUpdateUIEvent::SetText
}\label{wxupdateuieventsettext
}
236 \func{void
}{SetText
}{\param{const wxString\&
}{ text
}}
238 Sets the text for this UI element.
240 \membersection{wxUpdateUIEvent::SetUpdateInterval
}\label{wxupdateuieventsetupdateinterval
}
242 \func{static void
}{SetUpdateInterval
}{\param{long
}{updateInterval
}}
244 Sets the interval between updates in milliseconds.
245 Set to -
1 to disable updates, or to
0 to update as frequently as possible.
248 Use this to reduce the overhead of UI update events if your application
249 has a lot of windows. If you set the value to -
1 or greater than
0,
250 you may also need to call
\helpref{wxWindow::UpdateWindowUI
}{wxwindowupdatewindowui
}
251 at appropriate points in your application, such as when a dialog
252 is about to be shown.