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