]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: event.h | |
1f1d2182 | 3 | // Purpose: interface of wx*Event classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxKeyEvent | |
11 | @wxheader{event.h} | |
7c913512 | 12 | |
23324ae1 | 13 | This event class contains information about keypress (character) events. |
7c913512 | 14 | |
23324ae1 FM |
15 | Notice that there are three different kinds of keyboard events in wxWidgets: |
16 | key down and up events and char events. The difference between the first two | |
17 | is clear - the first corresponds to a key press and the second to a key | |
18 | release - otherwise they are identical. Just note that if the key is | |
19 | maintained in a pressed state you will typically get a lot of (automatically | |
20 | generated) down events but only one up so it is wrong to assume that there is | |
21 | one up event corresponding to each down one. | |
7c913512 | 22 | |
23324ae1 FM |
23 | Both key events provide untranslated key codes while the char event carries |
24 | the translated one. The untranslated code for alphanumeric keys is always | |
25 | an upper case value. For the other keys it is one of @c WXK_XXX values | |
1f1d2182 FM |
26 | from the @ref page_keycodes. |
27 | The translated key is, in general, the character the user expects to appear | |
28 | as the result of the key combination when typing the text into a text entry | |
29 | zone, for example. | |
7c913512 | 30 | |
23324ae1 FM |
31 | A few examples to clarify this (all assume that CAPS LOCK is unpressed |
32 | and the standard US keyboard): when the @c 'A' key is pressed, the key down | |
33 | event key code is equal to @c ASCII A == 65. But the char event key code | |
34 | is @c ASCII a == 97. On the other hand, if you press both SHIFT and | |
35 | @c 'A' keys simultaneously , the key code in key down event will still be | |
36 | just @c 'A' while the char event key code parameter will now be @c 'A' | |
37 | as well. | |
7c913512 | 38 | |
23324ae1 FM |
39 | Although in this simple case it is clear that the correct key code could be |
40 | found in the key down event handler by checking the value returned by | |
1f1d2182 FM |
41 | wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as |
42 | for non-alphanumeric keys the translation is keyboard-layout dependent and | |
43 | can only be done properly by the system itself. | |
7c913512 | 44 | |
23324ae1 FM |
45 | Another kind of translation is done when the control key is pressed: for |
46 | example, for CTRL-A key press the key down event still carries the | |
1f1d2182 FM |
47 | same key code @c 'a' as usual but the char event will have key code of 1, |
48 | the ASCII value of this key combination. | |
7c913512 | 49 | |
23324ae1 | 50 | You may discover how the other keys on your system behave interactively by |
1f1d2182 | 51 | running the @ref page_samples_text wxWidgets sample and pressing some keys |
23324ae1 | 52 | in any of the text controls shown in it. |
7c913512 | 53 | |
23324ae1 FM |
54 | @b Tip: be sure to call @c event.Skip() for events that you don't process in |
55 | key event function, otherwise menu shortcuts may cease to work under Windows. | |
7c913512 | 56 | |
1f1d2182 FM |
57 | @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler |
58 | does not call @c event.Skip() then the corresponding char event | |
59 | (@c EVT_CHAR) will not happen. | |
60 | This is by design and enables the programs that handle both types of | |
61 | events to be a bit simpler. | |
62 | ||
63 | @note For Windows programmers: The key and char events in wxWidgets are | |
64 | similar to but slightly different from Windows @c WM_KEYDOWN and | |
65 | @c WM_CHAR events. In particular, Alt-x combination will generate a | |
66 | char event in wxWidgets (unless it is used as an accelerator). | |
67 | ||
68 | ||
69 | @beginEventTable{wxKeyEvent} | |
70 | @event{EVT_KEY_DOWN(func)}: | |
71 | Process a wxEVT_KEY_DOWN event (any key has been pressed). | |
72 | @event{EVT_KEY_UP(func)}: | |
73 | Process a wxEVT_KEY_UP event (any key has been released). | |
74 | @event{EVT_CHAR(func)}: | |
75 | Process a wxEVT_CHAR event. | |
76 | @endEventTable | |
77 | ||
23324ae1 FM |
78 | @library{wxcore} |
79 | @category{events} | |
80 | */ | |
81 | class wxKeyEvent : public wxEvent | |
82 | { | |
83 | public: | |
84 | /** | |
1f1d2182 FM |
85 | Constructor. |
86 | Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK. | |
23324ae1 | 87 | */ |
1f1d2182 | 88 | wxKeyEvent(wxEventType keyEventType = wxEVT_NULL); |
23324ae1 FM |
89 | |
90 | /** | |
91 | Returns @true if the Alt key was down at the time of the key event. | |
1f1d2182 FM |
92 | |
93 | Notice that GetModifiers() is easier to use correctly than this function | |
94 | so you should consider using it in new code. | |
23324ae1 | 95 | */ |
328f5751 | 96 | bool AltDown() const; |
23324ae1 FM |
97 | |
98 | /** | |
99 | CMD is a pseudo key which is the same as Control for PC and Unix | |
1f1d2182 FM |
100 | platforms but the special APPLE (a.k.a as COMMAND) key under Macs: |
101 | it makes often sense to use it instead of, say, ControlDown() because Cmd | |
23324ae1 FM |
102 | key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still |
103 | exists, just not used for this purpose under Mac). So for non-Mac platforms | |
1f1d2182 | 104 | this is the same as ControlDown() and under Mac this is the same as MetaDown(). |
23324ae1 | 105 | */ |
328f5751 | 106 | bool CmdDown() const; |
23324ae1 FM |
107 | |
108 | /** | |
109 | Returns @true if the control key was down at the time of the key event. | |
1f1d2182 FM |
110 | |
111 | Notice that GetModifiers() is easier to use correctly than this function | |
112 | so you should consider using it in new code. | |
23324ae1 | 113 | */ |
328f5751 | 114 | bool ControlDown() const; |
23324ae1 FM |
115 | |
116 | /** | |
117 | Returns the virtual key code. ASCII events return normal ASCII values, | |
1f1d2182 FM |
118 | while non-ASCII events return values such as @b WXK_LEFT for the left cursor |
119 | key. See @ref page_keycodes for a full list of the virtual key codes. | |
120 | ||
23324ae1 FM |
121 | Note that in Unicode build, the returned value is meaningful only if the |
122 | user entered a character that can be represented in current locale's default | |
1f1d2182 | 123 | charset. You can obtain the corresponding Unicode character using GetUnicodeKey(). |
23324ae1 | 124 | */ |
328f5751 | 125 | int GetKeyCode() const; |
23324ae1 FM |
126 | |
127 | /** | |
128 | Return the bitmask of modifier keys which were pressed when this event | |
1f1d2182 FM |
129 | happened. See @ref page_keymodifiers for the full list of modifiers. |
130 | ||
7c913512 | 131 | Notice that this function is easier to use correctly than, for example, |
1f1d2182 FM |
132 | ControlDown() because when using the latter you also have to remember to |
133 | test that none of the other modifiers is pressed: | |
3c4f71cc | 134 | |
1f1d2182 FM |
135 | @code |
136 | if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() ) | |
137 | ... handle Ctrl-XXX ... | |
138 | @endcode | |
139 | ||
140 | and forgetting to do it can result in serious program bugs (e.g. program | |
141 | not working with European keyboard layout where ALTGR key which is seen by | |
142 | the program as combination of CTRL and ALT is used). On the other hand, | |
143 | you can simply write: | |
144 | ||
145 | @code | |
146 | if ( GetModifiers() == wxMOD_CONTROL ) | |
147 | ... handle Ctrl-XXX ... | |
148 | @endcode | |
3c4f71cc | 149 | |
23324ae1 FM |
150 | with this function. |
151 | */ | |
328f5751 | 152 | int GetModifiers() const; |
23324ae1 FM |
153 | |
154 | //@{ | |
155 | /** | |
156 | Obtains the position (in client coordinates) at which the key was pressed. | |
157 | */ | |
328f5751 | 158 | wxPoint GetPosition() const; |
1f1d2182 | 159 | void GetPosition(long* x, long* y) const; |
23324ae1 FM |
160 | //@} |
161 | ||
162 | /** | |
163 | Returns the raw key code for this event. This is a platform-dependent scan code | |
164 | which should only be used in advanced applications. | |
1f1d2182 FM |
165 | |
166 | @note Currently the raw key codes are not supported by all ports, use | |
167 | @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available. | |
23324ae1 | 168 | */ |
328f5751 | 169 | wxUint32 GetRawKeyCode() const; |
23324ae1 FM |
170 | |
171 | /** | |
172 | Returns the low level key flags for this event. The flags are | |
173 | platform-dependent and should only be used in advanced applications. | |
1f1d2182 FM |
174 | |
175 | @note Currently the raw key flags are not supported by all ports, use | |
176 | @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available. | |
23324ae1 | 177 | */ |
328f5751 | 178 | wxUint32 GetRawKeyFlags() const; |
23324ae1 FM |
179 | |
180 | /** | |
181 | Returns the Unicode character corresponding to this key event. | |
1f1d2182 | 182 | |
23324ae1 FM |
183 | This function is only available in Unicode build, i.e. when |
184 | @c wxUSE_UNICODE is 1. | |
185 | */ | |
328f5751 | 186 | wxChar GetUnicodeKey() const; |
23324ae1 FM |
187 | |
188 | /** | |
189 | Returns the X position (in client coordinates) of the event. | |
190 | */ | |
a6052817 | 191 | wxCoord GetX() const; |
23324ae1 FM |
192 | |
193 | /** | |
1f1d2182 | 194 | Returns the Y position (in client coordinates) of the event. |
23324ae1 | 195 | */ |
a6052817 | 196 | wxCoord GetY() const; |
23324ae1 FM |
197 | |
198 | /** | |
1f1d2182 FM |
199 | Returns @true if either CTRL or ALT keys was down at the time of the |
200 | key event. | |
201 | ||
202 | Note that this function does not take into account neither SHIFT nor | |
203 | META key states (the reason for ignoring the latter is that it is | |
204 | common for NUMLOCK key to be configured as META under X but the key | |
205 | presses even while NUMLOCK is on should be still processed normally). | |
23324ae1 | 206 | */ |
328f5751 | 207 | bool HasModifiers() const; |
23324ae1 FM |
208 | |
209 | /** | |
210 | Returns @true if the Meta key was down at the time of the key event. | |
1f1d2182 FM |
211 | |
212 | Notice that GetModifiers() is easier to use correctly than this function | |
213 | so you should consider using it in new code. | |
23324ae1 | 214 | */ |
328f5751 | 215 | bool MetaDown() const; |
23324ae1 FM |
216 | |
217 | /** | |
218 | Returns @true if the shift key was down at the time of the key event. | |
23324ae1 | 219 | |
1f1d2182 FM |
220 | Notice that GetModifiers() is easier to use correctly than this function |
221 | so you should consider using it in new code. | |
23324ae1 | 222 | */ |
1f1d2182 | 223 | bool ShiftDown() const; |
23324ae1 FM |
224 | }; |
225 | ||
226 | ||
e54c96f1 | 227 | |
23324ae1 FM |
228 | /** |
229 | @class wxJoystickEvent | |
230 | @wxheader{event.h} | |
7c913512 | 231 | |
1f1d2182 | 232 | This event class contains information about joystick events, particularly |
23324ae1 | 233 | events received by windows. |
7c913512 | 234 | |
1f1d2182 FM |
235 | @beginEventTable{wxJoystickEvent} |
236 | @style{EVT_JOY_BUTTON_DOWN(func)}: | |
237 | Process a wxEVT_JOY_BUTTON_DOWN event. | |
238 | @style{EVT_JOY_BUTTON_UP(func)}: | |
239 | Process a wxEVT_JOY_BUTTON_UP event. | |
240 | @style{EVT_JOY_MOVE(func)}: | |
241 | Process a wxEVT_JOY_MOVE event. | |
242 | @style{EVT_JOY_ZMOVE(func)}: | |
243 | Process a wxEVT_JOY_ZMOVE event. | |
244 | @style{EVT_JOYSTICK_EVENTS(func)}: | |
245 | Processes all joystick events. | |
246 | @endEventTable | |
247 | ||
23324ae1 FM |
248 | @library{wxcore} |
249 | @category{events} | |
7c913512 | 250 | |
e54c96f1 | 251 | @see wxJoystick |
23324ae1 FM |
252 | */ |
253 | class wxJoystickEvent : public wxEvent | |
254 | { | |
255 | public: | |
256 | /** | |
257 | Constructor. | |
258 | */ | |
1f1d2182 | 259 | wxJoystickEvent(wxEventType eventType = wxEVT_NULL, int state = 0, |
23324ae1 FM |
260 | int joystick = wxJOYSTICK1, |
261 | int change = 0); | |
262 | ||
263 | /** | |
1f1d2182 FM |
264 | Returns @true if the event was a down event from the specified button |
265 | (or any button). | |
3c4f71cc | 266 | |
7c913512 | 267 | @param button |
1f1d2182 | 268 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to |
4cc4bfaf | 269 | indicate any button down event. |
23324ae1 | 270 | */ |
328f5751 | 271 | bool ButtonDown(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
272 | |
273 | /** | |
274 | Returns @true if the specified button (or any button) was in a down state. | |
3c4f71cc | 275 | |
7c913512 | 276 | @param button |
1f1d2182 | 277 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to |
4cc4bfaf | 278 | indicate any button down event. |
23324ae1 | 279 | */ |
328f5751 | 280 | bool ButtonIsDown(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
281 | |
282 | /** | |
1f1d2182 FM |
283 | Returns @true if the event was an up event from the specified button |
284 | (or any button). | |
3c4f71cc | 285 | |
7c913512 | 286 | @param button |
1f1d2182 | 287 | Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to |
4cc4bfaf | 288 | indicate any button down event. |
23324ae1 | 289 | */ |
328f5751 | 290 | bool ButtonUp(int button = wxJOY_BUTTON_ANY) const; |
23324ae1 FM |
291 | |
292 | /** | |
1f1d2182 FM |
293 | Returns the identifier of the button changing state. |
294 | ||
295 | This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. | |
23324ae1 | 296 | */ |
328f5751 | 297 | int GetButtonChange() const; |
23324ae1 FM |
298 | |
299 | /** | |
1f1d2182 FM |
300 | Returns the down state of the buttons. |
301 | ||
302 | This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. | |
23324ae1 | 303 | */ |
328f5751 | 304 | int GetButtonState() const; |
23324ae1 FM |
305 | |
306 | /** | |
307 | Returns the identifier of the joystick generating the event - one of | |
308 | wxJOYSTICK1 and wxJOYSTICK2. | |
309 | */ | |
328f5751 | 310 | int GetJoystick() const; |
23324ae1 FM |
311 | |
312 | /** | |
313 | Returns the x, y position of the joystick event. | |
314 | */ | |
328f5751 | 315 | wxPoint GetPosition() const; |
23324ae1 FM |
316 | |
317 | /** | |
318 | Returns the z position of the joystick event. | |
319 | */ | |
328f5751 | 320 | int GetZPosition() const; |
23324ae1 FM |
321 | |
322 | /** | |
1f1d2182 FM |
323 | Returns @true if this was a button up or down event |
324 | (@e not 'is any button down?'). | |
23324ae1 | 325 | */ |
328f5751 | 326 | bool IsButton() const; |
23324ae1 FM |
327 | |
328 | /** | |
329 | Returns @true if this was an x, y move event. | |
330 | */ | |
328f5751 | 331 | bool IsMove() const; |
23324ae1 FM |
332 | |
333 | /** | |
334 | Returns @true if this was a z move event. | |
335 | */ | |
328f5751 | 336 | bool IsZMove() const; |
23324ae1 FM |
337 | }; |
338 | ||
339 | ||
e54c96f1 | 340 | |
23324ae1 FM |
341 | /** |
342 | @class wxScrollWinEvent | |
343 | @wxheader{event.h} | |
7c913512 | 344 | |
23324ae1 | 345 | A scroll event holds information about events sent from scrolling windows. |
7c913512 | 346 | |
1f1d2182 FM |
347 | |
348 | @beginEventTable{wxScrollWinEvent} | |
349 | You can use the EVT_SCROLLWIN* macros for intercepting scroll window events | |
350 | from the receiving window. | |
351 | @event{EVT_SCROLLWIN(func)}: | |
352 | Process all scroll events. | |
353 | @event{EVT_SCROLLWIN_TOP(func)}: | |
354 | Process wxEVT_SCROLLWIN_TOP scroll-to-top events. | |
355 | @event{EVT_SCROLLWIN_BOTTOM(func)}: | |
356 | Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events. | |
357 | @event{EVT_SCROLLWIN_LINEUP(func)}: | |
358 | Process wxEVT_SCROLLWIN_LINEUP line up events. | |
359 | @event{EVT_SCROLLWIN_LINEDOWN(func)}: | |
360 | Process wxEVT_SCROLLWIN_LINEDOWN line down events. | |
361 | @event{EVT_SCROLLWIN_PAGEUP(func)}: | |
362 | Process wxEVT_SCROLLWIN_PAGEUP page up events. | |
363 | @event{EVT_SCROLLWIN_PAGEDOWN(func)}: | |
364 | Process wxEVT_SCROLLWIN_PAGEDOWN page down events. | |
365 | @event{EVT_SCROLLWIN_THUMBTRACK(func)}: | |
366 | Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events | |
367 | (frequent events sent as the user drags the thumbtrack). | |
368 | @event{EVT_SCROLLWIN_THUMBRELEASE(func)}: | |
369 | Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events. | |
370 | @endEventTable | |
371 | ||
372 | ||
23324ae1 FM |
373 | @library{wxcore} |
374 | @category{events} | |
7c913512 | 375 | |
1f1d2182 | 376 | @see wxScrollEvent, @ref overview_eventhandling |
23324ae1 FM |
377 | */ |
378 | class wxScrollWinEvent : public wxEvent | |
379 | { | |
380 | public: | |
381 | /** | |
382 | Constructor. | |
383 | */ | |
1f1d2182 | 384 | wxScrollWinEvent(wxEventType commandType = wxEVT_NULL, int pos = 0, |
23324ae1 FM |
385 | int orientation = 0); |
386 | ||
387 | /** | |
388 | Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the | |
389 | scrollbar. | |
1f1d2182 FM |
390 | |
391 | @todo wxHORIZONTAL and wxVERTICAL should go in their own enum | |
23324ae1 | 392 | */ |
328f5751 | 393 | int GetOrientation() const; |
23324ae1 FM |
394 | |
395 | /** | |
396 | Returns the position of the scrollbar for the thumb track and release events. | |
1f1d2182 | 397 | |
23324ae1 FM |
398 | Note that this field can't be used for the other events, you need to query |
399 | the window itself for the current position in that case. | |
400 | */ | |
328f5751 | 401 | int GetPosition() const; |
23324ae1 FM |
402 | }; |
403 | ||
404 | ||
e54c96f1 | 405 | |
23324ae1 FM |
406 | /** |
407 | @class wxSysColourChangedEvent | |
408 | @wxheader{event.h} | |
7c913512 | 409 | |
23324ae1 FM |
410 | This class is used for system colour change events, which are generated |
411 | when the user changes the colour settings using the control panel. | |
412 | This is only appropriate under Windows. | |
7c913512 | 413 | |
1f1d2182 FM |
414 | @remarks |
415 | The default event handler for this event propagates the event to child windows, | |
416 | since Windows only sends the events to top-level windows. | |
417 | If intercepting this event for a top-level window, remember to call the base | |
418 | class handler, or to pass the event on to the window's children explicitly. | |
419 | ||
420 | @beginEventTable{wxSysColourChangedEvent} | |
421 | @event{EVT_SYS_COLOUR_CHANGED(func)}: | |
422 | Process a wxEVT_SYS_COLOUR_CHANGED event. | |
423 | @endEventTable | |
424 | ||
23324ae1 FM |
425 | @library{wxcore} |
426 | @category{events} | |
7c913512 | 427 | |
1f1d2182 | 428 | @see @ref overview_eventhandling |
23324ae1 FM |
429 | */ |
430 | class wxSysColourChangedEvent : public wxEvent | |
431 | { | |
432 | public: | |
433 | /** | |
434 | Constructor. | |
435 | */ | |
436 | wxSysColourChangedEvent(); | |
437 | }; | |
438 | ||
439 | ||
e54c96f1 | 440 | |
23324ae1 FM |
441 | /** |
442 | @class wxWindowCreateEvent | |
443 | @wxheader{event.h} | |
7c913512 | 444 | |
23324ae1 | 445 | This event is sent just after the actual window associated with a wxWindow |
1f1d2182 FM |
446 | object has been created. |
447 | ||
448 | Since it is derived from wxCommandEvent, the event propagates up | |
23324ae1 | 449 | the window hierarchy. |
7c913512 | 450 | |
1f1d2182 FM |
451 | @beginEventTable{wxWindowCreateEvent} |
452 | @event{EVT_WINDOW_CREATE(func)}: | |
453 | Process a wxEVT_CREATE event. | |
454 | @endEventTable | |
455 | ||
23324ae1 FM |
456 | @library{wxcore} |
457 | @category{events} | |
7c913512 | 458 | |
1f1d2182 | 459 | @see @ref overview_eventhandling, wxWindowDestroyEvent |
23324ae1 FM |
460 | */ |
461 | class wxWindowCreateEvent : public wxCommandEvent | |
462 | { | |
463 | public: | |
464 | /** | |
465 | Constructor. | |
466 | */ | |
4cc4bfaf | 467 | wxWindowCreateEvent(wxWindow* win = NULL); |
23324ae1 FM |
468 | }; |
469 | ||
470 | ||
e54c96f1 | 471 | |
23324ae1 FM |
472 | /** |
473 | @class wxPaintEvent | |
474 | @wxheader{event.h} | |
7c913512 | 475 | |
23324ae1 | 476 | A paint event is sent when a window's contents needs to be repainted. |
7c913512 | 477 | |
23324ae1 | 478 | Please notice that in general it is impossible to change the drawing of a |
1f1d2182 FM |
479 | standard control (such as wxButton) and so you shouldn't attempt to handle |
480 | paint events for them as even if it might work on some platforms, this is | |
481 | inherently not portable and won't work everywhere. | |
482 | ||
483 | @remarks | |
484 | Note that in a paint event handler, the application must always create a | |
485 | wxPaintDC object, even if you do not use it. Otherwise, under MS Windows, | |
486 | refreshing for this and other windows will go wrong. | |
487 | For example: | |
488 | @code | |
489 | void MyWindow::OnPaint(wxPaintEvent& event) | |
490 | { | |
491 | wxPaintDC dc(this); | |
492 | ||
493 | DrawMyDocument(dc); | |
494 | } | |
495 | @endcode | |
496 | You can optimize painting by retrieving the rectangles that have been damaged | |
497 | and only repainting these. The rectangles are in terms of the client area, | |
498 | and are unscrolled, so you will need to do some calculations using the current | |
499 | view position to obtain logical, scrolled units. | |
500 | Here is an example of using the wxRegionIterator class: | |
501 | @code | |
502 | // Called when window needs to be repainted. | |
503 | void MyWindow::OnPaint(wxPaintEvent& event) | |
504 | { | |
505 | wxPaintDC dc(this); | |
506 | ||
507 | // Find Out where the window is scrolled to | |
508 | int vbX,vbY; // Top left corner of client | |
509 | GetViewStart(&vbX,&vbY); | |
510 | ||
511 | int vX,vY,vW,vH; // Dimensions of client area in pixels | |
512 | wxRegionIterator upd(GetUpdateRegion()); // get the update rect list | |
513 | ||
514 | while (upd) | |
515 | { | |
516 | vX = upd.GetX(); | |
517 | vY = upd.GetY(); | |
518 | vW = upd.GetW(); | |
519 | vH = upd.GetH(); | |
520 | ||
521 | // Alternatively we can do this: | |
522 | // wxRect rect(upd.GetRect()); | |
523 | ||
524 | // Repaint this rectangle | |
525 | ...some code... | |
526 | ||
527 | upd ++ ; | |
528 | } | |
529 | } | |
530 | @endcode | |
531 | ||
532 | ||
533 | @beginEventTable{wxPaintEvent} | |
534 | @event{EVT_PAINT(func)}: | |
535 | Process a wxEVT_PAINT event. | |
536 | @endEventTable | |
7c913512 | 537 | |
23324ae1 FM |
538 | @library{wxcore} |
539 | @category{events} | |
7c913512 | 540 | |
1f1d2182 | 541 | @see @ref overview_eventhandling |
23324ae1 FM |
542 | */ |
543 | class wxPaintEvent : public wxEvent | |
544 | { | |
545 | public: | |
546 | /** | |
547 | Constructor. | |
548 | */ | |
549 | wxPaintEvent(int id = 0); | |
550 | }; | |
551 | ||
552 | ||
e54c96f1 | 553 | |
23324ae1 FM |
554 | /** |
555 | @class wxMaximizeEvent | |
556 | @wxheader{event.h} | |
7c913512 | 557 | |
23324ae1 FM |
558 | An event being sent when a top level window is maximized. Notice that it is |
559 | not sent when the window is restored to its original size after it had been | |
1f1d2182 FM |
560 | maximized, only a normal wxSizeEvent is generated in this case. |
561 | ||
562 | @beginEventTable{wxMaximizeEvent} | |
563 | @event{EVT_MAXIMIZE(func)}: | |
564 | Process a wxEVT_MAXIMIZE event. | |
565 | @endEventTable | |
7c913512 | 566 | |
23324ae1 FM |
567 | @library{wxcore} |
568 | @category{events} | |
7c913512 | 569 | |
1f1d2182 FM |
570 | @see @ref overview_eventhandling, wxTopLevelWindow::Maximize, |
571 | wxTopLevelWindow::IsMaximized | |
23324ae1 FM |
572 | */ |
573 | class wxMaximizeEvent : public wxEvent | |
574 | { | |
575 | public: | |
576 | /** | |
577 | Constructor. Only used by wxWidgets internally. | |
578 | */ | |
579 | wxMaximizeEvent(int id = 0); | |
580 | }; | |
581 | ||
582 | ||
e54c96f1 | 583 | |
23324ae1 FM |
584 | /** |
585 | @class wxUpdateUIEvent | |
586 | @wxheader{event.h} | |
7c913512 | 587 | |
23324ae1 FM |
588 | This class is used for pseudo-events which are called by wxWidgets |
589 | to give an application the chance to update various user interface elements. | |
7c913512 | 590 | |
1f1d2182 FM |
591 | @remarks |
592 | Without update UI events, an application has to work hard to check/uncheck, | |
593 | enable/disable, show/hide, and set the text for elements such as menu items | |
594 | and toolbar buttons. The code for doing this has to be mixed up with the code | |
595 | that is invoked when an action is invoked for a menu item or button. | |
596 | With update UI events, you define an event handler to look at the state of the | |
597 | application and change UI elements accordingly. wxWidgets will call your member | |
598 | functions in idle time, so you don't have to worry where to call this code. | |
599 | In addition to being a clearer and more declarative method, it also means you don't | |
600 | have to worry whether you're updating a toolbar or menubar identifier. The same | |
601 | handler can update a menu item and toolbar button, if the identifier is the same. | |
602 | Instead of directly manipulating the menu or button, you call functions in the event | |
603 | object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a | |
604 | call has been made, and which UI element to update. | |
605 | These events will work for popup menus as well as menubars. Just before a menu is | |
606 | popped up, wxMenu::UpdateUI is called to process any UI events for the window that | |
607 | owns the menu. | |
608 | If you find that the overhead of UI update processing is affecting your application, | |
609 | you can do one or both of the following: | |
610 | @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED, | |
611 | and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should | |
612 | receive update events. No other windows will receive update events. | |
613 | @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay | |
614 | between updates. You may need to call wxWindow::UpdateWindowUI at critical points, | |
615 | for example when a dialog is about to be shown, in case the user sees a slight | |
616 | delay before windows are updated. | |
617 | Note that although events are sent in idle time, defining a wxIdleEvent handler | |
618 | for a window does not affect this because the events are sent from wxWindow::OnInternalIdle | |
619 | which is always called in idle time. | |
620 | wxWidgets tries to optimize update events on some platforms. | |
621 | On Windows and GTK+, events for menubar items are only sent when the menu is about | |
622 | to be shown, and not in idle time. | |
623 | ||
624 | @beginEventTable{wxUpdateUIEvent} | |
625 | @event{EVT_UPDATE_UI(id, func)}: | |
626 | Process a wxEVT_UPDATE_UI event for the command with the given id. | |
627 | @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}: | |
628 | Process a wxEVT_UPDATE_UI event for any command with id included in the given range. | |
629 | @endEventTable | |
630 | ||
631 | ||
23324ae1 FM |
632 | @library{wxcore} |
633 | @category{events} | |
7c913512 | 634 | |
1f1d2182 | 635 | @see @ref overview_eventhandling |
23324ae1 FM |
636 | */ |
637 | class wxUpdateUIEvent : public wxCommandEvent | |
638 | { | |
639 | public: | |
640 | /** | |
641 | Constructor. | |
642 | */ | |
643 | wxUpdateUIEvent(wxWindowID commandId = 0); | |
644 | ||
645 | /** | |
646 | Returns @true if it is appropriate to update (send UI update events to) | |
647 | this window. | |
23324ae1 FM |
648 | This function looks at the mode used (see wxUpdateUIEvent::SetMode), |
649 | the wxWS_EX_PROCESS_UI_UPDATES flag in @e window, | |
650 | the time update events were last sent in idle time, and | |
651 | the update interval, to determine whether events should be sent to | |
652 | this window now. By default this will always return @true because | |
653 | the update mode is initially wxUPDATE_UI_PROCESS_ALL and | |
654 | the interval is set to 0; so update events will be sent as | |
655 | often as possible. You can reduce the frequency that events | |
656 | are sent by changing the mode and/or setting an update interval. | |
3c4f71cc | 657 | |
4cc4bfaf FM |
658 | @see ResetUpdateTime(), SetUpdateInterval(), |
659 | SetMode() | |
23324ae1 FM |
660 | */ |
661 | static bool CanUpdate(wxWindow* window); | |
662 | ||
663 | /** | |
664 | Check or uncheck the UI element. | |
665 | */ | |
666 | void Check(bool check); | |
667 | ||
668 | /** | |
669 | Enable or disable the UI element. | |
670 | */ | |
671 | void Enable(bool enable); | |
672 | ||
673 | /** | |
674 | Returns @true if the UI element should be checked. | |
675 | */ | |
328f5751 | 676 | bool GetChecked() const; |
23324ae1 FM |
677 | |
678 | /** | |
679 | Returns @true if the UI element should be enabled. | |
680 | */ | |
328f5751 | 681 | bool GetEnabled() const; |
23324ae1 FM |
682 | |
683 | /** | |
684 | Static function returning a value specifying how wxWidgets | |
685 | will send update events: to all windows, or only to those which specify that | |
686 | they | |
687 | will process the events. | |
23324ae1 FM |
688 | See SetMode(). |
689 | */ | |
690 | static wxUpdateUIMode GetMode(); | |
691 | ||
692 | /** | |
693 | Returns @true if the application has called Check(). For wxWidgets internal use | |
694 | only. | |
695 | */ | |
328f5751 | 696 | bool GetSetChecked() const; |
23324ae1 FM |
697 | |
698 | /** | |
699 | Returns @true if the application has called Enable(). For wxWidgets internal use | |
700 | only. | |
701 | */ | |
328f5751 | 702 | bool GetSetEnabled() const; |
23324ae1 FM |
703 | |
704 | /** | |
705 | Returns @true if the application has called Show(). For wxWidgets internal use | |
706 | only. | |
707 | */ | |
328f5751 | 708 | bool GetSetShown() const; |
23324ae1 FM |
709 | |
710 | /** | |
711 | Returns @true if the application has called SetText(). For wxWidgets internal | |
712 | use only. | |
713 | */ | |
328f5751 | 714 | bool GetSetText() const; |
23324ae1 FM |
715 | |
716 | /** | |
717 | Returns @true if the UI element should be shown. | |
718 | */ | |
328f5751 | 719 | bool GetShown() const; |
23324ae1 FM |
720 | |
721 | /** | |
722 | Returns the text that should be set for the UI element. | |
723 | */ | |
328f5751 | 724 | wxString GetText() const; |
23324ae1 FM |
725 | |
726 | /** | |
727 | Returns the current interval between updates in milliseconds. | |
728 | -1 disables updates, 0 updates as frequently as possible. | |
23324ae1 FM |
729 | See SetUpdateInterval(). |
730 | */ | |
731 | static long GetUpdateInterval(); | |
732 | ||
733 | /** | |
734 | Used internally to reset the last-updated time to the | |
735 | current time. It is assumed that update events are | |
736 | normally sent in idle time, so this is called at the end of | |
737 | idle processing. | |
3c4f71cc | 738 | |
4cc4bfaf FM |
739 | @see CanUpdate(), SetUpdateInterval(), |
740 | SetMode() | |
23324ae1 FM |
741 | */ |
742 | static void ResetUpdateTime(); | |
743 | ||
744 | /** | |
745 | Specify how wxWidgets will send update events: to | |
746 | all windows, or only to those which specify that they | |
747 | will process the events. | |
4cc4bfaf | 748 | @a mode may be one of the following values. |
23324ae1 FM |
749 | The default is wxUPDATE_UI_PROCESS_ALL. |
750 | */ | |
751 | static void SetMode(wxUpdateUIMode mode); | |
752 | ||
753 | /** | |
754 | Sets the text for this UI element. | |
755 | */ | |
756 | void SetText(const wxString& text); | |
757 | ||
758 | /** | |
759 | Sets the interval between updates in milliseconds. | |
760 | Set to -1 to disable updates, or to 0 to update as frequently as possible. | |
761 | The default is 0. | |
23324ae1 FM |
762 | Use this to reduce the overhead of UI update events if your application |
763 | has a lot of windows. If you set the value to -1 or greater than 0, | |
7c913512 | 764 | you may also need to call wxWindow::UpdateWindowUI |
23324ae1 FM |
765 | at appropriate points in your application, such as when a dialog |
766 | is about to be shown. | |
767 | */ | |
768 | static void SetUpdateInterval(long updateInterval); | |
769 | ||
770 | /** | |
771 | Show or hide the UI element. | |
772 | */ | |
773 | void Show(bool show); | |
774 | }; | |
775 | ||
776 | ||
e54c96f1 | 777 | |
23324ae1 FM |
778 | /** |
779 | @class wxClipboardTextEvent | |
780 | @wxheader{event.h} | |
7c913512 FM |
781 | |
782 | This class represents the events generated by a control (typically a | |
23324ae1 FM |
783 | wxTextCtrl but other windows can generate these events as |
784 | well) when its content gets copied or cut to, or pasted from the clipboard. | |
785 | There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY, | |
786 | wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE. | |
7c913512 | 787 | |
23324ae1 | 788 | If any of these events is processed (without being skipped) by an event |
3d6c68c1 VS |
789 | handler, the corresponding operation doesn't take place which allows to |
790 | prevent the text from being copied from or pasted to a control. It is also | |
791 | possible to examine the clipboard contents in the PASTE event handler and | |
792 | transform it in some way before inserting in a control -- for example, | |
793 | changing its case or removing invalid characters. | |
7c913512 | 794 | |
23324ae1 | 795 | Finally notice that a CUT event is always preceded by the COPY event which |
3d6c68c1 VS |
796 | makes it possible to only process the latter if it doesn't matter if the |
797 | text was copied or cut. | |
798 | ||
1f1d2182 | 799 | @beginEventTable{wxClipboardTextEvent} |
3d6c68c1 VS |
800 | @event{EVT_TEXT_COPY(id, func)}: |
801 | Some or all of the controls content was copied to the clipboard. | |
802 | @event{EVT_TEXT_CUT(id, func)}: | |
803 | Some or all of the controls content was cut (i.e. copied and | |
804 | deleted). | |
805 | @event{EVT_TEXT_PASTE(id, func)}: | |
806 | Clipboard content was pasted into the control. | |
807 | @endEventTable | |
808 | ||
809 | @note | |
e2cf30aa VS |
810 | These events are currently only generated by wxTextCtrl under GTK+. They |
811 | are generated by all controls under Windows. | |
7c913512 | 812 | |
23324ae1 FM |
813 | @library{wxcore} |
814 | @category{events} | |
7c913512 | 815 | |
e54c96f1 | 816 | @see wxClipboard |
23324ae1 FM |
817 | */ |
818 | class wxClipboardTextEvent : public wxCommandEvent | |
819 | { | |
820 | public: | |
821 | /** | |
3d6c68c1 | 822 | Constructor. |
23324ae1 | 823 | */ |
3d6c68c1 | 824 | wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
825 | }; |
826 | ||
827 | ||
e54c96f1 | 828 | |
23324ae1 FM |
829 | /** |
830 | @class wxMouseEvent | |
831 | @wxheader{event.h} | |
7c913512 | 832 | |
23324ae1 FM |
833 | This event class contains information about the events generated by the mouse: |
834 | they include mouse buttons press and release events and mouse move events. | |
7c913512 | 835 | |
23324ae1 FM |
836 | All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the |
837 | left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and | |
838 | @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more | |
839 | buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events | |
840 | can also be generated. Note that not all mice have even a middle button so a | |
841 | portable application should avoid relying on the events from it (but the right | |
842 | button click can be emulated using the left mouse button with the control key | |
843 | under Mac platforms with a single button mouse). | |
7c913512 | 844 | |
23324ae1 FM |
845 | For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events |
846 | purposes, the mouse is considered to be inside the window if it is in the | |
847 | window client area and not inside one of its children. In other words, the | |
848 | parent window receives @c wxEVT_LEAVE_WINDOW event not only when the | |
849 | mouse leaves the window entirely but also when it enters one of its children. | |
7c913512 | 850 | |
1f1d2182 | 851 | @note Note that under Windows CE mouse enter and leave events are not natively |
23324ae1 FM |
852 | supported |
853 | by the system but are generated by wxWidgets itself. This has several | |
854 | drawbacks: the LEAVE_WINDOW event might be received some time after the mouse | |
855 | left the window and the state variables for it may have changed during this | |
856 | time. | |
7c913512 | 857 | |
1f1d2182 | 858 | @note Note the difference between methods like |
23324ae1 FM |
859 | wxMouseEvent::LeftDown and |
860 | wxMouseEvent::LeftIsDown: the former returns @true | |
861 | when the event corresponds to the left mouse button click while the latter | |
862 | returns @true if the left mouse button is currently being pressed. For | |
863 | example, when the user is dragging the mouse you can use | |
864 | wxMouseEvent::LeftIsDown to test | |
865 | whether the left mouse button is (still) depressed. Also, by convention, if | |
866 | wxMouseEvent::LeftDown returns @true, | |
867 | wxMouseEvent::LeftIsDown will also return @true in | |
868 | wxWidgets whatever the underlying GUI behaviour is (which is | |
869 | platform-dependent). The same applies, of course, to other mouse buttons as | |
870 | well. | |
7c913512 | 871 | |
23324ae1 FM |
872 | @library{wxcore} |
873 | @category{events} | |
7c913512 | 874 | |
e54c96f1 | 875 | @see wxKeyEvent::CmdDown |
23324ae1 FM |
876 | */ |
877 | class wxMouseEvent : public wxEvent | |
878 | { | |
879 | public: | |
880 | /** | |
881 | Constructor. Valid event types are: | |
3c4f71cc | 882 | |
23324ae1 FM |
883 | @b wxEVT_ENTER_WINDOW |
884 | @b wxEVT_LEAVE_WINDOW | |
885 | @b wxEVT_LEFT_DOWN | |
886 | @b wxEVT_LEFT_UP | |
887 | @b wxEVT_LEFT_DCLICK | |
888 | @b wxEVT_MIDDLE_DOWN | |
889 | @b wxEVT_MIDDLE_UP | |
890 | @b wxEVT_MIDDLE_DCLICK | |
891 | @b wxEVT_RIGHT_DOWN | |
892 | @b wxEVT_RIGHT_UP | |
893 | @b wxEVT_RIGHT_DCLICK | |
894 | @b wxEVT_MOUSE_AUX1_DOWN | |
895 | @b wxEVT_MOUSE_AUX1_UP | |
896 | @b wxEVT_MOUSE_AUX1_DCLICK | |
897 | @b wxEVT_MOUSE_AUX2_DOWN | |
898 | @b wxEVT_MOUSE_AUX2_UP | |
899 | @b wxEVT_MOUSE_AUX2_DCLICK | |
900 | @b wxEVT_MOTION | |
901 | @b wxEVT_MOUSEWHEEL | |
902 | */ | |
1d497b99 | 903 | wxMouseEvent(wxEventType mouseEventType = 0); |
23324ae1 FM |
904 | |
905 | /** | |
906 | Returns @true if the Alt key was down at the time of the event. | |
907 | */ | |
a6052817 | 908 | bool AltDown() const; |
23324ae1 FM |
909 | |
910 | /** | |
911 | Returns @true if the event was a first extra button double click. | |
912 | */ | |
328f5751 | 913 | bool Aux1DClick() const; |
23324ae1 FM |
914 | |
915 | /** | |
916 | Returns @true if the first extra button mouse button changed to down. | |
917 | */ | |
328f5751 | 918 | bool Aux1Down() const; |
23324ae1 FM |
919 | |
920 | /** | |
921 | Returns @true if the first extra button mouse button is currently down, | |
922 | independent | |
923 | of the current event type. | |
924 | */ | |
328f5751 | 925 | bool Aux1IsDown() const; |
23324ae1 FM |
926 | |
927 | /** | |
928 | Returns @true if the first extra button mouse button changed to up. | |
929 | */ | |
328f5751 | 930 | bool Aux1Up() const; |
23324ae1 FM |
931 | |
932 | /** | |
933 | Returns @true if the event was a second extra button double click. | |
934 | */ | |
328f5751 | 935 | bool Aux2DClick() const; |
23324ae1 FM |
936 | |
937 | /** | |
938 | Returns @true if the second extra button mouse button changed to down. | |
939 | */ | |
328f5751 | 940 | bool Aux2Down() const; |
23324ae1 FM |
941 | |
942 | /** | |
943 | Returns @true if the second extra button mouse button is currently down, | |
944 | independent | |
945 | of the current event type. | |
946 | */ | |
328f5751 | 947 | bool Aux2IsDown() const; |
23324ae1 FM |
948 | |
949 | /** | |
950 | Returns @true if the second extra button mouse button changed to up. | |
951 | */ | |
328f5751 | 952 | bool Aux2Up() const; |
23324ae1 FM |
953 | |
954 | /** | |
955 | Returns @true if the identified mouse button is changing state. Valid | |
4cc4bfaf | 956 | values of @a button are: |
3c4f71cc | 957 | |
23324ae1 | 958 | @c wxMOUSE_BTN_LEFT |
3c4f71cc | 959 | |
23324ae1 | 960 | check if left button was pressed |
3c4f71cc | 961 | |
23324ae1 | 962 | @c wxMOUSE_BTN_MIDDLE |
3c4f71cc | 963 | |
23324ae1 | 964 | check if middle button was pressed |
3c4f71cc | 965 | |
23324ae1 | 966 | @c wxMOUSE_BTN_RIGHT |
3c4f71cc | 967 | |
23324ae1 | 968 | check if right button was pressed |
3c4f71cc | 969 | |
23324ae1 | 970 | @c wxMOUSE_BTN_AUX1 |
3c4f71cc | 971 | |
23324ae1 | 972 | check if the first extra button was pressed |
3c4f71cc | 973 | |
23324ae1 | 974 | @c wxMOUSE_BTN_AUX2 |
3c4f71cc | 975 | |
23324ae1 | 976 | check if the second extra button was pressed |
3c4f71cc | 977 | |
23324ae1 | 978 | @c wxMOUSE_BTN_ANY |
3c4f71cc | 979 | |
23324ae1 FM |
980 | check if any button was pressed |
981 | */ | |
a6052817 | 982 | bool Button(int button) const; |
23324ae1 FM |
983 | |
984 | /** | |
985 | If the argument is omitted, this returns @true if the event was a mouse | |
986 | double click event. Otherwise the argument specifies which double click event | |
987 | was generated (see Button() for the possible | |
988 | values). | |
989 | */ | |
a6052817 | 990 | bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
991 | |
992 | /** | |
993 | If the argument is omitted, this returns @true if the event was a mouse | |
994 | button down event. Otherwise the argument specifies which button-down event | |
995 | was generated (see Button() for the possible | |
996 | values). | |
997 | */ | |
a6052817 | 998 | bool ButtonDown(int = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
999 | |
1000 | /** | |
1001 | If the argument is omitted, this returns @true if the event was a mouse | |
1002 | button up event. Otherwise the argument specifies which button-up event | |
1003 | was generated (see Button() for the possible | |
1004 | values). | |
1005 | */ | |
a6052817 | 1006 | bool ButtonUp(int = wxMOUSE_BTN_ANY) const; |
23324ae1 FM |
1007 | |
1008 | /** | |
7c913512 | 1009 | Same as MetaDown() under Mac, same as |
23324ae1 | 1010 | ControlDown() elsewhere. |
3c4f71cc | 1011 | |
4cc4bfaf | 1012 | @see wxKeyEvent::CmdDown |
23324ae1 | 1013 | */ |
328f5751 | 1014 | bool CmdDown() const; |
23324ae1 FM |
1015 | |
1016 | /** | |
1017 | Returns @true if the control key was down at the time of the event. | |
1018 | */ | |
a6052817 | 1019 | bool ControlDown() const; |
23324ae1 FM |
1020 | |
1021 | /** | |
1022 | Returns @true if this was a dragging event (motion while a button is depressed). | |
3c4f71cc | 1023 | |
4cc4bfaf | 1024 | @see Moving() |
23324ae1 | 1025 | */ |
a6052817 | 1026 | bool Dragging() const; |
23324ae1 FM |
1027 | |
1028 | /** | |
1029 | Returns @true if the mouse was entering the window. | |
23324ae1 FM |
1030 | See also Leaving(). |
1031 | */ | |
a6052817 | 1032 | bool Entering() const; |
23324ae1 FM |
1033 | |
1034 | /** | |
7c913512 | 1035 | Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE |
23324ae1 FM |
1036 | if no button is involved (for mouse move, enter or leave event, for example). |
1037 | Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and | |
7c913512 | 1038 | double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT |
23324ae1 FM |
1039 | for the same events for the middle and the right buttons respectively. |
1040 | */ | |
328f5751 | 1041 | int GetButton() const; |
23324ae1 FM |
1042 | |
1043 | /** | |
1044 | Returns the number of mouse clicks for this event: 1 for a simple click, 2 | |
1045 | for a double-click, 3 for a triple-click and so on. | |
23324ae1 FM |
1046 | Currently this function is implemented only in wxMac and returns -1 for the |
1047 | other platforms (you can still distinguish simple clicks from double-clicks as | |
1048 | they generate different kinds of events however). | |
3c4f71cc | 1049 | |
e54c96f1 | 1050 | @wxsince{2.9.0} |
23324ae1 | 1051 | */ |
328f5751 | 1052 | int GetClickCount() const; |
23324ae1 FM |
1053 | |
1054 | /** | |
1055 | Returns the configured number of lines (or whatever) to be scrolled per | |
1056 | wheel action. Defaults to three. | |
1057 | */ | |
328f5751 | 1058 | int GetLinesPerAction() const; |
23324ae1 FM |
1059 | |
1060 | /** | |
1061 | Returns the logical mouse position in pixels (i.e. translated according to the | |
1062 | translation set for the DC, which usually indicates that the window has been | |
1063 | scrolled). | |
1064 | */ | |
328f5751 | 1065 | wxPoint GetLogicalPosition(const wxDC& dc) const; |
23324ae1 FM |
1066 | |
1067 | //@{ | |
1068 | /** | |
1069 | Sets *x and *y to the position at which the event occurred. | |
23324ae1 | 1070 | Returns the physical mouse position in pixels. |
23324ae1 FM |
1071 | Note that if the mouse event has been artificially generated from a special |
1072 | keyboard combination (e.g. under Windows when the "menu'' key is pressed), the | |
1073 | returned position is @c wxDefaultPosition. | |
1074 | */ | |
328f5751 FM |
1075 | wxPoint GetPosition() const; |
1076 | const void GetPosition(wxCoord* x, wxCoord* y) const; | |
1077 | const void GetPosition(long* x, long* y) const; | |
23324ae1 FM |
1078 | //@} |
1079 | ||
1080 | /** | |
1081 | Get wheel delta, normally 120. This is the threshold for action to be | |
1082 | taken, and one such action (for example, scrolling one increment) | |
1083 | should occur for each delta. | |
1084 | */ | |
328f5751 | 1085 | int GetWheelDelta() const; |
23324ae1 FM |
1086 | |
1087 | /** | |
1088 | Get wheel rotation, positive or negative indicates direction of | |
1089 | rotation. Current devices all send an event when rotation is at least | |
1090 | +/-WheelDelta, but finer resolution devices can be created in the future. | |
1091 | Because of this you shouldn't assume that one event is equal to 1 line, but you | |
1092 | should be able to either do partial line scrolling or wait until several | |
1093 | events accumulate before scrolling. | |
1094 | */ | |
328f5751 | 1095 | int GetWheelRotation() const; |
23324ae1 FM |
1096 | |
1097 | /** | |
1098 | Returns X coordinate of the physical mouse event position. | |
1099 | */ | |
a6052817 | 1100 | wxCoord GetX() const; |
23324ae1 FM |
1101 | |
1102 | /** | |
1103 | Returns Y coordinate of the physical mouse event position. | |
1104 | */ | |
a6052817 | 1105 | wxCoord GetY() const; |
23324ae1 FM |
1106 | |
1107 | /** | |
1108 | Returns @true if the event was a mouse button event (not necessarily a button | |
1109 | down event - | |
1110 | that may be tested using @e ButtonDown). | |
1111 | */ | |
328f5751 | 1112 | bool IsButton() const; |
23324ae1 FM |
1113 | |
1114 | /** | |
1115 | Returns @true if the system has been setup to do page scrolling with | |
1116 | the mouse wheel instead of line scrolling. | |
1117 | */ | |
328f5751 | 1118 | bool IsPageScroll() const; |
23324ae1 FM |
1119 | |
1120 | /** | |
1121 | Returns @true if the mouse was leaving the window. | |
23324ae1 FM |
1122 | See also Entering(). |
1123 | */ | |
328f5751 | 1124 | bool Leaving() const; |
23324ae1 FM |
1125 | |
1126 | /** | |
1127 | Returns @true if the event was a left double click. | |
1128 | */ | |
328f5751 | 1129 | bool LeftDClick() const; |
23324ae1 FM |
1130 | |
1131 | /** | |
1132 | Returns @true if the left mouse button changed to down. | |
1133 | */ | |
328f5751 | 1134 | bool LeftDown() const; |
23324ae1 FM |
1135 | |
1136 | /** | |
1137 | Returns @true if the left mouse button is currently down, independent | |
1138 | of the current event type. | |
7c913512 | 1139 | Please notice that it is not the same as |
23324ae1 FM |
1140 | LeftDown() which returns @true if the event was |
1141 | generated by the left mouse button being pressed. Rather, it simply describes | |
1142 | the state of the left mouse button at the time when the event was generated | |
1143 | (so while it will be @true for a left click event, it can also be @true for | |
1144 | a right click if it happened while the left mouse button was pressed). | |
23324ae1 FM |
1145 | This event is usually used in the mouse event handlers which process "move |
1146 | mouse" messages to determine whether the user is (still) dragging the mouse. | |
1147 | */ | |
328f5751 | 1148 | bool LeftIsDown() const; |
23324ae1 FM |
1149 | |
1150 | /** | |
1151 | Returns @true if the left mouse button changed to up. | |
1152 | */ | |
328f5751 | 1153 | bool LeftUp() const; |
23324ae1 FM |
1154 | |
1155 | /** | |
1156 | Returns @true if the Meta key was down at the time of the event. | |
1157 | */ | |
328f5751 | 1158 | bool MetaDown() const; |
23324ae1 FM |
1159 | |
1160 | /** | |
1161 | Returns @true if the event was a middle double click. | |
1162 | */ | |
328f5751 | 1163 | bool MiddleDClick() const; |
23324ae1 FM |
1164 | |
1165 | /** | |
1166 | Returns @true if the middle mouse button changed to down. | |
1167 | */ | |
328f5751 | 1168 | bool MiddleDown() const; |
23324ae1 FM |
1169 | |
1170 | /** | |
1171 | Returns @true if the middle mouse button is currently down, independent | |
1172 | of the current event type. | |
1173 | */ | |
328f5751 | 1174 | bool MiddleIsDown() const; |
23324ae1 FM |
1175 | |
1176 | /** | |
1177 | Returns @true if the middle mouse button changed to up. | |
1178 | */ | |
328f5751 | 1179 | bool MiddleUp() const; |
23324ae1 FM |
1180 | |
1181 | /** | |
7c913512 FM |
1182 | Returns @true if this was a motion event and no mouse buttons were pressed. |
1183 | If any mouse button is held pressed, then this method returns @false and | |
23324ae1 FM |
1184 | Dragging() returns @true. |
1185 | */ | |
328f5751 | 1186 | bool Moving() const; |
23324ae1 FM |
1187 | |
1188 | /** | |
1189 | Returns @true if the event was a right double click. | |
1190 | */ | |
328f5751 | 1191 | bool RightDClick() const; |
23324ae1 FM |
1192 | |
1193 | /** | |
1194 | Returns @true if the right mouse button changed to down. | |
1195 | */ | |
328f5751 | 1196 | bool RightDown() const; |
23324ae1 FM |
1197 | |
1198 | /** | |
1199 | Returns @true if the right mouse button is currently down, independent | |
1200 | of the current event type. | |
1201 | */ | |
328f5751 | 1202 | bool RightIsDown() const; |
23324ae1 FM |
1203 | |
1204 | /** | |
1205 | Returns @true if the right mouse button changed to up. | |
1206 | */ | |
328f5751 | 1207 | bool RightUp() const; |
23324ae1 FM |
1208 | |
1209 | /** | |
1210 | Returns @true if the shift key was down at the time of the event. | |
1211 | */ | |
328f5751 | 1212 | bool ShiftDown() const; |
23324ae1 FM |
1213 | |
1214 | /** | |
1215 | bool m_altDown | |
23324ae1 FM |
1216 | @true if the Alt key is pressed down. |
1217 | */ | |
1218 | ||
1219 | ||
1220 | /** | |
1221 | bool m_controlDown | |
23324ae1 FM |
1222 | @true if control key is pressed down. |
1223 | */ | |
1224 | ||
1225 | ||
1226 | /** | |
1227 | bool m_leftDown | |
23324ae1 FM |
1228 | @true if the left mouse button is currently pressed down. |
1229 | */ | |
1230 | ||
1231 | ||
1232 | /** | |
1233 | int m_linesPerAction | |
23324ae1 FM |
1234 | The configured number of lines (or whatever) to be scrolled per wheel |
1235 | action. | |
1236 | */ | |
1237 | ||
1238 | ||
1239 | /** | |
1240 | bool m_metaDown | |
23324ae1 FM |
1241 | @true if the Meta key is pressed down. |
1242 | */ | |
1243 | ||
1244 | ||
1245 | /** | |
1246 | bool m_middleDown | |
23324ae1 FM |
1247 | @true if the middle mouse button is currently pressed down. |
1248 | */ | |
1249 | ||
1250 | ||
1251 | /** | |
1252 | bool m_rightDown | |
23324ae1 FM |
1253 | @true if the right mouse button is currently pressed down. |
1254 | */ | |
1255 | ||
1256 | ||
1257 | /** | |
1258 | bool m_shiftDown | |
23324ae1 FM |
1259 | @true if shift is pressed down. |
1260 | */ | |
1261 | ||
1262 | ||
1263 | /** | |
1264 | int m_wheelDelta | |
23324ae1 FM |
1265 | The wheel delta, normally 120. |
1266 | */ | |
1267 | ||
1268 | ||
1269 | /** | |
1270 | int m_wheelRotation | |
23324ae1 FM |
1271 | The distance the mouse wheel is rotated. |
1272 | */ | |
1273 | ||
1274 | ||
1275 | /** | |
1276 | long m_x | |
23324ae1 FM |
1277 | X-coordinate of the event. |
1278 | */ | |
1279 | ||
1280 | ||
1281 | /** | |
1282 | long m_y | |
23324ae1 FM |
1283 | Y-coordinate of the event. |
1284 | */ | |
1285 | }; | |
1286 | ||
1287 | ||
e54c96f1 | 1288 | |
23324ae1 FM |
1289 | /** |
1290 | @class wxDropFilesEvent | |
1291 | @wxheader{event.h} | |
7c913512 | 1292 | |
23324ae1 FM |
1293 | This class is used for drop files events, that is, when files have been dropped |
1294 | onto the window. This functionality is currently only available under Windows. | |
7c913512 | 1295 | The window must have previously been enabled for dropping by calling |
23324ae1 | 1296 | wxWindow::DragAcceptFiles. |
7c913512 | 1297 | |
23324ae1 | 1298 | Important note: this is a separate implementation to the more general |
e54c96f1 | 1299 | drag and drop implementation documented here(). It uses the |
23324ae1 | 1300 | older, Windows message-based approach of dropping files. |
7c913512 | 1301 | |
23324ae1 FM |
1302 | @library{wxcore} |
1303 | @category{events} | |
7c913512 | 1304 | |
1f1d2182 | 1305 | @see @ref overview_eventhandling |
23324ae1 FM |
1306 | */ |
1307 | class wxDropFilesEvent : public wxEvent | |
1308 | { | |
1309 | public: | |
1310 | /** | |
1311 | Constructor. | |
1312 | */ | |
1d497b99 | 1313 | wxDropFilesEvent(wxEventType id = 0, int noFiles = 0, |
4cc4bfaf | 1314 | wxString* files = NULL); |
23324ae1 FM |
1315 | |
1316 | /** | |
1317 | Returns an array of filenames. | |
1318 | */ | |
328f5751 | 1319 | wxString* GetFiles() const; |
23324ae1 FM |
1320 | |
1321 | /** | |
1322 | Returns the number of files dropped. | |
1323 | */ | |
328f5751 | 1324 | int GetNumberOfFiles() const; |
23324ae1 FM |
1325 | |
1326 | /** | |
1327 | Returns the position at which the files were dropped. | |
23324ae1 FM |
1328 | Returns an array of filenames. |
1329 | */ | |
328f5751 | 1330 | wxPoint GetPosition() const; |
23324ae1 FM |
1331 | |
1332 | /** | |
1333 | wxString* m_files | |
23324ae1 FM |
1334 | An array of filenames. |
1335 | */ | |
1336 | ||
1337 | ||
1338 | /** | |
1339 | int m_noFiles | |
23324ae1 FM |
1340 | The number of files dropped. |
1341 | */ | |
1342 | ||
1343 | ||
1344 | /** | |
1345 | wxPoint m_pos | |
23324ae1 FM |
1346 | The point at which the drop took place. |
1347 | */ | |
1348 | }; | |
1349 | ||
1350 | ||
e54c96f1 | 1351 | |
23324ae1 FM |
1352 | /** |
1353 | @class wxCommandEvent | |
1354 | @wxheader{event.h} | |
7c913512 | 1355 | |
23324ae1 FM |
1356 | This event class contains information about command events, which originate |
1357 | from a variety of | |
1358 | simple controls. More complex controls, such as wxTreeCtrl, have separate | |
1359 | command event classes. | |
7c913512 | 1360 | |
23324ae1 FM |
1361 | @library{wxcore} |
1362 | @category{events} | |
1363 | */ | |
1364 | class wxCommandEvent : public wxEvent | |
1365 | { | |
1366 | public: | |
1367 | /** | |
1368 | Constructor. | |
1369 | */ | |
1d497b99 | 1370 | wxCommandEvent(wxEventType commandEventType = 0, int id = 0); |
23324ae1 FM |
1371 | |
1372 | /** | |
1373 | Deprecated, use IsChecked() instead. | |
1374 | */ | |
328f5751 | 1375 | bool Checked() const; |
23324ae1 FM |
1376 | |
1377 | /** | |
1378 | Returns client data pointer for a listbox or choice selection event | |
1379 | (not valid for a deselection). | |
1380 | */ | |
a6052817 | 1381 | void* GetClientData() const; |
23324ae1 FM |
1382 | |
1383 | /** | |
1384 | Returns client object pointer for a listbox or choice selection event | |
1385 | (not valid for a deselection). | |
1386 | */ | |
a6052817 | 1387 | wxClientData* GetClientObject() const; |
23324ae1 FM |
1388 | |
1389 | /** | |
1390 | Returns extra information dependant on the event objects type. | |
1391 | If the event comes from a listbox selection, it is a boolean | |
1392 | determining whether the event was a selection (@true) or a | |
1393 | deselection (@false). A listbox deselection only occurs for | |
1394 | multiple-selection boxes, and in this case the index and string values | |
1395 | are indeterminate and the listbox must be examined by the application. | |
1396 | */ | |
a6052817 | 1397 | long GetExtraLong() const; |
23324ae1 FM |
1398 | |
1399 | /** | |
1400 | Returns the integer identifier corresponding to a listbox, choice or | |
1401 | radiobox selection (only if the event was a selection, not a | |
1402 | deselection), or a boolean value representing the value of a checkbox. | |
1403 | */ | |
a6052817 | 1404 | int GetInt() const; |
23324ae1 FM |
1405 | |
1406 | /** | |
1407 | Returns item index for a listbox or choice selection event (not valid for | |
1408 | a deselection). | |
1409 | */ | |
a6052817 | 1410 | int GetSelection() const; |
23324ae1 FM |
1411 | |
1412 | /** | |
1413 | Returns item string for a listbox or choice selection event (not valid for | |
1414 | a deselection). | |
1415 | */ | |
a6052817 | 1416 | wxString GetString() const; |
23324ae1 FM |
1417 | |
1418 | /** | |
1419 | This method can be used with checkbox and menu events: for the checkboxes, the | |
1420 | method returns @true for a selection event and @false for a | |
1421 | deselection one. For the menu events, this method indicates if the menu item | |
1422 | just has become checked or unchecked (and thus only makes sense for checkable | |
1423 | menu items). | |
7c913512 | 1424 | Notice that this method can not be used with |
23324ae1 FM |
1425 | wxCheckListBox currently. |
1426 | */ | |
328f5751 | 1427 | bool IsChecked() const; |
23324ae1 FM |
1428 | |
1429 | /** | |
1430 | For a listbox or similar event, returns @true if it is a selection, @false if it | |
1431 | is a deselection. | |
1432 | */ | |
a6052817 | 1433 | bool IsSelection() const; |
23324ae1 FM |
1434 | |
1435 | /** | |
1436 | Sets the client data for this event. | |
1437 | */ | |
1438 | void SetClientData(void* clientData); | |
1439 | ||
1440 | /** | |
1441 | Sets the client object for this event. The client object is not owned by the | |
1442 | event | |
1443 | object and the event object will not delete the client object in its destructor. | |
1444 | The client object must be owned and deleted by another object (e.g. a control) | |
1445 | that has longer life time than the event object. | |
1446 | */ | |
1447 | void SetClientObject(wxClientData* clientObject); | |
1448 | ||
1449 | /** | |
1450 | Sets the @b m_extraLong member. | |
1451 | */ | |
1452 | void SetExtraLong(long extraLong); | |
1453 | ||
1454 | /** | |
1455 | Sets the @b m_commandInt member. | |
1456 | */ | |
1457 | void SetInt(int intCommand); | |
1458 | ||
1459 | /** | |
1460 | Sets the @b m_commandString member. | |
1461 | */ | |
1462 | void SetString(const wxString& string); | |
1463 | }; | |
1464 | ||
1465 | ||
e54c96f1 | 1466 | |
23324ae1 FM |
1467 | /** |
1468 | @class wxActivateEvent | |
1469 | @wxheader{event.h} | |
7c913512 | 1470 | |
23324ae1 FM |
1471 | An activate event is sent when a window or application is being activated |
1472 | or deactivated. | |
7c913512 | 1473 | |
23324ae1 FM |
1474 | @library{wxcore} |
1475 | @category{events} | |
7c913512 | 1476 | |
1f1d2182 | 1477 | @see @ref overview_eventhandling, wxApp::IsActive |
23324ae1 FM |
1478 | */ |
1479 | class wxActivateEvent : public wxEvent | |
1480 | { | |
1481 | public: | |
1482 | /** | |
1483 | Constructor. | |
1484 | */ | |
1d497b99 | 1485 | wxActivateEvent(wxEventType eventType = wxEVT_NULL, bool active = true, |
23324ae1 FM |
1486 | int id = 0); |
1487 | ||
1488 | /** | |
1489 | Returns @true if the application or window is being activated, @false otherwise. | |
1490 | */ | |
328f5751 | 1491 | bool GetActive() const; |
23324ae1 FM |
1492 | }; |
1493 | ||
1494 | ||
e54c96f1 | 1495 | |
23324ae1 FM |
1496 | /** |
1497 | @class wxContextMenuEvent | |
1498 | @wxheader{event.h} | |
7c913512 | 1499 | |
23324ae1 FM |
1500 | This class is used for context menu events, sent to give |
1501 | the application a chance to show a context (popup) menu. | |
7c913512 | 1502 | |
23324ae1 FM |
1503 | Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this |
1504 | means that the event originated | |
1505 | from a keyboard context button event, and you should compute a suitable | |
1506 | position yourself, | |
e54c96f1 | 1507 | for example by calling wxGetMousePosition(). |
7c913512 | 1508 | |
23324ae1 FM |
1509 | When a keyboard context menu button is pressed on Windows, a right-click event |
1510 | with default position is sent first, | |
1511 | and if this event is not processed, the context menu event is sent. So if you | |
1512 | process mouse events and you find your context menu event handler | |
1513 | is not being called, you could call wxEvent::Skip for mouse right-down events. | |
7c913512 | 1514 | |
23324ae1 FM |
1515 | @library{wxcore} |
1516 | @category{events} | |
7c913512 | 1517 | |
e54c96f1 | 1518 | @see @ref overview_wxcommandevent "Command events", @ref |
1f1d2182 | 1519 | overview_eventhandling |
23324ae1 FM |
1520 | */ |
1521 | class wxContextMenuEvent : public wxCommandEvent | |
1522 | { | |
1523 | public: | |
1524 | /** | |
1525 | Constructor. | |
1526 | */ | |
1d497b99 | 1527 | wxContextMenuEvent(wxEventType id = 0, int id = 0, |
4cc4bfaf | 1528 | const wxPoint& pos = wxDefaultPosition); |
23324ae1 FM |
1529 | |
1530 | /** | |
1531 | Returns the position in screen coordinates at which the menu should be shown. | |
1532 | Use wxWindow::ScreenToClient to | |
1533 | convert to client coordinates. You can also omit a position from | |
1534 | wxWindow::PopupMenu in order to use | |
1535 | the current mouse pointer position. | |
23324ae1 FM |
1536 | If the event originated from a keyboard event, the value returned from this |
1537 | function will be wxDefaultPosition. | |
1538 | */ | |
a6052817 | 1539 | const wxPoint& GetPosition() const; |
23324ae1 FM |
1540 | |
1541 | /** | |
1542 | Sets the position at which the menu should be shown. | |
1543 | */ | |
1544 | void SetPosition(const wxPoint& point); | |
1545 | }; | |
1546 | ||
1547 | ||
e54c96f1 | 1548 | |
23324ae1 FM |
1549 | /** |
1550 | @class wxEraseEvent | |
1551 | @wxheader{event.h} | |
7c913512 | 1552 | |
23324ae1 | 1553 | An erase event is sent when a window's background needs to be repainted. |
7c913512 | 1554 | |
23324ae1 FM |
1555 | On some platforms, such as GTK+, this event is simulated (simply generated just |
1556 | before the | |
1557 | paint event) and may cause flicker. It is therefore recommended that | |
1558 | you set the text background colour explicitly in order to prevent flicker. | |
1559 | The default background colour under GTK+ is grey. | |
7c913512 | 1560 | |
23324ae1 FM |
1561 | To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table |
1562 | definition. | |
7c913512 | 1563 | |
23324ae1 FM |
1564 | You must call wxEraseEvent::GetDC and use the returned device context if it is |
1565 | non-@NULL. | |
7c913512 FM |
1566 | If it is @NULL, create your own temporary wxClientDC object. |
1567 | ||
23324ae1 FM |
1568 | @library{wxcore} |
1569 | @category{events} | |
7c913512 | 1570 | |
1f1d2182 | 1571 | @see @ref overview_eventhandling |
23324ae1 FM |
1572 | */ |
1573 | class wxEraseEvent : public wxEvent | |
1574 | { | |
1575 | public: | |
1576 | /** | |
1577 | Constructor. | |
1578 | */ | |
4cc4bfaf | 1579 | wxEraseEvent(int id = 0, wxDC* dc = NULL); |
23324ae1 FM |
1580 | |
1581 | /** | |
1582 | Returns the device context associated with the erase event to draw on. | |
1583 | */ | |
328f5751 | 1584 | wxDC* GetDC() const; |
23324ae1 FM |
1585 | }; |
1586 | ||
1587 | ||
e54c96f1 | 1588 | |
23324ae1 FM |
1589 | /** |
1590 | @class wxFocusEvent | |
1591 | @wxheader{event.h} | |
7c913512 | 1592 | |
23324ae1 FM |
1593 | A focus event is sent when a window's focus changes. The window losing focus |
1594 | receives a "kill focus'' event while the window gaining it gets a "set | |
1595 | focus'' one. | |
7c913512 | 1596 | |
23324ae1 FM |
1597 | Notice that the set focus event happens both when the user gives focus to the |
1598 | window (whether using the mouse or keyboard) and when it is done from the | |
1599 | program itself using wxWindow::SetFocus. | |
7c913512 | 1600 | |
23324ae1 FM |
1601 | @library{wxcore} |
1602 | @category{events} | |
7c913512 | 1603 | |
1f1d2182 | 1604 | @see @ref overview_eventhandling |
23324ae1 FM |
1605 | */ |
1606 | class wxFocusEvent : public wxEvent | |
1607 | { | |
1608 | public: | |
1609 | /** | |
1610 | Constructor. | |
1611 | */ | |
1d497b99 | 1612 | wxFocusEvent(wxEventType eventType = 0, int id = 0); |
23324ae1 FM |
1613 | |
1614 | /** | |
1615 | Returns the window associated with this event, that is the window which had the | |
1616 | focus before for the @c wxEVT_SET_FOCUS event and the window which is | |
1617 | going to receive focus for the @c wxEVT_KILL_FOCUS one. | |
23324ae1 FM |
1618 | Warning: the window pointer may be @NULL! |
1619 | */ | |
1620 | }; | |
1621 | ||
1622 | ||
e54c96f1 | 1623 | |
23324ae1 FM |
1624 | /** |
1625 | @class wxChildFocusEvent | |
1626 | @wxheader{event.h} | |
7c913512 | 1627 | |
23324ae1 FM |
1628 | A child focus event is sent to a (parent-)window when one of its child windows |
1629 | gains focus, | |
1630 | so that the window could restore the focus back to its corresponding child | |
1631 | if it loses it now and regains later. | |
7c913512 | 1632 | |
23324ae1 | 1633 | Notice that child window is the direct child of the window receiving event. |
7c913512 FM |
1634 | Use wxWindow::FindFocus to retreive the window which is actually getting focus. |
1635 | ||
23324ae1 FM |
1636 | @library{wxcore} |
1637 | @category{events} | |
7c913512 | 1638 | |
1f1d2182 | 1639 | @see @ref overview_eventhandling |
23324ae1 FM |
1640 | */ |
1641 | class wxChildFocusEvent : public wxCommandEvent | |
1642 | { | |
1643 | public: | |
1644 | /** | |
1645 | Constructor. | |
3c4f71cc | 1646 | |
7c913512 | 1647 | @param win |
4cc4bfaf FM |
1648 | The direct child which is (or which contains the window which is) receiving |
1649 | the focus. | |
23324ae1 | 1650 | */ |
4cc4bfaf | 1651 | wxChildFocusEvent(wxWindow* win = NULL); |
23324ae1 FM |
1652 | |
1653 | /** | |
1654 | Returns the direct child which receives the focus, or a (grand-)parent of the | |
1655 | control receiving the focus. | |
23324ae1 FM |
1656 | To get the actually focused control use wxWindow::FindFocus. |
1657 | */ | |
1658 | }; | |
1659 | ||
1660 | ||
e54c96f1 | 1661 | |
23324ae1 FM |
1662 | /** |
1663 | @class wxMouseCaptureLostEvent | |
1664 | @wxheader{event.h} | |
7c913512 | 1665 | |
23324ae1 FM |
1666 | An mouse capture lost event is sent to a window that obtained mouse capture, |
1667 | which was subsequently loss due to "external" event, for example when a dialog | |
1668 | box is shown or if another application captures the mouse. | |
7c913512 | 1669 | |
23324ae1 FM |
1670 | If this happens, this event is sent to all windows that are on capture stack |
1671 | (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is | |
1672 | not sent if the capture changes because of a call to CaptureMouse or | |
1673 | ReleaseMouse. | |
7c913512 | 1674 | |
23324ae1 | 1675 | This event is currently emitted under Windows only. |
7c913512 | 1676 | |
23324ae1 FM |
1677 | @library{wxcore} |
1678 | @category{events} | |
7c913512 | 1679 | |
1f1d2182 | 1680 | @see wxMouseCaptureChangedEvent, @ref overview_eventhandling, |
4cc4bfaf | 1681 | wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture |
23324ae1 FM |
1682 | */ |
1683 | class wxMouseCaptureLostEvent : public wxEvent | |
1684 | { | |
1685 | public: | |
1686 | /** | |
1687 | Constructor. | |
1688 | */ | |
1689 | wxMouseCaptureLostEvent(wxWindowID windowId = 0); | |
1690 | }; | |
1691 | ||
1692 | ||
e54c96f1 | 1693 | |
23324ae1 FM |
1694 | /** |
1695 | @class wxNotifyEvent | |
1696 | @wxheader{event.h} | |
7c913512 | 1697 | |
23324ae1 FM |
1698 | This class is not used by the event handlers by itself, but is a base class |
1699 | for other event classes (such as wxNotebookEvent). | |
7c913512 | 1700 | |
23324ae1 FM |
1701 | It (or an object of a derived class) is sent when the controls state is being |
1702 | changed and allows the program to wxNotifyEvent::Veto this | |
1703 | change if it wants to prevent it from happening. | |
7c913512 | 1704 | |
23324ae1 FM |
1705 | @library{wxcore} |
1706 | @category{events} | |
7c913512 | 1707 | |
e54c96f1 | 1708 | @see wxNotebookEvent |
23324ae1 FM |
1709 | */ |
1710 | class wxNotifyEvent : public wxCommandEvent | |
1711 | { | |
1712 | public: | |
1713 | /** | |
1714 | Constructor (used internally by wxWidgets only). | |
1715 | */ | |
4cc4bfaf | 1716 | wxNotifyEvent(wxEventType eventType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
1717 | |
1718 | /** | |
1719 | This is the opposite of Veto(): it explicitly | |
1720 | allows the event to be processed. For most events it is not necessary to call | |
1721 | this method as the events are allowed anyhow but some are forbidden by default | |
1722 | (this will be mentioned in the corresponding event description). | |
1723 | */ | |
1724 | void Allow(); | |
1725 | ||
1726 | /** | |
7c913512 | 1727 | Returns @true if the change is allowed (Veto() |
23324ae1 FM |
1728 | hasn't been called) or @false otherwise (if it was). |
1729 | */ | |
328f5751 | 1730 | bool IsAllowed() const; |
23324ae1 FM |
1731 | |
1732 | /** | |
1733 | Prevents the change announced by this event from happening. | |
23324ae1 FM |
1734 | It is in general a good idea to notify the user about the reasons for vetoing |
1735 | the change because otherwise the applications behaviour (which just refuses to | |
1736 | do what the user wants) might be quite surprising. | |
1737 | */ | |
1738 | void Veto(); | |
1739 | }; | |
1740 | ||
1741 | ||
e54c96f1 | 1742 | |
23324ae1 FM |
1743 | /** |
1744 | @class wxHelpEvent | |
1745 | @wxheader{event.h} | |
7c913512 | 1746 | |
23324ae1 FM |
1747 | A help event is sent when the user has requested context-sensitive help. |
1748 | This can either be caused by the application requesting | |
1749 | context-sensitive help mode via wxContextHelp, or | |
1750 | (on MS Windows) by the system generating a WM_HELP message when the user | |
1751 | pressed F1 or clicked | |
1752 | on the query button in a dialog caption. | |
7c913512 | 1753 | |
23324ae1 FM |
1754 | A help event is sent to the window that the user clicked on, and is propagated |
1755 | up the | |
1756 | window hierarchy until the event is processed or there are no more event | |
1757 | handlers. | |
1758 | The application should call wxEvent::GetId to check the identity of the | |
1759 | clicked-on window, | |
1760 | and then either show some suitable help or call wxEvent::Skip if the identifier | |
1761 | is unrecognised. | |
1762 | Calling Skip is important because it allows wxWidgets to generate further | |
1763 | events for ancestors | |
1764 | of the clicked-on window. Otherwise it would be impossible to show help for | |
1765 | container windows, | |
1766 | since processing would stop after the first window found. | |
7c913512 | 1767 | |
23324ae1 | 1768 | @library{wxcore} |
1f1d2182 | 1769 | @category{events} |
7c913512 | 1770 | |
1f1d2182 | 1771 | @see wxContextHelp, wxDialog, @ref overview_eventhandling |
23324ae1 FM |
1772 | */ |
1773 | class wxHelpEvent : public wxCommandEvent | |
1774 | { | |
1775 | public: | |
a6052817 FM |
1776 | // how was this help event generated? |
1777 | enum Origin | |
1778 | { | |
1779 | Origin_Unknown, // unrecognized event source | |
1780 | Origin_Keyboard, // event generated from F1 key press | |
1781 | Origin_HelpButton // event from [?] button on the title bar (Windows) | |
1782 | }; | |
1783 | ||
23324ae1 FM |
1784 | /** |
1785 | Constructor. | |
1786 | */ | |
a6052817 FM |
1787 | wxHelpEvent(wxEventType type = wxEVT_NULL, |
1788 | wxWindowID winid = 0, | |
1789 | const wxPoint& pt = wxDefaultPosition, | |
1790 | Origin origin = Origin_Unknown); | |
23324ae1 FM |
1791 | |
1792 | /** | |
1793 | Returns the origin of the help event which is one of the following values: | |
3c4f71cc | 1794 | |
23324ae1 | 1795 | @b Origin_Unknown |
3c4f71cc | 1796 | |
23324ae1 | 1797 | Unrecognized event source. |
3c4f71cc | 1798 | |
23324ae1 | 1799 | @b Origin_Keyboard |
3c4f71cc | 1800 | |
23324ae1 | 1801 | Event generated by @c F1 key press. |
3c4f71cc | 1802 | |
23324ae1 | 1803 | @b Origin_HelpButton |
3c4f71cc | 1804 | |
7c913512 | 1805 | Event generated by |
23324ae1 FM |
1806 | wxContextHelp or using the "?" title bur button under |
1807 | MS Windows. | |
3c4f71cc | 1808 | |
23324ae1 | 1809 | The application may handle events generated using the keyboard or mouse |
e54c96f1 | 1810 | differently, e.g. by using wxGetMousePosition() |
23324ae1 | 1811 | for the mouse events. |
3c4f71cc | 1812 | |
4cc4bfaf | 1813 | @see SetOrigin() |
23324ae1 | 1814 | */ |
a6052817 | 1815 | Origin GetOrigin() const; |
23324ae1 FM |
1816 | |
1817 | /** | |
1818 | Returns the left-click position of the mouse, in screen coordinates. This allows | |
1819 | the application to position the help appropriately. | |
1820 | */ | |
a6052817 | 1821 | const wxPoint& GetPosition() const; |
23324ae1 FM |
1822 | |
1823 | /** | |
1824 | Set the help event origin, only used internally by wxWidgets normally. | |
3c4f71cc | 1825 | |
4cc4bfaf | 1826 | @see GetOrigin() |
23324ae1 | 1827 | */ |
a6052817 | 1828 | void SetOrigin(Origin); |
23324ae1 FM |
1829 | |
1830 | /** | |
1831 | Sets the left-click position of the mouse, in screen coordinates. | |
1832 | */ | |
1833 | void SetPosition(const wxPoint& pt); | |
1834 | }; | |
1835 | ||
1836 | ||
e54c96f1 | 1837 | |
23324ae1 FM |
1838 | /** |
1839 | @class wxScrollEvent | |
1840 | @wxheader{event.h} | |
7c913512 | 1841 | |
23324ae1 | 1842 | A scroll event holds information about events sent from stand-alone |
e54c96f1 | 1843 | scrollbars() and sliders(). Note that |
7c913512 | 1844 | starting from wxWidgets 2.1, scrolled windows send the |
23324ae1 FM |
1845 | wxScrollWinEvent which does not derive from |
1846 | wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of | |
1847 | events and use the event table macros mentioned below only for the | |
1848 | scrollbar-like controls. | |
7c913512 | 1849 | |
23324ae1 FM |
1850 | @library{wxcore} |
1851 | @category{events} | |
7c913512 | 1852 | |
e54c96f1 | 1853 | @see wxScrollBar, wxSlider, wxSpinButton, , wxScrollWinEvent, @ref |
1f1d2182 | 1854 | overview_eventhandling |
23324ae1 FM |
1855 | */ |
1856 | class wxScrollEvent : public wxCommandEvent | |
1857 | { | |
1858 | public: | |
1859 | /** | |
1860 | Constructor. | |
1861 | */ | |
1d497b99 | 1862 | wxScrollEvent(wxEventType commandType = 0, int id = 0, int pos = 0, |
23324ae1 FM |
1863 | int orientation = 0); |
1864 | ||
1865 | /** | |
1866 | Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the | |
1867 | scrollbar. | |
1868 | */ | |
328f5751 | 1869 | int GetOrientation() const; |
23324ae1 FM |
1870 | |
1871 | /** | |
1872 | Returns the position of the scrollbar. | |
1873 | */ | |
328f5751 | 1874 | int GetPosition() const; |
23324ae1 FM |
1875 | }; |
1876 | ||
1877 | ||
e54c96f1 | 1878 | |
23324ae1 FM |
1879 | /** |
1880 | @class wxIdleEvent | |
1881 | @wxheader{event.h} | |
7c913512 | 1882 | |
23324ae1 FM |
1883 | This class is used for idle events, which are generated when the system becomes |
1884 | idle. Note that, unless you do something specifically, the idle events are not | |
1885 | sent if the system remains idle once it has become it, e.g. only a single idle | |
1886 | event will be generated until something else resulting in more normal events | |
1887 | happens and only then is the next idle event sent again. If you need to ensure | |
7c913512 FM |
1888 | a continuous stream of idle events, you can either use |
1889 | wxIdleEvent::RequestMore method in your handler or call | |
e54c96f1 | 1890 | wxWakeUpIdle() periodically (for example from timer |
23324ae1 FM |
1891 | event), but note that both of these approaches (and especially the first one) |
1892 | increase the system load and so should be avoided if possible. | |
7c913512 FM |
1893 | |
1894 | By default, idle events are sent to all windows (and also | |
23324ae1 FM |
1895 | wxApp, as usual). If this is causing a significant |
1896 | overhead in your application, you can call wxIdleEvent::SetMode with | |
1897 | the value wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra | |
1898 | window style for every window which should receive idle events. | |
7c913512 | 1899 | |
23324ae1 FM |
1900 | @library{wxbase} |
1901 | @category{events} | |
7c913512 | 1902 | |
1f1d2182 | 1903 | @see @ref overview_eventhandling, wxUpdateUIEvent, |
e54c96f1 | 1904 | wxWindow::OnInternalIdle |
23324ae1 FM |
1905 | */ |
1906 | class wxIdleEvent : public wxEvent | |
1907 | { | |
1908 | public: | |
1909 | /** | |
1910 | Constructor. | |
1911 | */ | |
1912 | wxIdleEvent(); | |
1913 | ||
1914 | /** | |
1915 | Returns @true if it is appropriate to send idle events to | |
1916 | this window. | |
23324ae1 | 1917 | This function looks at the mode used (see wxIdleEvent::SetMode), |
4cc4bfaf | 1918 | and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle |
23324ae1 FM |
1919 | events should be sent to |
1920 | this window now. By default this will always return @true because | |
1921 | the update mode is initially wxIDLE_PROCESS_ALL. You can change the mode | |
1922 | to only send idle events to windows with the wxWS_EX_PROCESS_IDLE extra window | |
1923 | style set. | |
3c4f71cc | 1924 | |
4cc4bfaf | 1925 | @see SetMode() |
23324ae1 FM |
1926 | */ |
1927 | static bool CanSend(wxWindow* window); | |
1928 | ||
1929 | /** | |
1930 | Static function returning a value specifying how wxWidgets | |
1931 | will send idle events: to all windows, or only to those which specify that they | |
1932 | will process the events. | |
23324ae1 FM |
1933 | See SetMode(). |
1934 | */ | |
1935 | static wxIdleMode GetMode(); | |
1936 | ||
1937 | /** | |
1938 | Returns @true if the OnIdle function processing this event requested more | |
1939 | processing time. | |
3c4f71cc | 1940 | |
4cc4bfaf | 1941 | @see RequestMore() |
23324ae1 | 1942 | */ |
328f5751 | 1943 | bool MoreRequested() const; |
23324ae1 FM |
1944 | |
1945 | /** | |
1946 | Tells wxWidgets that more processing is required. This function can be called | |
1947 | by an OnIdle | |
1948 | handler for a window or window event handler to indicate that wxApp::OnIdle | |
1949 | should | |
1950 | forward the OnIdle event once more to the application windows. If no window | |
1951 | calls this function | |
1952 | during OnIdle, then the application will remain in a passive event loop (not | |
1953 | calling OnIdle) until a | |
1954 | new event is posted to the application by the windowing system. | |
3c4f71cc | 1955 | |
4cc4bfaf | 1956 | @see MoreRequested() |
23324ae1 | 1957 | */ |
4cc4bfaf | 1958 | void RequestMore(bool needMore = true); |
23324ae1 FM |
1959 | |
1960 | /** | |
1961 | Static function for specifying how wxWidgets will send idle events: to | |
1962 | all windows, or only to those which specify that they | |
1963 | will process the events. | |
4cc4bfaf | 1964 | @a mode can be one of the following values. |
23324ae1 FM |
1965 | The default is wxIDLE_PROCESS_ALL. |
1966 | */ | |
1967 | static void SetMode(wxIdleMode mode); | |
1968 | }; | |
1969 | ||
1970 | ||
e54c96f1 | 1971 | |
23324ae1 FM |
1972 | /** |
1973 | @class wxInitDialogEvent | |
1974 | @wxheader{event.h} | |
7c913512 | 1975 | |
23324ae1 FM |
1976 | A wxInitDialogEvent is sent as a dialog or panel is being initialised. |
1977 | Handlers for this event can transfer data to the window. | |
1978 | The default handler calls wxWindow::TransferDataToWindow. | |
7c913512 | 1979 | |
23324ae1 FM |
1980 | @library{wxcore} |
1981 | @category{events} | |
7c913512 | 1982 | |
1f1d2182 | 1983 | @see @ref overview_eventhandling |
23324ae1 FM |
1984 | */ |
1985 | class wxInitDialogEvent : public wxEvent | |
1986 | { | |
1987 | public: | |
1988 | /** | |
1989 | Constructor. | |
1990 | */ | |
1991 | wxInitDialogEvent(int id = 0); | |
1992 | }; | |
1993 | ||
1994 | ||
e54c96f1 | 1995 | |
23324ae1 FM |
1996 | /** |
1997 | @class wxWindowDestroyEvent | |
1998 | @wxheader{event.h} | |
7c913512 | 1999 | |
23324ae1 FM |
2000 | This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a |
2001 | window is destroyed. | |
7c913512 | 2002 | |
23324ae1 FM |
2003 | When a class derived from wxWindow is destroyed its destructor will have |
2004 | already run by the time this event is sent. Therefore this event will not | |
2005 | usually be received at all. | |
7c913512 | 2006 | |
23324ae1 FM |
2007 | To receive this event wxEvtHandler::Connect |
2008 | must be used (using an event table macro will not work). Since it is | |
2009 | received after the destructor has run, an object should not handle its | |
2010 | own wxWindowDestroyEvent, but it can be used to get notification of the | |
2011 | destruction of another window. | |
7c913512 | 2012 | |
23324ae1 FM |
2013 | @library{wxcore} |
2014 | @category{events} | |
7c913512 | 2015 | |
1f1d2182 | 2016 | @see @ref overview_eventhandling, wxWindowCreateEvent |
23324ae1 FM |
2017 | */ |
2018 | class wxWindowDestroyEvent : public wxCommandEvent | |
2019 | { | |
2020 | public: | |
2021 | /** | |
2022 | Constructor. | |
2023 | */ | |
4cc4bfaf | 2024 | wxWindowDestroyEvent(wxWindow* win = NULL); |
23324ae1 FM |
2025 | }; |
2026 | ||
2027 | ||
e54c96f1 | 2028 | |
23324ae1 FM |
2029 | /** |
2030 | @class wxNavigationKeyEvent | |
2031 | @wxheader{event.h} | |
7c913512 FM |
2032 | |
2033 | This event class contains information about navigation events, | |
2034 | generated by navigation keys such as tab and page down. | |
2035 | ||
2036 | This event is mainly used by wxWidgets implementations. A | |
2037 | wxNavigationKeyEvent handler is automatically provided by wxWidgets | |
23324ae1 | 2038 | when you make a class into a control container with the macro |
7c913512 FM |
2039 | WX_DECLARE_CONTROL_CONTAINER. |
2040 | ||
23324ae1 FM |
2041 | @library{wxcore} |
2042 | @category{events} | |
7c913512 | 2043 | |
e54c96f1 | 2044 | @see wxWindow::Navigate, wxWindow::NavigateIn |
23324ae1 | 2045 | */ |
7c913512 | 2046 | class wxNavigationKeyEvent |
23324ae1 FM |
2047 | { |
2048 | public: | |
2049 | //@{ | |
2050 | /** | |
2051 | Constructor. | |
2052 | */ | |
2053 | wxNavigationKeyEvent(); | |
7c913512 | 2054 | wxNavigationKeyEvent(const wxNavigationKeyEvent& event); |
23324ae1 FM |
2055 | //@} |
2056 | ||
2057 | /** | |
2058 | Returns the child that has the focus, or @NULL. | |
2059 | */ | |
328f5751 | 2060 | wxWindow* GetCurrentFocus() const; |
23324ae1 FM |
2061 | |
2062 | /** | |
2063 | Returns @true if the navigation was in the forward direction. | |
2064 | */ | |
328f5751 | 2065 | bool GetDirection() const; |
23324ae1 FM |
2066 | |
2067 | /** | |
2068 | Returns @true if the navigation event was from a tab key. This is required | |
2069 | for proper navigation over radio buttons. | |
2070 | */ | |
328f5751 | 2071 | bool IsFromTab() const; |
23324ae1 FM |
2072 | |
2073 | /** | |
2074 | Returns @true if the navigation event represents a window change (for | |
7c913512 | 2075 | example, from Ctrl-Page Down |
23324ae1 FM |
2076 | in a notebook). |
2077 | */ | |
328f5751 | 2078 | bool IsWindowChange() const; |
23324ae1 FM |
2079 | |
2080 | /** | |
2081 | Sets the current focus window member. | |
2082 | */ | |
2083 | void SetCurrentFocus(wxWindow* currentFocus); | |
2084 | ||
2085 | /** | |
4cc4bfaf | 2086 | Sets the direction to forward if @a direction is @true, or backward if @c |
23324ae1 FM |
2087 | @false. |
2088 | */ | |
2089 | void SetDirection(bool direction); | |
2090 | ||
2091 | /** | |
2092 | Sets the flags. | |
2093 | */ | |
2094 | void SetFlags(long flags); | |
2095 | ||
2096 | /** | |
2097 | Marks the navigation event as from a tab key. | |
2098 | */ | |
2099 | void SetFromTab(bool fromTab); | |
2100 | ||
2101 | /** | |
2102 | Marks the event as a window change event. | |
2103 | */ | |
2104 | void SetWindowChange(bool windowChange); | |
2105 | }; | |
2106 | ||
2107 | ||
e54c96f1 | 2108 | |
23324ae1 FM |
2109 | /** |
2110 | @class wxMouseCaptureChangedEvent | |
2111 | @wxheader{event.h} | |
7c913512 | 2112 | |
23324ae1 FM |
2113 | An mouse capture changed event is sent to a window that loses its |
2114 | mouse capture. This is called even if wxWindow::ReleaseCapture | |
2115 | was called by the application code. Handling this event allows | |
2116 | an application to cater for unexpected capture releases which | |
2117 | might otherwise confuse mouse handling code. | |
7c913512 | 2118 | |
23324ae1 | 2119 | This event is implemented under Windows only. |
7c913512 | 2120 | |
23324ae1 FM |
2121 | @library{wxcore} |
2122 | @category{events} | |
7c913512 | 2123 | |
1f1d2182 | 2124 | @see wxMouseCaptureLostEvent, @ref overview_eventhandling, |
4cc4bfaf | 2125 | wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture |
23324ae1 FM |
2126 | */ |
2127 | class wxMouseCaptureChangedEvent : public wxEvent | |
2128 | { | |
2129 | public: | |
2130 | /** | |
2131 | Constructor. | |
2132 | */ | |
2133 | wxMouseCaptureChangedEvent(wxWindowID windowId = 0, | |
4cc4bfaf | 2134 | wxWindow* gainedCapture = NULL); |
23324ae1 FM |
2135 | |
2136 | /** | |
2137 | Returns the window that gained the capture, or @NULL if it was a non-wxWidgets | |
2138 | window. | |
2139 | */ | |
328f5751 | 2140 | wxWindow* GetCapturedWindow() const; |
23324ae1 FM |
2141 | }; |
2142 | ||
2143 | ||
e54c96f1 | 2144 | |
23324ae1 FM |
2145 | /** |
2146 | @class wxCloseEvent | |
2147 | @wxheader{event.h} | |
7c913512 | 2148 | |
23324ae1 | 2149 | This event class contains information about window and session close events. |
7c913512 | 2150 | |
23324ae1 FM |
2151 | The handler function for EVT_CLOSE is called when the user has tried to close a |
2152 | a frame | |
2153 | or dialog box using the window manager (X) or system menu (Windows). It can | |
2154 | also be invoked by the application itself programmatically, for example by | |
2155 | calling the wxWindow::Close function. | |
7c913512 | 2156 | |
23324ae1 FM |
2157 | You should check whether the application is forcing the deletion of the window |
2158 | using wxCloseEvent::CanVeto. If this is @false, | |
2159 | you @e must destroy the window using wxWindow::Destroy. | |
2160 | If the return value is @true, it is up to you whether you respond by destroying | |
2161 | the window. | |
7c913512 | 2162 | |
23324ae1 FM |
2163 | If you don't destroy the window, you should call wxCloseEvent::Veto to |
2164 | let the calling code know that you did not destroy the window. This allows the | |
2165 | wxWindow::Close function | |
2166 | to return @true or @false depending on whether the close instruction was | |
2167 | honoured or not. | |
7c913512 | 2168 | |
23324ae1 FM |
2169 | @library{wxcore} |
2170 | @category{events} | |
7c913512 | 2171 | |
e54c96f1 FM |
2172 | @see wxWindow::Close, @ref overview_windowdeletionoverview "Window deletion |
2173 | overview" | |
23324ae1 FM |
2174 | */ |
2175 | class wxCloseEvent : public wxEvent | |
2176 | { | |
2177 | public: | |
2178 | /** | |
2179 | Constructor. | |
2180 | */ | |
1d497b99 | 2181 | wxCloseEvent(wxEventType commandEventType = 0, int id = 0); |
23324ae1 FM |
2182 | |
2183 | /** | |
2184 | Returns @true if you can veto a system shutdown or a window close event. | |
2185 | Vetoing a window close event is not possible if the calling code wishes to | |
2186 | force the application to exit, and so this function must be called to check | |
2187 | this. | |
2188 | */ | |
a6052817 | 2189 | bool CanVeto() const; |
23324ae1 FM |
2190 | |
2191 | /** | |
2192 | Returns @true if the user is just logging off or @false if the system is | |
2193 | shutting down. This method can only be called for end session and query end | |
2194 | session events, it doesn't make sense for close window event. | |
2195 | */ | |
328f5751 | 2196 | bool GetLoggingOff() const; |
23324ae1 FM |
2197 | |
2198 | /** | |
2199 | Sets the 'can veto' flag. | |
2200 | */ | |
2201 | void SetCanVeto(bool canVeto); | |
2202 | ||
2203 | /** | |
2204 | Sets the 'force' flag. | |
2205 | */ | |
328f5751 | 2206 | void SetForce(bool force) const; |
23324ae1 FM |
2207 | |
2208 | /** | |
2209 | Sets the 'logging off' flag. | |
2210 | */ | |
a6052817 | 2211 | void SetLoggingOff(bool loggingOff); |
23324ae1 FM |
2212 | |
2213 | /** | |
2214 | Call this from your event handler to veto a system shutdown or to signal | |
2215 | to the calling application that a window close did not happen. | |
23324ae1 FM |
2216 | You can only veto a shutdown if CanVeto() returns |
2217 | @true. | |
2218 | */ | |
4cc4bfaf | 2219 | void Veto(bool veto = true); |
23324ae1 FM |
2220 | }; |
2221 | ||
2222 | ||
e54c96f1 | 2223 | |
23324ae1 FM |
2224 | /** |
2225 | @class wxMenuEvent | |
2226 | @wxheader{event.h} | |
7c913512 | 2227 | |
23324ae1 FM |
2228 | This class is used for a variety of menu-related events. Note that |
2229 | these do not include menu command events, which are | |
2230 | handled using wxCommandEvent objects. | |
7c913512 | 2231 | |
23324ae1 FM |
2232 | The default handler for wxEVT_MENU_HIGHLIGHT displays help |
2233 | text in the first field of the status bar. | |
7c913512 | 2234 | |
23324ae1 FM |
2235 | @library{wxcore} |
2236 | @category{events} | |
7c913512 | 2237 | |
e54c96f1 | 2238 | @see @ref overview_wxcommandevent "Command events", @ref |
1f1d2182 | 2239 | overview_eventhandling |
23324ae1 FM |
2240 | */ |
2241 | class wxMenuEvent : public wxEvent | |
2242 | { | |
2243 | public: | |
2244 | /** | |
2245 | Constructor. | |
2246 | */ | |
1d497b99 | 2247 | wxMenuEvent(wxEventType id = 0, int id = 0, wxMenu* menu = NULL); |
23324ae1 FM |
2248 | |
2249 | /** | |
2250 | Returns the menu which is being opened or closed. This method should only be | |
2251 | used with the @c OPEN and @c CLOSE events and even for them the | |
2252 | returned pointer may be @NULL in some ports. | |
2253 | */ | |
328f5751 | 2254 | wxMenu* GetMenu() const; |
23324ae1 FM |
2255 | |
2256 | /** | |
2257 | Returns the menu identifier associated with the event. This method should be | |
2258 | only used with the @c HIGHLIGHT events. | |
2259 | */ | |
328f5751 | 2260 | int GetMenuId() const; |
23324ae1 FM |
2261 | |
2262 | /** | |
7c913512 | 2263 | Returns @true if the menu which is being opened or closed is a popup menu, |
23324ae1 | 2264 | @false if it is a normal one. |
23324ae1 FM |
2265 | This method should only be used with the @c OPEN and @c CLOSE events. |
2266 | */ | |
328f5751 | 2267 | bool IsPopup() const; |
23324ae1 FM |
2268 | }; |
2269 | ||
2270 | ||
e54c96f1 | 2271 | |
23324ae1 FM |
2272 | /** |
2273 | @class wxEventBlocker | |
2274 | @wxheader{event.h} | |
7c913512 | 2275 | |
23324ae1 FM |
2276 | This class is a special event handler which allows to discard |
2277 | any event (or a set of event types) directed to a specific window. | |
7c913512 | 2278 | |
23324ae1 | 2279 | Example: |
7c913512 | 2280 | |
23324ae1 FM |
2281 | @code |
2282 | { | |
2283 | // block all events directed to this window while | |
2284 | // we do the 1000 FuncWhichSendsEvents() calls | |
2285 | wxEventBlocker blocker(this); | |
7c913512 | 2286 | |
23324ae1 FM |
2287 | for ( int i = 0; i 1000; i++ ) |
2288 | FuncWhichSendsEvents(i); | |
7c913512 | 2289 | |
23324ae1 | 2290 | } // ~wxEventBlocker called, old event handler is restored |
7c913512 | 2291 | |
23324ae1 FM |
2292 | // the event generated by this call will be processed |
2293 | FuncWhichSendsEvents(0) | |
2294 | @endcode | |
7c913512 | 2295 | |
23324ae1 | 2296 | @library{wxcore} |
1f1d2182 | 2297 | @category{events} |
7c913512 | 2298 | |
1f1d2182 | 2299 | @see @ref overview_eventhandling, wxEvtHandler |
23324ae1 FM |
2300 | */ |
2301 | class wxEventBlocker : public wxEvtHandler | |
2302 | { | |
2303 | public: | |
2304 | /** | |
2305 | Constructs the blocker for the given window and for the given event type. | |
4cc4bfaf | 2306 | If @a type is @c wxEVT_ANY, then all events for that window are |
23324ae1 FM |
2307 | blocked. You can call Block() after creation to |
2308 | add other event types to the list of events to block. | |
4cc4bfaf | 2309 | Note that the @a win window @b must remain alive until the |
23324ae1 FM |
2310 | wxEventBlocker object destruction. |
2311 | */ | |
a6052817 | 2312 | wxEventBlocker(wxWindow* win, wxEventType = -0x000000001); |
23324ae1 FM |
2313 | |
2314 | /** | |
2315 | Destructor. The blocker will remove itself from the chain of event handlers for | |
2316 | the window provided in the constructor, thus restoring normal processing of | |
2317 | events. | |
2318 | */ | |
a6052817 | 2319 | virtual ~wxEventBlocker(); |
23324ae1 FM |
2320 | |
2321 | /** | |
2322 | Adds to the list of event types which should be blocked the given @e eventType. | |
2323 | */ | |
2324 | void Block(wxEventType eventType); | |
2325 | }; | |
2326 | ||
2327 | ||
e54c96f1 | 2328 | |
23324ae1 FM |
2329 | /** |
2330 | @class wxEvtHandler | |
2331 | @wxheader{event.h} | |
7c913512 | 2332 | |
23324ae1 FM |
2333 | A class that can handle events from the windowing system. |
2334 | wxWindow (and therefore all window classes) are derived from | |
2335 | this class. | |
7c913512 | 2336 | |
23324ae1 FM |
2337 | When events are received, wxEvtHandler invokes the method listed in the |
2338 | event table using itself as the object. When using multiple inheritance | |
2339 | it is imperative that the wxEvtHandler(-derived) class be the first | |
2340 | class inherited such that the "this" pointer for the overall object | |
2341 | will be identical to the "this" pointer for the wxEvtHandler portion. | |
7c913512 | 2342 | |
23324ae1 | 2343 | @library{wxbase} |
1f1d2182 | 2344 | @category{events} |
7c913512 | 2345 | |
1f1d2182 | 2346 | @see @ref overview_eventhandling |
23324ae1 FM |
2347 | */ |
2348 | class wxEvtHandler : public wxObject | |
2349 | { | |
2350 | public: | |
2351 | /** | |
2352 | Constructor. | |
2353 | */ | |
2354 | wxEvtHandler(); | |
2355 | ||
2356 | /** | |
2357 | Destructor. If the handler is part of a chain, the destructor will | |
2358 | unlink itself and restore the previous and next handlers so that they point to | |
2359 | each other. | |
2360 | */ | |
a6052817 | 2361 | virtual ~wxEvtHandler(); |
23324ae1 FM |
2362 | |
2363 | /** | |
2364 | This function posts an event to be processed later. | |
3c4f71cc | 2365 | |
7c913512 | 2366 | @param event |
4cc4bfaf | 2367 | Event to add to process queue. |
3c4f71cc | 2368 | |
23324ae1 | 2369 | @remarks The difference between sending an event (using the ProcessEvent |
4cc4bfaf FM |
2370 | method) and posting it is that in the first case the |
2371 | event is processed before the function returns, while | |
2372 | in the second case, the function returns immediately | |
2373 | and the event will be processed sometime later (usually | |
2374 | during the next event loop iteration). | |
23324ae1 FM |
2375 | */ |
2376 | virtual void AddPendingEvent(const wxEvent& event); | |
2377 | ||
2378 | //@{ | |
2379 | /** | |
2380 | Connects the given function dynamically with the event handler, id and event | |
2381 | type. This | |
2382 | is an alternative to the use of static event tables. See the 'event' or the old | |
2383 | 'dynamic' sample for usage. | |
3c4f71cc | 2384 | |
7c913512 | 2385 | @param id |
4cc4bfaf FM |
2386 | The identifier (or first of the identifier range) to be |
2387 | associated with the event handler function. For the version not taking this | |
2388 | argument, it defaults to wxID_ANY. | |
7c913512 | 2389 | @param lastId |
4cc4bfaf FM |
2390 | The second part of the identifier range to be associated with the event |
2391 | handler function. | |
7c913512 | 2392 | @param eventType |
4cc4bfaf | 2393 | The event type to be associated with this event handler. |
7c913512 | 2394 | @param function |
4cc4bfaf FM |
2395 | The event handler function. Note that this function should |
2396 | be explicitly converted to the correct type which can be done using a macro | |
2397 | called wxFooEventHandler for the handler for any wxFooEvent. | |
7c913512 | 2398 | @param userData |
4cc4bfaf | 2399 | Data to be associated with the event table entry. |
7c913512 | 2400 | @param eventSink |
4cc4bfaf FM |
2401 | Object whose member function should be called. If this is @NULL, |
2402 | this will be used. | |
23324ae1 FM |
2403 | */ |
2404 | void Connect(int id, int lastId, wxEventType eventType, | |
2405 | wxObjectEventFunction function, | |
4cc4bfaf FM |
2406 | wxObject* userData = NULL, |
2407 | wxEvtHandler* eventSink = NULL); | |
7c913512 FM |
2408 | void Connect(int id, wxEventType eventType, |
2409 | wxObjectEventFunction function, | |
4cc4bfaf FM |
2410 | wxObject* userData = NULL, |
2411 | wxEvtHandler* eventSink = NULL); | |
7c913512 FM |
2412 | void Connect(wxEventType eventType, |
2413 | wxObjectEventFunction function, | |
4cc4bfaf FM |
2414 | wxObject* userData = NULL, |
2415 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
2416 | //@} |
2417 | ||
2418 | //@{ | |
2419 | /** | |
2420 | Disconnects the given function dynamically from the event handler, using the | |
2421 | specified | |
2422 | parameters as search criteria and returning @true if a matching function has been | |
2423 | found and removed. This method can only disconnect functions which have been | |
2424 | added | |
2425 | using the Connect() method. There is no way | |
2426 | to disconnect functions connected using the (static) event tables. | |
3c4f71cc | 2427 | |
7c913512 | 2428 | @param id |
4cc4bfaf | 2429 | The identifier (or first of the identifier range) associated with the event |
23324ae1 | 2430 | handler function. |
7c913512 | 2431 | @param lastId |
4cc4bfaf | 2432 | The second part of the identifier range associated with the event handler |
23324ae1 | 2433 | function. |
7c913512 | 2434 | @param eventType |
4cc4bfaf | 2435 | The event type associated with this event handler. |
7c913512 | 2436 | @param function |
4cc4bfaf | 2437 | The event handler function. |
7c913512 | 2438 | @param userData |
4cc4bfaf | 2439 | Data associated with the event table entry. |
7c913512 | 2440 | @param eventSink |
4cc4bfaf | 2441 | Object whose member function should be called. |
23324ae1 | 2442 | */ |
4cc4bfaf FM |
2443 | bool Disconnect(wxEventType eventType = wxEVT_NULL, |
2444 | wxObjectEventFunction function = NULL, | |
2445 | wxObject* userData = NULL, | |
2446 | wxEvtHandler* eventSink = NULL); | |
7c913512 | 2447 | bool Disconnect(int id = wxID_ANY, |
4cc4bfaf FM |
2448 | wxEventType eventType = wxEVT_NULL, |
2449 | wxObjectEventFunction function = NULL, | |
2450 | wxObject* userData = NULL, | |
2451 | wxEvtHandler* eventSink = NULL); | |
7c913512 | 2452 | bool Disconnect(int id, int lastId = wxID_ANY, |
4cc4bfaf FM |
2453 | wxEventType eventType = wxEVT_NULL, |
2454 | wxObjectEventFunction function = NULL, | |
2455 | wxObject* userData = NULL, | |
2456 | wxEvtHandler* eventSink = NULL); | |
23324ae1 FM |
2457 | //@} |
2458 | ||
2459 | /** | |
2460 | Gets user-supplied client data. | |
3c4f71cc | 2461 | |
23324ae1 | 2462 | @remarks Normally, any extra data the programmer wishes to associate with |
4cc4bfaf FM |
2463 | the object should be made available by deriving a new |
2464 | class with new data members. | |
3c4f71cc | 2465 | |
4cc4bfaf | 2466 | @see SetClientData() |
23324ae1 | 2467 | */ |
a6052817 | 2468 | void* GetClientData() const; |
23324ae1 FM |
2469 | |
2470 | /** | |
2471 | Get a pointer to the user-supplied client data object. | |
3c4f71cc | 2472 | |
4cc4bfaf | 2473 | @see SetClientObject(), wxClientData |
23324ae1 | 2474 | */ |
328f5751 | 2475 | wxClientData* GetClientObject() const; |
23324ae1 FM |
2476 | |
2477 | /** | |
2478 | Returns @true if the event handler is enabled, @false otherwise. | |
3c4f71cc | 2479 | |
4cc4bfaf | 2480 | @see SetEvtHandlerEnabled() |
23324ae1 | 2481 | */ |
a6052817 | 2482 | bool GetEvtHandlerEnabled() const; |
23324ae1 FM |
2483 | |
2484 | /** | |
2485 | Gets the pointer to the next handler in the chain. | |
3c4f71cc | 2486 | |
4cc4bfaf FM |
2487 | @see SetNextHandler(), GetPreviousHandler(), |
2488 | SetPreviousHandler(), wxWindow::PushEventHandler, | |
2489 | wxWindow::PopEventHandler | |
23324ae1 | 2490 | */ |
a6052817 | 2491 | wxEvtHandler* GetNextHandler() const; |
23324ae1 FM |
2492 | |
2493 | /** | |
2494 | Gets the pointer to the previous handler in the chain. | |
3c4f71cc | 2495 | |
4cc4bfaf FM |
2496 | @see SetPreviousHandler(), GetNextHandler(), |
2497 | SetNextHandler(), wxWindow::PushEventHandler, | |
2498 | wxWindow::PopEventHandler | |
23324ae1 | 2499 | */ |
a6052817 | 2500 | wxEvtHandler* GetPreviousHandler() const; |
23324ae1 FM |
2501 | |
2502 | /** | |
2503 | Processes an event, searching event tables and calling zero or more suitable | |
2504 | event handler function(s). | |
3c4f71cc | 2505 | |
7c913512 | 2506 | @param event |
4cc4bfaf | 2507 | Event to process. |
3c4f71cc | 2508 | |
23324ae1 | 2509 | @returns @true if a suitable event handler function was found and |
4cc4bfaf | 2510 | executed, and the function did not call wxEvent::Skip. |
3c4f71cc | 2511 | |
23324ae1 | 2512 | @remarks Normally, your application would not call this function: it is |
4cc4bfaf FM |
2513 | called in the wxWidgets implementation to dispatch |
2514 | incoming user interface events to the framework (and | |
2515 | application). | |
3c4f71cc | 2516 | |
4cc4bfaf | 2517 | @see SearchEventTable() |
23324ae1 FM |
2518 | */ |
2519 | virtual bool ProcessEvent(wxEvent& event); | |
2520 | ||
2521 | /** | |
2522 | Processes an event by calling ProcessEvent() | |
2523 | and handles any exceptions that occur in the process. If an exception is | |
2524 | thrown in event handler, wxApp::OnExceptionInMainLoop | |
2525 | is called. | |
3c4f71cc | 2526 | |
7c913512 | 2527 | @param event |
4cc4bfaf | 2528 | Event to process. |
3c4f71cc | 2529 | |
23324ae1 | 2530 | @returns @true if the event was processed, @false if no handler was found |
4cc4bfaf | 2531 | or an exception was thrown. |
3c4f71cc | 2532 | |
4cc4bfaf | 2533 | @see wxWindow::HandleWindowEvent |
23324ae1 FM |
2534 | */ |
2535 | bool SafelyProcessEvent(wxEvent& event); | |
2536 | ||
2537 | /** | |
2538 | Searches the event table, executing an event handler function if an appropriate | |
2539 | one | |
2540 | is found. | |
3c4f71cc | 2541 | |
7c913512 | 2542 | @param table |
4cc4bfaf | 2543 | Event table to be searched. |
7c913512 | 2544 | @param event |
4cc4bfaf | 2545 | Event to be matched against an event table entry. |
3c4f71cc | 2546 | |
23324ae1 | 2547 | @returns @true if a suitable event handler function was found and |
4cc4bfaf | 2548 | executed, and the function did not call wxEvent::Skip. |
3c4f71cc | 2549 | |
23324ae1 | 2550 | @remarks This function looks through the object's event table and tries |
4cc4bfaf | 2551 | to find an entry that will match the event. |
3c4f71cc | 2552 | |
4cc4bfaf | 2553 | @see ProcessEvent() |
23324ae1 FM |
2554 | */ |
2555 | virtual bool SearchEventTable(wxEventTable& table, | |
2556 | wxEvent& event); | |
2557 | ||
2558 | /** | |
2559 | Sets user-supplied client data. | |
3c4f71cc | 2560 | |
7c913512 | 2561 | @param data |
4cc4bfaf | 2562 | Data to be associated with the event handler. |
3c4f71cc | 2563 | |
23324ae1 | 2564 | @remarks Normally, any extra data the programmer wishes to associate with |
4cc4bfaf FM |
2565 | the object should be made available by deriving a new |
2566 | class with new data members. You must not call this | |
2567 | method and SetClientObject on the same class - only one | |
2568 | of them. | |
3c4f71cc | 2569 | |
4cc4bfaf | 2570 | @see GetClientData() |
23324ae1 FM |
2571 | */ |
2572 | void SetClientData(void* data); | |
2573 | ||
2574 | /** | |
2575 | Set the client data object. Any previous object will be deleted. | |
3c4f71cc | 2576 | |
4cc4bfaf | 2577 | @see GetClientObject(), wxClientData |
23324ae1 FM |
2578 | */ |
2579 | void SetClientObject(wxClientData* data); | |
2580 | ||
2581 | /** | |
2582 | Enables or disables the event handler. | |
3c4f71cc | 2583 | |
7c913512 | 2584 | @param enabled |
4cc4bfaf | 2585 | @true if the event handler is to be enabled, @false if it is to be disabled. |
3c4f71cc | 2586 | |
23324ae1 | 2587 | @remarks You can use this function to avoid having to remove the event |
4cc4bfaf FM |
2588 | handler from the chain, for example when implementing a |
2589 | dialog editor and changing from edit to test mode. | |
3c4f71cc | 2590 | |
4cc4bfaf | 2591 | @see GetEvtHandlerEnabled() |
23324ae1 FM |
2592 | */ |
2593 | void SetEvtHandlerEnabled(bool enabled); | |
2594 | ||
2595 | /** | |
2596 | Sets the pointer to the next handler. | |
3c4f71cc | 2597 | |
7c913512 | 2598 | @param handler |
4cc4bfaf | 2599 | Event handler to be set as the next handler. |
3c4f71cc | 2600 | |
4cc4bfaf FM |
2601 | @see GetNextHandler(), SetPreviousHandler(), |
2602 | GetPreviousHandler(), wxWindow::PushEventHandler, | |
2603 | wxWindow::PopEventHandler | |
23324ae1 FM |
2604 | */ |
2605 | void SetNextHandler(wxEvtHandler* handler); | |
2606 | ||
2607 | /** | |
2608 | Sets the pointer to the previous handler. | |
3c4f71cc | 2609 | |
7c913512 | 2610 | @param handler |
4cc4bfaf | 2611 | Event handler to be set as the previous handler. |
23324ae1 FM |
2612 | */ |
2613 | void SetPreviousHandler(wxEvtHandler* handler); | |
2614 | }; | |
2615 | ||
2616 | ||
e54c96f1 | 2617 | |
23324ae1 FM |
2618 | /** |
2619 | @class wxIconizeEvent | |
2620 | @wxheader{event.h} | |
7c913512 | 2621 | |
23324ae1 | 2622 | An event being sent when the frame is iconized (minimized) or restored. |
7c913512 | 2623 | |
23324ae1 | 2624 | Currently only wxMSW and wxGTK generate such events. |
7c913512 | 2625 | |
23324ae1 FM |
2626 | @library{wxcore} |
2627 | @category{events} | |
7c913512 | 2628 | |
1f1d2182 | 2629 | @see @ref overview_eventhandling, wxTopLevelWindow::Iconize, |
4cc4bfaf | 2630 | wxTopLevelWindow::IsIconized |
23324ae1 FM |
2631 | */ |
2632 | class wxIconizeEvent : public wxEvent | |
2633 | { | |
2634 | public: | |
2635 | /** | |
2636 | Constructor. | |
2637 | */ | |
4cc4bfaf | 2638 | wxIconizeEvent(int id = 0, bool iconized = true); |
23324ae1 FM |
2639 | |
2640 | /** | |
2641 | Returns @true if the frame has been iconized, @false if it has been | |
2642 | restored. | |
2643 | */ | |
328f5751 | 2644 | bool Iconized() const; |
23324ae1 FM |
2645 | }; |
2646 | ||
2647 | ||
e54c96f1 | 2648 | |
23324ae1 FM |
2649 | /** |
2650 | @class wxMoveEvent | |
2651 | @wxheader{event.h} | |
7c913512 | 2652 | |
23324ae1 | 2653 | A move event holds information about move change events. |
7c913512 | 2654 | |
23324ae1 FM |
2655 | @library{wxcore} |
2656 | @category{events} | |
7c913512 | 2657 | |
1f1d2182 | 2658 | @see wxPoint, @ref overview_eventhandling |
23324ae1 FM |
2659 | */ |
2660 | class wxMoveEvent : public wxEvent | |
2661 | { | |
2662 | public: | |
2663 | /** | |
2664 | Constructor. | |
2665 | */ | |
2666 | wxMoveEvent(const wxPoint& pt, int id = 0); | |
2667 | ||
2668 | /** | |
2669 | Returns the position of the window generating the move change event. | |
2670 | */ | |
328f5751 | 2671 | wxPoint GetPosition() const; |
23324ae1 FM |
2672 | }; |
2673 | ||
2674 | ||
e54c96f1 | 2675 | |
23324ae1 FM |
2676 | /** |
2677 | @class wxEvent | |
2678 | @wxheader{event.h} | |
7c913512 | 2679 | |
23324ae1 FM |
2680 | An event is a structure holding information about an event passed to a |
2681 | callback or member function. @b wxEvent used to be a multipurpose | |
2682 | event object, and is an abstract base class for other event classes (see below). | |
7c913512 | 2683 | |
1f1d2182 | 2684 | For more information about events, see the @ref overview_eventhandling. |
7c913512 | 2685 | |
23324ae1 FM |
2686 | @b wxPerl note: In wxPerl custom event classes should be derived from |
2687 | @c Wx::PlEvent and @c Wx::PlCommandEvent. | |
7c913512 | 2688 | |
23324ae1 FM |
2689 | @library{wxbase} |
2690 | @category{events} | |
7c913512 | 2691 | |
e54c96f1 | 2692 | @see wxCommandEvent, wxMouseEvent |
23324ae1 FM |
2693 | */ |
2694 | class wxEvent : public wxObject | |
2695 | { | |
2696 | public: | |
2697 | /** | |
2698 | Constructor. Should not need to be used directly by an application. | |
2699 | */ | |
4cc4bfaf | 2700 | wxEvent(int id = 0, wxEventType eventType = wxEVT_NULL); |
23324ae1 FM |
2701 | |
2702 | /** | |
2703 | Returns a copy of the event. | |
23324ae1 FM |
2704 | Any event that is posted to the wxWidgets event system for later action (via |
2705 | wxEvtHandler::AddPendingEvent or | |
e54c96f1 | 2706 | wxPostEvent()) must implement this method. All wxWidgets |
23324ae1 FM |
2707 | events fully implement this method, but any derived events implemented by the |
2708 | user should also implement this method just in case they (or some event | |
2709 | derived from them) are ever posted. | |
23324ae1 FM |
2710 | All wxWidgets events implement a copy constructor, so the easiest way of |
2711 | implementing the Clone function is to implement a copy constructor for | |
2712 | a new event (call it MyEvent) and then define the Clone function like this: | |
2713 | */ | |
a6052817 | 2714 | virtual wxEvent* Clone() const = 0; |
23324ae1 FM |
2715 | |
2716 | /** | |
2717 | Returns the object (usually a window) associated with the | |
2718 | event, if any. | |
2719 | */ | |
a6052817 | 2720 | wxObject* GetEventObject() const; |
23324ae1 FM |
2721 | |
2722 | /** | |
2723 | Returns the identifier of the given event type, | |
2724 | such as @c wxEVT_COMMAND_BUTTON_CLICKED. | |
2725 | */ | |
a6052817 | 2726 | wxEventType GetEventType() const; |
23324ae1 FM |
2727 | |
2728 | /** | |
2729 | Returns the identifier associated with this event, such as a button command id. | |
2730 | */ | |
328f5751 | 2731 | int GetId() const; |
23324ae1 FM |
2732 | |
2733 | /** | |
2734 | Returns @true if the event handler should be skipped, @false otherwise. | |
2735 | */ | |
328f5751 | 2736 | bool GetSkipped() const; |
23324ae1 FM |
2737 | |
2738 | /** | |
2739 | Gets the timestamp for the event. The timestamp is the time in milliseconds | |
2740 | since some fixed moment (not necessarily the standard Unix Epoch, so | |
2741 | only differences between the timestamps and not their absolute values usually | |
2742 | make sense). | |
2743 | */ | |
a6052817 | 2744 | long GetTimestamp() const; |
23324ae1 FM |
2745 | |
2746 | /** | |
2747 | Returns @true if the event is or is derived from | |
2748 | wxCommandEvent else it returns @false. | |
2749 | Note: Exists only for optimization purposes. | |
2750 | */ | |
328f5751 | 2751 | bool IsCommandEvent() const; |
23324ae1 FM |
2752 | |
2753 | /** | |
2754 | Sets the propagation level to the given value (for example returned from an | |
2755 | earlier call to wxEvent::StopPropagation). | |
2756 | */ | |
2757 | void ResumePropagation(int propagationLevel); | |
2758 | ||
2759 | /** | |
2760 | Sets the originating object. | |
2761 | */ | |
2762 | void SetEventObject(wxObject* object); | |
2763 | ||
2764 | /** | |
2765 | Sets the event type. | |
2766 | */ | |
2767 | void SetEventType(wxEventType type); | |
2768 | ||
2769 | /** | |
2770 | Sets the identifier associated with this event, such as a button command id. | |
2771 | */ | |
2772 | void SetId(int id); | |
2773 | ||
2774 | /** | |
2775 | Sets the timestamp for the event. | |
2776 | */ | |
a6052817 | 2777 | void SetTimestamp(long = 0); |
23324ae1 FM |
2778 | |
2779 | /** | |
2780 | Test if this event should be propagated or not, i.e. if the propagation level | |
2781 | is currently greater than 0. | |
2782 | */ | |
328f5751 | 2783 | bool ShouldPropagate() const; |
23324ae1 FM |
2784 | |
2785 | /** | |
2786 | This method can be used inside an event handler to control whether further | |
2787 | event handlers bound to this event will be called after the current one | |
2788 | returns. Without Skip() (or equivalently if Skip(@false) is used), | |
2789 | the event will not be processed any more. If Skip(@true) is called, the event | |
2790 | processing system continues searching for a further handler function for this | |
2791 | event, even though it has been processed already in the current handler. | |
23324ae1 FM |
2792 | In general, it is recommended to skip all non-command events to allow the |
2793 | default handling to take place. The command events are, however, normally not | |
2794 | skipped as usually a single command such as a button click or menu item | |
2795 | selection must only be processed by one handler. | |
2796 | */ | |
4cc4bfaf | 2797 | void Skip(bool skip = true); |
23324ae1 FM |
2798 | |
2799 | /** | |
2800 | Stop the event from propagating to its parent window. | |
7c913512 | 2801 | Returns the old propagation level value which may be later passed to |
23324ae1 FM |
2802 | ResumePropagation() to allow propagating the |
2803 | event again. | |
2804 | */ | |
2805 | int StopPropagation(); | |
2806 | ||
2807 | /** | |
2808 | int m_propagationLevel | |
23324ae1 FM |
2809 | Indicates how many levels the event can propagate. This member is protected and |
2810 | should typically only be set in the constructors of the derived classes. It | |
7c913512 FM |
2811 | may be temporarily changed by StopPropagation() |
2812 | and ResumePropagation() and tested with | |
23324ae1 | 2813 | ShouldPropagate(). |
23324ae1 | 2814 | The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by |
7c913512 | 2815 | default) meaning that the event shouldn't be propagated at all or to |
23324ae1 FM |
2816 | @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be |
2817 | propagated as much as necessary. | |
23324ae1 FM |
2818 | Any positive number means that the event should be propagated but no more than |
2819 | the given number of times. E.g. the propagation level may be set to 1 to | |
2820 | propagate the event to its parent only, but not to its grandparent. | |
2821 | */ | |
2822 | }; | |
2823 | ||
2824 | ||
e54c96f1 | 2825 | |
23324ae1 FM |
2826 | /** |
2827 | @class wxSizeEvent | |
2828 | @wxheader{event.h} | |
7c913512 | 2829 | |
23324ae1 | 2830 | A size event holds information about size change events. |
7c913512 | 2831 | |
23324ae1 | 2832 | The EVT_SIZE handler function will be called when the window has been resized. |
7c913512 | 2833 | |
23324ae1 FM |
2834 | You may wish to use this for frames to resize their child windows as |
2835 | appropriate. | |
7c913512 | 2836 | |
23324ae1 FM |
2837 | Note that the size passed is of |
2838 | the whole window: call wxWindow::GetClientSize for the area which may be | |
2839 | used by the application. | |
7c913512 | 2840 | |
23324ae1 FM |
2841 | When a window is resized, usually only a small part of the window is damaged |
2842 | and you | |
2843 | may only need to repaint that area. However, if your drawing depends on the | |
2844 | size of the window, | |
2845 | you may need to clear the DC explicitly and repaint the whole window. In which | |
2846 | case, you | |
2847 | may need to call wxWindow::Refresh to invalidate the entire window. | |
7c913512 | 2848 | |
23324ae1 FM |
2849 | @library{wxcore} |
2850 | @category{events} | |
7c913512 | 2851 | |
1f1d2182 | 2852 | @see wxSize, @ref overview_eventhandling |
23324ae1 FM |
2853 | */ |
2854 | class wxSizeEvent : public wxEvent | |
2855 | { | |
2856 | public: | |
2857 | /** | |
2858 | Constructor. | |
2859 | */ | |
2860 | wxSizeEvent(const wxSize& sz, int id = 0); | |
2861 | ||
2862 | /** | |
2863 | Returns the entire size of the window generating the size change event. | |
2864 | */ | |
328f5751 | 2865 | wxSize GetSize() const; |
23324ae1 FM |
2866 | }; |
2867 | ||
2868 | ||
e54c96f1 | 2869 | |
23324ae1 FM |
2870 | /** |
2871 | @class wxSetCursorEvent | |
2872 | @wxheader{event.h} | |
7c913512 | 2873 | |
23324ae1 FM |
2874 | A SetCursorEvent is generated when the mouse cursor is about to be set as a |
2875 | result of mouse motion. This event gives the application the chance to perform | |
2876 | specific mouse cursor processing based on the current position of the mouse | |
2877 | within the window. Use wxSetCursorEvent::SetCursor to | |
2878 | specify the cursor you want to be displayed. | |
7c913512 | 2879 | |
23324ae1 | 2880 | @library{wxcore} |
1f1d2182 | 2881 | @category{events} |
7c913512 | 2882 | |
e54c96f1 | 2883 | @see ::wxSetCursor, wxWindow::wxSetCursor |
23324ae1 FM |
2884 | */ |
2885 | class wxSetCursorEvent : public wxEvent | |
2886 | { | |
2887 | public: | |
2888 | /** | |
2889 | Constructor, used by the library itself internally to initialize the event | |
2890 | object. | |
2891 | */ | |
2892 | wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0); | |
2893 | ||
2894 | /** | |
2895 | Returns a reference to the cursor specified by this event. | |
2896 | */ | |
a6052817 | 2897 | const wxCursor& GetCursor() const; |
23324ae1 FM |
2898 | |
2899 | /** | |
2900 | Returns the X coordinate of the mouse in client coordinates. | |
2901 | */ | |
328f5751 | 2902 | wxCoord GetX() const; |
23324ae1 FM |
2903 | |
2904 | /** | |
2905 | Returns the Y coordinate of the mouse in client coordinates. | |
2906 | */ | |
328f5751 | 2907 | wxCoord GetY() const; |
23324ae1 FM |
2908 | |
2909 | /** | |
2910 | Returns @true if the cursor specified by this event is a valid cursor. | |
3c4f71cc | 2911 | |
23324ae1 | 2912 | @remarks You cannot specify wxNullCursor with this event, as it is not |
4cc4bfaf | 2913 | considered a valid cursor. |
23324ae1 | 2914 | */ |
328f5751 | 2915 | bool HasCursor() const; |
23324ae1 FM |
2916 | |
2917 | /** | |
2918 | Sets the cursor associated with this event. | |
2919 | */ | |
2920 | void SetCursor(const wxCursor& cursor); | |
2921 | }; | |
e54c96f1 | 2922 | |
39fb8056 FM |
2923 | |
2924 | ||
7fa7088e BP |
2925 | // ============================================================================ |
2926 | // Global functions/macros | |
2927 | // ============================================================================ | |
2928 | ||
2929 | /** @ingroup group_funcmacro_misc */ | |
2930 | //@{ | |
2931 | ||
39fb8056 FM |
2932 | /** |
2933 | In a GUI application, this function posts @a event to the specified @e dest | |
7fa7088e BP |
2934 | object using wxEvtHandler::AddPendingEvent(). |
2935 | ||
2936 | Otherwise, it dispatches @a event immediately using | |
2937 | wxEvtHandler::ProcessEvent(). See the respective documentation for details | |
2938 | (and caveats). | |
39fb8056 | 2939 | |
7fa7088e | 2940 | @header{wx/event.h} |
39fb8056 | 2941 | */ |
3d6c68c1 | 2942 | void wxPostEvent(wxEvtHandler* dest, wxEvent& event); |
7fa7088e BP |
2943 | |
2944 | //@} | |
2945 |