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