1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxEventHandler, wxEventBlocker and many
4 // wxEvent-derived classes
5 // Author: wxWidgets team
7 // Licence: wxWindows license
8 /////////////////////////////////////////////////////////////////////////////
15 An event is a structure holding information about an event passed to a
16 callback or member function.
18 wxEvent used to be a multipurpose event object, and is an abstract base class
19 for other event classes (see below).
21 For more information about events, see the @ref overview_eventhandling overview.
24 In wxPerl custom event classes should be derived from
25 @c Wx::PlEvent and @c Wx::PlCommandEvent.
31 @see wxCommandEvent, wxMouseEvent
33 class wxEvent
: public wxObject
37 Constructor. Should not need to be used directly by an application.
39 wxEvent(int id
= 0, wxEventType eventType
= wxEVT_NULL
);
42 Returns a copy of the event.
44 Any event that is posted to the wxWidgets event system for later action
45 (via wxEvtHandler::AddPendingEvent or wxPostEvent()) must implement
48 All wxWidgets events fully implement this method, but any derived events
49 implemented by the user should also implement this method just in case they
50 (or some event derived from them) are ever posted.
52 All wxWidgets events implement a copy constructor, so the easiest way of
53 implementing the Clone function is to implement a copy constructor for
54 a new event (call it MyEvent) and then define the Clone function like this:
57 wxEvent *Clone() const { return new MyEvent(*this); }
60 virtual wxEvent
* Clone() const = 0;
63 Returns the object (usually a window) associated with the event, if any.
65 wxObject
* GetEventObject() const;
68 Returns the identifier of the given event type, such as @c wxEVT_COMMAND_BUTTON_CLICKED.
70 wxEventType
GetEventType() const;
73 Returns the identifier associated with this event, such as a button command id.
78 Returns @true if the event handler should be skipped, @false otherwise.
80 bool GetSkipped() const;
83 Gets the timestamp for the event. The timestamp is the time in milliseconds
84 since some fixed moment (not necessarily the standard Unix Epoch, so only
85 differences between the timestamps and not their absolute values usually make sense).
88 wxWidgets returns a non-NULL timestamp only for mouse and key events
89 (see wxMouseEvent and wxKeyEvent).
91 long GetTimestamp() const;
94 Returns @true if the event is or is derived from wxCommandEvent else it returns @false.
96 @note exists only for optimization purposes.
98 bool IsCommandEvent() const;
101 Sets the propagation level to the given value (for example returned from an
102 earlier call to wxEvent::StopPropagation).
104 void ResumePropagation(int propagationLevel
);
107 Sets the originating object.
109 void SetEventObject(wxObject
* object
);
114 void SetEventType(wxEventType type
);
117 Sets the identifier associated with this event, such as a button command id.
122 Sets the timestamp for the event.
124 void SetTimestamp(long timeStamp
= 0);
127 Test if this event should be propagated or not, i.e. if the propagation level
128 is currently greater than 0.
130 bool ShouldPropagate() const;
133 This method can be used inside an event handler to control whether further
134 event handlers bound to this event will be called after the current one returns.
136 Without Skip() (or equivalently if Skip(@false) is used), the event will not
137 be processed any more. If Skip(@true) is called, the event processing system
138 continues searching for a further handler function for this event, even though
139 it has been processed already in the current handler.
141 In general, it is recommended to skip all non-command events to allow the
142 default handling to take place. The command events are, however, normally not
143 skipped as usually a single command such as a button click or menu item
144 selection must only be processed by one handler.
146 void Skip(bool skip
= true);
149 Stop the event from propagating to its parent window.
151 Returns the old propagation level value which may be later passed to
152 ResumePropagation() to allow propagating the event again.
154 int StopPropagation();
158 Indicates how many levels the event can propagate.
160 This member is protected and should typically only be set in the constructors
161 of the derived classes. It may be temporarily changed by StopPropagation()
162 and ResumePropagation() and tested with ShouldPropagate().
164 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default)
165 meaning that the event shouldn't be propagated at all or to
166 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
167 propagated as much as necessary.
169 Any positive number means that the event should be propagated but no more than
170 the given number of times. E.g. the propagation level may be set to 1 to
171 propagate the event to its parent only, but not to its grandparent.
173 int m_propagationLevel
;
177 @class wxEventBlocker
179 This class is a special event handler which allows to discard
180 any event (or a set of event types) directed to a specific window.
185 void MyWindow::DoSomething()
188 // block all events directed to this window while
189 // we do the 1000 FunctionWhichSendsEvents() calls
190 wxEventBlocker blocker(this);
192 for ( int i = 0; i 1000; i++ )
193 FunctionWhichSendsEvents(i);
195 } // ~wxEventBlocker called, old event handler is restored
197 // the event generated by this call will be processed:
198 FunctionWhichSendsEvents(0)
205 @see @ref overview_eventhandling, wxEvtHandler
207 class wxEventBlocker
: public wxEvtHandler
211 Constructs the blocker for the given window and for the given event type.
213 If @a type is @c wxEVT_ANY, then all events for that window are blocked.
214 You can call Block() after creation to add other event types to the list
217 Note that the @a win window @b must remain alive until the
218 wxEventBlocker object destruction.
220 wxEventBlocker(wxWindow
* win
, wxEventType type
= -1);
223 Destructor. The blocker will remove itself from the chain of event handlers for
224 the window provided in the constructor, thus restoring normal processing of events.
226 virtual ~wxEventBlocker();
229 Adds to the list of event types which should be blocked the given @a eventType.
231 void Block(wxEventType eventType
);
239 A class that can handle events from the windowing system.
240 wxWindow (and therefore all window classes) are derived from this class.
242 When events are received, wxEvtHandler invokes the method listed in the
243 event table using itself as the object. When using multiple inheritance
244 it is imperative that the wxEvtHandler(-derived) class be the first
245 class inherited such that the "this" pointer for the overall object
246 will be identical to the "this" pointer for the wxEvtHandler portion.
251 @see @ref overview_eventhandling
253 class wxEvtHandler
: public wxObject
264 If the handler is part of a chain, the destructor will unlink itself and
265 restore the previous and next handlers so that they point to each other.
267 virtual ~wxEvtHandler();
270 Queue event for a later processing.
272 This method is similar to ProcessEvent() but while the latter is
273 synchronous, i.e. the event is processed immediately, before the
274 function returns, this one is asynchronous and returns immediately
275 while the event will be processed at some later time (usually during
276 the next event loop iteration).
278 Another important difference is that this method takes ownership of the
279 @a event parameter, i.e. it will delete it itself. This implies that
280 the event should be allocated on the heap and that the pointer can't be
281 used any more after the function returns (as it can be deleted at any
284 QueueEvent() can be used for inter-thread communication from the worker
285 threads to the main thread, it is safe in the sense that it uses
286 locking internally and avoids the problem mentioned in AddPendingEvent()
287 documentation by ensuring that the @a event object is not used by the
288 calling thread any more. Care should still be taken to avoid that some
289 fields of this object are used by it, notably any wxString members of
290 the event object must not be shallow copies of another wxString object
291 as this would result in them still using the same string buffer behind
292 the scenes. For example
294 void FunctionInAWorkerThread(const wxString& str)
296 wxCommandEvent* evt = new wxCommandEvent;
298 // NOT evt->SetString(str) as this would be a shallow copy
299 evt->SetString(str.c_str()); // make a deep copy
301 wxTheApp->QueueEvent( evt );
305 Finally notice that this method automatically wakes up the event loop
306 if it is currently idle by calling ::wxWakeUpIdle() so there is no need
307 to do it manually when using it.
312 A heap-allocated event to be queued, QueueEvent() takes ownership
313 of it. This parameter shouldn't be @c NULL.
315 virtual void QueueEvent(wxEvent
*event
);
318 Post an event to be processed later.
320 This function is similar to QueueEvent() but can't be used to post
321 events from worker threads for the event objects with wxString fields
322 (i.e. in practice most of them) because of an unsafe use of the same
323 wxString object which happens because the wxString field in the
324 original @a event object and its copy made internally by this function
325 share the same string buffer internally. Use QueueEvent() to avoid
328 A copy of @a event is made by the function, so the original can be deleted
329 as soon as function returns (it is common that the original is created
330 on the stack). This requires that the wxEvent::Clone() method be
331 implemented by event so that it can be duplicated and stored until it
335 Event to add to the pending events queue.
337 virtual void AddPendingEvent(const wxEvent
& event
);
340 Connects the given function dynamically with the event handler, id and event type.
341 This is an alternative to the use of static event tables.
343 See the @ref page_samples_event sample for usage.
345 This specific overload allows you to connect an event handler to a @e range
347 Do not confuse @e source IDs with event @e types: source IDs identify the
348 event generator objects (typically wxMenuItem or wxWindow objects) while the
349 event @e type identify which type of events should be handled by the
350 given @e function (an event generator object may generate many different
354 The first ID of the identifier range to be associated with the event
357 The last ID of the identifier range to be associated with the event
360 The event type to be associated with this event handler.
362 The event handler function. Note that this function should
363 be explicitly converted to the correct type which can be done using a macro
364 called @c wxFooEventHandler for the handler for any @c wxFooEvent.
366 Data to be associated with the event table entry.
368 Object whose member function should be called.
369 If this is @NULL, @c *this will be used.
371 void Connect(int id
, int lastId
, wxEventType eventType
,
372 wxObjectEventFunction function
,
373 wxObject
* userData
= NULL
,
374 wxEvtHandler
* eventSink
= NULL
);
377 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
378 overload for more info.
380 This overload can be used to attach an event handler to a single source ID:
384 frame->Connect( wxID_EXIT,
385 wxEVT_COMMAND_MENU_SELECTED,
386 wxCommandEventHandler(MyFrame::OnQuit) );
389 void Connect(int id
, wxEventType eventType
,
390 wxObjectEventFunction function
,
391 wxObject
* userData
= NULL
,
392 wxEvtHandler
* eventSink
= NULL
);
395 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
396 overload for more info.
398 This overload will connect the given event handler so that regardless of the
399 ID of the event source, the handler will be called.
401 void Connect(wxEventType eventType
,
402 wxObjectEventFunction function
,
403 wxObject
* userData
= NULL
,
404 wxEvtHandler
* eventSink
= NULL
);
407 Disconnects the given function dynamically from the event handler, using the
408 specified parameters as search criteria and returning @true if a matching
409 function has been found and removed.
411 This method can only disconnect functions which have been added using the
412 Connect() method. There is no way to disconnect functions connected using
413 the (static) event tables.
416 The event type associated with this event handler.
418 The event handler function.
420 Data associated with the event table entry.
422 Object whose member function should be called.
424 bool Disconnect(wxEventType eventType
,
425 wxObjectEventFunction function
,
426 wxObject
* userData
= NULL
,
427 wxEvtHandler
* eventSink
= NULL
);
430 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
431 overload for more info.
433 This overload takes the additional @a id parameter.
435 bool Disconnect(int id
= wxID_ANY
,
436 wxEventType eventType
= wxEVT_NULL
,
437 wxObjectEventFunction function
= NULL
,
438 wxObject
* userData
= NULL
,
439 wxEvtHandler
* eventSink
= NULL
);
442 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
443 overload for more info.
445 This overload takes an additional range of source IDs.
447 bool Disconnect(int id
, int lastId
,
448 wxEventType eventType
,
449 wxObjectEventFunction function
= NULL
,
450 wxObject
* userData
= NULL
,
451 wxEvtHandler
* eventSink
= NULL
);
454 Returns user-supplied client data.
456 @remarks Normally, any extra data the programmer wishes to associate with
457 the object should be made available by deriving a new class with
462 void* GetClientData() const;
465 Returns a pointer to the user-supplied client data object.
467 @see SetClientObject(), wxClientData
469 wxClientData
* GetClientObject() const;
472 Returns @true if the event handler is enabled, @false otherwise.
474 @see SetEvtHandlerEnabled()
476 bool GetEvtHandlerEnabled() const;
479 Returns the pointer to the next handler in the chain.
481 @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(),
482 wxWindow::PushEventHandler, wxWindow::PopEventHandler
484 wxEvtHandler
* GetNextHandler() const;
487 Returns the pointer to the previous handler in the chain.
489 @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(),
490 wxWindow::PushEventHandler, wxWindow::PopEventHandler
492 wxEvtHandler
* GetPreviousHandler() const;
495 Processes an event, searching event tables and calling zero or more suitable
496 event handler function(s).
498 Normally, your application would not call this function: it is called in the
499 wxWidgets implementation to dispatch incoming user interface events to the
500 framework (and application).
502 However, you might need to call it if implementing new functionality
503 (such as a new control) where you define new event types, as opposed to
504 allowing the user to override virtual functions.
506 An instance where you might actually override the ProcessEvent function is where
507 you want to direct event processing to event handlers not normally noticed by
508 wxWidgets. For example, in the document/view architecture, documents and views
509 are potential event handlers. When an event reaches a frame, ProcessEvent will
510 need to be called on the associated document and view in case event handler functions
511 are associated with these objects. The property classes library (wxProperty) also
512 overrides ProcessEvent for similar reasons.
514 The normal order of event table searching is as follows:
515 -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled)
516 the function skips to step (6).
517 -# If the object is a wxWindow, ProcessEvent() is recursively called on the
518 window's wxValidator. If this returns @true, the function exits.
519 -# SearchEventTable() is called for this event handler. If this fails, the base
520 class table is tried, and so on until no more tables exist or an appropriate
521 function was found, in which case the function exits.
522 -# The search is applied down the entire chain of event handlers (usually the
523 chain has a length of one). If this succeeds, the function exits.
524 -# If the object is a wxWindow and the event is a wxCommandEvent, ProcessEvent()
525 is recursively applied to the parent window's event handler.
526 If this returns true, the function exits.
527 -# Finally, ProcessEvent() is called on the wxApp object.
532 @return @true if a suitable event handler function was found and
533 executed, and the function did not call wxEvent::Skip.
535 @see SearchEventTable()
537 virtual bool ProcessEvent(wxEvent
& event
);
540 Processes an event by calling ProcessEvent() and handles any exceptions
541 that occur in the process.
542 If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called.
547 @return @true if the event was processed, @false if no handler was found
548 or an exception was thrown.
550 @see wxWindow::HandleWindowEvent
552 bool SafelyProcessEvent(wxEvent
& event
);
555 Searches the event table, executing an event handler function if an appropriate
559 Event table to be searched.
561 Event to be matched against an event table entry.
563 @return @true if a suitable event handler function was found and
564 executed, and the function did not call wxEvent::Skip.
566 @remarks This function looks through the object's event table and tries
567 to find an entry that will match the event.
568 An entry will match if:
569 @li The event type matches, and
570 @li the identifier or identifier range matches, or the event table
571 entry's identifier is zero.
572 If a suitable function is called but calls wxEvent::Skip, this
573 function will fail, and searching will continue.
577 virtual bool SearchEventTable(wxEventTable
& table
,
581 Sets user-supplied client data.
584 Data to be associated with the event handler.
586 @remarks Normally, any extra data the programmer wishes to associate
587 with the object should be made available by deriving a new
588 class with new data members. You must not call this method
589 and SetClientObject on the same class - only one of them.
593 void SetClientData(void* data
);
596 Set the client data object. Any previous object will be deleted.
598 @see GetClientObject(), wxClientData
600 void SetClientObject(wxClientData
* data
);
603 Enables or disables the event handler.
606 @true if the event handler is to be enabled, @false if it is to be disabled.
608 @remarks You can use this function to avoid having to remove the event
609 handler from the chain, for example when implementing a
610 dialog editor and changing from edit to test mode.
612 @see GetEvtHandlerEnabled()
614 void SetEvtHandlerEnabled(bool enabled
);
617 Sets the pointer to the next handler.
620 Event handler to be set as the next handler.
622 @see GetNextHandler(), SetPreviousHandler(), GetPreviousHandler(),
623 wxWindow::PushEventHandler, wxWindow::PopEventHandler
625 void SetNextHandler(wxEvtHandler
* handler
);
628 Sets the pointer to the previous handler.
631 Event handler to be set as the previous handler.
633 void SetPreviousHandler(wxEvtHandler
* handler
);
640 This event class contains information about keypress (character) events.
642 Notice that there are three different kinds of keyboard events in wxWidgets:
643 key down and up events and char events. The difference between the first two
644 is clear - the first corresponds to a key press and the second to a key
645 release - otherwise they are identical. Just note that if the key is
646 maintained in a pressed state you will typically get a lot of (automatically
647 generated) down events but only one up so it is wrong to assume that there is
648 one up event corresponding to each down one.
650 Both key events provide untranslated key codes while the char event carries
651 the translated one. The untranslated code for alphanumeric keys is always
652 an upper case value. For the other keys it is one of @c WXK_XXX values
653 from the @ref page_keycodes.
654 The translated key is, in general, the character the user expects to appear
655 as the result of the key combination when typing the text into a text entry
658 A few examples to clarify this (all assume that CAPS LOCK is unpressed
659 and the standard US keyboard): when the @c 'A' key is pressed, the key down
660 event key code is equal to @c ASCII A == 65. But the char event key code
661 is @c ASCII a == 97. On the other hand, if you press both SHIFT and
662 @c 'A' keys simultaneously , the key code in key down event will still be
663 just @c 'A' while the char event key code parameter will now be @c 'A'
666 Although in this simple case it is clear that the correct key code could be
667 found in the key down event handler by checking the value returned by
668 wxKeyEvent::ShiftDown(), in general you should use @c EVT_CHAR for this as
669 for non-alphanumeric keys the translation is keyboard-layout dependent and
670 can only be done properly by the system itself.
672 Another kind of translation is done when the control key is pressed: for
673 example, for CTRL-A key press the key down event still carries the
674 same key code @c 'a' as usual but the char event will have key code of 1,
675 the ASCII value of this key combination.
677 You may discover how the other keys on your system behave interactively by
678 running the @ref page_samples_text wxWidgets sample and pressing some keys
679 in any of the text controls shown in it.
681 @b Tip: be sure to call @c event.Skip() for events that you don't process in
682 key event function, otherwise menu shortcuts may cease to work under Windows.
684 @note If a key down (@c EVT_KEY_DOWN) event is caught and the event handler
685 does not call @c event.Skip() then the corresponding char event
686 (@c EVT_CHAR) will not happen.
687 This is by design and enables the programs that handle both types of
688 events to be a bit simpler.
690 @note For Windows programmers: The key and char events in wxWidgets are
691 similar to but slightly different from Windows @c WM_KEYDOWN and
692 @c WM_CHAR events. In particular, Alt-x combination will generate a
693 char event in wxWidgets (unless it is used as an accelerator).
696 @beginEventTable{wxKeyEvent}
697 @event{EVT_KEY_DOWN(func)}
698 Process a wxEVT_KEY_DOWN event (any key has been pressed).
699 @event{EVT_KEY_UP(func)}
700 Process a wxEVT_KEY_UP event (any key has been released).
701 @event{EVT_CHAR(func)}
702 Process a wxEVT_CHAR event.
710 class wxKeyEvent
: public wxEvent
,
711 public wxKeyboardState
716 Currently, the only valid event types are @c wxEVT_CHAR and @c wxEVT_CHAR_HOOK.
718 wxKeyEvent(wxEventType keyEventType
= wxEVT_NULL
);
721 Returns the virtual key code. ASCII events return normal ASCII values,
722 while non-ASCII events return values such as @b WXK_LEFT for the left cursor
723 key. See @ref page_keycodes for a full list of the virtual key codes.
725 Note that in Unicode build, the returned value is meaningful only if the
726 user entered a character that can be represented in current locale's default
727 charset. You can obtain the corresponding Unicode character using GetUnicodeKey().
729 int GetKeyCode() const;
733 Obtains the position (in client coordinates) at which the key was pressed.
735 wxPoint
GetPosition() const;
736 void GetPosition(long* x
, long* y
) const;
740 Returns the raw key code for this event. This is a platform-dependent scan code
741 which should only be used in advanced applications.
743 @note Currently the raw key codes are not supported by all ports, use
744 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
746 wxUint32
GetRawKeyCode() const;
749 Returns the low level key flags for this event. The flags are
750 platform-dependent and should only be used in advanced applications.
752 @note Currently the raw key flags are not supported by all ports, use
753 @ifdef_ wxHAS_RAW_KEY_CODES to determine if this feature is available.
755 wxUint32
GetRawKeyFlags() const;
758 Returns the Unicode character corresponding to this key event.
760 This function is only available in Unicode build, i.e. when
761 @c wxUSE_UNICODE is 1.
763 wxChar
GetUnicodeKey() const;
766 Returns the X position (in client coordinates) of the event.
768 wxCoord
GetX() const;
771 Returns the Y position (in client coordinates) of the event.
773 wxCoord
GetY() const;
779 @class wxJoystickEvent
781 This event class contains information about joystick events, particularly
782 events received by windows.
784 @beginEventTable{wxJoystickEvent}
785 @style{EVT_JOY_BUTTON_DOWN(func)}
786 Process a wxEVT_JOY_BUTTON_DOWN event.
787 @style{EVT_JOY_BUTTON_UP(func)}
788 Process a wxEVT_JOY_BUTTON_UP event.
789 @style{EVT_JOY_MOVE(func)}
790 Process a wxEVT_JOY_MOVE event.
791 @style{EVT_JOY_ZMOVE(func)}
792 Process a wxEVT_JOY_ZMOVE event.
793 @style{EVT_JOYSTICK_EVENTS(func)}
794 Processes all joystick events.
802 class wxJoystickEvent
: public wxEvent
808 wxJoystickEvent(wxEventType eventType
= wxEVT_NULL
, int state
= 0,
809 int joystick
= wxJOYSTICK1
,
813 Returns @true if the event was a down event from the specified button
817 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
818 indicate any button down event.
820 bool ButtonDown(int button
= wxJOY_BUTTON_ANY
) const;
823 Returns @true if the specified button (or any button) was in a down state.
826 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
827 indicate any button down event.
829 bool ButtonIsDown(int button
= wxJOY_BUTTON_ANY
) const;
832 Returns @true if the event was an up event from the specified button
836 Can be @c wxJOY_BUTTONn where @c n is 1, 2, 3 or 4; or @c wxJOY_BUTTON_ANY to
837 indicate any button down event.
839 bool ButtonUp(int button
= wxJOY_BUTTON_ANY
) const;
842 Returns the identifier of the button changing state.
844 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
846 int GetButtonChange() const;
849 Returns the down state of the buttons.
851 This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4.
853 int GetButtonState() const;
856 Returns the identifier of the joystick generating the event - one of
857 wxJOYSTICK1 and wxJOYSTICK2.
859 int GetJoystick() const;
862 Returns the x, y position of the joystick event.
864 wxPoint
GetPosition() const;
867 Returns the z position of the joystick event.
869 int GetZPosition() const;
872 Returns @true if this was a button up or down event
873 (@e not 'is any button down?').
875 bool IsButton() const;
878 Returns @true if this was an x, y move event.
883 Returns @true if this was a z move event.
885 bool IsZMove() const;
891 @class wxScrollWinEvent
893 A scroll event holds information about events sent from scrolling windows.
896 @beginEventTable{wxScrollWinEvent}
897 You can use the EVT_SCROLLWIN* macros for intercepting scroll window events
898 from the receiving window.
899 @event{EVT_SCROLLWIN(func)}
900 Process all scroll events.
901 @event{EVT_SCROLLWIN_TOP(func)}
902 Process wxEVT_SCROLLWIN_TOP scroll-to-top events.
903 @event{EVT_SCROLLWIN_BOTTOM(func)}
904 Process wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events.
905 @event{EVT_SCROLLWIN_LINEUP(func)}
906 Process wxEVT_SCROLLWIN_LINEUP line up events.
907 @event{EVT_SCROLLWIN_LINEDOWN(func)}
908 Process wxEVT_SCROLLWIN_LINEDOWN line down events.
909 @event{EVT_SCROLLWIN_PAGEUP(func)}
910 Process wxEVT_SCROLLWIN_PAGEUP page up events.
911 @event{EVT_SCROLLWIN_PAGEDOWN(func)}
912 Process wxEVT_SCROLLWIN_PAGEDOWN page down events.
913 @event{EVT_SCROLLWIN_THUMBTRACK(func)}
914 Process wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events
915 (frequent events sent as the user drags the thumbtrack).
916 @event{EVT_SCROLLWIN_THUMBRELEASE(func)}
917 Process wxEVT_SCROLLWIN_THUMBRELEASE thumb release events.
924 @see wxScrollEvent, @ref overview_eventhandling
926 class wxScrollWinEvent
: public wxEvent
932 wxScrollWinEvent(wxEventType commandType
= wxEVT_NULL
, int pos
= 0,
933 int orientation
= 0);
936 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
939 @todo wxHORIZONTAL and wxVERTICAL should go in their own enum
941 int GetOrientation() const;
944 Returns the position of the scrollbar for the thumb track and release events.
946 Note that this field can't be used for the other events, you need to query
947 the window itself for the current position in that case.
949 int GetPosition() const;
955 @class wxSysColourChangedEvent
957 This class is used for system colour change events, which are generated
958 when the user changes the colour settings using the control panel.
959 This is only appropriate under Windows.
962 The default event handler for this event propagates the event to child windows,
963 since Windows only sends the events to top-level windows.
964 If intercepting this event for a top-level window, remember to call the base
965 class handler, or to pass the event on to the window's children explicitly.
967 @beginEventTable{wxSysColourChangedEvent}
968 @event{EVT_SYS_COLOUR_CHANGED(func)}
969 Process a wxEVT_SYS_COLOUR_CHANGED event.
975 @see @ref overview_eventhandling
977 class wxSysColourChangedEvent
: public wxEvent
983 wxSysColourChangedEvent();
989 @class wxWindowCreateEvent
991 This event is sent just after the actual window associated with a wxWindow
992 object has been created.
994 Since it is derived from wxCommandEvent, the event propagates up
995 the window hierarchy.
997 @beginEventTable{wxWindowCreateEvent}
998 @event{EVT_WINDOW_CREATE(func)}
999 Process a wxEVT_CREATE event.
1005 @see @ref overview_eventhandling, wxWindowDestroyEvent
1007 class wxWindowCreateEvent
: public wxCommandEvent
1013 wxWindowCreateEvent(wxWindow
* win
= NULL
);
1021 A paint event is sent when a window's contents needs to be repainted.
1023 Please notice that in general it is impossible to change the drawing of a
1024 standard control (such as wxButton) and so you shouldn't attempt to handle
1025 paint events for them as even if it might work on some platforms, this is
1026 inherently not portable and won't work everywhere.
1029 Note that in a paint event handler, the application must always create a
1030 wxPaintDC object, even if you do not use it. Otherwise, under MS Windows,
1031 refreshing for this and other windows will go wrong.
1034 void MyWindow::OnPaint(wxPaintEvent& event)
1041 You can optimize painting by retrieving the rectangles that have been damaged
1042 and only repainting these. The rectangles are in terms of the client area,
1043 and are unscrolled, so you will need to do some calculations using the current
1044 view position to obtain logical, scrolled units.
1045 Here is an example of using the wxRegionIterator class:
1047 // Called when window needs to be repainted.
1048 void MyWindow::OnPaint(wxPaintEvent& event)
1052 // Find Out where the window is scrolled to
1053 int vbX,vbY; // Top left corner of client
1054 GetViewStart(&vbX,&vbY);
1056 int vX,vY,vW,vH; // Dimensions of client area in pixels
1057 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
1066 // Alternatively we can do this:
1067 // wxRect rect(upd.GetRect());
1069 // Repaint this rectangle
1078 @beginEventTable{wxPaintEvent}
1079 @event{EVT_PAINT(func)}
1080 Process a wxEVT_PAINT event.
1086 @see @ref overview_eventhandling
1088 class wxPaintEvent
: public wxEvent
1094 wxPaintEvent(int id
= 0);
1100 @class wxMaximizeEvent
1102 An event being sent when a top level window is maximized. Notice that it is
1103 not sent when the window is restored to its original size after it had been
1104 maximized, only a normal wxSizeEvent is generated in this case.
1106 @beginEventTable{wxMaximizeEvent}
1107 @event{EVT_MAXIMIZE(func)}
1108 Process a wxEVT_MAXIMIZE event.
1114 @see @ref overview_eventhandling, wxTopLevelWindow::Maximize,
1115 wxTopLevelWindow::IsMaximized
1117 class wxMaximizeEvent
: public wxEvent
1121 Constructor. Only used by wxWidgets internally.
1123 wxMaximizeEvent(int id
= 0);
1127 The possibles modes to pass to wxUpdateUIEvent::SetMode().
1131 /** Send UI update events to all windows. */
1132 wxUPDATE_UI_PROCESS_ALL
,
1134 /** Send UI update events to windows that have
1135 the wxWS_EX_PROCESS_UI_UPDATES flag specified. */
1136 wxUPDATE_UI_PROCESS_SPECIFIED
1141 @class wxUpdateUIEvent
1143 This class is used for pseudo-events which are called by wxWidgets
1144 to give an application the chance to update various user interface elements.
1146 Without update UI events, an application has to work hard to check/uncheck,
1147 enable/disable, show/hide, and set the text for elements such as menu items
1148 and toolbar buttons. The code for doing this has to be mixed up with the code
1149 that is invoked when an action is invoked for a menu item or button.
1151 With update UI events, you define an event handler to look at the state of the
1152 application and change UI elements accordingly. wxWidgets will call your member
1153 functions in idle time, so you don't have to worry where to call this code.
1155 In addition to being a clearer and more declarative method, it also means you don't
1156 have to worry whether you're updating a toolbar or menubar identifier. The same
1157 handler can update a menu item and toolbar button, if the identifier is the same.
1158 Instead of directly manipulating the menu or button, you call functions in the event
1159 object, such as wxUpdateUIEvent::Check. wxWidgets will determine whether such a
1160 call has been made, and which UI element to update.
1162 These events will work for popup menus as well as menubars. Just before a menu is
1163 popped up, wxMenu::UpdateUI is called to process any UI events for the window that
1166 If you find that the overhead of UI update processing is affecting your application,
1167 you can do one or both of the following:
1168 @li Call wxUpdateUIEvent::SetMode with a value of wxUPDATE_UI_PROCESS_SPECIFIED,
1169 and set the extra style wxWS_EX_PROCESS_UI_UPDATES for every window that should
1170 receive update events. No other windows will receive update events.
1171 @li Call wxUpdateUIEvent::SetUpdateInterval with a millisecond value to set the delay
1172 between updates. You may need to call wxWindow::UpdateWindowUI at critical points,
1173 for example when a dialog is about to be shown, in case the user sees a slight
1174 delay before windows are updated.
1176 Note that although events are sent in idle time, defining a wxIdleEvent handler
1177 for a window does not affect this because the events are sent from wxWindow::OnInternalIdle
1178 which is always called in idle time.
1180 wxWidgets tries to optimize update events on some platforms.
1181 On Windows and GTK+, events for menubar items are only sent when the menu is about
1182 to be shown, and not in idle time.
1185 @beginEventTable{wxUpdateUIEvent}
1186 @event{EVT_UPDATE_UI(id, func)}
1187 Process a wxEVT_UPDATE_UI event for the command with the given id.
1188 @event{EVT_UPDATE_UI_RANGE(id1, id2, func)}
1189 Process a wxEVT_UPDATE_UI event for any command with id included in the given range.
1195 @see @ref overview_eventhandling
1197 class wxUpdateUIEvent
: public wxCommandEvent
1203 wxUpdateUIEvent(wxWindowID commandId
= 0);
1206 Returns @true if it is appropriate to update (send UI update events to)
1209 This function looks at the mode used (see wxUpdateUIEvent::SetMode),
1210 the wxWS_EX_PROCESS_UI_UPDATES flag in @a window, the time update events
1211 were last sent in idle time, and the update interval, to determine whether
1212 events should be sent to this window now. By default this will always
1213 return @true because the update mode is initially wxUPDATE_UI_PROCESS_ALL
1214 and the interval is set to 0; so update events will be sent as often as
1215 possible. You can reduce the frequency that events are sent by changing the
1216 mode and/or setting an update interval.
1218 @see ResetUpdateTime(), SetUpdateInterval(), SetMode()
1220 static bool CanUpdate(wxWindow
* window
);
1223 Check or uncheck the UI element.
1225 void Check(bool check
);
1228 Enable or disable the UI element.
1230 void Enable(bool enable
);
1233 Returns @true if the UI element should be checked.
1235 bool GetChecked() const;
1238 Returns @true if the UI element should be enabled.
1240 bool GetEnabled() const;
1243 Static function returning a value specifying how wxWidgets will send update
1244 events: to all windows, or only to those which specify that they will process
1249 static wxUpdateUIMode
GetMode();
1252 Returns @true if the application has called Check().
1253 For wxWidgets internal use only.
1255 bool GetSetChecked() const;
1258 Returns @true if the application has called Enable().
1259 For wxWidgets internal use only.
1261 bool GetSetEnabled() const;
1264 Returns @true if the application has called Show().
1265 For wxWidgets internal use only.
1267 bool GetSetShown() const;
1270 Returns @true if the application has called SetText().
1271 For wxWidgets internal use only.
1273 bool GetSetText() const;
1276 Returns @true if the UI element should be shown.
1278 bool GetShown() const;
1281 Returns the text that should be set for the UI element.
1283 wxString
GetText() const;
1286 Returns the current interval between updates in milliseconds.
1287 The value -1 disables updates, 0 updates as frequently as possible.
1289 @see SetUpdateInterval().
1291 static long GetUpdateInterval();
1294 Used internally to reset the last-updated time to the current time.
1296 It is assumed that update events are normally sent in idle time, so this
1297 is called at the end of idle processing.
1299 @see CanUpdate(), SetUpdateInterval(), SetMode()
1301 static void ResetUpdateTime();
1304 Specify how wxWidgets will send update events: to all windows, or only to
1305 those which specify that they will process the events.
1308 this parameter may be one of the ::wxUpdateUIMode enumeration values.
1309 The default mode is wxUPDATE_UI_PROCESS_ALL.
1311 static void SetMode(wxUpdateUIMode mode
);
1314 Sets the text for this UI element.
1316 void SetText(const wxString
& text
);
1319 Sets the interval between updates in milliseconds.
1321 Set to -1 to disable updates, or to 0 to update as frequently as possible.
1324 Use this to reduce the overhead of UI update events if your application
1325 has a lot of windows. If you set the value to -1 or greater than 0,
1326 you may also need to call wxWindow::UpdateWindowUI at appropriate points
1327 in your application, such as when a dialog is about to be shown.
1329 static void SetUpdateInterval(long updateInterval
);
1332 Show or hide the UI element.
1334 void Show(bool show
);
1340 @class wxClipboardTextEvent
1342 This class represents the events generated by a control (typically a
1343 wxTextCtrl but other windows can generate these events as well) when its
1344 content gets copied or cut to, or pasted from the clipboard.
1346 There are three types of corresponding events wxEVT_COMMAND_TEXT_COPY,
1347 wxEVT_COMMAND_TEXT_CUT and wxEVT_COMMAND_TEXT_PASTE.
1349 If any of these events is processed (without being skipped) by an event
1350 handler, the corresponding operation doesn't take place which allows to
1351 prevent the text from being copied from or pasted to a control. It is also
1352 possible to examine the clipboard contents in the PASTE event handler and
1353 transform it in some way before inserting in a control -- for example,
1354 changing its case or removing invalid characters.
1356 Finally notice that a CUT event is always preceded by the COPY event which
1357 makes it possible to only process the latter if it doesn't matter if the
1358 text was copied or cut.
1361 These events are currently only generated by wxTextCtrl under GTK+.
1362 They are generated by all controls under Windows.
1364 @beginEventTable{wxClipboardTextEvent}
1365 @event{EVT_TEXT_COPY(id, func)}
1366 Some or all of the controls content was copied to the clipboard.
1367 @event{EVT_TEXT_CUT(id, func)}
1368 Some or all of the controls content was cut (i.e. copied and
1370 @event{EVT_TEXT_PASTE(id, func)}
1371 Clipboard content was pasted into the control.
1380 class wxClipboardTextEvent
: public wxCommandEvent
1386 wxClipboardTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
1394 This event class contains information about the events generated by the mouse:
1395 they include mouse buttons press and release events and mouse move events.
1397 All mouse events involving the buttons use @c wxMOUSE_BTN_LEFT for the
1398 left mouse button, @c wxMOUSE_BTN_MIDDLE for the middle one and
1399 @c wxMOUSE_BTN_RIGHT for the right one. And if the system supports more
1400 buttons, the @c wxMOUSE_BTN_AUX1 and @c wxMOUSE_BTN_AUX2 events
1401 can also be generated. Note that not all mice have even a middle button so a
1402 portable application should avoid relying on the events from it (but the right
1403 button click can be emulated using the left mouse button with the control key
1404 under Mac platforms with a single button mouse).
1406 For the @c wxEVT_ENTER_WINDOW and @c wxEVT_LEAVE_WINDOW events
1407 purposes, the mouse is considered to be inside the window if it is in the
1408 window client area and not inside one of its children. In other words, the
1409 parent window receives @c wxEVT_LEAVE_WINDOW event not only when the
1410 mouse leaves the window entirely but also when it enters one of its children.
1412 @note Note that under Windows CE mouse enter and leave events are not natively
1413 supported by the system but are generated by wxWidgets itself. This has several
1414 drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
1415 left the window and the state variables for it may have changed during this time.
1417 @note Note the difference between methods like wxMouseEvent::LeftDown and
1418 wxMouseEvent::LeftIsDown: the former returns @true when the event corresponds
1419 to the left mouse button click while the latter returns @true if the left
1420 mouse button is currently being pressed. For example, when the user is dragging
1421 the mouse you can use wxMouseEvent::LeftIsDown to test whether the left mouse
1422 button is (still) depressed. Also, by convention, if wxMouseEvent::LeftDown
1423 returns @true, wxMouseEvent::LeftIsDown will also return @true in wxWidgets
1424 whatever the underlying GUI behaviour is (which is platform-dependent).
1425 The same applies, of course, to other mouse buttons as well.
1428 @beginEventTable{wxMouseEvent}
1429 @event{EVT_LEFT_DOWN(func)}
1430 Process a wxEVT_LEFT_DOWN event. The handler of this event should normally
1431 call event.Skip() to allow the default processing to take place as otherwise
1432 the window under mouse wouldn't get the focus.
1433 @event{EVT_LEFT_UP(func)}
1434 Process a wxEVT_LEFT_UP event.
1435 @event{EVT_LEFT_DCLICK(func)}
1436 Process a wxEVT_LEFT_DCLICK event.
1437 @event{EVT_MIDDLE_DOWN(func)}
1438 Process a wxEVT_MIDDLE_DOWN event.
1439 @event{EVT_MIDDLE_UP(func)}
1440 Process a wxEVT_MIDDLE_UP event.
1441 @event{EVT_MIDDLE_DCLICK(func)}
1442 Process a wxEVT_MIDDLE_DCLICK event.
1443 @event{EVT_RIGHT_DOWN(func)}
1444 Process a wxEVT_RIGHT_DOWN event.
1445 @event{EVT_RIGHT_UP(func)}
1446 Process a wxEVT_RIGHT_UP event.
1447 @event{EVT_RIGHT_DCLICK(func)}
1448 Process a wxEVT_RIGHT_DCLICK event.
1449 @event{EVT_MOUSE_AUX1_DOWN(func)}
1450 Process a wxEVT_MOUSE_AUX1_DOWN event.
1451 @event{EVT_MOUSE_AUX1_UP(func)}
1452 Process a wxEVT_MOUSE_AUX1_UP event.
1453 @event{EVT_MOUSE_AUX1_DCLICK(func)}
1454 Process a wxEVT_MOUSE_AUX1_DCLICK event.
1455 @event{EVT_MOUSE_AUX2_DOWN(func)}
1456 Process a wxEVT_MOUSE_AUX2_DOWN event.
1457 @event{EVT_MOUSE_AUX2_UP(func)}
1458 Process a wxEVT_MOUSE_AUX2_UP event.
1459 @event{EVT_MOUSE_AUX2_DCLICK(func)}
1460 Process a wxEVT_MOUSE_AUX2_DCLICK event.
1461 @event{EVT_MOTION(func)}
1462 Process a wxEVT_MOTION event.
1463 @event{EVT_ENTER_WINDOW(func)}
1464 Process a wxEVT_ENTER_WINDOW event.
1465 @event{EVT_LEAVE_WINDOW(func)}
1466 Process a wxEVT_LEAVE_WINDOW event.
1467 @event{EVT_MOUSEWHEEL(func)}
1468 Process a wxEVT_MOUSEWHEEL event.
1469 @event{EVT_MOUSE_EVENTS(func)}
1470 Process all mouse events.
1478 class wxMouseEvent
: public wxEvent
,
1483 Constructor. Valid event types are:
1485 @li wxEVT_ENTER_WINDOW
1486 @li wxEVT_LEAVE_WINDOW
1489 @li wxEVT_LEFT_DCLICK
1490 @li wxEVT_MIDDLE_DOWN
1492 @li wxEVT_MIDDLE_DCLICK
1493 @li wxEVT_RIGHT_DOWN
1495 @li wxEVT_RIGHT_DCLICK
1496 @li wxEVT_MOUSE_AUX1_DOWN
1497 @li wxEVT_MOUSE_AUX1_UP
1498 @li wxEVT_MOUSE_AUX1_DCLICK
1499 @li wxEVT_MOUSE_AUX2_DOWN
1500 @li wxEVT_MOUSE_AUX2_UP
1501 @li wxEVT_MOUSE_AUX2_DCLICK
1503 @li wxEVT_MOUSEWHEEL
1505 wxMouseEvent(wxEventType mouseEventType
= wxEVT_NULL
);
1508 Returns @true if the event was a first extra button double click.
1510 bool Aux1DClick() const;
1513 Returns @true if the first extra button mouse button changed to down.
1515 bool Aux1Down() const;
1518 Returns @true if the first extra button mouse button is currently down,
1519 independent of the current event type.
1521 bool Aux1IsDown() const;
1524 Returns @true if the first extra button mouse button changed to up.
1526 bool Aux1Up() const;
1529 Returns @true if the event was a second extra button double click.
1531 bool Aux2DClick() const;
1534 Returns @true if the second extra button mouse button changed to down.
1536 bool Aux2Down() const;
1539 Returns @true if the second extra button mouse button is currently down,
1540 independent of the current event type.
1542 bool Aux2IsDown() const;
1545 Returns @true if the second extra button mouse button changed to up.
1547 bool Aux2Up() const;
1550 Returns @true if the identified mouse button is changing state.
1551 Valid values of @a button are:
1553 @li @c wxMOUSE_BTN_LEFT: check if left button was pressed
1554 @li @c wxMOUSE_BTN_MIDDLE: check if middle button was pressed
1555 @li @c wxMOUSE_BTN_RIGHT: check if right button was pressed
1556 @li @c wxMOUSE_BTN_AUX1: check if the first extra button was pressed
1557 @li @c wxMOUSE_BTN_AUX2: check if the second extra button was pressed
1558 @li @c wxMOUSE_BTN_ANY: check if any button was pressed
1560 @todo introduce wxMouseButton enum
1562 bool Button(int button
) const;
1565 If the argument is omitted, this returns @true if the event was a mouse
1566 double click event. Otherwise the argument specifies which double click event
1567 was generated (see Button() for the possible values).
1569 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
1572 If the argument is omitted, this returns @true if the event was a mouse
1573 button down event. Otherwise the argument specifies which button-down event
1574 was generated (see Button() for the possible values).
1576 bool ButtonDown(int = wxMOUSE_BTN_ANY
) const;
1579 If the argument is omitted, this returns @true if the event was a mouse
1580 button up event. Otherwise the argument specifies which button-up event
1581 was generated (see Button() for the possible values).
1583 bool ButtonUp(int = wxMOUSE_BTN_ANY
) const;
1586 Returns @true if this was a dragging event (motion while a button is depressed).
1590 bool Dragging() const;
1593 Returns @true if the mouse was entering the window.
1597 bool Entering() const;
1600 Returns the mouse button which generated this event or @c wxMOUSE_BTN_NONE
1601 if no button is involved (for mouse move, enter or leave event, for example).
1602 Otherwise @c wxMOUSE_BTN_LEFT is returned for the left button down, up and
1603 double click events, @c wxMOUSE_BTN_MIDDLE and @c wxMOUSE_BTN_RIGHT
1604 for the same events for the middle and the right buttons respectively.
1606 int GetButton() const;
1609 Returns the number of mouse clicks for this event: 1 for a simple click, 2
1610 for a double-click, 3 for a triple-click and so on.
1612 Currently this function is implemented only in wxMac and returns -1 for the
1613 other platforms (you can still distinguish simple clicks from double-clicks as
1614 they generate different kinds of events however).
1618 int GetClickCount() const;
1621 Returns the configured number of lines (or whatever) to be scrolled per
1622 wheel action. Defaults to three.
1624 int GetLinesPerAction() const;
1627 Returns the logical mouse position in pixels (i.e. translated according to the
1628 translation set for the DC, which usually indicates that the window has been
1631 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
1635 Sets *x and *y to the position at which the event occurred.
1636 Returns the physical mouse position in pixels.
1638 Note that if the mouse event has been artificially generated from a special
1639 keyboard combination (e.g. under Windows when the "menu" key is pressed), the
1640 returned position is ::wxDefaultPosition.
1642 wxPoint
GetPosition() const;
1643 void GetPosition(wxCoord
* x
, wxCoord
* y
) const;
1644 void GetPosition(long* x
, long* y
) const;
1648 Get wheel delta, normally 120.
1650 This is the threshold for action to be taken, and one such action
1651 (for example, scrolling one increment) should occur for each delta.
1653 int GetWheelDelta() const;
1656 Get wheel rotation, positive or negative indicates direction of rotation.
1658 Current devices all send an event when rotation is at least +/-WheelDelta, but
1659 finer resolution devices can be created in the future.
1661 Because of this you shouldn't assume that one event is equal to 1 line, but you
1662 should be able to either do partial line scrolling or wait until several
1663 events accumulate before scrolling.
1665 int GetWheelRotation() const;
1668 Returns X coordinate of the physical mouse event position.
1670 wxCoord
GetX() const;
1673 Returns Y coordinate of the physical mouse event position.
1675 wxCoord
GetY() const;
1678 Returns @true if the event was a mouse button event (not necessarily a button
1679 down event - that may be tested using ButtonDown()).
1681 bool IsButton() const;
1684 Returns @true if the system has been setup to do page scrolling with
1685 the mouse wheel instead of line scrolling.
1687 bool IsPageScroll() const;
1690 Returns @true if the mouse was leaving the window.
1694 bool Leaving() const;
1697 Returns @true if the event was a left double click.
1699 bool LeftDClick() const;
1702 Returns @true if the left mouse button changed to down.
1704 bool LeftDown() const;
1707 Returns @true if the left mouse button is currently down, independent
1708 of the current event type.
1710 Please notice that it is not the same as LeftDown() which returns @true if the
1711 event was generated by the left mouse button being pressed. Rather, it simply
1712 describes the state of the left mouse button at the time when the event was
1713 generated (so while it will be @true for a left click event, it can also be @true
1714 for a right click if it happened while the left mouse button was pressed).
1716 This event is usually used in the mouse event handlers which process "move
1717 mouse" messages to determine whether the user is (still) dragging the mouse.
1719 bool LeftIsDown() const;
1722 Returns @true if the left mouse button changed to up.
1724 bool LeftUp() const;
1727 Returns @true if the Meta key was down at the time of the event.
1729 bool MetaDown() const;
1732 Returns @true if the event was a middle double click.
1734 bool MiddleDClick() const;
1737 Returns @true if the middle mouse button changed to down.
1739 bool MiddleDown() const;
1742 Returns @true if the middle mouse button is currently down, independent
1743 of the current event type.
1745 bool MiddleIsDown() const;
1748 Returns @true if the middle mouse button changed to up.
1750 bool MiddleUp() const;
1753 Returns @true if this was a motion event and no mouse buttons were pressed.
1754 If any mouse button is held pressed, then this method returns @false and
1755 Dragging() returns @true.
1757 bool Moving() const;
1760 Returns @true if the event was a right double click.
1762 bool RightDClick() const;
1765 Returns @true if the right mouse button changed to down.
1767 bool RightDown() const;
1770 Returns @true if the right mouse button is currently down, independent
1771 of the current event type.
1773 bool RightIsDown() const;
1776 Returns @true if the right mouse button changed to up.
1778 bool RightUp() const;
1784 @class wxDropFilesEvent
1786 This class is used for drop files events, that is, when files have been dropped
1787 onto the window. This functionality is currently only available under Windows.
1789 The window must have previously been enabled for dropping by calling
1790 wxWindow::DragAcceptFiles().
1792 Important note: this is a separate implementation to the more general drag and drop
1793 implementation documented in the @ref overview_dnd. It uses the older, Windows
1794 message-based approach of dropping files.
1796 @beginEventTable{wxDropFilesEvent}
1797 @event{EVT_DROP_FILES(func)}
1798 Process a wxEVT_DROP_FILES event.
1806 @see @ref overview_eventhandling
1808 class wxDropFilesEvent
: public wxEvent
1814 wxDropFilesEvent(wxEventType id
= 0, int noFiles
= 0,
1815 wxString
* files
= NULL
);
1818 Returns an array of filenames.
1820 wxString
* GetFiles() const;
1823 Returns the number of files dropped.
1825 int GetNumberOfFiles() const;
1828 Returns the position at which the files were dropped.
1829 Returns an array of filenames.
1831 wxPoint
GetPosition() const;
1837 @class wxCommandEvent
1839 This event class contains information about command events, which originate
1840 from a variety of simple controls.
1842 More complex controls, such as wxTreeCtrl, have separate command event classes.
1844 @beginEventTable{wxCommandEvent}
1845 @event{EVT_COMMAND(id, event, func)}
1846 Process a command, supplying the window identifier, command event identifier,
1847 and member function.
1848 @event{EVT_COMMAND_RANGE(id1, id2, event, func)}
1849 Process a command for a range of window identifiers, supplying the minimum and
1850 maximum window identifiers, command event identifier, and member function.
1851 @event{EVT_BUTTON(id, func)}
1852 Process a wxEVT_COMMAND_BUTTON_CLICKED command, which is generated by a wxButton control.
1853 @event{EVT_CHECKBOX(id, func)}
1854 Process a wxEVT_COMMAND_CHECKBOX_CLICKED command, which is generated by a wxCheckBox control.
1855 @event{EVT_CHOICE(id, func)}
1856 Process a wxEVT_COMMAND_CHOICE_SELECTED command, which is generated by a wxChoice control.
1857 @event{EVT_COMBOBOX(id, func)}
1858 Process a wxEVT_COMMAND_COMBOBOX_SELECTED command, which is generated by a wxComboBox control.
1859 @event{EVT_LISTBOX(id, func)}
1860 Process a wxEVT_COMMAND_LISTBOX_SELECTED command, which is generated by a wxListBox control.
1861 @event{EVT_LISTBOX_DCLICK(id, func)}
1862 Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED command, which is generated by a wxListBox control.
1863 @event{EVT_MENU(id, func)}
1864 Process a wxEVT_COMMAND_MENU_SELECTED command, which is generated by a menu item.
1865 @event{EVT_MENU_RANGE(id1, id2, func)}
1866 Process a wxEVT_COMMAND_MENU_RANGE command, which is generated by a range of menu items.
1867 @event{EVT_CONTEXT_MENU(func)}
1868 Process the event generated when the user has requested a popup menu to appear by
1869 pressing a special keyboard key (under Windows) or by right clicking the mouse.
1870 @event{EVT_RADIOBOX(id, func)}
1871 Process a wxEVT_COMMAND_RADIOBOX_SELECTED command, which is generated by a wxRadioBox control.
1872 @event{EVT_RADIOBUTTON(id, func)}
1873 Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED command, which is generated by a wxRadioButton control.
1874 @event{EVT_SCROLLBAR(id, func)}
1875 Process a wxEVT_COMMAND_SCROLLBAR_UPDATED command, which is generated by a wxScrollBar
1876 control. This is provided for compatibility only; more specific scrollbar event macros
1877 should be used instead (see wxScrollEvent).
1878 @event{EVT_SLIDER(id, func)}
1879 Process a wxEVT_COMMAND_SLIDER_UPDATED command, which is generated by a wxSlider control.
1880 @event{EVT_TEXT(id, func)}
1881 Process a wxEVT_COMMAND_TEXT_UPDATED command, which is generated by a wxTextCtrl control.
1882 @event{EVT_TEXT_ENTER(id, func)}
1883 Process a wxEVT_COMMAND_TEXT_ENTER command, which is generated by a wxTextCtrl control.
1884 Note that you must use wxTE_PROCESS_ENTER flag when creating the control if you want it
1885 to generate such events.
1886 @event{EVT_TEXT_MAXLEN(id, func)}
1887 Process a wxEVT_COMMAND_TEXT_MAXLEN command, which is generated by a wxTextCtrl control
1888 when the user tries to enter more characters into it than the limit previously set
1889 with SetMaxLength().
1890 @event{EVT_TOGGLEBUTTON(id, func)}
1891 Process a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
1892 @event{EVT_TOOL(id, func)}
1893 Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED).
1894 Pass the id of the tool.
1895 @event{EVT_TOOL_RANGE(id1, id2, func)}
1896 Process a wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. Pass the ids of the tools.
1897 @event{EVT_TOOL_RCLICKED(id, func)}
1898 Process a wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool.
1899 @event{EVT_TOOL_RCLICKED_RANGE(id1, id2, func)}
1900 Process a wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools.
1901 @event{EVT_TOOL_ENTER(id, func)}
1902 Process a wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar itself.
1903 The value of wxCommandEvent::GetSelection() is the tool id, or -1 if the mouse cursor
1904 has moved off a tool.
1905 @event{EVT_COMMAND_LEFT_CLICK(id, func)}
1906 Process a wxEVT_COMMAND_LEFT_CLICK command, which is generated by a control (wxMSW only).
1907 @event{EVT_COMMAND_LEFT_DCLICK(id, func)}
1908 Process a wxEVT_COMMAND_LEFT_DCLICK command, which is generated by a control (wxMSW only).
1909 @event{EVT_COMMAND_RIGHT_CLICK(id, func)}
1910 Process a wxEVT_COMMAND_RIGHT_CLICK command, which is generated by a control (wxMSW only).
1911 @event{EVT_COMMAND_SET_FOCUS(id, func)}
1912 Process a wxEVT_COMMAND_SET_FOCUS command, which is generated by a control (wxMSW only).
1913 @event{EVT_COMMAND_KILL_FOCUS(id, func)}
1914 Process a wxEVT_COMMAND_KILL_FOCUS command, which is generated by a control (wxMSW only).
1915 @event{EVT_COMMAND_ENTER(id, func)}
1916 Process a wxEVT_COMMAND_ENTER command, which is generated by a control.
1922 class wxCommandEvent
: public wxEvent
1928 wxCommandEvent(wxEventType commandEventType
= wxEVT_NULL
, int id
= 0);
1931 Returns client data pointer for a listbox or choice selection event
1932 (not valid for a deselection).
1934 void* GetClientData() const;
1937 Returns client object pointer for a listbox or choice selection event
1938 (not valid for a deselection).
1940 wxClientData
* GetClientObject() const;
1943 Returns extra information dependant on the event objects type.
1945 If the event comes from a listbox selection, it is a boolean
1946 determining whether the event was a selection (@true) or a
1947 deselection (@false). A listbox deselection only occurs for
1948 multiple-selection boxes, and in this case the index and string values
1949 are indeterminate and the listbox must be examined by the application.
1951 long GetExtraLong() const;
1954 Returns the integer identifier corresponding to a listbox, choice or
1955 radiobox selection (only if the event was a selection, not a deselection),
1956 or a boolean value representing the value of a checkbox.
1961 Returns item index for a listbox or choice selection event (not valid for
1964 int GetSelection() const;
1967 Returns item string for a listbox or choice selection event. If one
1968 or several items have been deselected, returns the index of the first
1969 deselected item. If some items have been selected and others deselected
1970 at the same time, it will return the index of the first selected item.
1972 wxString
GetString() const;
1975 This method can be used with checkbox and menu events: for the checkboxes, the
1976 method returns @true for a selection event and @false for a deselection one.
1977 For the menu events, this method indicates if the menu item just has become
1978 checked or unchecked (and thus only makes sense for checkable menu items).
1980 Notice that this method can not be used with wxCheckListBox currently.
1982 bool IsChecked() const;
1985 For a listbox or similar event, returns @true if it is a selection, @false
1986 if it is a deselection. If some items have been selected and others deselected
1987 at the same time, it will return @true.
1989 bool IsSelection() const;
1992 Sets the client data for this event.
1994 void SetClientData(void* clientData
);
1997 Sets the client object for this event. The client object is not owned by the
1998 event object and the event object will not delete the client object in its destructor.
2000 The client object must be owned and deleted by another object (e.g. a control)
2001 that has longer life time than the event object.
2003 void SetClientObject(wxClientData
* clientObject
);
2006 Sets the @b m_extraLong member.
2008 void SetExtraLong(long extraLong
);
2011 Sets the @b m_commandInt member.
2013 void SetInt(int intCommand
);
2016 Sets the @b m_commandString member.
2018 void SetString(const wxString
& string
);
2024 @class wxActivateEvent
2026 An activate event is sent when a window or application is being activated
2029 @beginEventTable{wxActivateEvent}
2030 @event{EVT_ACTIVATE(func)}
2031 Process a wxEVT_ACTIVATE event.
2032 @event{EVT_ACTIVATE_APP(func)}
2033 Process a wxEVT_ACTIVATE_APP event.
2034 @event{EVT_HIBERNATE(func)}
2035 Process a hibernate event, supplying the member function. This event applies
2036 to wxApp only, and only on Windows SmartPhone and PocketPC.
2037 It is generated when the system is low on memory; the application should free
2038 up as much memory as possible, and restore full working state when it receives
2039 a wxEVT_ACTIVATE or wxEVT_ACTIVATE_APP event.
2046 @see @ref overview_eventhandling, wxApp::IsActive
2048 class wxActivateEvent
: public wxEvent
2054 wxActivateEvent(wxEventType eventType
= wxEVT_NULL
, bool active
= true,
2058 Returns @true if the application or window is being activated, @false otherwise.
2060 bool GetActive() const;
2066 @class wxContextMenuEvent
2068 This class is used for context menu events, sent to give
2069 the application a chance to show a context (popup) menu.
2071 Note that if wxContextMenuEvent::GetPosition returns wxDefaultPosition, this
2072 means that the event originated from a keyboard context button event, and you
2073 should compute a suitable position yourself, for example by calling wxGetMousePosition().
2075 When a keyboard context menu button is pressed on Windows, a right-click event
2076 with default position is sent first, and if this event is not processed, the
2077 context menu event is sent. So if you process mouse events and you find your
2078 context menu event handler is not being called, you could call wxEvent::Skip()
2079 for mouse right-down events.
2081 @beginEventTable{wxContextMenuEvent}
2082 @event{EVT_CONTEXT_MENU(func)}
2083 A right click (or other context menu command depending on platform) has been detected.
2090 @see wxCommandEvent, @ref overview_eventhandling
2092 class wxContextMenuEvent
: public wxCommandEvent
2098 wxContextMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0,
2099 const wxPoint
& pos
= wxDefaultPosition
);
2102 Returns the position in screen coordinates at which the menu should be shown.
2103 Use wxWindow::ScreenToClient to convert to client coordinates.
2105 You can also omit a position from wxWindow::PopupMenu in order to use
2106 the current mouse pointer position.
2108 If the event originated from a keyboard event, the value returned from this
2109 function will be wxDefaultPosition.
2111 const wxPoint
& GetPosition() const;
2114 Sets the position at which the menu should be shown.
2116 void SetPosition(const wxPoint
& point
);
2124 An erase event is sent when a window's background needs to be repainted.
2126 On some platforms, such as GTK+, this event is simulated (simply generated just
2127 before the paint event) and may cause flicker. It is therefore recommended that
2128 you set the text background colour explicitly in order to prevent flicker.
2129 The default background colour under GTK+ is grey.
2131 To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table
2134 You must call wxEraseEvent::GetDC and use the returned device context if it is
2135 non-@NULL. If it is @NULL, create your own temporary wxClientDC object.
2138 Use the device context returned by GetDC to draw on, don't create
2139 a wxPaintDC in the event handler.
2141 @beginEventTable{wxEraseEvent}
2142 @event{EVT_ERASE_BACKGROUND(func)}
2143 Process a wxEVT_ERASE_BACKGROUND event.
2149 @see @ref overview_eventhandling
2151 class wxEraseEvent
: public wxEvent
2157 wxEraseEvent(int id
= 0, wxDC
* dc
= NULL
);
2160 Returns the device context associated with the erase event to draw on.
2162 wxDC
* GetDC() const;
2170 A focus event is sent when a window's focus changes. The window losing focus
2171 receives a "kill focus" event while the window gaining it gets a "set focus" one.
2173 Notice that the set focus event happens both when the user gives focus to the
2174 window (whether using the mouse or keyboard) and when it is done from the
2175 program itself using wxWindow::SetFocus.
2177 @beginEventTable{wxFocusEvent}
2178 @event{EVT_SET_FOCUS(func)}
2179 Process a wxEVT_SET_FOCUS event.
2180 @event{EVT_KILL_FOCUS(func)}
2181 Process a wxEVT_KILL_FOCUS event.
2187 @see @ref overview_eventhandling
2189 class wxFocusEvent
: public wxEvent
2195 wxFocusEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2198 Returns the window associated with this event, that is the window which had the
2199 focus before for the @c wxEVT_SET_FOCUS event and the window which is
2200 going to receive focus for the @c wxEVT_KILL_FOCUS one.
2202 Warning: the window pointer may be @NULL!
2204 wxWindow
*GetWindow() const;
2210 @class wxChildFocusEvent
2212 A child focus event is sent to a (parent-)window when one of its child windows
2213 gains focus, so that the window could restore the focus back to its corresponding
2214 child if it loses it now and regains later.
2216 Notice that child window is the direct child of the window receiving event.
2217 Use wxWindow::FindFocus() to retreive the window which is actually getting focus.
2219 @beginEventTable{wxChildFocusEvent}
2220 @event{EVT_CHILD_FOCUS(func)}
2221 Process a wxEVT_CHILD_FOCUS event.
2227 @see @ref overview_eventhandling
2229 class wxChildFocusEvent
: public wxCommandEvent
2236 The direct child which is (or which contains the window which is) receiving
2239 wxChildFocusEvent(wxWindow
* win
= NULL
);
2242 Returns the direct child which receives the focus, or a (grand-)parent of the
2243 control receiving the focus.
2245 To get the actually focused control use wxWindow::FindFocus.
2247 wxWindow
*GetWindow() const;
2253 @class wxMouseCaptureLostEvent
2255 An mouse capture lost event is sent to a window that obtained mouse capture,
2256 which was subsequently loss due to "external" event, for example when a dialog
2257 box is shown or if another application captures the mouse.
2259 If this happens, this event is sent to all windows that are on capture stack
2260 (i.e. called CaptureMouse, but didn't call ReleaseMouse yet). The event is
2261 not sent if the capture changes because of a call to CaptureMouse or
2264 This event is currently emitted under Windows only.
2266 @beginEventTable{wxMouseCaptureLostEvent}
2267 @event{EVT_MOUSE_CAPTURE_LOST(func)}
2268 Process a wxEVT_MOUSE_CAPTURE_LOST event.
2276 @see wxMouseCaptureChangedEvent, @ref overview_eventhandling,
2277 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2279 class wxMouseCaptureLostEvent
: public wxEvent
2285 wxMouseCaptureLostEvent(wxWindowID windowId
= 0);
2291 @class wxNotifyEvent
2293 This class is not used by the event handlers by itself, but is a base class
2294 for other event classes (such as wxBookCtrlEvent).
2296 It (or an object of a derived class) is sent when the controls state is being
2297 changed and allows the program to wxNotifyEvent::Veto() this change if it wants
2298 to prevent it from happening.
2303 @see wxBookCtrlEvent
2305 class wxNotifyEvent
: public wxCommandEvent
2309 Constructor (used internally by wxWidgets only).
2311 wxNotifyEvent(wxEventType eventType
= wxEVT_NULL
, int id
= 0);
2314 This is the opposite of Veto(): it explicitly allows the event to be processed.
2315 For most events it is not necessary to call this method as the events are allowed
2316 anyhow but some are forbidden by default (this will be mentioned in the corresponding
2322 Returns @true if the change is allowed (Veto() hasn't been called) or @false
2323 otherwise (if it was).
2325 bool IsAllowed() const;
2328 Prevents the change announced by this event from happening.
2330 It is in general a good idea to notify the user about the reasons for vetoing
2331 the change because otherwise the applications behaviour (which just refuses to
2332 do what the user wants) might be quite surprising.
2340 enum wxHelpEventOrigin
2342 wxHE_ORIGIN_UNKNOWN
= -1,
2343 wxHE_ORIGIN_KEYBOARD
,
2345 /** event generated by wxContextHelp or from the [?] button on
2346 the title bar (Windows). */
2347 wxHE_ORIGIN_HELPBUTTON
2353 A help event is sent when the user has requested context-sensitive help.
2354 This can either be caused by the application requesting context-sensitive help mode
2355 via wxContextHelp, or (on MS Windows) by the system generating a WM_HELP message when
2356 the user pressed F1 or clicked on the query button in a dialog caption.
2358 A help event is sent to the window that the user clicked on, and is propagated
2359 up the window hierarchy until the event is processed or there are no more event
2362 The application should call wxEvent::GetId to check the identity of the
2363 clicked-on window, and then either show some suitable help or call wxEvent::Skip()
2364 if the identifier is unrecognised.
2366 Calling Skip is important because it allows wxWidgets to generate further
2367 events for ancestors of the clicked-on window. Otherwise it would be impossible to
2368 show help for container windows, since processing would stop after the first window
2371 @beginEventTable{wxHelpEvent}
2372 @event{EVT_HELP(id, func)}
2373 Process a wxEVT_HELP event.
2374 @event{EVT_HELP_RANGE(id1, id2, func)}
2375 Process a wxEVT_HELP event for a range of ids.
2381 @see wxContextHelp, wxDialog, @ref overview_eventhandling
2383 class wxHelpEvent
: public wxCommandEvent
2387 Indicates how a wxHelpEvent was generated.
2391 Origin_Unknown
, /**< unrecognized event source. */
2392 Origin_Keyboard
, /**< event generated from F1 key press. */
2394 /** event generated by wxContextHelp or from the [?] button on
2395 the title bar (Windows). */
2402 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
2403 wxWindowID winid
= 0,
2404 const wxPoint
& pt
= wxDefaultPosition
,
2405 wxHelpEvent::Origin origin
= Origin_Unknown
);
2408 Returns the origin of the help event which is one of the ::wxHelpEventOrigin
2411 The application may handle events generated using the keyboard or mouse
2412 differently, e.g. by using wxGetMousePosition() for the mouse events.
2416 wxHelpEvent::Origin
GetOrigin() const;
2419 Returns the left-click position of the mouse, in screen coordinates.
2420 This allows the application to position the help appropriately.
2422 const wxPoint
& GetPosition() const;
2425 Set the help event origin, only used internally by wxWidgets normally.
2429 void SetOrigin(wxHelpEvent::Origin origin
);
2432 Sets the left-click position of the mouse, in screen coordinates.
2434 void SetPosition(const wxPoint
& pt
);
2440 @class wxScrollEvent
2442 A scroll event holds information about events sent from stand-alone
2443 scrollbars (see wxScrollBar) and sliders (see wxSlider).
2445 Note that scrolled windows send the wxScrollWinEvent which does not derive from
2446 wxCommandEvent, but from wxEvent directly - don't confuse these two kinds of
2447 events and use the event table macros mentioned below only for the scrollbar-like
2450 @section scrollevent_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
2452 The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb
2453 using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed
2454 by an EVT_SCROLL_CHANGED event).
2456 The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change the thumb
2457 position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE
2458 event does not happen).
2460 In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving has finished
2461 independently of the way it had started. Please see the widgets sample ("Slider" page)
2462 to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
2465 Note that unless specifying a scroll control identifier, you will need to test for scrollbar
2466 orientation with wxScrollEvent::GetOrientation, since horizontal and vertical scroll events
2467 are processed using the same event handler.
2469 @beginEventTable{wxScrollEvent}
2470 You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
2471 scroll events from controls, or EVT_SCROLL... macros without window IDs for
2472 intercepting scroll events from the receiving window -- except for this, the
2473 macros behave exactly the same.
2474 @event{EVT_SCROLL(func)}
2475 Process all scroll events.
2476 @event{EVT_SCROLL_TOP(func)}
2477 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2478 @event{EVT_SCROLL_BOTTOM(func)}
2479 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2480 @event{EVT_SCROLL_LINEUP(func)}
2481 Process wxEVT_SCROLL_LINEUP line up events.
2482 @event{EVT_SCROLL_LINEDOWN(func)}
2483 Process wxEVT_SCROLL_LINEDOWN line down events.
2484 @event{EVT_SCROLL_PAGEUP(func)}
2485 Process wxEVT_SCROLL_PAGEUP page up events.
2486 @event{EVT_SCROLL_PAGEDOWN(func)}
2487 Process wxEVT_SCROLL_PAGEDOWN page down events.
2488 @event{EVT_SCROLL_THUMBTRACK(func)}
2489 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the
2490 user drags the thumbtrack).
2491 @event{EVT_SCROLL_THUMBRELEASE(func)}
2492 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2493 @event{EVT_SCROLL_CHANGED(func)}
2494 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2495 @event{EVT_COMMAND_SCROLL(id, func)}
2496 Process all scroll events.
2497 @event{EVT_COMMAND_SCROLL_TOP(id, func)}
2498 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
2499 @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
2500 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
2501 @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
2502 Process wxEVT_SCROLL_LINEUP line up events.
2503 @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
2504 Process wxEVT_SCROLL_LINEDOWN line down events.
2505 @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
2506 Process wxEVT_SCROLL_PAGEUP page up events.
2507 @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
2508 Process wxEVT_SCROLL_PAGEDOWN page down events.
2509 @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
2510 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent
2511 as the user drags the thumbtrack).
2512 @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
2513 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
2514 @event{EVT_COMMAND_SCROLL_CHANGED(func)}
2515 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
2521 @see wxScrollBar, wxSlider, wxSpinButton, wxScrollWinEvent, @ref overview_eventhandling
2523 class wxScrollEvent
: public wxCommandEvent
2529 wxScrollEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0, int pos
= 0,
2530 int orientation
= 0);
2533 Returns wxHORIZONTAL or wxVERTICAL, depending on the orientation of the
2536 int GetOrientation() const;
2539 Returns the position of the scrollbar.
2541 int GetPosition() const;
2545 See wxIdleEvent::SetMode() for more info.
2549 /** Send idle events to all windows */
2552 /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */
2553 wxIDLE_PROCESS_SPECIFIED
2560 This class is used for idle events, which are generated when the system becomes
2561 idle. Note that, unless you do something specifically, the idle events are not
2562 sent if the system remains idle once it has become it, e.g. only a single idle
2563 event will be generated until something else resulting in more normal events
2564 happens and only then is the next idle event sent again.
2566 If you need to ensure a continuous stream of idle events, you can either use
2567 wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically
2568 (for example from a timer event handler), but note that both of these approaches
2569 (and especially the first one) increase the system load and so should be avoided
2572 By default, idle events are sent to all windows (and also wxApp, as usual).
2573 If this is causing a significant overhead in your application, you can call
2574 wxIdleEvent::SetMode with the value wxIDLE_PROCESS_SPECIFIED, and set the
2575 wxWS_EX_PROCESS_IDLE extra window style for every window which should receive
2578 @beginEventTable{wxIdleEvent}
2579 @event{EVT_IDLE(func)}
2580 Process a wxEVT_IDLE event.
2586 @see @ref overview_eventhandling, wxUpdateUIEvent, wxWindow::OnInternalIdle
2588 class wxIdleEvent
: public wxEvent
2597 Returns @true if it is appropriate to send idle events to this window.
2599 This function looks at the mode used (see wxIdleEvent::SetMode),
2600 and the wxWS_EX_PROCESS_IDLE style in @a window to determine whether idle
2601 events should be sent to this window now.
2603 By default this will always return @true because the update mode is initially
2604 wxIDLE_PROCESS_ALL. You can change the mode to only send idle events to
2605 windows with the wxWS_EX_PROCESS_IDLE extra window style set.
2609 static bool CanSend(wxWindow
* window
);
2612 Static function returning a value specifying how wxWidgets will send idle
2613 events: to all windows, or only to those which specify that they
2614 will process the events.
2618 static wxIdleMode
GetMode();
2621 Returns @true if the OnIdle function processing this event requested more
2626 bool MoreRequested() const;
2629 Tells wxWidgets that more processing is required.
2631 This function can be called by an OnIdle handler for a window or window event
2632 handler to indicate that wxApp::OnIdle should forward the OnIdle event once
2633 more to the application windows.
2635 If no window calls this function during OnIdle, then the application will
2636 remain in a passive event loop (not calling OnIdle) until a new event is
2637 posted to the application by the windowing system.
2639 @see MoreRequested()
2641 void RequestMore(bool needMore
= true);
2644 Static function for specifying how wxWidgets will send idle events: to
2645 all windows, or only to those which specify that they will process the events.
2648 Can be one of the ::wxIdleMode values.
2649 The default is wxIDLE_PROCESS_ALL.
2651 static void SetMode(wxIdleMode mode
);
2657 @class wxInitDialogEvent
2659 A wxInitDialogEvent is sent as a dialog or panel is being initialised.
2660 Handlers for this event can transfer data to the window.
2662 The default handler calls wxWindow::TransferDataToWindow.
2664 @beginEventTable{wxInitDialogEvent}
2665 @event{EVT_INIT_DIALOG(func)}
2666 Process a wxEVT_INIT_DIALOG event.
2672 @see @ref overview_eventhandling
2674 class wxInitDialogEvent
: public wxEvent
2680 wxInitDialogEvent(int id
= 0);
2686 @class wxWindowDestroyEvent
2688 This event is sent from the wxWindow destructor wxWindow::~wxWindow() when a
2689 window is destroyed.
2691 When a class derived from wxWindow is destroyed its destructor will have
2692 already run by the time this event is sent. Therefore this event will not
2693 usually be received at all.
2695 To receive this event wxEvtHandler::Connect() must be used (using an event
2696 table macro will not work). Since it is received after the destructor has run,
2697 an object should not handle its own wxWindowDestroyEvent, but it can be used
2698 to get notification of the destruction of another window.
2703 @see @ref overview_eventhandling, wxWindowCreateEvent
2705 class wxWindowDestroyEvent
: public wxCommandEvent
2711 wxWindowDestroyEvent(wxWindow
* win
= NULL
);
2716 The possible flag values for a wxNavigationKeyEvent.
2718 enum wxNavigationKeyEventFlags
2720 wxNKEF_IS_BACKWARD
= 0x0000,
2721 wxNKEF_IS_FORWARD
= 0x0001,
2722 wxNKEF_WINCHANGE
= 0x0002,
2723 wxNKEF_FROMTAB
= 0x0004
2728 @class wxNavigationKeyEvent
2730 This event class contains information about navigation events,
2731 generated by navigation keys such as tab and page down.
2733 This event is mainly used by wxWidgets implementations.
2734 A wxNavigationKeyEvent handler is automatically provided by wxWidgets
2735 when you make a class into a control container with the macro
2736 WX_DECLARE_CONTROL_CONTAINER.
2738 @beginEventTable{wxNavigationKeyEvent}
2739 @event{EVT_NAVIGATION_KEY(func)}
2740 Process a navigation key event.
2746 @see wxWindow::Navigate, wxWindow::NavigateIn
2748 class wxNavigationKeyEvent
: public wxEvent
2751 wxNavigationKeyEvent();
2752 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
);
2755 Returns the child that has the focus, or @NULL.
2757 wxWindow
* GetCurrentFocus() const;
2760 Returns @true if the navigation was in the forward direction.
2762 bool GetDirection() const;
2765 Returns @true if the navigation event was from a tab key.
2766 This is required for proper navigation over radio buttons.
2768 bool IsFromTab() const;
2771 Returns @true if the navigation event represents a window change
2772 (for example, from Ctrl-Page Down in a notebook).
2774 bool IsWindowChange() const;
2777 Sets the current focus window member.
2779 void SetCurrentFocus(wxWindow
* currentFocus
);
2782 Sets the direction to forward if @a direction is @true, or backward
2785 void SetDirection(bool direction
);
2788 Sets the flags for this event.
2789 The @a flags can be a combination of the ::wxNavigationKeyEventFlags values.
2791 void SetFlags(long flags
);
2794 Marks the navigation event as from a tab key.
2796 void SetFromTab(bool fromTab
);
2799 Marks the event as a window change event.
2801 void SetWindowChange(bool windowChange
);
2807 @class wxMouseCaptureChangedEvent
2809 An mouse capture changed event is sent to a window that loses its
2810 mouse capture. This is called even if wxWindow::ReleaseCapture
2811 was called by the application code. Handling this event allows
2812 an application to cater for unexpected capture releases which
2813 might otherwise confuse mouse handling code.
2817 @beginEventTable{wxMouseCaptureChangedEvent}
2818 @event{EVT_MOUSE_CAPTURE_CHANGED(func)}
2819 Process a wxEVT_MOUSE_CAPTURE_CHANGED event.
2825 @see wxMouseCaptureLostEvent, @ref overview_eventhandling,
2826 wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxWindow::GetCapture
2828 class wxMouseCaptureChangedEvent
: public wxEvent
2834 wxMouseCaptureChangedEvent(wxWindowID windowId
= 0,
2835 wxWindow
* gainedCapture
= NULL
);
2838 Returns the window that gained the capture, or @NULL if it was a
2839 non-wxWidgets window.
2841 wxWindow
* GetCapturedWindow() const;
2849 This event class contains information about window and session close events.
2851 The handler function for EVT_CLOSE is called when the user has tried to close a
2852 a frame or dialog box using the window manager (X) or system menu (Windows).
2853 It can also be invoked by the application itself programmatically, for example by
2854 calling the wxWindow::Close function.
2856 You should check whether the application is forcing the deletion of the window
2857 using wxCloseEvent::CanVeto. If this is @false, you @e must destroy the window
2858 using wxWindow::Destroy.
2860 If the return value is @true, it is up to you whether you respond by destroying
2863 If you don't destroy the window, you should call wxCloseEvent::Veto to
2864 let the calling code know that you did not destroy the window.
2865 This allows the wxWindow::Close function to return @true or @false depending
2866 on whether the close instruction was honoured or not.
2868 Example of a wxCloseEvent handler:
2871 void MyFrame::OnClose(wxCloseEvent& event)
2873 if ( event.CanVeto() && m_bFileNotSaved )
2875 if ( wxMessageBox("The file has not been saved... continue closing?",
2877 wxICON_QUESTION | wxYES_NO) != wxYES )
2884 Destroy(); // you may also do: event.Skip();
2885 // since the default event handler does call Destroy(), too
2889 The EVT_END_SESSION event is slightly different as it is sent by the system
2890 when the user session is ending (e.g. because of log out or shutdown) and
2891 so all windows are being forcefully closed. At least under MSW, after the
2892 handler for this event is executed the program is simply killed by the
2893 system. Because of this, the default handler for this event provided by
2894 wxWidgets calls all the usual cleanup code (including wxApp::OnExit()) so
2895 that it could still be executed and exit()s the process itself, without
2896 waiting for being killed. If this behaviour is for some reason undesirable,
2897 make sure that you define a handler for this event in your wxApp-derived
2898 class and do not call @c event.Skip() in it (but be aware that the system
2899 will still kill your application).
2901 @beginEventTable{wxCloseEvent}
2902 @event{EVT_CLOSE(func)}
2903 Process a close event, supplying the member function.
2904 This event applies to wxFrame and wxDialog classes.
2905 @event{EVT_QUERY_END_SESSION(func)}
2906 Process a query end session event, supplying the member function.
2907 This event can be handled in wxApp-derived class only.
2908 @event{EVT_END_SESSION(func)}
2909 Process an end session event, supplying the member function.
2910 This event can be handled in wxApp-derived class only.
2916 @see wxWindow::Close, @ref overview_windowdeletion
2918 class wxCloseEvent
: public wxEvent
2924 wxCloseEvent(wxEventType commandEventType
= wxEVT_NULL
, int id
= 0);
2927 Returns @true if you can veto a system shutdown or a window close event.
2928 Vetoing a window close event is not possible if the calling code wishes to
2929 force the application to exit, and so this function must be called to check this.
2931 bool CanVeto() const;
2934 Returns @true if the user is just logging off or @false if the system is
2935 shutting down. This method can only be called for end session and query end
2936 session events, it doesn't make sense for close window event.
2938 bool GetLoggingOff() const;
2941 Sets the 'can veto' flag.
2943 void SetCanVeto(bool canVeto
);
2946 Sets the 'logging off' flag.
2948 void SetLoggingOff(bool loggingOff
);
2951 Call this from your event handler to veto a system shutdown or to signal
2952 to the calling application that a window close did not happen.
2954 You can only veto a shutdown if CanVeto() returns @true.
2956 void Veto(bool veto
= true);
2964 This class is used for a variety of menu-related events. Note that
2965 these do not include menu command events, which are
2966 handled using wxCommandEvent objects.
2968 The default handler for wxEVT_MENU_HIGHLIGHT displays help
2969 text in the first field of the status bar.
2971 @beginEventTable{wxMenuEvent}
2972 @event{EVT_MENU_OPEN(func)}
2973 A menu is about to be opened. On Windows, this is only sent once for each
2974 navigation of the menubar (up until all menus have closed).
2975 @event{EVT_MENU_CLOSE(func)}
2976 A menu has been just closed.
2977 @event{EVT_MENU_HIGHLIGHT(id, func)}
2978 The menu item with the specified id has been highlighted: used to show
2979 help prompts in the status bar by wxFrame
2980 @event{EVT_MENU_HIGHLIGHT_ALL(func)}
2981 A menu item has been highlighted, i.e. the currently selected menu item has changed.
2987 @see wxCommandEvent, @ref overview_eventhandling
2989 class wxMenuEvent
: public wxEvent
2995 wxMenuEvent(wxEventType id
= wxEVT_NULL
, int id
= 0, wxMenu
* menu
= NULL
);
2998 Returns the menu which is being opened or closed. This method should only be
2999 used with the @c OPEN and @c CLOSE events and even for them the
3000 returned pointer may be @NULL in some ports.
3002 wxMenu
* GetMenu() const;
3005 Returns the menu identifier associated with the event.
3006 This method should be only used with the @c HIGHLIGHT events.
3008 int GetMenuId() const;
3011 Returns @true if the menu which is being opened or closed is a popup menu,
3012 @false if it is a normal one.
3014 This method should only be used with the @c OPEN and @c CLOSE events.
3016 bool IsPopup() const;
3022 An event being sent when the window is shown or hidden.
3024 Currently only wxMSW, wxGTK and wxOS2 generate such events.
3026 @onlyfor{wxmsw,wxgtk,wxos2}
3028 @beginEventTable{wxShowEvent}
3029 @event{EVT_SHOW(func)}
3030 Process a wxEVT_SHOW event.
3036 @see @ref overview_eventhandling, wxWindow::Show,
3040 class wxShowEvent
: public wxEvent
3046 wxShowEvent(int winid
= 0, bool show
= false);
3049 Set whether the windows was shown or hidden.
3051 void SetShow(bool show
);
3054 Return @true if the window has been shown, @false if it has been
3057 bool IsShown() const;
3060 @deprecated This function is deprecated in favour of IsShown().
3062 bool GetShow() const;
3068 @class wxIconizeEvent
3070 An event being sent when the frame is iconized (minimized) or restored.
3072 Currently only wxMSW and wxGTK generate such events.
3074 @onlyfor{wxmsw,wxgtk}
3076 @beginEventTable{wxIconizeEvent}
3077 @event{EVT_ICONIZE(func)}
3078 Process a wxEVT_ICONIZE event.
3084 @see @ref overview_eventhandling, wxTopLevelWindow::Iconize,
3085 wxTopLevelWindow::IsIconized
3087 class wxIconizeEvent
: public wxEvent
3093 wxIconizeEvent(int id
= 0, bool iconized
= true);
3096 Returns @true if the frame has been iconized, @false if it has been
3099 bool IsIconized() const;
3102 @deprecated This function is deprecated in favour of IsIconized().
3104 bool Iconized() const;
3112 A move event holds information about move change events.
3114 @beginEventTable{wxMoveEvent}
3115 @event{EVT_MOVE(func)}
3116 Process a wxEVT_MOVE event, which is generated when a window is moved.
3117 @event{EVT_MOVE_START(func)}
3118 Process a wxEVT_MOVE_START event, which is generated when the user starts
3119 to move or size a window. wxMSW only.
3120 @event{EVT_MOVE_END(func)}
3121 Process a wxEVT_MOVE_END event, which is generated when the user stops
3122 moving or sizing a window. wxMSW only.
3128 @see wxPoint, @ref overview_eventhandling
3130 class wxMoveEvent
: public wxEvent
3136 wxMoveEvent(const wxPoint
& pt
, int id
= 0);
3139 Returns the position of the window generating the move change event.
3141 wxPoint
GetPosition() const;
3148 A size event holds information about size change events.
3150 The EVT_SIZE handler function will be called when the window has been resized.
3152 You may wish to use this for frames to resize their child windows as appropriate.
3154 Note that the size passed is of the whole window: call wxWindow::GetClientSize
3155 for the area which may be used by the application.
3157 When a window is resized, usually only a small part of the window is damaged
3158 and you may only need to repaint that area. However, if your drawing depends on the
3159 size of the window, you may need to clear the DC explicitly and repaint the whole window.
3160 In which case, you may need to call wxWindow::Refresh to invalidate the entire window.
3162 @beginEventTable{wxSizeEvent}
3163 @event{EVT_SIZE(func)}
3164 Process a wxEVT_SIZE event.
3170 @see wxSize, @ref overview_eventhandling
3172 class wxSizeEvent
: public wxEvent
3178 wxSizeEvent(const wxSize
& sz
, int id
= 0);
3181 Returns the entire size of the window generating the size change event.
3183 wxSize
GetSize() const;
3189 @class wxSetCursorEvent
3191 A wxSetCursorEvent is generated when the mouse cursor is about to be set as a
3192 result of mouse motion.
3194 This event gives the application the chance to perform specific mouse cursor
3195 processing based on the current position of the mouse within the window.
3196 Use wxSetCursorEvent::SetCursor to specify the cursor you want to be displayed.
3198 @beginEventTable{wxSetCursorEvent}
3199 @event{EVT_SET_CURSOR(func)}
3200 Process a wxEVT_SET_CURSOR event.
3206 @see ::wxSetCursor, wxWindow::wxSetCursor
3208 class wxSetCursorEvent
: public wxEvent
3212 Constructor, used by the library itself internally to initialize the event
3215 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0);
3218 Returns a reference to the cursor specified by this event.
3220 const wxCursor
& GetCursor() const;
3223 Returns the X coordinate of the mouse in client coordinates.
3225 wxCoord
GetX() const;
3228 Returns the Y coordinate of the mouse in client coordinates.
3230 wxCoord
GetY() const;
3233 Returns @true if the cursor specified by this event is a valid cursor.
3235 @remarks You cannot specify wxNullCursor with this event, as it is not
3236 considered a valid cursor.
3238 bool HasCursor() const;
3241 Sets the cursor associated with this event.
3243 void SetCursor(const wxCursor
& cursor
);
3248 // ============================================================================
3249 // Global functions/macros
3250 // ============================================================================
3252 /** @ingroup group_funcmacro_misc */
3256 In a GUI application, this function posts @a event to the specified @e dest
3257 object using wxEvtHandler::AddPendingEvent().
3259 Otherwise, it dispatches @a event immediately using
3260 wxEvtHandler::ProcessEvent(). See the respective documentation for details
3261 (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent()
3262 this function is not thread-safe for event objects having wxString fields,
3263 use wxQueueEvent() instead.
3267 void wxPostEvent(wxEvtHandler
* dest
, const wxEvent
& event
);
3270 Queue an event for processing on the given object.
3272 This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation
3278 The object to queue the event on, can't be @c NULL.
3280 The heap-allocated and non-@c NULL event to queue, the function takes
3283 void wxQueueEvent(wxEvtHandler
* dest
, wxEvent
*event
);