1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxEventHandler, wxEventBlocker and many
4 // wxEvent-derived classes
5 // Author: wxWidgets team
7 // Licence: wxWindows license
8 /////////////////////////////////////////////////////////////////////////////
16 An event is a structure holding information about an event passed to a
17 callback or member function.
19 wxEvent used to be a multipurpose event object, and is an abstract base class
20 for other event classes (see below).
22 For more information about events, see the @ref overview_eventhandling overview.
25 In wxPerl custom event classes should be derived from
26 @c Wx::PlEvent and @c Wx::PlCommandEvent.
32 @see wxCommandEvent, wxMouseEvent
34 class wxEvent
: public wxObject
38 Constructor. Should not need to be used directly by an application.
40 wxEvent(int id
= 0, wxEventType eventType
= wxEVT_NULL
);
43 Returns a copy of the event.
45 Any event that is posted to the wxWidgets event system for later action
46 (via wxEvtHandler::AddPendingEvent or wxPostEvent()) must implement
49 All wxWidgets events fully implement this method, but any derived events
50 implemented by the user should also implement this method just in case they
51 (or some event derived from them) are ever posted.
53 All wxWidgets events implement a copy constructor, so the easiest way of
54 implementing the Clone function is to implement a copy constructor for
55 a new event (call it MyEvent) and then define the Clone function like this:
58 wxEvent *Clone() const { return new MyEvent(*this); }
61 virtual wxEvent
* Clone() const = 0;
64 Returns the object (usually a window) associated with the event, if any.
66 wxObject
* GetEventObject() const;
69 Returns the identifier of the given event type, such as @c wxEVT_COMMAND_BUTTON_CLICKED.
71 wxEventType
GetEventType() const;
74 Returns the identifier associated with this event, such as a button command id.
79 Returns @true if the event handler should be skipped, @false otherwise.
81 bool GetSkipped() const;
84 Gets the timestamp for the event. The timestamp is the time in milliseconds
85 since some fixed moment (not necessarily the standard Unix Epoch, so only
86 differences between the timestamps and not their absolute values usually make sense).
88 long GetTimestamp() const;
91 Returns @true if the event is or is derived from wxCommandEvent else it returns @false.
93 @note exists only for optimization purposes.
95 bool IsCommandEvent() const;
98 Sets the propagation level to the given value (for example returned from an
99 earlier call to wxEvent::StopPropagation).
101 void ResumePropagation(int propagationLevel
);
104 Sets the originating object.
106 void SetEventObject(wxObject
* object
);
111 void SetEventType(wxEventType type
);
114 Sets the identifier associated with this event, such as a button command id.
119 Sets the timestamp for the event.
121 void SetTimestamp(long = 0);
124 Test if this event should be propagated or not, i.e. if the propagation level
125 is currently greater than 0.
127 bool ShouldPropagate() const;
130 This method can be used inside an event handler to control whether further
131 event handlers bound to this event will be called after the current one returns.
133 Without Skip() (or equivalently if Skip(@false) is used), the event will not
134 be processed any more. If Skip(@true) is called, the event processing system
135 continues searching for a further handler function for this event, even though
136 it has been processed already in the current handler.
138 In general, it is recommended to skip all non-command events to allow the
139 default handling to take place. The command events are, however, normally not
140 skipped as usually a single command such as a button click or menu item
141 selection must only be processed by one handler.
143 void Skip(bool skip
= true);
146 Stop the event from propagating to its parent window.
148 Returns the old propagation level value which may be later passed to
149 ResumePropagation() to allow propagating the event again.
151 int StopPropagation();
155 Indicates how many levels the event can propagate.
157 This member is protected and should typically only be set in the constructors
158 of the derived classes. It may be temporarily changed by StopPropagation()
159 and ResumePropagation() and tested with ShouldPropagate().
161 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default)
162 meaning that the event shouldn't be propagated at all or to
163 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
164 propagated as much as necessary.
166 Any positive number means that the event should be propagated but no more than
167 the given number of times. E.g. the propagation level may be set to 1 to
168 propagate the event to its parent only, but not to its grandparent.
170 int m_propagationLevel
;
174 @class wxEventBlocker
177 This class is a special event handler which allows to discard
178 any event (or a set of event types) directed to a specific window.
183 void MyWindow::DoSomething()
186 // block all events directed to this window while
187 // we do the 1000 FunctionWhichSendsEvents() calls
188 wxEventBlocker blocker(this);
190 for ( int i = 0; i 1000; i++ )
191 FunctionWhichSendsEvents(i);
193 } // ~wxEventBlocker called, old event handler is restored
195 // the event generated by this call will be processed:
196 FunctionWhichSendsEvents(0)
203 @see @ref overview_eventhandling, wxEvtHandler
205 class wxEventBlocker
: public wxEvtHandler
209 Constructs the blocker for the given window and for the given event type.
211 If @a type is @c wxEVT_ANY, then all events for that window are blocked.
212 You can call Block() after creation to add other event types to the list
215 Note that the @a win window @b must remain alive until the
216 wxEventBlocker object destruction.
218 wxEventBlocker(wxWindow
* win
, wxEventType
= wxEVT_ANY
);
221 Destructor. The blocker will remove itself from the chain of event handlers for
222 the window provided in the constructor, thus restoring normal processing of events.
224 virtual ~wxEventBlocker();
227 Adds to the list of event types which should be blocked the given @a eventType.
229 void Block(wxEventType eventType
);
238 A class that can handle events from the windowing system.
239 wxWindow (and therefore all window classes) are derived from this class.
241 When events are received, wxEvtHandler invokes the method listed in the
242 event table using itself as the object. When using multiple inheritance
243 it is imperative that the wxEvtHandler(-derived) class be the first
244 class inherited such that the "this" pointer for the overall object
245 will be identical to the "this" pointer for the wxEvtHandler portion.
250 @see @ref overview_eventhandling
252 class wxEvtHandler
: public wxObject
263 If the handler is part of a chain, the destructor will unlink itself and
264 restore the previous and next handlers so that they point to each other.
266 virtual ~wxEvtHandler();
269 Queue event for a later processing.
271 This method is similar to ProcessEvent() but while the latter is
272 synchronous, i.e. the event is processed immediately, before the
273 function returns, this one is asynchronous and returns immediately
274 while the event will be processed at some later time (usually during
275 the next event loop iteration).
277 Another important difference is that this method takes ownership of the
278 @a event parameter, i.e. it will delete it itself. This implies that
279 the event should be allocated on the heap and that the pointer can't be
280 used any more after the function returns (as it can be deleted at any
283 QueueEvent() can be used for inter-thread communication from the worker
284 threads to the main thread, it is safe in the sense that it uses
285 locking internally and avoids the problem mentioned in AddPendingEvent()
286 documentation by ensuring that the @a event object is not used by the
287 calling thread any more. Care should still be taken to avoid that some
288 fields of this object are used by it, notably any wxString members of
289 the event object must not be shallow copies of another wxString object
290 as this would result in them still using the same string buffer behind
291 the scenes. For example
293 void FunctionInAWorkerThread(const wxString& str)
295 wxCommandEvent * const e = new wxCommandEvent;
297 // NOT e->SetString(str) as this would be a shallow copy
298 e->SetString(str.c_str()); // make a deep copy
300 wxTheApp->QueueEvent(new wxCommandEvent
304 Finally notice that this method automatically wakes up the event loop
305 if it is currently idle by calling ::wxWakeUpIdle() so there is no need
306 to do it manually when using it.
311 A heap-allocated event to be queued, QueueEvent() takes ownership
312 of it. This parameter shouldn't be @c NULL.
314 virtual void QueueEvent(wxEvent
*event
);
317 Post an event to be processed later.
319 This function is similar to QueueEvent() but can't be used to post
320 events from worker threads for the event objects with wxString fields
321 (i.e. in practice most of them) because of an unsafe use of the same
322 wxString object which happens because the wxString field in the
323 original @a event object and its copy made internally by this function
324 share the same string buffer internally. Use QueueEvent() to avoid
327 A copy of event is made by the function, so the original can be deleted
328 as soon as function returns (it is common that the original is created
329 on the stack). This requires that the wxEvent::Clone() method be
330 implemented by event so that it can be duplicated and stored until it
334 Event to add to the pending events queue.
336 virtual void AddPendingEvent(const wxEvent
& event
);
339 Connects the given function dynamically with the event handler, id and event type.
340 This is an alternative to the use of static event tables.
342 See the @ref page_samples_event sample for usage.
344 This specific overload allows you to connect an event handler to a @e range
346 Do not confuse @e source IDs with event @e types: source IDs identify the
347 event generator objects (typically wxMenuItem or wxWindow objects) while the
348 event @e type identify which type of events should be handled by the
349 given @e function (an event generator object may generate many different
353 The first ID of the identifier range to be associated with the event
356 The last ID of the identifier range to be associated with the event
359 The event type to be associated with this event handler.
361 The event handler function. Note that this function should
362 be explicitly converted to the correct type which can be done using a macro
363 called @c wxFooEventHandler for the handler for any @c wxFooEvent.
365 Data to be associated with the event table entry.
367 Object whose member function should be called.
368 If this is @NULL, @c *this will be used.
370 void Connect(int id
, int lastId
, wxEventType eventType
,
371 wxObjectEventFunction function
,
372 wxObject
* userData
= NULL
,
373 wxEvtHandler
* eventSink
= NULL
);
376 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
377 overload for more info.
379 This overload can be used to attach an event handler to a single source ID:
383 frame->Connect( wxID_EXIT,
384 wxEVT_COMMAND_MENU_SELECTED,
385 wxCommandEventHandler(MyFrame::OnQuit) );
388 void Connect(int id
, wxEventType eventType
,
389 wxObjectEventFunction function
,
390 wxObject
* userData
= NULL
,
391 wxEvtHandler
* eventSink
= NULL
);
394 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
395 overload for more info.
397 This overload will connect the given event handler so that regardless of the
398 ID of the event source, the handler will be called.
400 void Connect(wxEventType eventType
,
401 wxObjectEventFunction function
,
402 wxObject
* userData
= NULL
,
403 wxEvtHandler
* eventSink
= NULL
);
406 Disconnects the given function dynamically from the event handler, using the
407 specified parameters as search criteria and returning @true if a matching
408 function has been found and removed.
410 This method can only disconnect functions which have been added using the
411 Connect() method. There is no way to disconnect functions connected using
412 the (static) event tables.
415 The event type associated with this event handler.
417 The event handler function.
419 Data associated with the event table entry.
421 Object whose member function should be called.
423 bool Disconnect(wxEventType eventType
= wxEVT_NULL
,
424 wxObjectEventFunction function
= NULL
,
425 wxObject
* userData
= NULL
,
426 wxEvtHandler
* eventSink
= NULL
);
429 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
430 overload for more info.
432 This overload takes the additional @a id parameter.
434 bool Disconnect(int id
= wxID_ANY
,
435 wxEventType eventType
= wxEVT_NULL
,
436 wxObjectEventFunction function
= NULL
,
437 wxObject
* userData
= NULL
,
438 wxEvtHandler
* eventSink
= NULL
);
441 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
442 overload for more info.
444 This overload takes an additional range of source IDs.
446 bool Disconnect(int id
, int lastId
= wxID_ANY
,
447 wxEventType eventType
= wxEVT_NULL
,
448 wxObjectEventFunction function
= NULL
,
449 wxObject
* userData
= NULL
,
450 wxEvtHandler
* eventSink
= NULL
);
453 Returns user-supplied client data.
455 @remarks Normally, any extra data the programmer wishes to associate with
456 the object should be made available by deriving a new class with
461 void* GetClientData() const;
464 Returns a pointer to the user-supplied client data object.
466 @see SetClientObject(), wxClientData
468 wxClientData
* GetClientObject() const;
471 Returns @true if the event handler is enabled, @false otherwise.
473 @see SetEvtHandlerEnabled()
475 bool GetEvtHandlerEnabled() const;
478 Returns the pointer to the next handler in the chain.
480 @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(),
481 wxWindow::PushEventHandler, wxWindow::PopEventHandler
483 wxEvtHandler
* GetNextHandler() const;
486 Returns the pointer to the previous handler in the chain.
488 @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(),
489 wxWindow::PushEventHandler, wxWindow::PopEventHandler
491 wxEvtHandler
* GetPreviousHandler() const;
494 Processes an event, searching event tables and calling zero or more suitable
495 event handler function(s).
497 Normally, your application would not call this function: it is called in the
498 wxWidgets implementation to dispatch incoming user interface events to the
499 framework (and application).
501 However, you might need to call it if implementing new functionality
502 (such as a new control) where you define new event types, as opposed to
503 allowing the user to override virtual functions.
505 An instance where you might actually override the ProcessEvent function is where
506 you want to direct event processing to event handlers not normally noticed by
507 wxWidgets. For example, in the document/view architecture, documents and views
508 are potential event handlers. When an event reaches a frame, ProcessEvent will
509 need to be called on the associated document and view in case event handler functions
510 are associated with these objects. The property classes library (wxProperty) also
511 overrides ProcessEvent for similar reasons.
513 The normal order of event table searching is as follows:
514 -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled)
515 the function skips to step (6).
516 -# If the object is a wxWindow, ProcessEvent() is recursively called on the
517 window's wxValidator. If this returns @true, the function exits.
518 -# SearchEventTable() is called for this event handler. If this fails, the base
519 class table is tried, and so on until no more tables exist or an appropriate
520 function was found, in which case the function exits.
521 -# The search is applied down the entire chain of event handlers (usually the
522 chain has a length of one). If this succeeds, the function exits.
523 -# If the object is a wxWindow and the event is a wxCommandEvent, ProcessEvent()
524 is recursively applied to the parent window's event handler.
525 If this returns true, the function exits.
526 -# Finally, ProcessEvent() is called on the wxApp object.
531 @returns @true if a suitable event handler function was found and
532 executed, and the function did not call wxEvent::Skip.
534 @see SearchEventTable()
536 virtual bool ProcessEvent(wxEvent
& event
);
539 Processes an event by calling ProcessEvent() and handles any exceptions
540 that occur in the process.
541 If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called.
546 @returns @true if the event was processed, @false if no handler was found
547 or an exception was thrown.
549 @see wxWindow::HandleWindowEvent
551 bool SafelyProcessEvent(wxEvent
& event
);
554 Searches the event table, executing an event handler function if an appropriate
558 Event table to be searched.
560 Event to be matched against an event table entry.
562 @returns @true if a suitable event handler function was found and
563 executed, and the function did not call wxEvent::Skip.
565 @remarks This function looks through the object's event table and tries
566 to find an entry that will match the event.
567 An entry will match if:
568 @li The event type matches, and
569 @li the identifier or identifier range matches, or the event table
570 entry's identifier is zero.
571 If a suitable function is called but calls wxEvent::Skip, this
572 function will fail, and searching will continue.
576 virtual bool SearchEventTable(wxEventTable
& table
,
580 Sets user-supplied client data.
583 Data to be associated with the event handler.
585 @remarks Normally, any extra data the programmer wishes to associate
586 with the object should be made available by deriving a new
587 class with new data members. You must not call this method
588 and SetClientObject on the same class - only one of them.
592 void SetClientData(void* data
);
595 Set the client data object. Any previous object will be deleted.
597 @see GetClientObject(), wxClientData
599 void SetClientObject(wxClientData
* data
);
602 Enables or disables the event handler.
605 @true if the event handler is to be enabled, @false if it is to be disabled.
607 @remarks You can use this function to avoid having to remove the event
608 handler from the chain, for example when implementing a
609 dialog editor and changing from edit to test mode.
611 @see GetEvtHandlerEnabled()
613 void SetEvtHandlerEnabled(bool enabled
);
616 Sets the pointer to the next handler.
619 Event handler to be set as the next handler.
621 @see GetNextHandler(), SetPreviousHandler(), GetPreviousHandler(),
622 wxWindow::PushEventHandler, wxWindow::PopEventHandler
624 void SetNextHandler(wxEvtHandler
* handler
);
627 Sets the pointer to the previous handler.
630 Event handler to be set as the previous handler.
632 void SetPreviousHandler(wxEvtHandler
* handler
);
640 This event class contains information about keypress (character) events.
642 Notice that there are three different kinds of keyboard events in wxWidgets:
643 key down and up events and char events. The difference between the first two
644 is clear - the first corresponds to a key press and the second to a key
645 release - otherwise they are identical. Just note that if the key is
646 maintained in a pressed state you will typically get a lot of (automatically
647 generated) down events but only one up so it is wrong to assume that there is
648 one up event corresponding to each down one.
650 Both key events provide untranslated key codes while the char event carries
651 the translated one. The untranslated code for alphanumeric keys is always
652 an upper case value. For the other keys it is one of @c WXK_XXX values
653 from the @ref page_keycodes.
654 The translated key is, in general, the character the user expects to appear
655 as the result of the key combination when typing the text into a text entry
658 A few examples to clarify this (all assume that CAPS LOCK is unpressed
659 and the standard US keyboard): when the @c 'A' key is pressed, the key down
660 event key code is equal to @c ASCII A == 65. But the char event key code
661 is @c ASCII a == 97. On the other hand, if you press both SHIFT and
662 @c 'A' keys simultaneously , the key code in key down event will still be
663 just @c 'A' while the char event key code parameter will now be @c 'A'
666 Although in this simple case it is clear that the correct key code could be
667 found in the key down event handler by checking the value returned by
668 wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as
669 for non-alphanumeric keys the translation is keyboard-layout dependent and
670 can only be done properly by the system itself.
672 Another kind of translation is done when the control key is pressed: for
673 example, for CTRL-A key press the key down event still carries the
674 same key code @c 'a' as usual but the char event will have key code of 1,
675 the ASCII value of this key combination.
677 You may discover how the other keys on your system behave interactively by
678 running the @ref page_samples_text wxWidgets sample and pressing some keys
679 in any of the text controls shown in it.
681 @b Tip: be sure to call @c event.Skip() for events that you don't process in
682 key event function, otherwise menu shortcuts may cease to work under Windows.
684 @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler
685 does not call @c event.Skip() then the corresponding char event
686 (@c EVT_CHAR) will not happen.
687 This is by design and enables the programs that handle both types of
688 events to be a bit simpler.
690 @note For Windows programmers: The key and char events in wxWidgets are
691 similar to but slightly different from Windows @c WM_KEYDOWN and
692 @c WM_CHAR events. In particular, Alt-x combination will generate a
693 char event in wxWidgets (unless it is used as an accelerator).
696 @beginEventTable{wxKeyEvent}
697 @event{EVT_KEY_DOWN(func)}
698 Process a wxEVT_KEY_DOWN event (any key has been pressed).
699 @event{EVT_KEY_UP(func)}
700 Process a wxEVT_KEY_UP event (any key has been released).
701 @event{EVT_CHAR(func)}
702 Process a wxEVT_CHAR event.
708 class wxKeyEvent
: public wxEvent
713 Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK.
715 wxKeyEvent(wxEventType keyEventType
= wxEVT_NULL
);
718 Returns @true if the Alt key was down at the time of the key event.
720 Notice that GetModifiers() is easier to use correctly than this function
721 so you should consider using it in new code.
723 bool AltDown() const;
726 CMD is a pseudo key which is the same as Control for PC and Unix
727 platforms but the special APPLE (a.k.a as COMMAND) key under Macs:
728 it makes often sense to use it instead of, say, ControlDown() because Cmd
729 key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still
730 exists, just not used for this purpose under Mac). So for non-Mac platforms
731 this is the same as ControlDown() and under Mac this is the same as MetaDown().
733 bool CmdDown() const;
736 Returns @true if the control key was down at the time of the key event.
738 Notice that GetModifiers() is easier to use correctly than this function
739 so you should consider using it in new code.
741 bool ControlDown() const;
744 Returns the virtual key code. ASCII events return normal ASCII values,
745 while non-ASCII events return values such as @b WXK_LEFT for the left cursor
746 key. See @ref page_keycodes for a full list of the virtual key codes.
748 Note that in Unicode build, the returned value is meaningful only if the
749 user entered a character that can be represented in current locale's default
750 charset. You can obtain the corresponding Unicode character using GetUnicodeKey().
752 int GetKeyCode() const;
755 Return the bitmask of modifier keys which were pressed when this event
756 happened. See @ref page_keymodifiers for the full list of modifiers.
758 Notice that this function is easier to use correctly than, for example,
759 ControlDown() because when using the latter you also have to remember to
760 test that none of the other modifiers is pressed:
763 if ( ControlDown() && !AltDown() && !ShiftDown() && !MetaDown() )
764 ... handle Ctrl-XXX ...
767 and forgetting to do it can result in serious program bugs (e.g. program
768 not working with European keyboard layout where ALTGR key which is seen by
769 the program as combination of CTRL and ALT is used). On the other hand,
770 you can simply write:
773 if ( GetModifiers() == wxMOD_CONTROL )
774 ... handle Ctrl-XXX ...
779 int GetModifiers() const;
783 Obtains the position (in client coordinates) at which the key was pressed.
785 wxPoint
GetPosition() const;
786 void GetPosition(long* x
, long* y
) const;
790 Returns the raw key code for this event. This is a platform-dependent scan code
791 which should only be used in advanced applications.
793 @note Currently the raw key codes are not supported by all ports, use
794 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
796 wxUint32
GetRawKeyCode() const;
799 Returns the low level key flags for this event. The flags are
800 platform-dependent and should only be used in advanced applications.
802 @note Currently the raw key flags are not supported by all ports, use
803 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
805 wxUint32
GetRawKeyFlags() const;
808 Returns the Unicode character corresponding to this key event.
810 This function is only available in Unicode build, i.e. when
811 @c wxUSE_UNICODE is 1.
813 wxChar
GetUnicodeKey() const;
816 Returns the X position (in client coordinates) of the event.
818 wxCoord
GetX() const;
821 Returns the Y position (in client coordinates) of the event.
823 wxCoord
GetY() const;
826 Returns @true if either CTRL or ALT keys was down at the time of the
829 Note that this function does not take into account neither SHIFT nor
830 META key states (the reason for ignoring the latter is that it is
831 common for NUMLOCK key to be configured as META under X but the key
832 presses even while NUMLOCK is on should be still processed normally).
834 bool HasModifiers() const;
837 Returns @true if the Meta key was down at the time of the key event.
839 Notice that GetModifiers() is easier to use correctly than this function
840 so you should consider using it in new code.
842 bool MetaDown() const;
845 Returns @true if the shift key was down at the time of the key event.
847 Notice that GetModifiers() is easier to use correctly than this function
848 so you should consider using it in new code.
850 bool ShiftDown() const;
856 @class wxJoystickEvent
859 This event class contains information about joystick events, particularly
860 events received by windows.
862 @beginEventTable{wxJoystickEvent}
863 @style{EVT_JOY_BUTTON_DOWN(func)}
864 Process a wxEVT_JOY_BUTTON_DOWN event.
865 @style{EVT_JOY_BUTTON_UP(func)}
866 Process a wxEVT_JOY_BUTTON_UP event.
867 @style{EVT_JOY_MOVE(func)}
868 Process a wxEVT_JOY_MOVE event.
869 @style{EVT_JOY_ZMOVE(func)}
870 Process a wxEVT_JOY_ZMOVE event.
871 @style{EVT_JOYSTICK_EVENTS(func)}
872 Processes all joystick events.
880 class wxJoystickEvent
: public wxEvent
886 wxJoystickEvent(wxEventType eventType
= wxEVT_NULL
, int state
= 0,
887 int joystick
= wxJOYSTICK1
,
891 Returns @true if the event was a down event from the specified button
895 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
896 indicate any button down event.
898 bool ButtonDown(int button
= wxJOY_BUTTON_ANY
) const;
901 Returns @true if the specified button (or any button) was in a down state.
904 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
905 indicate any button down event.
907 bool ButtonIsDown(int button
= wxJOY_BUTTON_ANY
) const;
910 Returns @true if the event was an up event from the specified button
914 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
915 indicate any button down event.
917 bool ButtonUp(int button
= wxJOY_BUTTON_ANY
) const;
920 Returns the identifier of the button changing state.
922 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
924 int GetButtonChange() const;
927 Returns the down state of the buttons.
929 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
931 int GetButtonState() const;
934 Returns the identifier of the joystick generating the event - one of
935 wxJOYSTICK1 and wxJOYSTICK2.
937 int GetJoystick() const;
940 Returns the x, y position of the joystick event.
942 wxPoint
GetPosition() const;
945 Returns the z position of the joystick event.
947 int GetZPosition() const;
950 Returns @true if this was a button up or down event
951 (@e not 'is any button down?').
953 bool IsButton() const;
956 Returns @true if this was an x, y move event.
961 Returns @true if this was a z move event.
963 bool IsZMove() const;
969 @class wxScrollWinEvent
972 A scroll event holds information about events sent from scrolling windows.
975 @beginEventTable{wxScrollWinEvent}
976 You can use the EVT_SCROLLWIN* macros for intercepting scroll window events
977 from the receiving window.
978 @event{EVT_SCROLLWIN(func)}
979 Process all scroll events.
980 @event{EVT_SCROLLWIN_TOP(func)}
981 Process wxEVT_SCROLLWIN_TOP scroll-to-top events.
982 @event{EVT_SCROLLWIN_BOTTOM(func)}
983 Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events.
984 @event{EVT_SCROLLWIN_LINEUP(func)}
985 Process wxEVT_SCROLLWIN_LINEUP line up events.
986 @event{EVT_SCROLLWIN_LINEDOWN(func)}
987 Process wxEVT_SCROLLWIN_LINEDOWN line down events.
988 @event{EVT_SCROLLWIN_PAGEUP(func)}
989 Process wxEVT_SCROLLWIN_PAGEUP page up events.
990 @event{EVT_SCROLLWIN_PAGEDOWN(func)}
991 Process wxEVT_SCROLLWIN_PAGEDOWN page down events.
992 @event{EVT_SCROLLWIN_THUMBTRACK(func)}
993 Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events
994 (frequent events sent as the user drags the thumbtrack).
995 @event{EVT_SCROLLWIN_THUMBRELEASE(func)}
996 Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events.
1003 @see wxScrollEvent, @ref overview_eventhandling
1005 class wxScrollWinEvent
: public wxEvent
1011 wxScrollWinEvent(wxEventType commandType
= wxEVT_NULL
, int pos
= 0,
1012 int orientation
= 0);
1015 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
1018 @todo wxHORIZONTAL and wxVERTICAL should go in their own enum
1020 int GetOrientation() const;
1023 Returns the position of the scrollbar for the thumb track and release events.
1025 Note that this field can't be used for the other events, you need to query
1026 the window itself for the current position in that case.
1028 int GetPosition() const;
1034 @class wxSysColourChangedEvent
1037 This class is used for system colour change events, which are generated
1038 when the user changes the colour settings using the control panel.
1039 This is only appropriate under Windows.
1042 The default event handler for this event propagates the event to child windows,
1043 since Windows only sends the events to top-level windows.
1044 If intercepting this event for a top-level window, remember to call the base
1045 class handler, or to pass the event on to the window's children explicitly.
1047 @beginEventTable{wxSysColourChangedEvent}
1048 @event{EVT_SYS_COLOUR_CHANGED(func)}
1049 Process a wxEVT_SYS_COLOUR_CHANGED event.
1055 @see @ref overview_eventhandling
1057 class wxSysColourChangedEvent
: public wxEvent
1063 wxSysColourChangedEvent();
1069 @class wxWindowCreateEvent
1072 This event is sent just after the actual window associated with a wxWindow
1073 object has been created.
1075 Since it is derived from wxCommandEvent, the event propagates up
1076 the window hierarchy.
1078 @beginEventTable{wxWindowCreateEvent}
1079 @event{EVT_WINDOW_CREATE(func)}
1080 Process a wxEVT_CREATE event.
1086 @see @ref overview_eventhandling, wxWindowDestroyEvent
1088 class wxWindowCreateEvent
: public wxCommandEvent
1094 wxWindowCreateEvent(wxWindow
* win
= NULL
);
1103 A paint event is sent when a window's contents needs to be repainted.
1105 Please notice that in general it is impossible to change the drawing of a
1106 standard control (such as wxButton) and so you shouldn't attempt to handle
1107 paint events for them as even if it might work on some platforms, this is
1108 inherently not portable and won't work everywhere.
1111 Note that in a paint event handler, the application must always create a
1112 wxPaintDC object, even if you do not use it. Otherwise, under MS Windows,
1113 refreshing for this and other windows will go wrong.
1116 void MyWindow::OnPaint(wxPaintEvent& event)
1123 You can optimize painting by retrieving the rectangles that have been damaged
1124 and only repainting these. The rectangles are in terms of the client area,
1125 and are unscrolled, so you will need to do some calculations using the current
1126 view position to obtain logical, scrolled units.
1127 Here is an example of using the wxRegionIterator class:
1129 // Called when window needs to be repainted.
1130 void MyWindow::OnPaint(wxPaintEvent& event)
1134 // Find Out where the window is scrolled to
1135 int vbX,vbY; // Top left corner of client
1136 GetViewStart(&vbX,&vbY);
1138 int vX,vY,vW,vH; // Dimensions of client area in pixels
1139 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
1148 // Alternatively we can do this:
1149 // wxRect rect(upd.GetRect());
1151 // Repaint this rectangle
1160 @beginEventTable{wxPaintEvent}
1161 @event{EVT_PAINT(func)}
1162 Process a wxEVT_PAINT event.
1168 @see @ref overview_eventhandling
1170 class wxPaintEvent
: public wxEvent
1176 wxPaintEvent(int id
= 0);
1182 @class wxMaximizeEvent
1185 An event being sent when a top level window is maximized. Notice that it is
1186 not sent when the window is restored to its original size after it had been
1187 maximized, only a normal wxSizeEvent is generated in this case.
1189 @beginEventTable{wxMaximizeEvent}
1190 @event{EVT_MAXIMIZE(func)}
1191 Process a wxEVT_MAXIMIZE event.
1197 @see @ref overview_eventhandling, wxTopLevelWindow::Maximize,
1198 wxTopLevelWindow::IsMaximized
1200 class wxMaximizeEvent
: public wxEvent
1204 Constructor. Only used by wxWidgets internally.
1206 wxMaximizeEvent(int id
= 0);
1210 The possibles modes to pass to wxUpdateUIEvent::SetMode().
1214 /** Send UI update events to all windows. */
1215 wxUPDATE_UI_PROCESS_ALL
,
1217 /** Send UI update events to windows that have
1218 the wxWS_EX_PROCESS_UI_UPDATES flag specified. */
1219 wxUPDATE_UI_PROCESS_SPECIFIED
1224 @class wxUpdateUIEvent
1227 This class is used for pseudo-events which are called by wxWidgets
1228 to give an application the chance to update various user interface elements.
1230 Without update UI events, an application has to work hard to check/uncheck,
1231 enable/disable, show/hide, and set the text for elements such as menu items
1232 and toolbar buttons. The code for doing this has to be mixed up with the code
1233 that is invoked when an action is invoked for a menu item or button.
1235 With update UI events, you define an event handler to look at the state of the
1236 application and change UI elements accordingly. wxWidgets will call your member
1237 functions in idle time, so you don't have to worry where to call this code.
1239 In addition to being a clearer and more declarative method, it also means you don't
1240 have to worry whether you're updating a toolbar or menubar identifier. The same
1241 handler can update a menu item and toolbar button, if the identifier is the same.
1242 Instead of directly manipulating the menu or button, you call functions in the event
1243 object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a
1244 call has been made, and which UI element to update.
1246 These events will work for popup menus as well as menubars. Just before a menu is
1247 popped up, wxMenu::UpdateUI is called to process any UI events for the window that
1250 If you find that the overhead of UI update processing is affecting your application,
1251 you can do one or both of the following:
1252 @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED,
1253 and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should
1254 receive update events. No other windows will receive update events.
1255 @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay
1256 between updates. You may need to call wxWindow::UpdateWindowUI at critical points,
1257 for example when a dialog is about to be shown, in case the user sees a slight
1258 delay before windows are updated.
1260 Note that although events are sent in idle time, defining a wxIdleEvent handler
1261 for a window does not affect this because the events are sent from wxWindow::OnInternalIdle
1262 which is always called in idle time.
1264 wxWidgets tries to optimize update events on some platforms.
1265 On Windows and GTK+, events for menubar items are only sent when the menu is about
1266 to be shown, and not in idle time.
1269 @beginEventTable{wxUpdateUIEvent}
1270 @event{EVT_UPDATE_UI(id, func)}
1271 Process a wxEVT_UPDATE_UI event for the command with the given id.
1272 @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}
1273 Process a wxEVT_UPDATE_UI event for any command with id included in the given range.
1279 @see @ref overview_eventhandling
1281 class wxUpdateUIEvent
: public wxCommandEvent
1287 wxUpdateUIEvent(wxWindowID commandId
= 0);
1290 Returns @true if it is appropriate to update (send UI update events to)
1293 This function looks at the mode used (see wxUpdateUIEvent::SetMode),
1294 the wxWS_EX_PROCESS_UI_UPDATES flag in @a window, the time update events
1295 were last sent in idle time, and the update interval, to determine whether
1296 events should be sent to this window now. By default this will always
1297 return @true because the update mode is initially wxUPDATE_UI_PROCESS_ALL
1298 and the interval is set to 0; so update events will be sent as often as
1299 possible. You can reduce the frequency that events are sent by changing the
1300 mode and/or setting an update interval.
1302 @see ResetUpdateTime(), SetUpdateInterval(), SetMode()
1304 static bool CanUpdate(wxWindow
* window
);
1307 Check or uncheck the UI element.
1309 void Check(bool check
);
1312 Enable or disable the UI element.
1314 void Enable(bool enable
);
1317 Returns @true if the UI element should be checked.
1319 bool GetChecked() const;
1322 Returns @true if the UI element should be enabled.
1324 bool GetEnabled() const;
1327 Static function returning a value specifying how wxWidgets will send update
1328 events: to all windows, or only to those which specify that they will process
1333 static wxUpdateUIMode
GetMode();
1336 Returns @true if the application has called Check().
1337 For wxWidgets internal use only.
1339 bool GetSetChecked() const;
1342 Returns @true if the application has called Enable().
1343 For wxWidgets internal use only.
1345 bool GetSetEnabled() const;
1348 Returns @true if the application has called Show().
1349 For wxWidgets internal use only.
1351 bool GetSetShown() const;
1354 Returns @true if the application has called SetText().
1355 For wxWidgets internal use only.
1357 bool GetSetText() const;
1360 Returns @true if the UI element should be shown.
1362 bool GetShown() const;
1365 Returns the text that should be set for the UI element.
1367 wxString
GetText() const;
1370 Returns the current interval between updates in milliseconds.
1371 The value -1 disables updates, 0 updates as frequently as possible.
1373 @see SetUpdateInterval().
1375 static long GetUpdateInterval();
1378 Used internally to reset the last-updated time to the current time.
1380 It is assumed that update events are normally sent in idle time, so this
1381 is called at the end of idle processing.
1383 @see CanUpdate(), SetUpdateInterval(), SetMode()
1385 static void ResetUpdateTime();
1388 Specify how wxWidgets will send update events: to all windows, or only to
1389 those which specify that they will process the events.
1392 this parameter may be one of the ::wxUpdateUIMode enumeration values.
1393 The default mode is wxUPDATE_UI_PROCESS_ALL.
1395 static void SetMode(wxUpdateUIMode mode
);
1398 Sets the text for this UI element.
1400 void SetText(const wxString
& text
);
1403 Sets the interval between updates in milliseconds.
1405 Set to -1 to disable updates, or to 0 to update as frequently as possible.
1408 Use this to reduce the overhead of UI update events if your application
1409 has a lot of windows. If you set the value to -1 or greater than 0,
1410 you may also need to call wxWindow::UpdateWindowUI at appropriate points
1411 in your application, such as when a dialog is about to be shown.
1413 static void SetUpdateInterval(long updateInterval
);
1416 Show or hide the UI element.
1418 void Show(bool show
);
1424 @class wxClipboardTextEvent
1427 This class represents the events generated by a control (typically a
1428 wxTextCtrl but other windows can generate these events as well) when its
1429 content gets copied or cut to, or pasted from the clipboard.
1431 There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY,
1432 wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE.
1434 If any of these events is processed (without being skipped) by an event
1435 handler, the corresponding operation doesn't take place which allows to
1436 prevent the text from being copied from or pasted to a control. It is also
1437 possible to examine the clipboard contents in the PASTE event handler and
1438 transform it in some way before inserting in a control -- for example,
1439 changing its case or removing invalid characters.
1441 Finally notice that a CUT event is always preceded by the COPY event which
1442 makes it possible to only process the latter if it doesn't matter if the
1443 text was copied or cut.
1446 These events are currently only generated by wxTextCtrl under GTK+.
1447 They are generated by all controls under Windows.
1449 @beginEventTable{wxClipboardTextEvent}
1450 @event{EVT_TEXT_COPY(id, func)}
1451 Some or all of the controls content was copied to the clipboard.
1452 @event{EVT_TEXT_CUT(id, func)}
1453 Some or all of the controls content was cut (i.e. copied and
1455 @event{EVT_TEXT_PASTE(id, func)}
1456 Clipboard content was pasted into the control.
1465 class wxClipboardTextEvent
: public wxCommandEvent
1471 wxClipboardTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
1480 This event class contains information about the events generated by the mouse:
1481 they include mouse buttons press and release events and mouse move events.
1483 All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
1484 left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
1485 @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
1486 buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
1487 can also be generated. Note that not all mice have even a middle button so a
1488 portable application should avoid relying on the events from it (but the right
1489 button click can be emulated using the left mouse button with the control key
1490 under Mac platforms with a single button mouse).
1492 For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
1493 purposes, the mouse is considered to be inside the window if it is in the
1494 window client area and not inside one of its children. In other words, the
1495 parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
1496 mouse leaves the window entirely but also when it enters one of its children.
1498 @note Note that under Windows CE mouse enter and leave events are not natively
1499 supported by the system but are generated by wxWidgets itself. This has several
1500 drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
1501 left the window and the state variables for it may have changed during this time.
1503 @note Note the difference between methods like wxMouseEvent::LeftDown and
1504 wxMouseEvent::LeftIsDown: the former returns @true when the event corresponds
1505 to the left mouse button click while the latter returns @true if the left
1506 mouse button is currently being pressed. For example, when the user is dragging
1507 the mouse you can use wxMouseEvent::LeftIsDown to test whether the left mouse
1508 button is (still) depressed. Also, by convention, if wxMouseEvent::LeftDown
1509 returns @true, wxMouseEvent::LeftIsDown will also return @true in wxWidgets
1510 whatever the underlying GUI behaviour is (which is platform-dependent).
1511 The same applies, of course, to other mouse buttons as well.
1514 @beginEventTable{wxMouseEvent}
1515 @event{EVT_LEFT_DOWN(func)}
1516 Process a wxEVT_LEFT_DOWN event. The handler of this event should normally
1517 call event.Skip() to allow the default processing to take place as otherwise
1518 the window under mouse wouldn't get the focus.
1519 @event{EVT_LEFT_UP(func)}
1520 Process a wxEVT_LEFT_UP event.
1521 @event{EVT_LEFT_DCLICK(func)}
1522 Process a wxEVT_LEFT_DCLICK event.
1523 @event{EVT_MIDDLE_DOWN(func)}
1524 Process a wxEVT_MIDDLE_DOWN event.
1525 @event{EVT_MIDDLE_UP(func)}
1526 Process a wxEVT_MIDDLE_UP event.
1527 @event{EVT_MIDDLE_DCLICK(func)}
1528 Process a wxEVT_MIDDLE_DCLICK event.
1529 @event{EVT_RIGHT_DOWN(func)}
1530 Process a wxEVT_RIGHT_DOWN event.
1531 @event{EVT_RIGHT_UP(func)}
1532 Process a wxEVT_RIGHT_UP event.
1533 @event{EVT_RIGHT_DCLICK(func)}
1534 Process a wxEVT_RIGHT_DCLICK event.
1535 @event{EVT_MOUSE_AUX1_DOWN(func)}
1536 Process a wxEVT_MOUSE_AUX1_DOWN event.
1537 @event{EVT_MOUSE_AUX1_UP(func)}
1538 Process a wxEVT_MOUSE_AUX1_UP event.
1539 @event{EVT_MOUSE_AUX1_DCLICK(func)}
1540 Process a wxEVT_MOUSE_AUX1_DCLICK event.
1541 @event{EVT_MOUSE_AUX2_DOWN(func)}
1542 Process a wxEVT_MOUSE_AUX2_DOWN event.
1543 @event{EVT_MOUSE_AUX2_UP(func)}
1544 Process a wxEVT_MOUSE_AUX2_UP event.
1545 @event{EVT_MOUSE_AUX2_DCLICK(func)}
1546 Process a wxEVT_MOUSE_AUX2_DCLICK event.
1547 @event{EVT_MOTION(func)}
1548 Process a wxEVT_MOTION event.
1549 @event{EVT_ENTER_WINDOW(func)}
1550 Process a wxEVT_ENTER_WINDOW event.
1551 @event{EVT_LEAVE_WINDOW(func)}
1552 Process a wxEVT_LEAVE_WINDOW event.
1553 @event{EVT_MOUSEWHEEL(func)}
1554 Process a wxEVT_MOUSEWHEEL event.
1555 @event{EVT_MOUSE_EVENTS(func)}
1556 Process all mouse events.
1562 @see wxKeyEvent::CmdDown
1564 class wxMouseEvent
: public wxEvent
1568 Constructor. Valid event types are:
1570 @li wxEVT_ENTER_WINDOW
1571 @li wxEVT_LEAVE_WINDOW
1574 @li wxEVT_LEFT_DCLICK
1575 @li wxEVT_MIDDLE_DOWN
1577 @li wxEVT_MIDDLE_DCLICK
1578 @li wxEVT_RIGHT_DOWN
1580 @li wxEVT_RIGHT_DCLICK
1581 @li wxEVT_MOUSE_AUX1_DOWN
1582 @li wxEVT_MOUSE_AUX1_UP
1583 @li wxEVT_MOUSE_AUX1_DCLICK
1584 @li wxEVT_MOUSE_AUX2_DOWN
1585 @li wxEVT_MOUSE_AUX2_UP
1586 @li wxEVT_MOUSE_AUX2_DCLICK
1588 @li wxEVT_MOUSEWHEEL
1590 wxMouseEvent(wxEventType mouseEventType
= wxEVT_NULL
);
1593 Returns @true if the Alt key was down at the time of the event.
1595 bool AltDown() const;
1598 Returns @true if the event was a first extra button double click.
1600 bool Aux1DClick() const;
1603 Returns @true if the first extra button mouse button changed to down.
1605 bool Aux1Down() const;
1608 Returns @true if the first extra button mouse button is currently down,
1609 independent of the current event type.
1611 bool Aux1IsDown() const;
1614 Returns @true if the first extra button mouse button changed to up.
1616 bool Aux1Up() const;
1619 Returns @true if the event was a second extra button double click.
1621 bool Aux2DClick() const;
1624 Returns @true if the second extra button mouse button changed to down.
1626 bool Aux2Down() const;
1629 Returns @true if the second extra button mouse button is currently down,
1630 independent of the current event type.
1632 bool Aux2IsDown() const;
1635 Returns @true if the second extra button mouse button changed to up.
1637 bool Aux2Up() const;
1640 Returns @true if the identified mouse button is changing state.
1641 Valid values of @a button are:
1643 @li @c wxMOUSE_BTN_LEFT: check if left button was pressed
1644 @li @c wxMOUSE_BTN_MIDDLE: check if middle button was pressed
1645 @li @c wxMOUSE_BTN_RIGHT: check if right button was pressed
1646 @li @c wxMOUSE_BTN_AUX1: check if the first extra button was pressed
1647 @li @c wxMOUSE_BTN_AUX2: check if the second extra button was pressed
1648 @li @c wxMOUSE_BTN_ANY: check if any button was pressed
1650 @todo introduce wxMouseButton enum
1652 bool Button(int button
) const;
1655 If the argument is omitted, this returns @true if the event was a mouse
1656 double click event. Otherwise the argument specifies which double click event
1657 was generated (see Button() for the possible values).
1659 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
1662 If the argument is omitted, this returns @true if the event was a mouse
1663 button down event. Otherwise the argument specifies which button-down event
1664 was generated (see Button() for the possible values).
1666 bool ButtonDown(int = wxMOUSE_BTN_ANY
) const;
1669 If the argument is omitted, this returns @true if the event was a mouse
1670 button up event. Otherwise the argument specifies which button-up event
1671 was generated (see Button() for the possible values).
1673 bool ButtonUp(int = wxMOUSE_BTN_ANY
) const;
1676 Same as MetaDown() under Mac, same as ControlDown() elsewhere.
1678 @see wxKeyEvent::CmdDown
1680 bool CmdDown() const;
1683 Returns @true if the control key was down at the time of the event.
1685 bool ControlDown() const;
1688 Returns @true if this was a dragging event (motion while a button is depressed).
1692 bool Dragging() const;
1695 Returns @true if the mouse was entering the window.
1699 bool Entering() const;
1702 Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
1703 if no button is involved (for mouse move, enter or leave event, for example).
1704 Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
1705 double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
1706 for the same events for the middle and the right buttons respectively.
1708 int GetButton() const;
1711 Returns the number of mouse clicks for this event: 1 for a simple click, 2
1712 for a double-click, 3 for a triple-click and so on.
1714 Currently this function is implemented only in wxMac and returns -1 for the
1715 other platforms (you can still distinguish simple clicks from double-clicks as
1716 they generate different kinds of events however).
1720 int GetClickCount() const;
1723 Returns the configured number of lines (or whatever) to be scrolled per
1724 wheel action. Defaults to three.
1726 int GetLinesPerAction() const;
1729 Returns the logical mouse position in pixels (i.e. translated according to the
1730 translation set for the DC, which usually indicates that the window has been
1733 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
1737 Sets *x and *y to the position at which the event occurred.
1738 Returns the physical mouse position in pixels.
1740 Note that if the mouse event has been artificially generated from a special
1741 keyboard combination (e.g. under Windows when the "menu" key is pressed), the
1742 returned position is ::wxDefaultPosition.
1744 wxPoint
GetPosition() const;
1745 void GetPosition(wxCoord
* x
, wxCoord
* y
) const;
1746 void GetPosition(long* x
, long* y
) const;
1750 Get wheel delta, normally 120.
1752 This is the threshold for action to be taken, and one such action
1753 (for example, scrolling one increment) should occur for each delta.
1755 int GetWheelDelta() const;
1758 Get wheel rotation, positive or negative indicates direction of rotation.
1760 Current devices all send an event when rotation is at least +/-WheelDelta, but
1761 finer resolution devices can be created in the future.
1763 Because of this you shouldn't assume that one event is equal to 1 line, but you
1764 should be able to either do partial line scrolling or wait until several
1765 events accumulate before scrolling.
1767 int GetWheelRotation() const;
1770 Returns X coordinate of the physical mouse event position.
1772 wxCoord
GetX() const;
1775 Returns Y coordinate of the physical mouse event position.
1777 wxCoord
GetY() const;
1780 Returns @true if the event was a mouse button event (not necessarily a button
1781 down event - that may be tested using ButtonDown()).
1783 bool IsButton() const;
1786 Returns @true if the system has been setup to do page scrolling with
1787 the mouse wheel instead of line scrolling.
1789 bool IsPageScroll() const;
1792 Returns @true if the mouse was leaving the window.
1796 bool Leaving() const;
1799 Returns @true if the event was a left double click.
1801 bool LeftDClick() const;
1804 Returns @true if the left mouse button changed to down.
1806 bool LeftDown() const;
1809 Returns @true if the left mouse button is currently down, independent
1810 of the current event type.
1812 Please notice that it is not the same as LeftDown() which returns @true if the
1813 event was generated by the left mouse button being pressed. Rather, it simply
1814 describes the state of the left mouse button at the time when the event was
1815 generated (so while it will be @true for a left click event, it can also be @true
1816 for a right click if it happened while the left mouse button was pressed).
1818 This event is usually used in the mouse event handlers which process "move
1819 mouse" messages to determine whether the user is (still) dragging the mouse.
1821 bool LeftIsDown() const;
1824 Returns @true if the left mouse button changed to up.
1826 bool LeftUp() const;
1829 Returns @true if the Meta key was down at the time of the event.
1831 bool MetaDown() const;
1834 Returns @true if the event was a middle double click.
1836 bool MiddleDClick() const;
1839 Returns @true if the middle mouse button changed to down.
1841 bool MiddleDown() const;
1844 Returns @true if the middle mouse button is currently down, independent
1845 of the current event type.
1847 bool MiddleIsDown() const;
1850 Returns @true if the middle mouse button changed to up.
1852 bool MiddleUp() const;
1855 Returns @true if this was a motion event and no mouse buttons were pressed.
1856 If any mouse button is held pressed, then this method returns @false and
1857 Dragging() returns @true.
1859 bool Moving() const;
1862 Returns @true if the event was a right double click.
1864 bool RightDClick() const;
1867 Returns @true if the right mouse button changed to down.
1869 bool RightDown() const;
1872 Returns @true if the right mouse button is currently down, independent
1873 of the current event type.
1875 bool RightIsDown() const;
1878 Returns @true if the right mouse button changed to up.
1880 bool RightUp() const;
1883 Returns @true if the shift key was down at the time of the event.
1885 bool ShiftDown() const;
1891 @class wxDropFilesEvent
1894 This class is used for drop files events, that is, when files have been dropped
1895 onto the window. This functionality is currently only available under Windows.
1897 The window must have previously been enabled for dropping by calling
1898 wxWindow::DragAcceptFiles().
1900 Important note: this is a separate implementation to the more general drag and drop
1901 implementation documented in the @ref overview_dnd. It uses the older, Windows
1902 message-based approach of dropping files.
1904 @beginEventTable{wxDropFilesEvent}
1905 @event{EVT_DROP_FILES(func)}
1906 Process a wxEVT_DROP_FILES event.
1914 @see @ref overview_eventhandling
1916 class wxDropFilesEvent
: public wxEvent
1922 wxDropFilesEvent(wxEventType id
= 0, int noFiles
= 0,
1923 wxString
* files
= NULL
);
1926 Returns an array of filenames.
1928 wxString
* GetFiles() const;
1931 Returns the number of files dropped.
1933 int GetNumberOfFiles() const;
1936 Returns the position at which the files were dropped.
1937 Returns an array of filenames.
1939 wxPoint
GetPosition() const;
1945 @class wxCommandEvent
1948 This event class contains information about command events, which originate
1949 from a variety of simple controls.
1951 More complex controls, such as wxTreeCtrl, have separate command event classes.
1953 @beginEventTable{wxCommandEvent}
1954 @event{EVT_COMMAND(id, event, func)}
1955 Process a command, supplying the window identifier, command event identifier,
1956 and member function.
1957 @event{EVT_COMMAND_RANGE(id1, id2, event, func)}
1958 Process a command for a range of window identifiers, supplying the minimum and
1959 maximum window identifiers, command event identifier, and member function.
1960 @event{EVT_BUTTON(id, func)}
1961 Process a wxEVT_COMMAND_BUTTON_CLICKED command, which is generated by a wxButton control.
1962 @event{EVT_CHECKBOX(id, func)}
1963 Process a wxEVT_COMMAND_CHECKBOX_CLICKED command, which is generated by a wxCheckBox control.
1964 @event{EVT_CHOICE(id, func)}
1965 Process a wxEVT_COMMAND_CHOICE_SELECTED command, which is generated by a wxChoice control.
1966 @event{EVT_COMBOBOX(id, func)}
1967 Process a wxEVT_COMMAND_COMBOBOX_SELECTED command, which is generated by a wxComboBox control.
1968 @event{EVT_LISTBOX(id, func)}
1969 Process a wxEVT_COMMAND_LISTBOX_SELECTED command, which is generated by a wxListBox control.
1970 @event{EVT_LISTBOX_DCLICK(id, func)}
1971 Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED command, which is generated by a wxListBox control.
1972 @event{EVT_MENU(id, func)}
1973 Process a wxEVT_COMMAND_MENU_SELECTED command, which is generated by a menu item.
1974 @event{EVT_MENU_RANGE(id1, id2, func)}
1975 Process a wxEVT_COMMAND_MENU_RANGE command, which is generated by a range of menu items.
1976 @event{EVT_CONTEXT_MENU(func)}
1977 Process the event generated when the user has requested a popup menu to appear by
1978 pressing a special keyboard key (under Windows) or by right clicking the mouse.
1979 @event{EVT_RADIOBOX(id, func)}
1980 Process a wxEVT_COMMAND_RADIOBOX_SELECTED command, which is generated by a wxRadioBox control.
1981 @event{EVT_RADIOBUTTON(id, func)}
1982 Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED command, which is generated by a wxRadioButton control.
1983 @event{EVT_SCROLLBAR(id, func)}
1984 Process a wxEVT_COMMAND_SCROLLBAR_UPDATED command, which is generated by a wxScrollBar
1985 control. This is provided for compatibility only; more specific scrollbar event macros
1986 should be used instead (see wxScrollEvent).
1987 @event{EVT_SLIDER(id, func)}
1988 Process a wxEVT_COMMAND_SLIDER_UPDATED command, which is generated by a wxSlider control.
1989 @event{EVT_TEXT(id, func)}
1990 Process a wxEVT_COMMAND_TEXT_UPDATED command, which is generated by a wxTextCtrl control.
1991 @event{EVT_TEXT_ENTER(id, func)}
1992 Process a wxEVT_COMMAND_TEXT_ENTER command, which is generated by a wxTextCtrl control.
1993 Note that you must use wxTE_PROCESS_ENTER flag when creating the control if you want it
1994 to generate such events.
1995 @event{EVT_TEXT_MAXLEN(id, func)}
1996 Process a wxEVT_COMMAND_TEXT_MAXLEN command, which is generated by a wxTextCtrl control
1997 when the user tries to enter more characters into it than the limit previously set
1998 with SetMaxLength().
1999 @event{EVT_TOGGLEBUTTON(id, func)}
2000 Process a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
2001 @event{EVT_TOOL(id, func)}
2002 Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED).
2003 Pass the id of the tool.
2004 @event{EVT_TOOL_RANGE(id1, id2, func)}
2005 Process a wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. Pass the ids of the tools.
2006 @event{EVT_TOOL_RCLICKED(id, func)}
2007 Process a wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool.
2008 @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)}
2009 Process a wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools.
2010 @event{EVT_TOOL_ENTER(id, func)}
2011 Process a wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar itself.
2012 The value of wxCommandEvent::GetSelection() is the tool id, or -1 if the mouse cursor
2013 has moved off a tool.
2014 @event{EVT_COMMAND_LEFT_CLICK(id, func)}
2015 Process a wxEVT_COMMAND_LEFT_CLICK command, which is generated by a control (Windows 95 and NT only).
2016 @event{EVT_COMMAND_LEFT_DCLICK(id, func)}
2017 Process a wxEVT_COMMAND_LEFT_DCLICK command, which is generated by a control (Windows 95 and NT only).
2018 @event{EVT_COMMAND_RIGHT_CLICK(id, func)}
2019 Process a wxEVT_COMMAND_RIGHT_CLICK command, which is generated by a control (Windows 95 and NT only).
2020 @event{EVT_COMMAND_SET_FOCUS(id, func)}
2021 Process a wxEVT_COMMAND_SET_FOCUS command, which is generated by a control (Windows 95 and NT only).
2022 @event{EVT_COMMAND_KILL_FOCUS(id, func)}
2023 Process a wxEVT_COMMAND_KILL_FOCUS command, which is generated by a control (Windows 95 and NT only).
2024 @event{EVT_COMMAND_ENTER(id, func)}
2025 Process a wxEVT_COMMAND_ENTER command, which is generated by a control.
2031 class wxCommandEvent
: public wxEvent
2037 wxCommandEvent(wxEventType commandEventType
= 0, int id
= 0);
2040 Returns client data pointer for a listbox or choice selection event
2041 (not valid for a deselection).
2043 void* GetClientData() const;
2046 Returns client object pointer for a listbox or choice selection event
2047 (not valid for a deselection).
2049 wxClientData
* GetClientObject() const;
2052 Returns extra information dependant on the event objects type.
2054 If the event comes from a listbox selection, it is a boolean
2055 determining whether the event was a selection (@true) or a
2056 deselection (@false). A listbox deselection only occurs for
2057 multiple-selection boxes, and in this case the index and string values
2058 are indeterminate and the listbox must be examined by the application.
2060 long GetExtraLong() const;
2063 Returns the integer identifier corresponding to a listbox, choice or
2064 radiobox selection (only if the event was a selection, not a deselection),
2065 or a boolean value representing the value of a checkbox.
2070 Returns item index for a listbox or choice selection event (not valid for
2073 int GetSelection() const;
2076 Returns item string for a listbox or choice selection event (not valid for
2079 wxString
GetString() const;
2082 This method can be used with checkbox and menu events: for the checkboxes, the
2083 method returns @true for a selection event and @false for a deselection one.
2084 For the menu events, this method indicates if the menu item just has become
2085 checked or unchecked (and thus only makes sense for checkable menu items).
2087 Notice that this method can not be used with wxCheckListBox currently.
2089 bool IsChecked() const;
2092 For a listbox or similar event, returns @true if it is a selection, @false if it
2095 bool IsSelection() const;
2098 Sets the client data for this event.
2100 void SetClientData(void* clientData
);
2103 Sets the client object for this event. The client object is not owned by the
2104 event object and the event object will not delete the client object in its destructor.
2106 The client object must be owned and deleted by another object (e.g. a control)
2107 that has longer life time than the event object.
2109 void SetClientObject(wxClientData
* clientObject
);
2112 Sets the @b m_extraLong member.
2114 void SetExtraLong(long extraLong
);
2117 Sets the @b m_commandInt member.
2119 void SetInt(int intCommand
);
2122 Sets the @b m_commandString member.
2124 void SetString(const wxString
& string
);
2130 @class wxActivateEvent
2133 An activate event is sent when a window or application is being activated
2136 @beginEventTable{wxActivateEvent}
2137 @event{EVT_ACTIVATE(func)}
2138 Process a wxEVT_ACTIVATE event.
2139 @event{EVT_ACTIVATE_APP(func)}
2140 Process a wxEVT_ACTIVATE_APP event.
2141 @event{EVT_HIBERNATE(func)}
2142 Process a hibernate event, supplying the member function. This event applies
2143 to wxApp only, and only on Windows SmartPhone and PocketPC.
2144 It is generated when the system is low on memory; the application should free
2145 up as much memory as possible, and restore full working state when it receives
2146 a wxEVT_ACTIVATE or wxEVT_ACTIVATE_APP event.
2153 @see @ref overview_eventhandling, wxApp::IsActive
2155 class wxActivateEvent
: public wxEvent
2161 wxActivateEvent(wxEventType eventType
= wxEVT_NULL
, bool active
= true,
2165 Returns @true if the application or window is being activated, @false otherwise.
2167 bool GetActive() const;
2173 @class wxContextMenuEvent
2176 This class is used for context menu events, sent to give
2177 the application a chance to show a context (popup) menu.
2179 Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
2180 means that the event originated from a keyboard context button event, and you
2181 should compute a suitable position yourself, for example by calling wxGetMousePosition().
2183 When a keyboard context menu button is pressed on Windows, a right-click event
2184 with default position is sent first, and if this event is not processed, the
2185 context menu event is sent. So if you process mouse events and you find your
2186 context menu event handler is not being called, you could call wxEvent::Skip()
2187 for mouse right-down events.
2189 @beginEventTable{wxContextMenuEvent}
2190 @event{EVT_CONTEXT_MENU(func)}
2191 A right click (or other context menu command depending on platform) has been detected.
2198 @see wxCommandEvent, @ref overview_eventhandling
2200 class wxContextMenuEvent
: public wxCommandEvent
2206 wxContextMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0,
2207 const wxPoint
& pos
= wxDefaultPosition
);
2210 Returns the position in screen coordinates at which the menu should be shown.
2211 Use wxWindow::ScreenToClient to convert to client coordinates.
2213 You can also omit a position from wxWindow::PopupMenu in order to use
2214 the current mouse pointer position.
2216 If the event originated from a keyboard event, the value returned from this
2217 function will be wxDefaultPosition.
2219 const wxPoint
& GetPosition() const;
2222 Sets the position at which the menu should be shown.
2224 void SetPosition(const wxPoint
& point
);
2233 An erase event is sent when a window's background needs to be repainted.
2235 On some platforms, such as GTK+, this event is simulated (simply generated just
2236 before the paint event) and may cause flicker. It is therefore recommended that
2237 you set the text background colour explicitly in order to prevent flicker.
2238 The default background colour under GTK+ is grey.
2240 To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
2243 You must call wxEraseEvent::GetDC and use the returned device context if it is
2244 non-@NULL. If it is @NULL, create your own temporary wxClientDC object.
2247 Use the device context returned by GetDC to draw on, don't create
2248 a wxPaintDC in the event handler.
2250 @beginEventTable{wxEraseEvent}
2251 @event{EVT_ERASE_BACKGROUND(func)}
2252 Process a wxEVT_ERASE_BACKGROUND event.
2258 @see @ref overview_eventhandling
2260 class wxEraseEvent
: public wxEvent
2266 wxEraseEvent(int id
= 0, wxDC
* dc
= NULL
);
2269 Returns the device context associated with the erase event to draw on.
2271 wxDC
* GetDC() const;
2280 A focus event is sent when a window's focus changes. The window losing focus
2281 receives a "kill focus" event while the window gaining it gets a "set focus" one.
2283 Notice that the set focus event happens both when the user gives focus to the
2284 window (whether using the mouse or keyboard) and when it is done from the
2285 program itself using wxWindow::SetFocus.
2287 @beginEventTable{wxFocusEvent}
2288 @event{EVT_SET_FOCUS(func)}
2289 Process a wxEVT_SET_FOCUS event.
2290 @event{EVT_KILL_FOCUS(func)}
2291 Process a wxEVT_KILL_FOCUS event.
2297 @see @ref overview_eventhandling
2299 class wxFocusEvent
: public wxEvent
2305 wxFocusEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2308 Returns the window associated with this event, that is the window which had the
2309 focus before for the @c wxEVT_SET_FOCUS event and the window which is
2310 going to receive focus for the @c wxEVT_KILL_FOCUS one.
2312 Warning: the window pointer may be @NULL!
2314 wxWindow
*GetWindow() const;
2320 @class wxChildFocusEvent
2323 A child focus event is sent to a (parent-)window when one of its child windows
2324 gains focus, so that the window could restore the focus back to its corresponding
2325 child if it loses it now and regains later.
2327 Notice that child window is the direct child of the window receiving event.
2328 Use wxWindow::FindFocus() to retreive the window which is actually getting focus.
2330 @beginEventTable{wxChildFocusEvent}
2331 @event{EVT_CHILD_FOCUS(func)}
2332 Process a wxEVT_CHILD_FOCUS event.
2338 @see @ref overview_eventhandling
2340 class wxChildFocusEvent
: public wxCommandEvent
2347 The direct child which is (or which contains the window which is) receiving
2350 wxChildFocusEvent(wxWindow
* win
= NULL
);
2353 Returns the direct child which receives the focus, or a (grand-)parent of the
2354 control receiving the focus.
2356 To get the actually focused control use wxWindow::FindFocus.
2358 wxWindow
*GetWindow() const;
2364 @class wxMouseCaptureLostEvent
2367 An mouse capture lost event is sent to a window that obtained mouse capture,
2368 which was subsequently loss due to "external" event, for example when a dialog
2369 box is shown or if another application captures the mouse.
2371 If this happens, this event is sent to all windows that are on capture stack
2372 (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
2373 not sent if the capture changes because of a call to CaptureMouse or
2376 This event is currently emitted under Windows only.
2378 @beginEventTable{wxMouseCaptureLostEvent}
2379 @event{EVT_MOUSE_CAPTURE_LOST(func)}
2380 Process a wxEVT_MOUSE_CAPTURE_LOST event.
2388 @see wxMouseCaptureChangedEvent, @ref overview_eventhandling,
2389 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2391 class wxMouseCaptureLostEvent
: public wxEvent
2397 wxMouseCaptureLostEvent(wxWindowID windowId
= 0);
2403 @class wxNotifyEvent
2406 This class is not used by the event handlers by itself, but is a base class
2407 for other event classes (such as wxNotebookEvent).
2409 It (or an object of a derived class) is sent when the controls state is being
2410 changed and allows the program to wxNotifyEvent::Veto() this change if it wants
2411 to prevent it from happening.
2416 @see wxNotebookEvent
2418 class wxNotifyEvent
: public wxCommandEvent
2422 Constructor (used internally by wxWidgets only).
2424 wxNotifyEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2427 This is the opposite of Veto(): it explicitly allows the event to be processed.
2428 For most events it is not necessary to call this method as the events are allowed
2429 anyhow but some are forbidden by default (this will be mentioned in the corresponding
2435 Returns @true if the change is allowed (Veto() hasn't been called) or @false
2436 otherwise (if it was).
2438 bool IsAllowed() const;
2441 Prevents the change announced by this event from happening.
2443 It is in general a good idea to notify the user about the reasons for vetoing
2444 the change because otherwise the applications behaviour (which just refuses to
2445 do what the user wants) might be quite surprising.
2454 Indicates how a wxHelpEvent was generated.
2456 enum wxHelpEventOrigin
2458 wxHE_ORIGIN_UNKNOWN
= -1, /**< unrecognized event source. */
2459 wxHE_ORIGIN_KEYBOARD
, /**< event generated from F1 key press. */
2461 /** event generated by wxContextHelp or from the [?] button on
2462 the title bar (Windows). */
2463 wxHE_ORIGIN_HELPBUTTON
2470 A help event is sent when the user has requested context-sensitive help.
2471 This can either be caused by the application requesting context-sensitive help mode
2472 via wxContextHelp, or (on MS Windows) by the system generating a WM_HELP message when
2473 the user pressed F1 or clicked on the query button in a dialog caption.
2475 A help event is sent to the window that the user clicked on, and is propagated
2476 up the window hierarchy until the event is processed or there are no more event
2479 The application should call wxEvent::GetId to check the identity of the
2480 clicked-on window, and then either show some suitable help or call wxEvent::Skip()
2481 if the identifier is unrecognised.
2483 Calling Skip is important because it allows wxWidgets to generate further
2484 events for ancestors of the clicked-on window. Otherwise it would be impossible to
2485 show help for container windows, since processing would stop after the first window
2488 @beginEventTable{wxHelpEvent}
2489 @event{EVT_HELP(id, func)}
2490 Process a wxEVT_HELP event.
2491 @event{EVT_HELP_RANGE(id1, id2, func)}
2492 Process a wxEVT_HELP event for a range of ids.
2498 @see wxContextHelp, wxDialog, @ref overview_eventhandling
2500 class wxHelpEvent
: public wxCommandEvent
2506 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
2507 wxWindowID winid
= 0,
2508 const wxPoint
& pt
= wxDefaultPosition
,
2509 wxHelpEventOrigin origin
= wxHE_ORIGIN_UNKNOWN
);
2512 Returns the origin of the help event which is one of the ::wxHelpEventOrigin
2515 The application may handle events generated using the keyboard or mouse
2516 differently, e.g. by using wxGetMousePosition() for the mouse events.
2520 wxHelpEventOrigin
GetOrigin() const;
2523 Returns the left-click position of the mouse, in screen coordinates.
2524 This allows the application to position the help appropriately.
2526 const wxPoint
& GetPosition() const;
2529 Set the help event origin, only used internally by wxWidgets normally.
2533 void SetOrigin(wxHelpEventOrigin
);
2536 Sets the left-click position of the mouse, in screen coordinates.
2538 void SetPosition(const wxPoint
& pt
);
2544 @class wxScrollEvent
2547 A scroll event holds information about events sent from stand-alone
2548 scrollbars (see wxScrollBar) and sliders (see wxSlider).
2550 Note that scrolled windows send the wxScrollWinEvent which does not derive from
2551 wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
2552 events and use the event table macros mentioned below only for the scrollbar-like
2555 @section wxscrollevent_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
2557 The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb
2558 using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed
2559 by an EVT_SCROLL_CHANGED event).
2561 The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change the thumb
2562 position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE
2563 event does not happen).
2565 In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving has finished
2566 independently of the way it had started. Please see the widgets sample ("Slider" page)
2567 to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
2570 Note that unless specifying a scroll control identifier, you will need to test for scrollbar
2571 orientation with wxScrollEvent::GetOrientation, since horizontal and vertical scroll events
2572 are processed using the same event handler.
2574 @beginEventTable{wxScrollEvent}
2575 You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
2576 scroll events from controls, or EVT_SCROLL... macros without window IDs for
2577 intercepting scroll events from the receiving window -- except for this, the
2578 macros behave exactly the same.
2579 @event{EVT_SCROLL(func)}
2580 Process all scroll events.
2581 @event{EVT_SCROLL_TOP(func)}
2582 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2583 @event{EVT_SCROLL_BOTTOM(func)}
2584 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2585 @event{EVT_SCROLL_LINEUP(func)}
2586 Process wxEVT_SCROLL_LINEUP line up events.
2587 @event{EVT_SCROLL_LINEDOWN(func)}
2588 Process wxEVT_SCROLL_LINEDOWN line down events.
2589 @event{EVT_SCROLL_PAGEUP(func)}
2590 Process wxEVT_SCROLL_PAGEUP page up events.
2591 @event{EVT_SCROLL_PAGEDOWN(func)}
2592 Process wxEVT_SCROLL_PAGEDOWN page down events.
2593 @event{EVT_SCROLL_THUMBTRACK(func)}
2594 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the
2595 user drags the thumbtrack).
2596 @event{EVT_SCROLL_THUMBRELEASE(func)}
2597 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2598 @event{EVT_SCROLL_CHANGED(func)}
2599 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2600 @event{EVT_COMMAND_SCROLL(id, func)}
2601 Process all scroll events.
2602 @event{EVT_COMMAND_SCROLL_TOP(id, func)}
2603 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2604 @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
2605 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2606 @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
2607 Process wxEVT_SCROLL_LINEUP line up events.
2608 @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
2609 Process wxEVT_SCROLL_LINEDOWN line down events.
2610 @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
2611 Process wxEVT_SCROLL_PAGEUP page up events.
2612 @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
2613 Process wxEVT_SCROLL_PAGEDOWN page down events.
2614 @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
2615 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent
2616 as the user drags the thumbtrack).
2617 @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
2618 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2619 @event{EVT_COMMAND_SCROLL_CHANGED(func)}
2620 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2626 @see wxScrollBar, wxSlider, wxSpinButton, wxScrollWinEvent, @ref overview_eventhandling
2628 class wxScrollEvent
: public wxCommandEvent
2634 wxScrollEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0, int pos
= 0,
2635 int orientation
= 0);
2638 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
2641 int GetOrientation() const;
2644 Returns the position of the scrollbar.
2646 int GetPosition() const;
2650 See wxIdleEvent::SetMode() for more info.
2654 /** Send idle events to all windows */
2657 /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */
2658 wxIDLE_PROCESS_SPECIFIED
2666 This class is used for idle events, which are generated when the system becomes
2667 idle. Note that, unless you do something specifically, the idle events are not
2668 sent if the system remains idle once it has become it, e.g. only a single idle
2669 event will be generated until something else resulting in more normal events
2670 happens and only then is the next idle event sent again.
2672 If you need to ensure a continuous stream of idle events, you can either use
2673 wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically
2674 (for example from a timer event handler), but note that both of these approaches
2675 (and especially the first one) increase the system load and so should be avoided
2678 By default, idle events are sent to all windows (and also wxApp, as usual).
2679 If this is causing a significant overhead in your application, you can call
2680 wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the
2681 wxWS_EX_PROCESS_IDLE extra window style for every window which should receive
2684 @beginEventTable{wxIdleEvent}
2685 @event{EVT_IDLE(func)}
2686 Process a wxEVT_IDLE event.
2692 @see @ref overview_eventhandling, wxUpdateUIEvent, wxWindow::OnInternalIdle
2694 class wxIdleEvent
: public wxEvent
2703 Returns @true if it is appropriate to send idle events to this window.
2705 This function looks at the mode used (see wxIdleEvent::SetMode),
2706 and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle
2707 events should be sent to this window now.
2709 By default this will always return @true because the update mode is initially
2710 wxIDLE_PROCESS_ALL. You can change the mode to only send idle events to
2711 windows with the wxWS_EX_PROCESS_IDLE extra window style set.
2715 static bool CanSend(wxWindow
* window
);
2718 Static function returning a value specifying how wxWidgets will send idle
2719 events: to all windows, or only to those which specify that they
2720 will process the events.
2724 static wxIdleMode
GetMode();
2727 Returns @true if the OnIdle function processing this event requested more
2732 bool MoreRequested() const;
2735 Tells wxWidgets that more processing is required.
2737 This function can be called by an OnIdle handler for a window or window event
2738 handler to indicate that wxApp::OnIdle should forward the OnIdle event once
2739 more to the application windows.
2741 If no window calls this function during OnIdle, then the application will
2742 remain in a passive event loop (not calling OnIdle) until a new event is
2743 posted to the application by the windowing system.
2745 @see MoreRequested()
2747 void RequestMore(bool needMore
= true);
2750 Static function for specifying how wxWidgets will send idle events: to
2751 all windows, or only to those which specify that they will process the events.
2754 Can be one of the ::wxIdleMode values.
2755 The default is wxIDLE_PROCESS_ALL.
2757 static void SetMode(wxIdleMode mode
);
2763 @class wxInitDialogEvent
2766 A wxInitDialogEvent is sent as a dialog or panel is being initialised.
2767 Handlers for this event can transfer data to the window.
2769 The default handler calls wxWindow::TransferDataToWindow.
2771 @beginEventTable{wxInitDialogEvent}
2772 @event{EVT_INIT_DIALOG(func)}
2773 Process a wxEVT_INIT_DIALOG event.
2779 @see @ref overview_eventhandling
2781 class wxInitDialogEvent
: public wxEvent
2787 wxInitDialogEvent(int id
= 0);
2793 @class wxWindowDestroyEvent
2796 This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a
2797 window is destroyed.
2799 When a class derived from wxWindow is destroyed its destructor will have
2800 already run by the time this event is sent. Therefore this event will not
2801 usually be received at all.
2803 To receive this event wxEvtHandler::Connect() must be used (using an event
2804 table macro will not work). Since it is received after the destructor has run,
2805 an object should not handle its own wxWindowDestroyEvent, but it can be used
2806 to get notification of the destruction of another window.
2811 @see @ref overview_eventhandling, wxWindowCreateEvent
2813 class wxWindowDestroyEvent
: public wxCommandEvent
2819 wxWindowDestroyEvent(wxWindow
* win
= NULL
);
2824 The possible flag values for a wxNavigationKeyEvent.
2826 enum wxNavigationKeyEventFlags
2828 wxNKEF_IS_BACKWARD
= 0x0000,
2829 wxNKEF_IS_FORWARD
= 0x0001,
2830 wxNKEF_WINCHANGE
= 0x0002,
2831 wxNKEF_FROMTAB
= 0x0004
2836 @class wxNavigationKeyEvent
2839 This event class contains information about navigation events,
2840 generated by navigation keys such as tab and page down.
2842 This event is mainly used by wxWidgets implementations.
2843 A wxNavigationKeyEvent handler is automatically provided by wxWidgets
2844 when you make a class into a control container with the macro
2845 WX_DECLARE_CONTROL_CONTAINER.
2847 @beginEventTable{wxNavigationKeyEvent}
2848 @event{EVT_NAVIGATION_KEY(func)}
2849 Process a navigation key event.
2855 @see wxWindow::Navigate, wxWindow::NavigateIn
2857 class wxNavigationKeyEvent
: public wxEvent
2860 wxNavigationKeyEvent();
2861 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
);
2864 Returns the child that has the focus, or @NULL.
2866 wxWindow
* GetCurrentFocus() const;
2869 Returns @true if the navigation was in the forward direction.
2871 bool GetDirection() const;
2874 Returns @true if the navigation event was from a tab key.
2875 This is required for proper navigation over radio buttons.
2877 bool IsFromTab() const;
2880 Returns @true if the navigation event represents a window change
2881 (for example, from Ctrl-Page Down in a notebook).
2883 bool IsWindowChange() const;
2886 Sets the current focus window member.
2888 void SetCurrentFocus(wxWindow
* currentFocus
);
2891 Sets the direction to forward if @a direction is @true, or backward
2894 void SetDirection(bool direction
);
2897 Sets the flags for this event.
2898 The @a flags can be a combination of the ::wxNavigationKeyEventFlags values.
2900 void SetFlags(long flags
);
2903 Marks the navigation event as from a tab key.
2905 void SetFromTab(bool fromTab
);
2908 Marks the event as a window change event.
2910 void SetWindowChange(bool windowChange
);
2916 @class wxMouseCaptureChangedEvent
2919 An mouse capture changed event is sent to a window that loses its
2920 mouse capture. This is called even if wxWindow::ReleaseCapture
2921 was called by the application code. Handling this event allows
2922 an application to cater for unexpected capture releases which
2923 might otherwise confuse mouse handling code.
2927 @beginEventTable{wxMouseCaptureChangedEvent}
2928 @event{EVT_MOUSE_CAPTURE_CHANGED(func)}
2929 Process a wxEVT_MOUSE_CAPTURE_CHANGED event.
2935 @see wxMouseCaptureLostEvent, @ref overview_eventhandling,
2936 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2938 class wxMouseCaptureChangedEvent
: public wxEvent
2944 wxMouseCaptureChangedEvent(wxWindowID windowId
= 0,
2945 wxWindow
* gainedCapture
= NULL
);
2948 Returns the window that gained the capture, or @NULL if it was a
2949 non-wxWidgets window.
2951 wxWindow
* GetCapturedWindow() const;
2960 This event class contains information about window and session close events.
2962 The handler function for EVT_CLOSE is called when the user has tried to close a
2963 a frame or dialog box using the window manager (X) or system menu (Windows).
2964 It can also be invoked by the application itself programmatically, for example by
2965 calling the wxWindow::Close function.
2967 You should check whether the application is forcing the deletion of the window
2968 using wxCloseEvent::CanVeto. If this is @false, you @e must destroy the window
2969 using wxWindow::Destroy.
2971 If the return value is @true, it is up to you whether you respond by destroying
2974 If you don't destroy the window, you should call wxCloseEvent::Veto to
2975 let the calling code know that you did not destroy the window.
2976 This allows the wxWindow::Close function to return @true or @false depending
2977 on whether the close instruction was honoured or not.
2979 The EVT_END_SESSION event is slightly different as it is sent by the system
2980 when the user session is ending (e.g. because of log out or shutdown) and
2981 so all windows are being forcefully closed. At least under MSW, after the
2982 handler for this event is executed the program is simply killed by the
2983 system. Because of this, the default handler for this event provided by
2984 wxWidgets calls all the usual cleanup code (including wxApp::OnExit()) so
2985 that it could still be executed and exit()s the process itself, without
2986 waiting for being killed. If this behaviour is for some reason undesirable,
2987 make sure that you define a handler for this event in your wxApp-derived
2988 class and do not call @c event.Skip() in it (but be aware that the system
2989 will still kill your application).
2991 @beginEventTable{wxCloseEvent}
2992 @event{EVT_CLOSE(func)}
2993 Process a close event, supplying the member function.
2994 This event applies to wxFrame and wxDialog classes.
2995 @event{EVT_QUERY_END_SESSION(func)}
2996 Process a query end session event, supplying the member function.
2997 This event can be handled in wxApp-derived class only.
2998 @event{EVT_END_SESSION(func)}
2999 Process an end session event, supplying the member function.
3000 This event can be handled in wxApp-derived class only.
3006 @see wxWindow::Close, @ref overview_windowdeletion
3008 class wxCloseEvent
: public wxEvent
3014 wxCloseEvent(wxEventType commandEventType
= wxEVT_NULL
, int id
= 0);
3017 Returns @true if you can veto a system shutdown or a window close event.
3018 Vetoing a window close event is not possible if the calling code wishes to
3019 force the application to exit, and so this function must be called to check this.
3021 bool CanVeto() const;
3024 Returns @true if the user is just logging off or @false if the system is
3025 shutting down. This method can only be called for end session and query end
3026 session events, it doesn't make sense for close window event.
3028 bool GetLoggingOff() const;
3031 Sets the 'can veto' flag.
3033 void SetCanVeto(bool canVeto
);
3036 Sets the 'force' flag.
3038 void SetForce(bool force
) const;
3041 Sets the 'logging off' flag.
3043 void SetLoggingOff(bool loggingOff
);
3046 Call this from your event handler to veto a system shutdown or to signal
3047 to the calling application that a window close did not happen.
3049 You can only veto a shutdown if CanVeto() returns @true.
3051 void Veto(bool veto
= true);
3060 This class is used for a variety of menu-related events. Note that
3061 these do not include menu command events, which are
3062 handled using wxCommandEvent objects.
3064 The default handler for wxEVT_MENU_HIGHLIGHT displays help
3065 text in the first field of the status bar.
3067 @beginEventTable{wxMenuEvent}
3068 @event{EVT_MENU_OPEN(func)}
3069 A menu is about to be opened. On Windows, this is only sent once for each
3070 navigation of the menubar (up until all menus have closed).
3071 @event{EVT_MENU_CLOSE(func)}
3072 A menu has been just closed.
3073 @event{EVT_MENU_HIGHLIGHT(id, func)}
3074 The menu item with the specified id has been highlighted: used to show
3075 help prompts in the status bar by wxFrame
3076 @event{EVT_MENU_HIGHLIGHT_ALL(func)}
3077 A menu item has been highlighted, i.e. the currently selected menu item has changed.
3083 @see wxCommandEvent, @ref overview_eventhandling
3085 class wxMenuEvent
: public wxEvent
3091 wxMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0, wxMenu
* menu
= NULL
);
3094 Returns the menu which is being opened or closed. This method should only be
3095 used with the @c OPEN and @c CLOSE events and even for them the
3096 returned pointer may be @NULL in some ports.
3098 wxMenu
* GetMenu() const;
3101 Returns the menu identifier associated with the event.
3102 This method should be only used with the @c HIGHLIGHT events.
3104 int GetMenuId() const;
3107 Returns @true if the menu which is being opened or closed is a popup menu,
3108 @false if it is a normal one.
3110 This method should only be used with the @c OPEN and @c CLOSE events.
3112 bool IsPopup() const;
3117 @class wxIconizeEvent
3120 An event being sent when the frame is iconized (minimized) or restored.
3122 Currently only wxMSW and wxGTK generate such events.
3124 @onlyfor{wxmsw,wxgtk}
3126 @beginEventTable{wxIconizeEvent}
3127 @event{EVT_ICONIZE(func)}
3128 Process a wxEVT_ICONIZE event.
3134 @see @ref overview_eventhandling, wxTopLevelWindow::Iconize,
3135 wxTopLevelWindow::IsIconized
3137 class wxIconizeEvent
: public wxEvent
3143 wxIconizeEvent(int id
= 0, bool iconized
= true);
3146 Returns @true if the frame has been iconized, @false if it has been
3149 bool Iconized() const;
3158 A move event holds information about move change events.
3160 @beginEventTable{wxMoveEvent}
3161 @event{EVT_MOVE(func)}
3162 Process a wxEVT_MOVE event, which is generated when a window is moved.
3163 @event{EVT_MOVE_START(func)}
3164 Process a wxEVT_MOVE_START event, which is generated when the user starts
3165 to move or size a window. wxMSW only.
3166 @event{EVT_MOVE_END(func)}
3167 Process a wxEVT_MOVE_END event, which is generated when the user stops
3168 moving or sizing a window. wxMSW only.
3174 @see wxPoint, @ref overview_eventhandling
3176 class wxMoveEvent
: public wxEvent
3182 wxMoveEvent(const wxPoint
& pt
, int id
= 0);
3185 Returns the position of the window generating the move change event.
3187 wxPoint
GetPosition() const;
3195 A size event holds information about size change events.
3197 The EVT_SIZE handler function will be called when the window has been resized.
3199 You may wish to use this for frames to resize their child windows as appropriate.
3201 Note that the size passed is of the whole window: call wxWindow::GetClientSize
3202 for the area which may be used by the application.
3204 When a window is resized, usually only a small part of the window is damaged
3205 and you may only need to repaint that area. However, if your drawing depends on the
3206 size of the window, you may need to clear the DC explicitly and repaint the whole window.
3207 In which case, you may need to call wxWindow::Refresh to invalidate the entire window.
3209 @beginEventTable{wxSizeEvent}
3210 @event{EVT_SIZE(func)}
3211 Process a wxEVT_SIZE event.
3217 @see wxSize, @ref overview_eventhandling
3219 class wxSizeEvent
: public wxEvent
3225 wxSizeEvent(const wxSize
& sz
, int id
= 0);
3228 Returns the entire size of the window generating the size change event.
3230 wxSize
GetSize() const;
3236 @class wxSetCursorEvent
3239 A SetCursorEvent is generated when the mouse cursor is about to be set as a
3240 result of mouse motion.
3242 This event gives the application the chance to perform specific mouse cursor
3243 processing based on the current position of the mouse within the window.
3244 Use wxSetCursorEvent::SetCursor to specify the cursor you want to be displayed.
3246 @beginEventTable{wxSetCursorEvent}
3247 @event{EVT_SET_CURSOR(func)}
3248 Process a wxEVT_SET_CURSOR event.
3254 @see ::wxSetCursor, wxWindow::wxSetCursor
3256 class wxSetCursorEvent
: public wxEvent
3260 Constructor, used by the library itself internally to initialize the event
3263 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0);
3266 Returns a reference to the cursor specified by this event.
3268 const wxCursor
& GetCursor() const;
3271 Returns the X coordinate of the mouse in client coordinates.
3273 wxCoord
GetX() const;
3276 Returns the Y coordinate of the mouse in client coordinates.
3278 wxCoord
GetY() const;
3281 Returns @true if the cursor specified by this event is a valid cursor.
3283 @remarks You cannot specify wxNullCursor with this event, as it is not
3284 considered a valid cursor.
3286 bool HasCursor() const;
3289 Sets the cursor associated with this event.
3291 void SetCursor(const wxCursor
& cursor
);
3296 // ============================================================================
3297 // Global functions/macros
3298 // ============================================================================
3300 /** @ingroup group_funcmacro_misc */
3304 In a GUI application, this function posts @a event to the specified @e dest
3305 object using wxEvtHandler::AddPendingEvent().
3307 Otherwise, it dispatches @a event immediately using
3308 wxEvtHandler::ProcessEvent(). See the respective documentation for details
3309 (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent()
3310 this function is not thread-safe for event objects having wxString fields,
3311 use wxQueueEvent() instead.
3315 void wxPostEvent(wxEvtHandler
* dest
, const wxEvent
& event
);
3318 Queue an event for processing on the given object.
3320 This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation
3326 The object to queue the event on, can't be @c NULL.
3328 The heap-allocated and non-@c NULL event to queue, the function takes
3331 void wxQueueEvent(wxEvtHandler
* dest
, wxEvent
*event
);