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