1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxEvtHandler, wxEventBlocker and many
4 // wxEvent-derived classes
5 // Author: wxWidgets team
7 // Licence: wxWindows license
8 /////////////////////////////////////////////////////////////////////////////
14 An event is a structure holding information about an event passed to a
15 callback or member function.
17 wxEvent used to be a multipurpose event object, and is an abstract base class
18 for other event classes (see below).
20 For more information about events, see the @ref overview_eventhandling overview.
23 In wxPerl custom event classes should be derived from
24 @c Wx::PlEvent and @c Wx::PlCommandEvent.
30 @see wxCommandEvent, wxMouseEvent
32 class wxEvent
: public wxObject
38 Notice that events are usually created by wxWidgets itself and creating
39 e.g. a wxPaintEvent in your code and sending it to e.g. a wxTextCtrl
40 will not usually affect it at all as native controls have no specific
41 knowledge about wxWidgets events. However you may construct objects of
42 specific types and pass them to wxEvtHandler::ProcessEvent() if you
43 want to create your own custom control and want to process its events
44 in the same manner as the standard ones.
46 Also please notice that the order of parameters in this constructor is
47 different from almost all the derived classes which specify the event
48 type as the first argument.
51 The identifier of the object (window, timer, ...) which generated
54 The unique type of event, e.g. wxEVT_PAINT, wxEVT_SIZE or
55 wxEVT_COMMAND_BUTTON_CLICKED.
57 wxEvent(int id
= 0, wxEventType eventType
= wxEVT_NULL
);
60 Returns a copy of the event.
62 Any event that is posted to the wxWidgets event system for later action
63 (via wxEvtHandler::AddPendingEvent, wxEvtHandler::QueueEvent or wxPostEvent())
64 must implement this method.
66 All wxWidgets events fully implement this method, but any derived events
67 implemented by the user should also implement this method just in case they
68 (or some event derived from them) are ever posted.
70 All wxWidgets events implement a copy constructor, so the easiest way of
71 implementing the Clone function is to implement a copy constructor for
72 a new event (call it MyEvent) and then define the Clone function like this:
75 wxEvent *Clone() const { return new MyEvent(*this); }
78 virtual wxEvent
* Clone() const = 0;
81 Returns the object (usually a window) associated with the event, if any.
83 wxObject
* GetEventObject() const;
86 Returns the identifier of the given event type, such as @c wxEVT_COMMAND_BUTTON_CLICKED.
88 wxEventType
GetEventType() const;
91 Returns the identifier associated with this event, such as a button command id.
96 Returns @true if the event handler should be skipped, @false otherwise.
98 bool GetSkipped() const;
101 Gets the timestamp for the event. The timestamp is the time in milliseconds
102 since some fixed moment (not necessarily the standard Unix Epoch, so only
103 differences between the timestamps and not their absolute values usually make sense).
106 wxWidgets returns a non-NULL timestamp only for mouse and key events
107 (see wxMouseEvent and wxKeyEvent).
109 long GetTimestamp() const;
112 Returns @true if the event is or is derived from wxCommandEvent else it returns @false.
114 @note exists only for optimization purposes.
116 bool IsCommandEvent() const;
119 Sets the propagation level to the given value (for example returned from an
120 earlier call to wxEvent::StopPropagation).
122 void ResumePropagation(int propagationLevel
);
125 Sets the originating object.
127 void SetEventObject(wxObject
* object
);
132 void SetEventType(wxEventType type
);
135 Sets the identifier associated with this event, such as a button command id.
140 Sets the timestamp for the event.
142 void SetTimestamp(long timeStamp
= 0);
145 Test if this event should be propagated or not, i.e. if the propagation level
146 is currently greater than 0.
148 bool ShouldPropagate() const;
151 This method can be used inside an event handler to control whether further
152 event handlers bound to this event will be called after the current one returns.
154 Without Skip() (or equivalently if Skip(@false) is used), the event will not
155 be processed any more. If Skip(@true) is called, the event processing system
156 continues searching for a further handler function for this event, even though
157 it has been processed already in the current handler.
159 In general, it is recommended to skip all non-command events to allow the
160 default handling to take place. The command events are, however, normally not
161 skipped as usually a single command such as a button click or menu item
162 selection must only be processed by one handler.
164 void Skip(bool skip
= true);
167 Stop the event from propagating to its parent window.
169 Returns the old propagation level value which may be later passed to
170 ResumePropagation() to allow propagating the event again.
172 int StopPropagation();
176 Indicates how many levels the event can propagate.
178 This member is protected and should typically only be set in the constructors
179 of the derived classes. It may be temporarily changed by StopPropagation()
180 and ResumePropagation() and tested with ShouldPropagate().
182 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default)
183 meaning that the event shouldn't be propagated at all or to
184 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
185 propagated as much as necessary.
187 Any positive number means that the event should be propagated but no more than
188 the given number of times. E.g. the propagation level may be set to 1 to
189 propagate the event to its parent only, but not to its grandparent.
191 int m_propagationLevel
;
195 @class wxEventBlocker
197 This class is a special event handler which allows to discard
198 any event (or a set of event types) directed to a specific window.
203 void MyWindow::DoSomething()
206 // block all events directed to this window while
207 // we do the 1000 FunctionWhichSendsEvents() calls
208 wxEventBlocker blocker(this);
210 for ( int i = 0; i 1000; i++ )
211 FunctionWhichSendsEvents(i);
213 } // ~wxEventBlocker called, old event handler is restored
215 // the event generated by this call will be processed:
216 FunctionWhichSendsEvents(0)
223 @see @ref overview_eventhandling, wxEvtHandler
225 class wxEventBlocker
: public wxEvtHandler
229 Constructs the blocker for the given window and for the given event type.
231 If @a type is @c wxEVT_ANY, then all events for that window are blocked.
232 You can call Block() after creation to add other event types to the list
235 Note that the @a win window @b must remain alive until the
236 wxEventBlocker object destruction.
238 wxEventBlocker(wxWindow
* win
, wxEventType type
= -1);
241 Destructor. The blocker will remove itself from the chain of event handlers for
242 the window provided in the constructor, thus restoring normal processing of events.
244 virtual ~wxEventBlocker();
247 Adds to the list of event types which should be blocked the given @a eventType.
249 void Block(wxEventType eventType
);
257 A class that can handle events from the windowing system.
258 wxWindow is (and therefore all window classes are) derived from this class.
260 When events are received, wxEvtHandler invokes the method listed in the
261 event table using itself as the object. When using multiple inheritance
262 <b>it is imperative that the wxEvtHandler(-derived) class is the first
263 class inherited</b> such that the @c this pointer for the overall object
264 will be identical to the @c this pointer of the wxEvtHandler portion.
269 @see @ref overview_eventhandling
271 class wxEvtHandler
: public wxObject
282 If the handler is part of a chain, the destructor will unlink itself and
283 restore the previous and next handlers so that they point to each other.
285 virtual ~wxEvtHandler();
289 @name Event queuing and processing
294 Queue event for a later processing.
296 This method is similar to ProcessEvent() but while the latter is
297 synchronous, i.e. the event is processed immediately, before the
298 function returns, this one is asynchronous and returns immediately
299 while the event will be processed at some later time (usually during
300 the next event loop iteration).
302 Another important difference is that this method takes ownership of the
303 @a event parameter, i.e. it will delete it itself. This implies that
304 the event should be allocated on the heap and that the pointer can't be
305 used any more after the function returns (as it can be deleted at any
308 QueueEvent() can be used for inter-thread communication from the worker
309 threads to the main thread, it is safe in the sense that it uses
310 locking internally and avoids the problem mentioned in AddPendingEvent()
311 documentation by ensuring that the @a event object is not used by the
312 calling thread any more. Care should still be taken to avoid that some
313 fields of this object are used by it, notably any wxString members of
314 the event object must not be shallow copies of another wxString object
315 as this would result in them still using the same string buffer behind
316 the scenes. For example
318 void FunctionInAWorkerThread(const wxString& str)
320 wxCommandEvent* evt = new wxCommandEvent;
322 // NOT evt->SetString(str) as this would be a shallow copy
323 evt->SetString(str.c_str()); // make a deep copy
325 wxTheApp->QueueEvent( evt );
329 Finally notice that this method automatically wakes up the event loop
330 if it is currently idle by calling ::wxWakeUpIdle() so there is no need
331 to do it manually when using it.
336 A heap-allocated event to be queued, QueueEvent() takes ownership
337 of it. This parameter shouldn't be @c NULL.
339 virtual void QueueEvent(wxEvent
*event
);
342 Post an event to be processed later.
344 This function is similar to QueueEvent() but can't be used to post
345 events from worker threads for the event objects with wxString fields
346 (i.e. in practice most of them) because of an unsafe use of the same
347 wxString object which happens because the wxString field in the
348 original @a event object and its copy made internally by this function
349 share the same string buffer internally. Use QueueEvent() to avoid
352 A copy of @a event is made by the function, so the original can be deleted
353 as soon as function returns (it is common that the original is created
354 on the stack). This requires that the wxEvent::Clone() method be
355 implemented by event so that it can be duplicated and stored until it
359 Event to add to the pending events queue.
361 virtual void AddPendingEvent(const wxEvent
& event
);
364 Processes an event, searching event tables and calling zero or more suitable
365 event handler function(s).
367 Normally, your application would not call this function: it is called in the
368 wxWidgets implementation to dispatch incoming user interface events to the
369 framework (and application).
371 However, you might need to call it if implementing new functionality
372 (such as a new control) where you define new event types, as opposed to
373 allowing the user to override virtual functions.
375 An instance where you might actually override the ProcessEvent() function is where
376 you want to direct event processing to event handlers not normally noticed by
377 wxWidgets. For example, in the document/view architecture, documents and views
378 are potential event handlers. When an event reaches a frame, ProcessEvent() will
379 need to be called on the associated document and view in case event handler functions
380 are associated with these objects. The property classes library (wxProperty) also
381 overrides ProcessEvent() for similar reasons.
383 The normal order of event table searching is as follows:
384 -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled)
385 the function skips to step (6).
386 -# If the object is a wxWindow, ProcessEvent() is recursively called on the
387 window's wxValidator. If this returns @true, the function exits.
388 -# SearchEventTable() is called for this event handler. If this fails, the base
389 class table is tried, and so on until no more tables exist or an appropriate
390 function was found, in which case the function exits.
391 -# The search is applied down the entire chain of event handlers (usually the
392 chain has a length of one). If this succeeds, the function exits.
393 -# If the object is a wxWindow and the event is a wxCommandEvent, ProcessEvent()
394 is recursively applied to the parent window's event handler.
395 If this returns true, the function exits.
396 -# Finally, ProcessEvent() is called on the wxApp object.
401 @return @true if a suitable event handler function was found and
402 executed, and the function did not call wxEvent::Skip.
404 @see SearchEventTable()
406 virtual bool ProcessEvent(wxEvent
& event
);
409 Processes an event by calling ProcessEvent() and handles any exceptions
410 that occur in the process.
411 If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called.
416 @return @true if the event was processed, @false if no handler was found
417 or an exception was thrown.
419 @see wxWindow::HandleWindowEvent
421 bool SafelyProcessEvent(wxEvent
& event
);
424 Searches the event table, executing an event handler function if an appropriate
428 Event table to be searched.
430 Event to be matched against an event table entry.
432 @return @true if a suitable event handler function was found and
433 executed, and the function did not call wxEvent::Skip.
435 @remarks This function looks through the object's event table and tries
436 to find an entry that will match the event.
437 An entry will match if:
438 @li The event type matches, and
439 @li the identifier or identifier range matches, or the event table
440 entry's identifier is zero.
442 If a suitable function is called but calls wxEvent::Skip, this
443 function will fail, and searching will continue.
447 virtual bool SearchEventTable(wxEventTable
& table
,
454 @name Connecting and disconnecting
459 Connects the given function dynamically with the event handler, id and event type.
460 This is an alternative to the use of static event tables.
462 See the @ref page_samples_event sample for usage.
464 This specific overload allows you to connect an event handler to a @e range
466 Do not confuse @e source IDs with event @e types: source IDs identify the
467 event generator objects (typically wxMenuItem or wxWindow objects) while the
468 event @e type identify which type of events should be handled by the
469 given @e function (an event generator object may generate many different
473 The first ID of the identifier range to be associated with the event
476 The last ID of the identifier range to be associated with the event
479 The event type to be associated with this event handler.
481 The event handler function. Note that this function should
482 be explicitly converted to the correct type which can be done using a macro
483 called @c wxFooEventHandler for the handler for any @c wxFooEvent.
485 Data to be associated with the event table entry.
487 Object whose member function should be called.
488 If this is @NULL, @c *this will be used.
490 void Connect(int id
, int lastId
, wxEventType eventType
,
491 wxObjectEventFunction function
,
492 wxObject
* userData
= NULL
,
493 wxEvtHandler
* eventSink
= NULL
);
496 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
497 overload for more info.
499 This overload can be used to attach an event handler to a single source ID:
503 frame->Connect( wxID_EXIT,
504 wxEVT_COMMAND_MENU_SELECTED,
505 wxCommandEventHandler(MyFrame::OnQuit) );
508 void Connect(int id
, wxEventType eventType
,
509 wxObjectEventFunction function
,
510 wxObject
* userData
= NULL
,
511 wxEvtHandler
* eventSink
= NULL
);
514 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
515 overload for more info.
517 This overload will connect the given event handler so that regardless of the
518 ID of the event source, the handler will be called.
520 void Connect(wxEventType eventType
,
521 wxObjectEventFunction function
,
522 wxObject
* userData
= NULL
,
523 wxEvtHandler
* eventSink
= NULL
);
526 Disconnects the given function dynamically from the event handler, using the
527 specified parameters as search criteria and returning @true if a matching
528 function has been found and removed.
530 This method can only disconnect functions which have been added using the
531 Connect() method. There is no way to disconnect functions connected using
532 the (static) event tables.
535 The event type associated with this event handler.
537 The event handler function.
539 Data associated with the event table entry.
541 Object whose member function should be called.
543 bool Disconnect(wxEventType eventType
,
544 wxObjectEventFunction function
,
545 wxObject
* userData
= NULL
,
546 wxEvtHandler
* eventSink
= NULL
);
549 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
550 overload for more info.
552 This overload takes the additional @a id parameter.
554 bool Disconnect(int id
= wxID_ANY
,
555 wxEventType eventType
= wxEVT_NULL
,
556 wxObjectEventFunction function
= NULL
,
557 wxObject
* userData
= NULL
,
558 wxEvtHandler
* eventSink
= NULL
);
561 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
562 overload for more info.
564 This overload takes an additional range of source IDs.
566 bool Disconnect(int id
, int lastId
,
567 wxEventType eventType
,
568 wxObjectEventFunction function
= NULL
,
569 wxObject
* userData
= NULL
,
570 wxEvtHandler
* eventSink
= NULL
);
575 @name User-supplied data
580 Returns user-supplied client data.
582 @remarks Normally, any extra data the programmer wishes to associate with
583 the object should be made available by deriving a new class with
588 void* GetClientData() const;
591 Returns a pointer to the user-supplied client data object.
593 @see SetClientObject(), wxClientData
595 wxClientData
* GetClientObject() const;
598 Sets user-supplied client data.
601 Data to be associated with the event handler.
603 @remarks Normally, any extra data the programmer wishes to associate
604 with the object should be made available by deriving a new
605 class with new data members. You must not call this method
606 and SetClientObject on the same class - only one of them.
610 void SetClientData(void* data
);
613 Set the client data object. Any previous object will be deleted.
615 @see GetClientObject(), wxClientData
617 void SetClientObject(wxClientData
* data
);
623 @name Event handler chain
628 Returns @true if the event handler is enabled, @false otherwise.
630 @see SetEvtHandlerEnabled()
632 bool GetEvtHandlerEnabled() const;
635 Returns the pointer to the next handler in the chain.
637 @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(),
638 wxWindow::PushEventHandler, wxWindow::PopEventHandler
640 wxEvtHandler
* GetNextHandler() const;
643 Returns the pointer to the previous handler in the chain.
645 @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(),
646 wxWindow::PushEventHandler, wxWindow::PopEventHandler
648 wxEvtHandler
* GetPreviousHandler() const;
651 Enables or disables the event handler.
654 @true if the event handler is to be enabled, @false if it is to be disabled.
656 @remarks You can use this function to avoid having to remove the event
657 handler from the chain, for example when implementing a
658 dialog editor and changing from edit to test mode.
660 @see GetEvtHandlerEnabled()
662 void SetEvtHandlerEnabled(bool enabled
);
665 Sets the pointer to the next handler.
668 Event handler to be set as the next handler.
670 @see GetNextHandler(), SetPreviousHandler(), GetPreviousHandler(),
671 wxWindow::PushEventHandler, wxWindow::PopEventHandler
673 void SetNextHandler(wxEvtHandler
* handler
);
676 Sets the pointer to the previous handler.
679 Event handler to be set as the previous handler.
681 void SetPreviousHandler(wxEvtHandler
* handler
);
690 This event class contains information about keypress (character) events.
692 Notice that there are three different kinds of keyboard events in wxWidgets:
693 key down and up events and char events. The difference between the first two
694 is clear - the first corresponds to a key press and the second to a key
695 release - otherwise they are identical. Just note that if the key is
696 maintained in a pressed state you will typically get a lot of (automatically
697 generated) down events but only one up so it is wrong to assume that there is
698 one up event corresponding to each down one.
700 Both key events provide untranslated key codes while the char event carries
701 the translated one. The untranslated code for alphanumeric keys is always
702 an upper case value. For the other keys it is one of @c WXK_XXX values
703 from the @ref page_keycodes.
704 The translated key is, in general, the character the user expects to appear
705 as the result of the key combination when typing the text into a text entry
708 A few examples to clarify this (all assume that CAPS LOCK is unpressed
709 and the standard US keyboard): when the @c 'A' key is pressed, the key down
710 event key code is equal to @c ASCII A == 65. But the char event key code
711 is @c ASCII a == 97. On the other hand, if you press both SHIFT and
712 @c 'A' keys simultaneously , the key code in key down event will still be
713 just @c 'A' while the char event key code parameter will now be @c 'A'
716 Although in this simple case it is clear that the correct key code could be
717 found in the key down event handler by checking the value returned by
718 wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as
719 for non-alphanumeric keys the translation is keyboard-layout dependent and
720 can only be done properly by the system itself.
722 Another kind of translation is done when the control key is pressed: for
723 example, for CTRL-A key press the key down event still carries the
724 same key code @c 'a' as usual but the char event will have key code of 1,
725 the ASCII value of this key combination.
727 You may discover how the other keys on your system behave interactively by
728 running the @ref page_samples_text wxWidgets sample and pressing some keys
729 in any of the text controls shown in it.
731 @b Tip: be sure to call @c event.Skip() for events that you don't process in
732 key event function, otherwise menu shortcuts may cease to work under Windows.
734 @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler
735 does not call @c event.Skip() then the corresponding char event
736 (@c EVT_CHAR) will not happen.
737 This is by design and enables the programs that handle both types of
738 events to be a bit simpler.
740 @note For Windows programmers: The key and char events in wxWidgets are
741 similar to but slightly different from Windows @c WM_KEYDOWN and
742 @c WM_CHAR events. In particular, Alt-x combination will generate a
743 char event in wxWidgets (unless it is used as an accelerator).
746 @beginEventTable{wxKeyEvent}
747 @event{EVT_KEY_DOWN(func)}
748 Process a wxEVT_KEY_DOWN event (any key has been pressed).
749 @event{EVT_KEY_UP(func)}
750 Process a wxEVT_KEY_UP event (any key has been released).
751 @event{EVT_CHAR(func)}
752 Process a wxEVT_CHAR event.
760 class wxKeyEvent
: public wxEvent
,
761 public wxKeyboardState
766 Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK.
768 wxKeyEvent(wxEventType keyEventType
= wxEVT_NULL
);
771 Returns the virtual key code. ASCII events return normal ASCII values,
772 while non-ASCII events return values such as @b WXK_LEFT for the left cursor
773 key. See @ref page_keycodes for a full list of the virtual key codes.
775 Note that in Unicode build, the returned value is meaningful only if the
776 user entered a character that can be represented in current locale's default
777 charset. You can obtain the corresponding Unicode character using GetUnicodeKey().
779 int GetKeyCode() 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;
829 @class wxJoystickEvent
831 This event class contains information about joystick events, particularly
832 events received by windows.
834 @beginEventTable{wxJoystickEvent}
835 @style{EVT_JOY_BUTTON_DOWN(func)}
836 Process a wxEVT_JOY_BUTTON_DOWN event.
837 @style{EVT_JOY_BUTTON_UP(func)}
838 Process a wxEVT_JOY_BUTTON_UP event.
839 @style{EVT_JOY_MOVE(func)}
840 Process a wxEVT_JOY_MOVE event.
841 @style{EVT_JOY_ZMOVE(func)}
842 Process a wxEVT_JOY_ZMOVE event.
843 @style{EVT_JOYSTICK_EVENTS(func)}
844 Processes all joystick events.
852 class wxJoystickEvent
: public wxEvent
858 wxJoystickEvent(wxEventType eventType
= wxEVT_NULL
, int state
= 0,
859 int joystick
= wxJOYSTICK1
,
863 Returns @true if the event was a down event from the specified button
867 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
868 indicate any button down event.
870 bool ButtonDown(int button
= wxJOY_BUTTON_ANY
) const;
873 Returns @true if the specified button (or any button) was in a down state.
876 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
877 indicate any button down event.
879 bool ButtonIsDown(int button
= wxJOY_BUTTON_ANY
) const;
882 Returns @true if the event was an up event from the specified button
886 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
887 indicate any button down event.
889 bool ButtonUp(int button
= wxJOY_BUTTON_ANY
) const;
892 Returns the identifier of the button changing state.
894 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
896 int GetButtonChange() const;
899 Returns the down state of the buttons.
901 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
903 int GetButtonState() const;
906 Returns the identifier of the joystick generating the event - one of
907 wxJOYSTICK1 and wxJOYSTICK2.
909 int GetJoystick() const;
912 Returns the x, y position of the joystick event.
914 wxPoint
GetPosition() const;
917 Returns the z position of the joystick event.
919 int GetZPosition() const;
922 Returns @true if this was a button up or down event
923 (@e not 'is any button down?').
925 bool IsButton() const;
928 Returns @true if this was an x, y move event.
933 Returns @true if this was a z move event.
935 bool IsZMove() const;
941 @class wxScrollWinEvent
943 A scroll event holds information about events sent from scrolling windows.
946 @beginEventTable{wxScrollWinEvent}
947 You can use the EVT_SCROLLWIN* macros for intercepting scroll window events
948 from the receiving window.
949 @event{EVT_SCROLLWIN(func)}
950 Process all scroll events.
951 @event{EVT_SCROLLWIN_TOP(func)}
952 Process wxEVT_SCROLLWIN_TOP scroll-to-top events.
953 @event{EVT_SCROLLWIN_BOTTOM(func)}
954 Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events.
955 @event{EVT_SCROLLWIN_LINEUP(func)}
956 Process wxEVT_SCROLLWIN_LINEUP line up events.
957 @event{EVT_SCROLLWIN_LINEDOWN(func)}
958 Process wxEVT_SCROLLWIN_LINEDOWN line down events.
959 @event{EVT_SCROLLWIN_PAGEUP(func)}
960 Process wxEVT_SCROLLWIN_PAGEUP page up events.
961 @event{EVT_SCROLLWIN_PAGEDOWN(func)}
962 Process wxEVT_SCROLLWIN_PAGEDOWN page down events.
963 @event{EVT_SCROLLWIN_THUMBTRACK(func)}
964 Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events
965 (frequent events sent as the user drags the thumbtrack).
966 @event{EVT_SCROLLWIN_THUMBRELEASE(func)}
967 Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events.
974 @see wxScrollEvent, @ref overview_eventhandling
976 class wxScrollWinEvent
: public wxEvent
982 wxScrollWinEvent(wxEventType commandType
= wxEVT_NULL
, int pos
= 0,
983 int orientation
= 0);
986 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
989 @todo wxHORIZONTAL and wxVERTICAL should go in their own enum
991 int GetOrientation() const;
994 Returns the position of the scrollbar for the thumb track and release events.
996 Note that this field can't be used for the other events, you need to query
997 the window itself for the current position in that case.
999 int GetPosition() const;
1005 @class wxSysColourChangedEvent
1007 This class is used for system colour change events, which are generated
1008 when the user changes the colour settings using the control panel.
1009 This is only appropriate under Windows.
1012 The default event handler for this event propagates the event to child windows,
1013 since Windows only sends the events to top-level windows.
1014 If intercepting this event for a top-level window, remember to call the base
1015 class handler, or to pass the event on to the window's children explicitly.
1017 @beginEventTable{wxSysColourChangedEvent}
1018 @event{EVT_SYS_COLOUR_CHANGED(func)}
1019 Process a wxEVT_SYS_COLOUR_CHANGED event.
1025 @see @ref overview_eventhandling
1027 class wxSysColourChangedEvent
: public wxEvent
1033 wxSysColourChangedEvent();
1039 @class wxWindowCreateEvent
1041 This event is sent just after the actual window associated with a wxWindow
1042 object has been created.
1044 Since it is derived from wxCommandEvent, the event propagates up
1045 the window hierarchy.
1047 @beginEventTable{wxWindowCreateEvent}
1048 @event{EVT_WINDOW_CREATE(func)}
1049 Process a wxEVT_CREATE event.
1055 @see @ref overview_eventhandling, wxWindowDestroyEvent
1057 class wxWindowCreateEvent
: public wxCommandEvent
1063 wxWindowCreateEvent(wxWindow
* win
= NULL
);
1065 /// Retutn the window being created.
1066 wxWindow
*GetWindow() const;
1074 A paint event is sent when a window's contents needs to be repainted.
1076 Please notice that in general it is impossible to change the drawing of a
1077 standard control (such as wxButton) and so you shouldn't attempt to handle
1078 paint events for them as even if it might work on some platforms, this is
1079 inherently not portable and won't work everywhere.
1082 Note that in a paint event handler, the application must always create a
1083 wxPaintDC object, even if you do not use it. Otherwise, under MS Windows,
1084 refreshing for this and other windows will go wrong.
1087 void MyWindow::OnPaint(wxPaintEvent& event)
1094 You can optimize painting by retrieving the rectangles that have been damaged
1095 and only repainting these. The rectangles are in terms of the client area,
1096 and are unscrolled, so you will need to do some calculations using the current
1097 view position to obtain logical, scrolled units.
1098 Here is an example of using the wxRegionIterator class:
1100 // Called when window needs to be repainted.
1101 void MyWindow::OnPaint(wxPaintEvent& event)
1105 // Find Out where the window is scrolled to
1106 int vbX,vbY; // Top left corner of client
1107 GetViewStart(&vbX,&vbY);
1109 int vX,vY,vW,vH; // Dimensions of client area in pixels
1110 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
1119 // Alternatively we can do this:
1120 // wxRect rect(upd.GetRect());
1122 // Repaint this rectangle
1131 @beginEventTable{wxPaintEvent}
1132 @event{EVT_PAINT(func)}
1133 Process a wxEVT_PAINT event.
1139 @see @ref overview_eventhandling
1141 class wxPaintEvent
: public wxEvent
1147 wxPaintEvent(int id
= 0);
1153 @class wxMaximizeEvent
1155 An event being sent when a top level window is maximized. Notice that it is
1156 not sent when the window is restored to its original size after it had been
1157 maximized, only a normal wxSizeEvent is generated in this case.
1159 @beginEventTable{wxMaximizeEvent}
1160 @event{EVT_MAXIMIZE(func)}
1161 Process a wxEVT_MAXIMIZE event.
1167 @see @ref overview_eventhandling, wxTopLevelWindow::Maximize,
1168 wxTopLevelWindow::IsMaximized
1170 class wxMaximizeEvent
: public wxEvent
1174 Constructor. Only used by wxWidgets internally.
1176 wxMaximizeEvent(int id
= 0);
1180 The possibles modes to pass to wxUpdateUIEvent::SetMode().
1184 /** Send UI update events to all windows. */
1185 wxUPDATE_UI_PROCESS_ALL
,
1187 /** Send UI update events to windows that have
1188 the wxWS_EX_PROCESS_UI_UPDATES flag specified. */
1189 wxUPDATE_UI_PROCESS_SPECIFIED
1194 @class wxUpdateUIEvent
1196 This class is used for pseudo-events which are called by wxWidgets
1197 to give an application the chance to update various user interface elements.
1199 Without update UI events, an application has to work hard to check/uncheck,
1200 enable/disable, show/hide, and set the text for elements such as menu items
1201 and toolbar buttons. The code for doing this has to be mixed up with the code
1202 that is invoked when an action is invoked for a menu item or button.
1204 With update UI events, you define an event handler to look at the state of the
1205 application and change UI elements accordingly. wxWidgets will call your member
1206 functions in idle time, so you don't have to worry where to call this code.
1208 In addition to being a clearer and more declarative method, it also means you don't
1209 have to worry whether you're updating a toolbar or menubar identifier. The same
1210 handler can update a menu item and toolbar button, if the identifier is the same.
1211 Instead of directly manipulating the menu or button, you call functions in the event
1212 object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a
1213 call has been made, and which UI element to update.
1215 These events will work for popup menus as well as menubars. Just before a menu is
1216 popped up, wxMenu::UpdateUI is called to process any UI events for the window that
1219 If you find that the overhead of UI update processing is affecting your application,
1220 you can do one or both of the following:
1221 @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED,
1222 and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should
1223 receive update events. No other windows will receive update events.
1224 @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay
1225 between updates. You may need to call wxWindow::UpdateWindowUI at critical points,
1226 for example when a dialog is about to be shown, in case the user sees a slight
1227 delay before windows are updated.
1229 Note that although events are sent in idle time, defining a wxIdleEvent handler
1230 for a window does not affect this because the events are sent from wxWindow::OnInternalIdle
1231 which is always called in idle time.
1233 wxWidgets tries to optimize update events on some platforms.
1234 On Windows and GTK+, events for menubar items are only sent when the menu is about
1235 to be shown, and not in idle time.
1238 @beginEventTable{wxUpdateUIEvent}
1239 @event{EVT_UPDATE_UI(id, func)}
1240 Process a wxEVT_UPDATE_UI event for the command with the given id.
1241 @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}
1242 Process a wxEVT_UPDATE_UI event for any command with id included in the given range.
1248 @see @ref overview_eventhandling
1250 class wxUpdateUIEvent
: public wxCommandEvent
1256 wxUpdateUIEvent(wxWindowID commandId
= 0);
1259 Returns @true if it is appropriate to update (send UI update events to)
1262 This function looks at the mode used (see wxUpdateUIEvent::SetMode),
1263 the wxWS_EX_PROCESS_UI_UPDATES flag in @a window, the time update events
1264 were last sent in idle time, and the update interval, to determine whether
1265 events should be sent to this window now. By default this will always
1266 return @true because the update mode is initially wxUPDATE_UI_PROCESS_ALL
1267 and the interval is set to 0; so update events will be sent as often as
1268 possible. You can reduce the frequency that events are sent by changing the
1269 mode and/or setting an update interval.
1271 @see ResetUpdateTime(), SetUpdateInterval(), SetMode()
1273 static bool CanUpdate(wxWindow
* window
);
1276 Check or uncheck the UI element.
1278 void Check(bool check
);
1281 Enable or disable the UI element.
1283 void Enable(bool enable
);
1286 Returns @true if the UI element should be checked.
1288 bool GetChecked() const;
1291 Returns @true if the UI element should be enabled.
1293 bool GetEnabled() const;
1296 Static function returning a value specifying how wxWidgets will send update
1297 events: to all windows, or only to those which specify that they will process
1302 static wxUpdateUIMode
GetMode();
1305 Returns @true if the application has called Check().
1306 For wxWidgets internal use only.
1308 bool GetSetChecked() const;
1311 Returns @true if the application has called Enable().
1312 For wxWidgets internal use only.
1314 bool GetSetEnabled() const;
1317 Returns @true if the application has called Show().
1318 For wxWidgets internal use only.
1320 bool GetSetShown() const;
1323 Returns @true if the application has called SetText().
1324 For wxWidgets internal use only.
1326 bool GetSetText() const;
1329 Returns @true if the UI element should be shown.
1331 bool GetShown() const;
1334 Returns the text that should be set for the UI element.
1336 wxString
GetText() const;
1339 Returns the current interval between updates in milliseconds.
1340 The value -1 disables updates, 0 updates as frequently as possible.
1342 @see SetUpdateInterval().
1344 static long GetUpdateInterval();
1347 Used internally to reset the last-updated time to the current time.
1349 It is assumed that update events are normally sent in idle time, so this
1350 is called at the end of idle processing.
1352 @see CanUpdate(), SetUpdateInterval(), SetMode()
1354 static void ResetUpdateTime();
1357 Specify how wxWidgets will send update events: to all windows, or only to
1358 those which specify that they will process the events.
1361 this parameter may be one of the ::wxUpdateUIMode enumeration values.
1362 The default mode is wxUPDATE_UI_PROCESS_ALL.
1364 static void SetMode(wxUpdateUIMode mode
);
1367 Sets the text for this UI element.
1369 void SetText(const wxString
& text
);
1372 Sets the interval between updates in milliseconds.
1374 Set to -1 to disable updates, or to 0 to update as frequently as possible.
1377 Use this to reduce the overhead of UI update events if your application
1378 has a lot of windows. If you set the value to -1 or greater than 0,
1379 you may also need to call wxWindow::UpdateWindowUI at appropriate points
1380 in your application, such as when a dialog is about to be shown.
1382 static void SetUpdateInterval(long updateInterval
);
1385 Show or hide the UI element.
1387 void Show(bool show
);
1393 @class wxClipboardTextEvent
1395 This class represents the events generated by a control (typically a
1396 wxTextCtrl but other windows can generate these events as well) when its
1397 content gets copied or cut to, or pasted from the clipboard.
1399 There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY,
1400 wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE.
1402 If any of these events is processed (without being skipped) by an event
1403 handler, the corresponding operation doesn't take place which allows to
1404 prevent the text from being copied from or pasted to a control. It is also
1405 possible to examine the clipboard contents in the PASTE event handler and
1406 transform it in some way before inserting in a control -- for example,
1407 changing its case or removing invalid characters.
1409 Finally notice that a CUT event is always preceded by the COPY event which
1410 makes it possible to only process the latter if it doesn't matter if the
1411 text was copied or cut.
1414 These events are currently only generated by wxTextCtrl under GTK+.
1415 They are generated by all controls under Windows.
1417 @beginEventTable{wxClipboardTextEvent}
1418 @event{EVT_TEXT_COPY(id, func)}
1419 Some or all of the controls content was copied to the clipboard.
1420 @event{EVT_TEXT_CUT(id, func)}
1421 Some or all of the controls content was cut (i.e. copied and
1423 @event{EVT_TEXT_PASTE(id, func)}
1424 Clipboard content was pasted into the control.
1433 class wxClipboardTextEvent
: public wxCommandEvent
1439 wxClipboardTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
1447 This event class contains information about the events generated by the mouse:
1448 they include mouse buttons press and release events and mouse move events.
1450 All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
1451 left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
1452 @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
1453 buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
1454 can also be generated. Note that not all mice have even a middle button so a
1455 portable application should avoid relying on the events from it (but the right
1456 button click can be emulated using the left mouse button with the control key
1457 under Mac platforms with a single button mouse).
1459 For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
1460 purposes, the mouse is considered to be inside the window if it is in the
1461 window client area and not inside one of its children. In other words, the
1462 parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
1463 mouse leaves the window entirely but also when it enters one of its children.
1465 The position associated with a mouse event is expressed in the window
1466 coordinates of the window which generated the event, you can use
1467 wxWindow::ClientToScreen() to convert it to screen coordinates and possibly
1468 call wxWindow::ScreenToClient() next to convert it to window coordinates of
1471 @note Note that under Windows CE mouse enter and leave events are not natively
1472 supported by the system but are generated by wxWidgets itself. This has several
1473 drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
1474 left the window and the state variables for it may have changed during this time.
1476 @note Note the difference between methods like wxMouseEvent::LeftDown and
1477 wxMouseEvent::LeftIsDown: the former returns @true when the event corresponds
1478 to the left mouse button click while the latter returns @true if the left
1479 mouse button is currently being pressed. For example, when the user is dragging
1480 the mouse you can use wxMouseEvent::LeftIsDown to test whether the left mouse
1481 button is (still) depressed. Also, by convention, if wxMouseEvent::LeftDown
1482 returns @true, wxMouseEvent::LeftIsDown will also return @true in wxWidgets
1483 whatever the underlying GUI behaviour is (which is platform-dependent).
1484 The same applies, of course, to other mouse buttons as well.
1487 @beginEventTable{wxMouseEvent}
1488 @event{EVT_LEFT_DOWN(func)}
1489 Process a wxEVT_LEFT_DOWN event. The handler of this event should normally
1490 call event.Skip() to allow the default processing to take place as otherwise
1491 the window under mouse wouldn't get the focus.
1492 @event{EVT_LEFT_UP(func)}
1493 Process a wxEVT_LEFT_UP event.
1494 @event{EVT_LEFT_DCLICK(func)}
1495 Process a wxEVT_LEFT_DCLICK event.
1496 @event{EVT_MIDDLE_DOWN(func)}
1497 Process a wxEVT_MIDDLE_DOWN event.
1498 @event{EVT_MIDDLE_UP(func)}
1499 Process a wxEVT_MIDDLE_UP event.
1500 @event{EVT_MIDDLE_DCLICK(func)}
1501 Process a wxEVT_MIDDLE_DCLICK event.
1502 @event{EVT_RIGHT_DOWN(func)}
1503 Process a wxEVT_RIGHT_DOWN event.
1504 @event{EVT_RIGHT_UP(func)}
1505 Process a wxEVT_RIGHT_UP event.
1506 @event{EVT_RIGHT_DCLICK(func)}
1507 Process a wxEVT_RIGHT_DCLICK event.
1508 @event{EVT_MOUSE_AUX1_DOWN(func)}
1509 Process a wxEVT_MOUSE_AUX1_DOWN event.
1510 @event{EVT_MOUSE_AUX1_UP(func)}
1511 Process a wxEVT_MOUSE_AUX1_UP event.
1512 @event{EVT_MOUSE_AUX1_DCLICK(func)}
1513 Process a wxEVT_MOUSE_AUX1_DCLICK event.
1514 @event{EVT_MOUSE_AUX2_DOWN(func)}
1515 Process a wxEVT_MOUSE_AUX2_DOWN event.
1516 @event{EVT_MOUSE_AUX2_UP(func)}
1517 Process a wxEVT_MOUSE_AUX2_UP event.
1518 @event{EVT_MOUSE_AUX2_DCLICK(func)}
1519 Process a wxEVT_MOUSE_AUX2_DCLICK event.
1520 @event{EVT_MOTION(func)}
1521 Process a wxEVT_MOTION event.
1522 @event{EVT_ENTER_WINDOW(func)}
1523 Process a wxEVT_ENTER_WINDOW event.
1524 @event{EVT_LEAVE_WINDOW(func)}
1525 Process a wxEVT_LEAVE_WINDOW event.
1526 @event{EVT_MOUSEWHEEL(func)}
1527 Process a wxEVT_MOUSEWHEEL event.
1528 @event{EVT_MOUSE_EVENTS(func)}
1529 Process all mouse events.
1537 class wxMouseEvent
: public wxEvent
,
1542 Constructor. Valid event types are:
1544 @li wxEVT_ENTER_WINDOW
1545 @li wxEVT_LEAVE_WINDOW
1548 @li wxEVT_LEFT_DCLICK
1549 @li wxEVT_MIDDLE_DOWN
1551 @li wxEVT_MIDDLE_DCLICK
1552 @li wxEVT_RIGHT_DOWN
1554 @li wxEVT_RIGHT_DCLICK
1555 @li wxEVT_MOUSE_AUX1_DOWN
1556 @li wxEVT_MOUSE_AUX1_UP
1557 @li wxEVT_MOUSE_AUX1_DCLICK
1558 @li wxEVT_MOUSE_AUX2_DOWN
1559 @li wxEVT_MOUSE_AUX2_UP
1560 @li wxEVT_MOUSE_AUX2_DCLICK
1562 @li wxEVT_MOUSEWHEEL
1564 wxMouseEvent(wxEventType mouseEventType
= wxEVT_NULL
);
1567 Returns @true if the event was a first extra button double click.
1569 bool Aux1DClick() const;
1572 Returns @true if the first extra button mouse button changed to down.
1574 bool Aux1Down() const;
1577 Returns @true if the first extra button mouse button is currently down,
1578 independent of the current event type.
1580 bool Aux1IsDown() const;
1583 Returns @true if the first extra button mouse button changed to up.
1585 bool Aux1Up() const;
1588 Returns @true if the event was a second extra button double click.
1590 bool Aux2DClick() const;
1593 Returns @true if the second extra button mouse button changed to down.
1595 bool Aux2Down() const;
1598 Returns @true if the second extra button mouse button is currently down,
1599 independent of the current event type.
1601 bool Aux2IsDown() const;
1604 Returns @true if the second extra button mouse button changed to up.
1606 bool Aux2Up() const;
1609 Returns @true if the identified mouse button is changing state.
1610 Valid values of @a button are:
1612 @li @c wxMOUSE_BTN_LEFT: check if left button was pressed
1613 @li @c wxMOUSE_BTN_MIDDLE: check if middle button was pressed
1614 @li @c wxMOUSE_BTN_RIGHT: check if right button was pressed
1615 @li @c wxMOUSE_BTN_AUX1: check if the first extra button was pressed
1616 @li @c wxMOUSE_BTN_AUX2: check if the second extra button was pressed
1617 @li @c wxMOUSE_BTN_ANY: check if any button was pressed
1619 @todo introduce wxMouseButton enum
1621 bool Button(int button
) const;
1624 If the argument is omitted, this returns @true if the event was a mouse
1625 double click event. Otherwise the argument specifies which double click event
1626 was generated (see Button() for the possible values).
1628 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
1631 If the argument is omitted, this returns @true if the event was a mouse
1632 button down event. Otherwise the argument specifies which button-down event
1633 was generated (see Button() for the possible values).
1635 bool ButtonDown(int = wxMOUSE_BTN_ANY
) const;
1638 If the argument is omitted, this returns @true if the event was a mouse
1639 button up event. Otherwise the argument specifies which button-up event
1640 was generated (see Button() for the possible values).
1642 bool ButtonUp(int = wxMOUSE_BTN_ANY
) const;
1645 Returns @true if this was a dragging event (motion while a button is depressed).
1649 bool Dragging() const;
1652 Returns @true if the mouse was entering the window.
1656 bool Entering() const;
1659 Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
1660 if no button is involved (for mouse move, enter or leave event, for example).
1661 Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
1662 double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
1663 for the same events for the middle and the right buttons respectively.
1665 int GetButton() const;
1668 Returns the number of mouse clicks for this event: 1 for a simple click, 2
1669 for a double-click, 3 for a triple-click and so on.
1671 Currently this function is implemented only in wxMac and returns -1 for the
1672 other platforms (you can still distinguish simple clicks from double-clicks as
1673 they generate different kinds of events however).
1677 int GetClickCount() const;
1680 Returns the configured number of lines (or whatever) to be scrolled per
1681 wheel action. Defaults to three.
1683 int GetLinesPerAction() const;
1686 Returns the logical mouse position in pixels (i.e. translated according to the
1687 translation set for the DC, which usually indicates that the window has been
1690 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
1694 Sets *x and *y to the position at which the event occurred.
1695 Returns the physical mouse position in pixels.
1697 Note that if the mouse event has been artificially generated from a special
1698 keyboard combination (e.g. under Windows when the "menu" key is pressed), the
1699 returned position is ::wxDefaultPosition.
1701 wxPoint
GetPosition() const;
1702 void GetPosition(wxCoord
* x
, wxCoord
* y
) const;
1703 void GetPosition(long* x
, long* y
) const;
1707 Get wheel delta, normally 120.
1709 This is the threshold for action to be taken, and one such action
1710 (for example, scrolling one increment) should occur for each delta.
1712 int GetWheelDelta() const;
1715 Get wheel rotation, positive or negative indicates direction of rotation.
1717 Current devices all send an event when rotation is at least +/-WheelDelta, but
1718 finer resolution devices can be created in the future.
1720 Because of this you shouldn't assume that one event is equal to 1 line, but you
1721 should be able to either do partial line scrolling or wait until several
1722 events accumulate before scrolling.
1724 int GetWheelRotation() const;
1727 Gets the axis the wheel operation concerns; @c 0 is the Y axis as on
1728 most mouse wheels, @c 1 is the X axis.
1730 Note that only some models of mouse have horizontal wheel axis.
1732 int GetWheelAxis() const;
1735 Returns X coordinate of the physical mouse event position.
1737 wxCoord
GetX() const;
1740 Returns Y coordinate of the physical mouse event position.
1742 wxCoord
GetY() const;
1745 Returns @true if the event was a mouse button event (not necessarily a button
1746 down event - that may be tested using ButtonDown()).
1748 bool IsButton() const;
1751 Returns @true if the system has been setup to do page scrolling with
1752 the mouse wheel instead of line scrolling.
1754 bool IsPageScroll() const;
1757 Returns @true if the mouse was leaving the window.
1761 bool Leaving() const;
1764 Returns @true if the event was a left double click.
1766 bool LeftDClick() const;
1769 Returns @true if the left mouse button changed to down.
1771 bool LeftDown() const;
1774 Returns @true if the left mouse button is currently down, independent
1775 of the current event type.
1777 Please notice that it is not the same as LeftDown() which returns @true if the
1778 event was generated by the left mouse button being pressed. Rather, it simply
1779 describes the state of the left mouse button at the time when the event was
1780 generated (so while it will be @true for a left click event, it can also be @true
1781 for a right click if it happened while the left mouse button was pressed).
1783 This event is usually used in the mouse event handlers which process "move
1784 mouse" messages to determine whether the user is (still) dragging the mouse.
1786 bool LeftIsDown() const;
1789 Returns @true if the left mouse button changed to up.
1791 bool LeftUp() const;
1794 Returns @true if the Meta key was down at the time of the event.
1796 bool MetaDown() const;
1799 Returns @true if the event was a middle double click.
1801 bool MiddleDClick() const;
1804 Returns @true if the middle mouse button changed to down.
1806 bool MiddleDown() const;
1809 Returns @true if the middle mouse button is currently down, independent
1810 of the current event type.
1812 bool MiddleIsDown() const;
1815 Returns @true if the middle mouse button changed to up.
1817 bool MiddleUp() const;
1820 Returns @true if this was a motion event and no mouse buttons were pressed.
1821 If any mouse button is held pressed, then this method returns @false and
1822 Dragging() returns @true.
1824 bool Moving() const;
1827 Returns @true if the event was a right double click.
1829 bool RightDClick() const;
1832 Returns @true if the right mouse button changed to down.
1834 bool RightDown() const;
1837 Returns @true if the right mouse button is currently down, independent
1838 of the current event type.
1840 bool RightIsDown() const;
1843 Returns @true if the right mouse button changed to up.
1845 bool RightUp() const;
1851 @class wxDropFilesEvent
1853 This class is used for drop files events, that is, when files have been dropped
1854 onto the window. This functionality is currently only available under Windows.
1856 The window must have previously been enabled for dropping by calling
1857 wxWindow::DragAcceptFiles().
1859 Important note: this is a separate implementation to the more general drag and drop
1860 implementation documented in the @ref overview_dnd. It uses the older, Windows
1861 message-based approach of dropping files.
1863 @beginEventTable{wxDropFilesEvent}
1864 @event{EVT_DROP_FILES(func)}
1865 Process a wxEVT_DROP_FILES event.
1873 @see @ref overview_eventhandling
1875 class wxDropFilesEvent
: public wxEvent
1881 wxDropFilesEvent(wxEventType id
= 0, int noFiles
= 0,
1882 wxString
* files
= NULL
);
1885 Returns an array of filenames.
1887 wxString
* GetFiles() const;
1890 Returns the number of files dropped.
1892 int GetNumberOfFiles() const;
1895 Returns the position at which the files were dropped.
1896 Returns an array of filenames.
1898 wxPoint
GetPosition() const;
1904 @class wxCommandEvent
1906 This event class contains information about command events, which originate
1907 from a variety of simple controls.
1909 More complex controls, such as wxTreeCtrl, have separate command event classes.
1911 @beginEventTable{wxCommandEvent}
1912 @event{EVT_COMMAND(id, event, func)}
1913 Process a command, supplying the window identifier, command event identifier,
1914 and member function.
1915 @event{EVT_COMMAND_RANGE(id1, id2, event, func)}
1916 Process a command for a range of window identifiers, supplying the minimum and
1917 maximum window identifiers, command event identifier, and member function.
1918 @event{EVT_BUTTON(id, func)}
1919 Process a @c wxEVT_COMMAND_BUTTON_CLICKED command, which is generated by a wxButton control.
1920 @event{EVT_CHECKBOX(id, func)}
1921 Process a @c wxEVT_COMMAND_CHECKBOX_CLICKED command, which is generated by a wxCheckBox control.
1922 @event{EVT_CHOICE(id, func)}
1923 Process a @c wxEVT_COMMAND_CHOICE_SELECTED command, which is generated by a wxChoice control.
1924 @event{EVT_COMBOBOX(id, func)}
1925 Process a @c wxEVT_COMMAND_COMBOBOX_SELECTED command, which is generated by a wxComboBox control.
1926 @event{EVT_LISTBOX(id, func)}
1927 Process a @c wxEVT_COMMAND_LISTBOX_SELECTED command, which is generated by a wxListBox control.
1928 @event{EVT_LISTBOX_DCLICK(id, func)}
1929 Process a @c wxEVT_COMMAND_LISTBOX_DOUBLECLICKED command, which is generated by a wxListBox control.
1930 @event{EVT_MENU(id, func)}
1931 Process a @c wxEVT_COMMAND_MENU_SELECTED command, which is generated by a menu item.
1932 @event{EVT_MENU_RANGE(id1, id2, func)}
1933 Process a @c wxEVT_COMMAND_MENU_RANGE command, which is generated by a range of menu items.
1934 @event{EVT_CONTEXT_MENU(func)}
1935 Process the event generated when the user has requested a popup menu to appear by
1936 pressing a special keyboard key (under Windows) or by right clicking the mouse.
1937 @event{EVT_RADIOBOX(id, func)}
1938 Process a @c wxEVT_COMMAND_RADIOBOX_SELECTED command, which is generated by a wxRadioBox control.
1939 @event{EVT_RADIOBUTTON(id, func)}
1940 Process a @c wxEVT_COMMAND_RADIOBUTTON_SELECTED command, which is generated by a wxRadioButton control.
1941 @event{EVT_SCROLLBAR(id, func)}
1942 Process a @c wxEVT_COMMAND_SCROLLBAR_UPDATED command, which is generated by a wxScrollBar
1943 control. This is provided for compatibility only; more specific scrollbar event macros
1944 should be used instead (see wxScrollEvent).
1945 @event{EVT_SLIDER(id, func)}
1946 Process a @c wxEVT_COMMAND_SLIDER_UPDATED command, which is generated by a wxSlider control.
1947 @event{EVT_TEXT(id, func)}
1948 Process a @c wxEVT_COMMAND_TEXT_UPDATED command, which is generated by a wxTextCtrl control.
1949 @event{EVT_TEXT_ENTER(id, func)}
1950 Process a @c wxEVT_COMMAND_TEXT_ENTER command, which is generated by a wxTextCtrl control.
1951 Note that you must use wxTE_PROCESS_ENTER flag when creating the control if you want it
1952 to generate such events.
1953 @event{EVT_TEXT_MAXLEN(id, func)}
1954 Process a @c wxEVT_COMMAND_TEXT_MAXLEN command, which is generated by a wxTextCtrl control
1955 when the user tries to enter more characters into it than the limit previously set
1956 with SetMaxLength().
1957 @event{EVT_TOGGLEBUTTON(id, func)}
1958 Process a @c wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
1959 @event{EVT_TOOL(id, func)}
1960 Process a @c wxEVT_COMMAND_TOOL_CLICKED event (a synonym for @c wxEVT_COMMAND_MENU_SELECTED).
1961 Pass the id of the tool.
1962 @event{EVT_TOOL_RANGE(id1, id2, func)}
1963 Process a @c wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. Pass the ids of the tools.
1964 @event{EVT_TOOL_RCLICKED(id, func)}
1965 Process a @c wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool.
1966 @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)}
1967 Process a @c wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools.
1968 @event{EVT_TOOL_ENTER(id, func)}
1969 Process a @c wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar itself.
1970 The value of wxCommandEvent::GetSelection() is the tool id, or -1 if the mouse cursor
1971 has moved off a tool.
1972 @event{EVT_COMMAND_LEFT_CLICK(id, func)}
1973 Process a @c wxEVT_COMMAND_LEFT_CLICK command, which is generated by a control (wxMSW only).
1974 @event{EVT_COMMAND_LEFT_DCLICK(id, func)}
1975 Process a @c wxEVT_COMMAND_LEFT_DCLICK command, which is generated by a control (wxMSW only).
1976 @event{EVT_COMMAND_RIGHT_CLICK(id, func)}
1977 Process a @c wxEVT_COMMAND_RIGHT_CLICK command, which is generated by a control (wxMSW only).
1978 @event{EVT_COMMAND_SET_FOCUS(id, func)}
1979 Process a @c wxEVT_COMMAND_SET_FOCUS command, which is generated by a control (wxMSW only).
1980 @event{EVT_COMMAND_KILL_FOCUS(id, func)}
1981 Process a @c wxEVT_COMMAND_KILL_FOCUS command, which is generated by a control (wxMSW only).
1982 @event{EVT_COMMAND_ENTER(id, func)}
1983 Process a @c wxEVT_COMMAND_ENTER command, which is generated by a control.
1989 class wxCommandEvent
: public wxEvent
1995 wxCommandEvent(wxEventType commandEventType
= wxEVT_NULL
, int id
= 0);
1998 Returns client data pointer for a listbox or choice selection event
1999 (not valid for a deselection).
2001 void* GetClientData() const;
2004 Returns client object pointer for a listbox or choice selection event
2005 (not valid for a deselection).
2007 wxClientData
* GetClientObject() const;
2010 Returns extra information dependant on the event objects type.
2012 If the event comes from a listbox selection, it is a boolean
2013 determining whether the event was a selection (@true) or a
2014 deselection (@false). A listbox deselection only occurs for
2015 multiple-selection boxes, and in this case the index and string values
2016 are indeterminate and the listbox must be examined by the application.
2018 long GetExtraLong() const;
2021 Returns the integer identifier corresponding to a listbox, choice or
2022 radiobox selection (only if the event was a selection, not a deselection),
2023 or a boolean value representing the value of a checkbox.
2028 Returns item index for a listbox or choice selection event (not valid for
2031 int GetSelection() const;
2034 Returns item string for a listbox or choice selection event. If one
2035 or several items have been deselected, returns the index of the first
2036 deselected item. If some items have been selected and others deselected
2037 at the same time, it will return the index of the first selected item.
2039 wxString
GetString() const;
2042 This method can be used with checkbox and menu events: for the checkboxes, the
2043 method returns @true for a selection event and @false for a deselection one.
2044 For the menu events, this method indicates if the menu item just has become
2045 checked or unchecked (and thus only makes sense for checkable menu items).
2047 Notice that this method can not be used with wxCheckListBox currently.
2049 bool IsChecked() const;
2052 For a listbox or similar event, returns @true if it is a selection, @false
2053 if it is a deselection. If some items have been selected and others deselected
2054 at the same time, it will return @true.
2056 bool IsSelection() const;
2059 Sets the client data for this event.
2061 void SetClientData(void* clientData
);
2064 Sets the client object for this event. The client object is not owned by the
2065 event object and the event object will not delete the client object in its destructor.
2067 The client object must be owned and deleted by another object (e.g. a control)
2068 that has longer life time than the event object.
2070 void SetClientObject(wxClientData
* clientObject
);
2073 Sets the @b m_extraLong member.
2075 void SetExtraLong(long extraLong
);
2078 Sets the @b m_commandInt member.
2080 void SetInt(int intCommand
);
2083 Sets the @b m_commandString member.
2085 void SetString(const wxString
& string
);
2091 @class wxActivateEvent
2093 An activate event is sent when a window or application is being activated
2096 @beginEventTable{wxActivateEvent}
2097 @event{EVT_ACTIVATE(func)}
2098 Process a wxEVT_ACTIVATE event.
2099 @event{EVT_ACTIVATE_APP(func)}
2100 Process a wxEVT_ACTIVATE_APP event.
2101 @event{EVT_HIBERNATE(func)}
2102 Process a hibernate event, supplying the member function. This event applies
2103 to wxApp only, and only on Windows SmartPhone and PocketPC.
2104 It is generated when the system is low on memory; the application should free
2105 up as much memory as possible, and restore full working state when it receives
2106 a wxEVT_ACTIVATE or wxEVT_ACTIVATE_APP event.
2113 @see @ref overview_eventhandling, wxApp::IsActive
2115 class wxActivateEvent
: public wxEvent
2121 wxActivateEvent(wxEventType eventType
= wxEVT_NULL
, bool active
= true,
2125 Returns @true if the application or window is being activated, @false otherwise.
2127 bool GetActive() const;
2133 @class wxContextMenuEvent
2135 This class is used for context menu events, sent to give
2136 the application a chance to show a context (popup) menu.
2138 Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
2139 means that the event originated from a keyboard context button event, and you
2140 should compute a suitable position yourself, for example by calling wxGetMousePosition().
2142 When a keyboard context menu button is pressed on Windows, a right-click event
2143 with default position is sent first, and if this event is not processed, the
2144 context menu event is sent. So if you process mouse events and you find your
2145 context menu event handler is not being called, you could call wxEvent::Skip()
2146 for mouse right-down events.
2148 @beginEventTable{wxContextMenuEvent}
2149 @event{EVT_CONTEXT_MENU(func)}
2150 A right click (or other context menu command depending on platform) has been detected.
2157 @see wxCommandEvent, @ref overview_eventhandling
2159 class wxContextMenuEvent
: public wxCommandEvent
2165 wxContextMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0,
2166 const wxPoint
& pos
= wxDefaultPosition
);
2169 Returns the position in screen coordinates at which the menu should be shown.
2170 Use wxWindow::ScreenToClient to convert to client coordinates.
2172 You can also omit a position from wxWindow::PopupMenu in order to use
2173 the current mouse pointer position.
2175 If the event originated from a keyboard event, the value returned from this
2176 function will be wxDefaultPosition.
2178 const wxPoint
& GetPosition() const;
2181 Sets the position at which the menu should be shown.
2183 void SetPosition(const wxPoint
& point
);
2191 An erase event is sent when a window's background needs to be repainted.
2193 On some platforms, such as GTK+, this event is simulated (simply generated just
2194 before the paint event) and may cause flicker. It is therefore recommended that
2195 you set the text background colour explicitly in order to prevent flicker.
2196 The default background colour under GTK+ is grey.
2198 To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
2201 You must call wxEraseEvent::GetDC and use the returned device context if it is
2202 non-@NULL. If it is @NULL, create your own temporary wxClientDC object.
2205 Use the device context returned by GetDC to draw on, don't create
2206 a wxPaintDC in the event handler.
2208 @beginEventTable{wxEraseEvent}
2209 @event{EVT_ERASE_BACKGROUND(func)}
2210 Process a wxEVT_ERASE_BACKGROUND event.
2216 @see @ref overview_eventhandling
2218 class wxEraseEvent
: public wxEvent
2224 wxEraseEvent(int id
= 0, wxDC
* dc
= NULL
);
2227 Returns the device context associated with the erase event to draw on.
2229 wxDC
* GetDC() const;
2237 A focus event is sent when a window's focus changes. The window losing focus
2238 receives a "kill focus" event while the window gaining it gets a "set focus" one.
2240 Notice that the set focus event happens both when the user gives focus to the
2241 window (whether using the mouse or keyboard) and when it is done from the
2242 program itself using wxWindow::SetFocus.
2244 @beginEventTable{wxFocusEvent}
2245 @event{EVT_SET_FOCUS(func)}
2246 Process a wxEVT_SET_FOCUS event.
2247 @event{EVT_KILL_FOCUS(func)}
2248 Process a wxEVT_KILL_FOCUS event.
2254 @see @ref overview_eventhandling
2256 class wxFocusEvent
: public wxEvent
2262 wxFocusEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2265 Returns the window associated with this event, that is the window which had the
2266 focus before for the @c wxEVT_SET_FOCUS event and the window which is
2267 going to receive focus for the @c wxEVT_KILL_FOCUS one.
2269 Warning: the window pointer may be @NULL!
2271 wxWindow
*GetWindow() const;
2277 @class wxChildFocusEvent
2279 A child focus event is sent to a (parent-)window when one of its child windows
2280 gains focus, so that the window could restore the focus back to its corresponding
2281 child if it loses it now and regains later.
2283 Notice that child window is the direct child of the window receiving event.
2284 Use wxWindow::FindFocus() to retreive the window which is actually getting focus.
2286 @beginEventTable{wxChildFocusEvent}
2287 @event{EVT_CHILD_FOCUS(func)}
2288 Process a wxEVT_CHILD_FOCUS event.
2294 @see @ref overview_eventhandling
2296 class wxChildFocusEvent
: public wxCommandEvent
2303 The direct child which is (or which contains the window which is) receiving
2306 wxChildFocusEvent(wxWindow
* win
= NULL
);
2309 Returns the direct child which receives the focus, or a (grand-)parent of the
2310 control receiving the focus.
2312 To get the actually focused control use wxWindow::FindFocus.
2314 wxWindow
*GetWindow() const;
2320 @class wxMouseCaptureLostEvent
2322 An mouse capture lost event is sent to a window that obtained mouse capture,
2323 which was subsequently loss due to "external" event, for example when a dialog
2324 box is shown or if another application captures the mouse.
2326 If this happens, this event is sent to all windows that are on capture stack
2327 (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
2328 not sent if the capture changes because of a call to CaptureMouse or
2331 This event is currently emitted under Windows only.
2333 @beginEventTable{wxMouseCaptureLostEvent}
2334 @event{EVT_MOUSE_CAPTURE_LOST(func)}
2335 Process a wxEVT_MOUSE_CAPTURE_LOST event.
2343 @see wxMouseCaptureChangedEvent, @ref overview_eventhandling,
2344 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2346 class wxMouseCaptureLostEvent
: public wxEvent
2352 wxMouseCaptureLostEvent(wxWindowID windowId
= 0);
2358 @class wxNotifyEvent
2360 This class is not used by the event handlers by itself, but is a base class
2361 for other event classes (such as wxBookCtrlEvent).
2363 It (or an object of a derived class) is sent when the controls state is being
2364 changed and allows the program to wxNotifyEvent::Veto() this change if it wants
2365 to prevent it from happening.
2370 @see wxBookCtrlEvent
2372 class wxNotifyEvent
: public wxCommandEvent
2376 Constructor (used internally by wxWidgets only).
2378 wxNotifyEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2381 This is the opposite of Veto(): it explicitly allows the event to be processed.
2382 For most events it is not necessary to call this method as the events are allowed
2383 anyhow but some are forbidden by default (this will be mentioned in the corresponding
2389 Returns @true if the change is allowed (Veto() hasn't been called) or @false
2390 otherwise (if it was).
2392 bool IsAllowed() const;
2395 Prevents the change announced by this event from happening.
2397 It is in general a good idea to notify the user about the reasons for vetoing
2398 the change because otherwise the applications behaviour (which just refuses to
2399 do what the user wants) might be quite surprising.
2407 enum wxHelpEventOrigin
2409 wxHE_ORIGIN_UNKNOWN
= -1,
2410 wxHE_ORIGIN_KEYBOARD
,
2412 /** event generated by wxContextHelp or from the [?] button on
2413 the title bar (Windows). */
2414 wxHE_ORIGIN_HELPBUTTON
2420 A help event is sent when the user has requested context-sensitive help.
2421 This can either be caused by the application requesting context-sensitive help mode
2422 via wxContextHelp, or (on MS Windows) by the system generating a WM_HELP message when
2423 the user pressed F1 or clicked on the query button in a dialog caption.
2425 A help event is sent to the window that the user clicked on, and is propagated
2426 up the window hierarchy until the event is processed or there are no more event
2429 The application should call wxEvent::GetId to check the identity of the
2430 clicked-on window, and then either show some suitable help or call wxEvent::Skip()
2431 if the identifier is unrecognised.
2433 Calling Skip is important because it allows wxWidgets to generate further
2434 events for ancestors of the clicked-on window. Otherwise it would be impossible to
2435 show help for container windows, since processing would stop after the first window
2438 @beginEventTable{wxHelpEvent}
2439 @event{EVT_HELP(id, func)}
2440 Process a wxEVT_HELP event.
2441 @event{EVT_HELP_RANGE(id1, id2, func)}
2442 Process a wxEVT_HELP event for a range of ids.
2448 @see wxContextHelp, wxDialog, @ref overview_eventhandling
2450 class wxHelpEvent
: public wxCommandEvent
2454 Indicates how a wxHelpEvent was generated.
2458 Origin_Unknown
, /**< unrecognized event source. */
2459 Origin_Keyboard
, /**< event generated from F1 key press. */
2461 /** event generated by wxContextHelp or from the [?] button on
2462 the title bar (Windows). */
2469 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
2470 wxWindowID winid
= 0,
2471 const wxPoint
& pt
= wxDefaultPosition
,
2472 wxHelpEvent::Origin origin
= Origin_Unknown
);
2475 Returns the origin of the help event which is one of the ::wxHelpEventOrigin
2478 The application may handle events generated using the keyboard or mouse
2479 differently, e.g. by using wxGetMousePosition() for the mouse events.
2483 wxHelpEvent::Origin
GetOrigin() const;
2486 Returns the left-click position of the mouse, in screen coordinates.
2487 This allows the application to position the help appropriately.
2489 const wxPoint
& GetPosition() const;
2492 Set the help event origin, only used internally by wxWidgets normally.
2496 void SetOrigin(wxHelpEvent::Origin origin
);
2499 Sets the left-click position of the mouse, in screen coordinates.
2501 void SetPosition(const wxPoint
& pt
);
2507 @class wxScrollEvent
2509 A scroll event holds information about events sent from stand-alone
2510 scrollbars (see wxScrollBar) and sliders (see wxSlider).
2512 Note that scrolled windows send the wxScrollWinEvent which does not derive from
2513 wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
2514 events and use the event table macros mentioned below only for the scrollbar-like
2517 @section scrollevent_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
2519 The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb
2520 using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed
2521 by an EVT_SCROLL_CHANGED event).
2523 The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change the thumb
2524 position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE
2525 event does not happen).
2527 In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving has finished
2528 independently of the way it had started. Please see the widgets sample ("Slider" page)
2529 to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
2532 Note that unless specifying a scroll control identifier, you will need to test for scrollbar
2533 orientation with wxScrollEvent::GetOrientation, since horizontal and vertical scroll events
2534 are processed using the same event handler.
2536 @beginEventTable{wxScrollEvent}
2537 You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
2538 scroll events from controls, or EVT_SCROLL... macros without window IDs for
2539 intercepting scroll events from the receiving window -- except for this, the
2540 macros behave exactly the same.
2541 @event{EVT_SCROLL(func)}
2542 Process all scroll events.
2543 @event{EVT_SCROLL_TOP(func)}
2544 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2545 @event{EVT_SCROLL_BOTTOM(func)}
2546 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2547 @event{EVT_SCROLL_LINEUP(func)}
2548 Process wxEVT_SCROLL_LINEUP line up events.
2549 @event{EVT_SCROLL_LINEDOWN(func)}
2550 Process wxEVT_SCROLL_LINEDOWN line down events.
2551 @event{EVT_SCROLL_PAGEUP(func)}
2552 Process wxEVT_SCROLL_PAGEUP page up events.
2553 @event{EVT_SCROLL_PAGEDOWN(func)}
2554 Process wxEVT_SCROLL_PAGEDOWN page down events.
2555 @event{EVT_SCROLL_THUMBTRACK(func)}
2556 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the
2557 user drags the thumbtrack).
2558 @event{EVT_SCROLL_THUMBRELEASE(func)}
2559 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2560 @event{EVT_SCROLL_CHANGED(func)}
2561 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2562 @event{EVT_COMMAND_SCROLL(id, func)}
2563 Process all scroll events.
2564 @event{EVT_COMMAND_SCROLL_TOP(id, func)}
2565 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2566 @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
2567 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2568 @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
2569 Process wxEVT_SCROLL_LINEUP line up events.
2570 @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
2571 Process wxEVT_SCROLL_LINEDOWN line down events.
2572 @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
2573 Process wxEVT_SCROLL_PAGEUP page up events.
2574 @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
2575 Process wxEVT_SCROLL_PAGEDOWN page down events.
2576 @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
2577 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent
2578 as the user drags the thumbtrack).
2579 @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
2580 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2581 @event{EVT_COMMAND_SCROLL_CHANGED(func)}
2582 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2588 @see wxScrollBar, wxSlider, wxSpinButton, wxScrollWinEvent, @ref overview_eventhandling
2590 class wxScrollEvent
: public wxCommandEvent
2596 wxScrollEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0, int pos
= 0,
2597 int orientation
= 0);
2600 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
2603 int GetOrientation() const;
2606 Returns the position of the scrollbar.
2608 int GetPosition() const;
2612 See wxIdleEvent::SetMode() for more info.
2616 /** Send idle events to all windows */
2619 /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */
2620 wxIDLE_PROCESS_SPECIFIED
2627 This class is used for idle events, which are generated when the system becomes
2628 idle. Note that, unless you do something specifically, the idle events are not
2629 sent if the system remains idle once it has become it, e.g. only a single idle
2630 event will be generated until something else resulting in more normal events
2631 happens and only then is the next idle event sent again.
2633 If you need to ensure a continuous stream of idle events, you can either use
2634 wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically
2635 (for example from a timer event handler), but note that both of these approaches
2636 (and especially the first one) increase the system load and so should be avoided
2639 By default, idle events are sent to all windows (and also wxApp, as usual).
2640 If this is causing a significant overhead in your application, you can call
2641 wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the
2642 wxWS_EX_PROCESS_IDLE extra window style for every window which should receive
2645 @beginEventTable{wxIdleEvent}
2646 @event{EVT_IDLE(func)}
2647 Process a wxEVT_IDLE event.
2653 @see @ref overview_eventhandling, wxUpdateUIEvent, wxWindow::OnInternalIdle
2655 class wxIdleEvent
: public wxEvent
2664 Returns @true if it is appropriate to send idle events to this window.
2666 This function looks at the mode used (see wxIdleEvent::SetMode),
2667 and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle
2668 events should be sent to this window now.
2670 By default this will always return @true because the update mode is initially
2671 wxIDLE_PROCESS_ALL. You can change the mode to only send idle events to
2672 windows with the wxWS_EX_PROCESS_IDLE extra window style set.
2676 static bool CanSend(wxWindow
* window
);
2679 Static function returning a value specifying how wxWidgets will send idle
2680 events: to all windows, or only to those which specify that they
2681 will process the events.
2685 static wxIdleMode
GetMode();
2688 Returns @true if the OnIdle function processing this event requested more
2693 bool MoreRequested() const;
2696 Tells wxWidgets that more processing is required.
2698 This function can be called by an OnIdle handler for a window or window event
2699 handler to indicate that wxApp::OnIdle should forward the OnIdle event once
2700 more to the application windows.
2702 If no window calls this function during OnIdle, then the application will
2703 remain in a passive event loop (not calling OnIdle) until a new event is
2704 posted to the application by the windowing system.
2706 @see MoreRequested()
2708 void RequestMore(bool needMore
= true);
2711 Static function for specifying how wxWidgets will send idle events: to
2712 all windows, or only to those which specify that they will process the events.
2715 Can be one of the ::wxIdleMode values.
2716 The default is wxIDLE_PROCESS_ALL.
2718 static void SetMode(wxIdleMode mode
);
2724 @class wxInitDialogEvent
2726 A wxInitDialogEvent is sent as a dialog or panel is being initialised.
2727 Handlers for this event can transfer data to the window.
2729 The default handler calls wxWindow::TransferDataToWindow.
2731 @beginEventTable{wxInitDialogEvent}
2732 @event{EVT_INIT_DIALOG(func)}
2733 Process a wxEVT_INIT_DIALOG event.
2739 @see @ref overview_eventhandling
2741 class wxInitDialogEvent
: public wxEvent
2747 wxInitDialogEvent(int id
= 0);
2753 @class wxWindowDestroyEvent
2755 This event is sent as early as possible during the window destruction
2758 For the top level windows, as early as possible means that this is done by
2759 wxFrame or wxDialog destructor, i.e. after the destructor of the derived
2760 class was executed and so any methods specific to the derived class can't
2761 be called any more from this event handler. If you need to do this, you
2762 must call wxWindow::SendDestroyEvent() from your derived class destructor.
2764 For the child windows, this event is generated just before deleting the
2765 window from wxWindow::Destroy() (which is also called when the parent
2766 window is deleted) or from the window destructor if operator @c delete was
2767 used directly (which is not recommended for this very reason).
2769 It is usually pointless to handle this event in the window itself but it ca
2770 be very useful to receive notifications about the window destruction in the
2771 parent window or in any other object interested in this window.
2776 @see @ref overview_eventhandling, wxWindowCreateEvent
2778 class wxWindowDestroyEvent
: public wxCommandEvent
2784 wxWindowDestroyEvent(wxWindow
* win
= NULL
);
2786 /// Retutn the window being destroyed.
2787 wxWindow
*GetWindow() const;
2792 The possible flag values for a wxNavigationKeyEvent.
2794 enum wxNavigationKeyEventFlags
2796 wxNKEF_IS_BACKWARD
= 0x0000,
2797 wxNKEF_IS_FORWARD
= 0x0001,
2798 wxNKEF_WINCHANGE
= 0x0002,
2799 wxNKEF_FROMTAB
= 0x0004
2804 @class wxNavigationKeyEvent
2806 This event class contains information about navigation events,
2807 generated by navigation keys such as tab and page down.
2809 This event is mainly used by wxWidgets implementations.
2810 A wxNavigationKeyEvent handler is automatically provided by wxWidgets
2811 when you make a class into a control container with the macro
2812 WX_DECLARE_CONTROL_CONTAINER.
2814 @beginEventTable{wxNavigationKeyEvent}
2815 @event{EVT_NAVIGATION_KEY(func)}
2816 Process a navigation key event.
2822 @see wxWindow::Navigate, wxWindow::NavigateIn
2824 class wxNavigationKeyEvent
: public wxEvent
2827 wxNavigationKeyEvent();
2828 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
);
2831 Returns the child that has the focus, or @NULL.
2833 wxWindow
* GetCurrentFocus() const;
2836 Returns @true if the navigation was in the forward direction.
2838 bool GetDirection() const;
2841 Returns @true if the navigation event was from a tab key.
2842 This is required for proper navigation over radio buttons.
2844 bool IsFromTab() const;
2847 Returns @true if the navigation event represents a window change
2848 (for example, from Ctrl-Page Down in a notebook).
2850 bool IsWindowChange() const;
2853 Sets the current focus window member.
2855 void SetCurrentFocus(wxWindow
* currentFocus
);
2858 Sets the direction to forward if @a direction is @true, or backward
2861 void SetDirection(bool direction
);
2864 Sets the flags for this event.
2865 The @a flags can be a combination of the ::wxNavigationKeyEventFlags values.
2867 void SetFlags(long flags
);
2870 Marks the navigation event as from a tab key.
2872 void SetFromTab(bool fromTab
);
2875 Marks the event as a window change event.
2877 void SetWindowChange(bool windowChange
);
2883 @class wxMouseCaptureChangedEvent
2885 An mouse capture changed event is sent to a window that loses its
2886 mouse capture. This is called even if wxWindow::ReleaseCapture
2887 was called by the application code. Handling this event allows
2888 an application to cater for unexpected capture releases which
2889 might otherwise confuse mouse handling code.
2893 @beginEventTable{wxMouseCaptureChangedEvent}
2894 @event{EVT_MOUSE_CAPTURE_CHANGED(func)}
2895 Process a wxEVT_MOUSE_CAPTURE_CHANGED event.
2901 @see wxMouseCaptureLostEvent, @ref overview_eventhandling,
2902 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2904 class wxMouseCaptureChangedEvent
: public wxEvent
2910 wxMouseCaptureChangedEvent(wxWindowID windowId
= 0,
2911 wxWindow
* gainedCapture
= NULL
);
2914 Returns the window that gained the capture, or @NULL if it was a
2915 non-wxWidgets window.
2917 wxWindow
* GetCapturedWindow() const;
2925 This event class contains information about window and session close events.
2927 The handler function for EVT_CLOSE is called when the user has tried to close a
2928 a frame or dialog box using the window manager (X) or system menu (Windows).
2929 It can also be invoked by the application itself programmatically, for example by
2930 calling the wxWindow::Close function.
2932 You should check whether the application is forcing the deletion of the window
2933 using wxCloseEvent::CanVeto. If this is @false, you @e must destroy the window
2934 using wxWindow::Destroy.
2936 If the return value is @true, it is up to you whether you respond by destroying
2939 If you don't destroy the window, you should call wxCloseEvent::Veto to
2940 let the calling code know that you did not destroy the window.
2941 This allows the wxWindow::Close function to return @true or @false depending
2942 on whether the close instruction was honoured or not.
2944 Example of a wxCloseEvent handler:
2947 void MyFrame::OnClose(wxCloseEvent& event)
2949 if ( event.CanVeto() && m_bFileNotSaved )
2951 if ( wxMessageBox("The file has not been saved... continue closing?",
2953 wxICON_QUESTION | wxYES_NO) != wxYES )
2960 Destroy(); // you may also do: event.Skip();
2961 // since the default event handler does call Destroy(), too
2965 The EVT_END_SESSION event is slightly different as it is sent by the system
2966 when the user session is ending (e.g. because of log out or shutdown) and
2967 so all windows are being forcefully closed. At least under MSW, after the
2968 handler for this event is executed the program is simply killed by the
2969 system. Because of this, the default handler for this event provided by
2970 wxWidgets calls all the usual cleanup code (including wxApp::OnExit()) so
2971 that it could still be executed and exit()s the process itself, without
2972 waiting for being killed. If this behaviour is for some reason undesirable,
2973 make sure that you define a handler for this event in your wxApp-derived
2974 class and do not call @c event.Skip() in it (but be aware that the system
2975 will still kill your application).
2977 @beginEventTable{wxCloseEvent}
2978 @event{EVT_CLOSE(func)}
2979 Process a close event, supplying the member function.
2980 This event applies to wxFrame and wxDialog classes.
2981 @event{EVT_QUERY_END_SESSION(func)}
2982 Process a query end session event, supplying the member function.
2983 This event can be handled in wxApp-derived class only.
2984 @event{EVT_END_SESSION(func)}
2985 Process an end session event, supplying the member function.
2986 This event can be handled in wxApp-derived class only.
2992 @see wxWindow::Close, @ref overview_windowdeletion
2994 class wxCloseEvent
: public wxEvent
3000 wxCloseEvent(wxEventType commandEventType
= wxEVT_NULL
, int id
= 0);
3003 Returns @true if you can veto a system shutdown or a window close event.
3004 Vetoing a window close event is not possible if the calling code wishes to
3005 force the application to exit, and so this function must be called to check this.
3007 bool CanVeto() const;
3010 Returns @true if the user is just logging off or @false if the system is
3011 shutting down. This method can only be called for end session and query end
3012 session events, it doesn't make sense for close window event.
3014 bool GetLoggingOff() const;
3017 Sets the 'can veto' flag.
3019 void SetCanVeto(bool canVeto
);
3022 Sets the 'logging off' flag.
3024 void SetLoggingOff(bool loggingOff
);
3027 Call this from your event handler to veto a system shutdown or to signal
3028 to the calling application that a window close did not happen.
3030 You can only veto a shutdown if CanVeto() returns @true.
3032 void Veto(bool veto
= true);
3040 This class is used for a variety of menu-related events. Note that
3041 these do not include menu command events, which are
3042 handled using wxCommandEvent objects.
3044 The default handler for @c wxEVT_MENU_HIGHLIGHT displays help
3045 text in the first field of the status bar.
3047 @beginEventTable{wxMenuEvent}
3048 @event{EVT_MENU_OPEN(func)}
3049 A menu is about to be opened. On Windows, this is only sent once for each
3050 navigation of the menubar (up until all menus have closed).
3051 @event{EVT_MENU_CLOSE(func)}
3052 A menu has been just closed.
3053 @event{EVT_MENU_HIGHLIGHT(id, func)}
3054 The menu item with the specified id has been highlighted: used to show
3055 help prompts in the status bar by wxFrame
3056 @event{EVT_MENU_HIGHLIGHT_ALL(func)}
3057 A menu item has been highlighted, i.e. the currently selected menu item has changed.
3063 @see wxCommandEvent, @ref overview_eventhandling
3065 class wxMenuEvent
: public wxEvent
3071 wxMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0, wxMenu
* menu
= NULL
);
3074 Returns the menu which is being opened or closed. This method should only be
3075 used with the @c OPEN and @c CLOSE events and even for them the
3076 returned pointer may be @NULL in some ports.
3078 wxMenu
* GetMenu() const;
3081 Returns the menu identifier associated with the event.
3082 This method should be only used with the @c HIGHLIGHT events.
3084 int GetMenuId() const;
3087 Returns @true if the menu which is being opened or closed is a popup menu,
3088 @false if it is a normal one.
3090 This method should only be used with the @c OPEN and @c CLOSE events.
3092 bool IsPopup() const;
3098 An event being sent when the window is shown or hidden.
3100 Currently only wxMSW, wxGTK and wxOS2 generate such events.
3102 @onlyfor{wxmsw,wxgtk,wxos2}
3104 @beginEventTable{wxShowEvent}
3105 @event{EVT_SHOW(func)}
3106 Process a wxEVT_SHOW event.
3112 @see @ref overview_eventhandling, wxWindow::Show,
3116 class wxShowEvent
: public wxEvent
3122 wxShowEvent(int winid
= 0, bool show
= false);
3125 Set whether the windows was shown or hidden.
3127 void SetShow(bool show
);
3130 Return @true if the window has been shown, @false if it has been
3133 bool IsShown() const;
3136 @deprecated This function is deprecated in favour of IsShown().
3138 bool GetShow() const;
3144 @class wxIconizeEvent
3146 An event being sent when the frame is iconized (minimized) or restored.
3148 Currently only wxMSW and wxGTK generate such events.
3150 @onlyfor{wxmsw,wxgtk}
3152 @beginEventTable{wxIconizeEvent}
3153 @event{EVT_ICONIZE(func)}
3154 Process a wxEVT_ICONIZE event.
3160 @see @ref overview_eventhandling, wxTopLevelWindow::Iconize,
3161 wxTopLevelWindow::IsIconized
3163 class wxIconizeEvent
: public wxEvent
3169 wxIconizeEvent(int id
= 0, bool iconized
= true);
3172 Returns @true if the frame has been iconized, @false if it has been
3175 bool IsIconized() const;
3178 @deprecated This function is deprecated in favour of IsIconized().
3180 bool Iconized() const;
3188 A move event holds information about move change events.
3190 @beginEventTable{wxMoveEvent}
3191 @event{EVT_MOVE(func)}
3192 Process a wxEVT_MOVE event, which is generated when a window is moved.
3193 @event{EVT_MOVE_START(func)}
3194 Process a wxEVT_MOVE_START event, which is generated when the user starts
3195 to move or size a window. wxMSW only.
3196 @event{EVT_MOVE_END(func)}
3197 Process a wxEVT_MOVE_END event, which is generated when the user stops
3198 moving or sizing a window. wxMSW only.
3204 @see wxPoint, @ref overview_eventhandling
3206 class wxMoveEvent
: public wxEvent
3212 wxMoveEvent(const wxPoint
& pt
, int id
= 0);
3215 Returns the position of the window generating the move change event.
3217 wxPoint
GetPosition() const;
3224 A size event holds information about size change events.
3226 The EVT_SIZE handler function will be called when the window has been resized.
3228 You may wish to use this for frames to resize their child windows as appropriate.
3230 Note that the size passed is of the whole window: call wxWindow::GetClientSize
3231 for the area which may be used by the application.
3233 When a window is resized, usually only a small part of the window is damaged
3234 and you may only need to repaint that area. However, if your drawing depends on the
3235 size of the window, you may need to clear the DC explicitly and repaint the whole window.
3236 In which case, you may need to call wxWindow::Refresh to invalidate the entire window.
3238 @beginEventTable{wxSizeEvent}
3239 @event{EVT_SIZE(func)}
3240 Process a wxEVT_SIZE event.
3246 @see wxSize, @ref overview_eventhandling
3248 class wxSizeEvent
: public wxEvent
3254 wxSizeEvent(const wxSize
& sz
, int id
= 0);
3257 Returns the entire size of the window generating the size change event.
3259 wxSize
GetSize() const;
3265 @class wxSetCursorEvent
3267 A wxSetCursorEvent is generated when the mouse cursor is about to be set as a
3268 result of mouse motion.
3270 This event gives the application the chance to perform specific mouse cursor
3271 processing based on the current position of the mouse within the window.
3272 Use wxSetCursorEvent::SetCursor to specify the cursor you want to be displayed.
3274 @beginEventTable{wxSetCursorEvent}
3275 @event{EVT_SET_CURSOR(func)}
3276 Process a wxEVT_SET_CURSOR event.
3282 @see ::wxSetCursor, wxWindow::wxSetCursor
3284 class wxSetCursorEvent
: public wxEvent
3288 Constructor, used by the library itself internally to initialize the event
3291 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0);
3294 Returns a reference to the cursor specified by this event.
3296 const wxCursor
& GetCursor() const;
3299 Returns the X coordinate of the mouse in client coordinates.
3301 wxCoord
GetX() const;
3304 Returns the Y coordinate of the mouse in client coordinates.
3306 wxCoord
GetY() const;
3309 Returns @true if the cursor specified by this event is a valid cursor.
3311 @remarks You cannot specify wxNullCursor with this event, as it is not
3312 considered a valid cursor.
3314 bool HasCursor() const;
3317 Sets the cursor associated with this event.
3319 void SetCursor(const wxCursor
& cursor
);
3324 // ============================================================================
3325 // Global functions/macros
3326 // ============================================================================
3328 /** @addtogroup group_funcmacro_events */
3332 A special event type usually used to indicate that some wxEvent has yet
3335 wxEventType wxEVT_NULL
;
3338 Each wxEvent-derived class has an @e event-type associated.
3339 See the macro DEFINE_EVENT_TYPE() for more info.
3341 @see @ref overview_eventhandling_custom
3343 typedef int wxEventType
;
3346 Initializes a new event type using wxNewEventType().
3348 #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
3351 Generates a new unique event type.
3353 wxEventType
wxNewEventType();
3356 Use this macro inside a class declaration to declare a @e static event table
3359 In the implementation file you'll need to use the BEGIN_EVENT_TABLE()
3360 and the END_EVENT_TABLE() macros, plus some additional @c EVT_xxx macro
3363 @see @ref overview_eventhandling_eventtables
3365 #define DECLARE_EVENT_TABLE()
3368 Use this macro in a source file to start listing @e static event handlers
3369 for a specific class.
3371 Use END_EVENT_TABLE() to terminate the event-declaration block.
3373 @see @ref overview_eventhandling_eventtables
3375 #define BEGIN_EVENT_TABLE(theClass, baseClass)
3378 Use this macro in a source file to end listing @e static event handlers
3379 for a specific class.
3381 Use BEGIN_EVENT_TABLE() to start the event-declaration block.
3383 @see @ref overview_eventhandling_eventtables
3385 #define END_EVENT_TABLE()
3388 In a GUI application, this function posts @a event to the specified @e dest
3389 object using wxEvtHandler::AddPendingEvent().
3391 Otherwise, it dispatches @a event immediately using
3392 wxEvtHandler::ProcessEvent(). See the respective documentation for details
3393 (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent()
3394 this function is not thread-safe for event objects having wxString fields,
3395 use wxQueueEvent() instead.
3399 void wxPostEvent(wxEvtHandler
* dest
, const wxEvent
& event
);
3402 Queue an event for processing on the given object.
3404 This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation
3410 The object to queue the event on, can't be @c NULL.
3412 The heap-allocated and non-@c NULL event to queue, the function takes
3415 void wxQueueEvent(wxEvtHandler
* dest
, wxEvent
*event
);