]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/event_base.h
Compare file paths using wxFileName, not wxString, in the sample.
[wxWidgets.git] / interface / wx / event_base.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: interface/wx/event_base.h
3 // Purpose: Documentation of wxEvtHandler, wxEvent, wxIdleEvent and other
4 // non-GUI event-related classes declared in include/wx/event.h
5 // (see interface/wx/event.h for the GUI event classes)
6 // Author: wxWidgets team
7 // RCS-ID: $Id$
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 /**
12 The predefined constants for the number of times we propagate event
13 upwards window child-parent chain.
14 */
15 enum wxEventPropagation
16 {
17 /// don't propagate it at all
18 wxEVENT_PROPAGATE_NONE = 0,
19
20 /// propagate it until it is processed
21 wxEVENT_PROPAGATE_MAX = INT_MAX
22 };
23
24 /**
25 The different categories for a wxEvent; see wxEvent::GetEventCategory.
26
27 @note They are used as OR-combinable flags by wxEventLoopBase::YieldFor.
28 */
29 enum wxEventCategory
30 {
31 /**
32 This is the category for those events which are generated to update
33 the appearance of the GUI but which (usually) do not comport data
34 processing, i.e. which do not provide input or output data
35 (e.g. size events, scroll events, etc).
36 They are events NOT directly generated by the user's input devices.
37 */
38 wxEVT_CATEGORY_UI = 1,
39
40 /**
41 This category groups those events which are generated directly from the
42 user through input devices like mouse and keyboard and usually result in
43 data to be processed from the application
44 (e.g. mouse clicks, key presses, etc).
45 */
46 wxEVT_CATEGORY_USER_INPUT = 2,
47
48 /// This category is for wxSocketEvent
49 wxEVT_CATEGORY_SOCKET = 4,
50
51 /// This category is for wxTimerEvent
52 wxEVT_CATEGORY_TIMER = 8,
53
54 /**
55 This category is for any event used to send notifications from the
56 secondary threads to the main one or in general for notifications among
57 different threads (which may or may not be user-generated).
58 See e.g. wxThreadEvent.
59 */
60 wxEVT_CATEGORY_THREAD = 16,
61
62 /**
63 This mask is used in wxEventLoopBase::YieldFor to specify that all event
64 categories should be processed.
65 */
66 wxEVT_CATEGORY_ALL =
67 wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \
68 wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD
69 };
70
71 /**
72 @class wxEvent
73
74 An event is a structure holding information about an event passed to a
75 callback or member function.
76
77 wxEvent used to be a multipurpose event object, and is an abstract base class
78 for other event classes (see below).
79
80 For more information about events, see the @ref overview_events overview.
81
82 @beginWxPerlOnly
83 In wxPerl custom event classes should be derived from
84 @c Wx::PlEvent and @c Wx::PlCommandEvent.
85 @endWxPerlOnly
86
87 @library{wxbase}
88 @category{events}
89 @header{wx/event.h}
90
91 @see wxCommandEvent, wxMouseEvent
92 */
93 class wxEvent : public wxObject
94 {
95 public:
96 /**
97 Constructor.
98
99 Notice that events are usually created by wxWidgets itself and creating
100 e.g. a wxPaintEvent in your code and sending it to e.g. a wxTextCtrl
101 will not usually affect it at all as native controls have no specific
102 knowledge about wxWidgets events. However you may construct objects of
103 specific types and pass them to wxEvtHandler::ProcessEvent() if you
104 want to create your own custom control and want to process its events
105 in the same manner as the standard ones.
106
107 Also please notice that the order of parameters in this constructor is
108 different from almost all the derived classes which specify the event
109 type as the first argument.
110
111 @param id
112 The identifier of the object (window, timer, ...) which generated
113 this event.
114 @param eventType
115 The unique type of event, e.g. @c wxEVT_PAINT, @c wxEVT_SIZE or
116 @c wxEVT_COMMAND_BUTTON_CLICKED.
117 */
118 wxEvent(int id = 0, wxEventType eventType = wxEVT_NULL);
119
120 /**
121 Returns a copy of the event.
122
123 Any event that is posted to the wxWidgets event system for later action
124 (via wxEvtHandler::AddPendingEvent, wxEvtHandler::QueueEvent or wxPostEvent())
125 must implement this method.
126
127 All wxWidgets events fully implement this method, but any derived events
128 implemented by the user should also implement this method just in case they
129 (or some event derived from them) are ever posted.
130
131 All wxWidgets events implement a copy constructor, so the easiest way of
132 implementing the Clone function is to implement a copy constructor for
133 a new event (call it MyEvent) and then define the Clone function like this:
134
135 @code
136 wxEvent *Clone() const { return new MyEvent(*this); }
137 @endcode
138 */
139 virtual wxEvent* Clone() const = 0;
140
141 /**
142 Returns the object (usually a window) associated with the event, if any.
143 */
144 wxObject* GetEventObject() const;
145
146 /**
147 Returns the identifier of the given event type, such as @c wxEVT_COMMAND_BUTTON_CLICKED.
148 */
149 wxEventType GetEventType() const;
150
151 /**
152 Returns a generic category for this event.
153 wxEvent implementation returns @c wxEVT_CATEGORY_UI by default.
154
155 This function is used to selectively process events in wxEventLoopBase::YieldFor.
156 */
157 virtual wxEventCategory GetEventCategory() const;
158
159 /**
160 Returns the identifier associated with this event, such as a button command id.
161 */
162 int GetId() const;
163
164 /**
165 Return the user data associated with a dynamically connected event handler.
166
167 wxEvtHandler::Connect() and wxEvtHandler::Bind() allow associating
168 optional @c userData pointer with the handler and this method returns
169 the value of this pointer.
170
171 The returned pointer is owned by wxWidgets and must not be deleted.
172
173 @since 2.9.5
174 */
175 wxObject *GetEventUserData() const;
176
177 /**
178 Returns @true if the event handler should be skipped, @false otherwise.
179 */
180 bool GetSkipped() const;
181
182 /**
183 Gets the timestamp for the event. The timestamp is the time in milliseconds
184 since some fixed moment (not necessarily the standard Unix Epoch, so only
185 differences between the timestamps and not their absolute values usually make sense).
186
187 @warning
188 wxWidgets returns a non-NULL timestamp only for mouse and key events
189 (see wxMouseEvent and wxKeyEvent).
190 */
191 long GetTimestamp() const;
192
193 /**
194 Returns @true if the event is or is derived from wxCommandEvent else it returns @false.
195
196 @note exists only for optimization purposes.
197 */
198 bool IsCommandEvent() const;
199
200 /**
201 Sets the propagation level to the given value (for example returned from an
202 earlier call to wxEvent::StopPropagation).
203 */
204 void ResumePropagation(int propagationLevel);
205
206 /**
207 Sets the originating object.
208 */
209 void SetEventObject(wxObject* object);
210
211 /**
212 Sets the event type.
213 */
214 void SetEventType(wxEventType type);
215
216 /**
217 Sets the identifier associated with this event, such as a button command id.
218 */
219 void SetId(int id);
220
221 /**
222 Sets the timestamp for the event.
223 */
224 void SetTimestamp(long timeStamp = 0);
225
226 /**
227 Test if this event should be propagated or not, i.e. if the propagation level
228 is currently greater than 0.
229 */
230 bool ShouldPropagate() const;
231
232 /**
233 This method can be used inside an event handler to control whether further
234 event handlers bound to this event will be called after the current one returns.
235
236 Without Skip() (or equivalently if Skip(@false) is used), the event will not
237 be processed any more. If Skip(@true) is called, the event processing system
238 continues searching for a further handler function for this event, even though
239 it has been processed already in the current handler.
240
241 In general, it is recommended to skip all non-command events to allow the
242 default handling to take place. The command events are, however, normally not
243 skipped as usually a single command such as a button click or menu item
244 selection must only be processed by one handler.
245 */
246 void Skip(bool skip = true);
247
248 /**
249 Stop the event from propagating to its parent window.
250
251 Returns the old propagation level value which may be later passed to
252 ResumePropagation() to allow propagating the event again.
253 */
254 int StopPropagation();
255
256 protected:
257 /**
258 Indicates how many levels the event can propagate.
259
260 This member is protected and should typically only be set in the constructors
261 of the derived classes. It may be temporarily changed by StopPropagation()
262 and ResumePropagation() and tested with ShouldPropagate().
263
264 The initial value is set to either @c wxEVENT_PROPAGATE_NONE (by default)
265 meaning that the event shouldn't be propagated at all or to
266 @c wxEVENT_PROPAGATE_MAX (for command events) meaning that it should be
267 propagated as much as necessary.
268
269 Any positive number means that the event should be propagated but no more than
270 the given number of times. E.g. the propagation level may be set to 1 to
271 propagate the event to its parent only, but not to its grandparent.
272 */
273 int m_propagationLevel;
274 };
275
276
277
278
279 /**
280 @class wxEvtHandler
281
282 A class that can handle events from the windowing system.
283 wxWindow is (and therefore all window classes are) derived from this class.
284
285 When events are received, wxEvtHandler invokes the method listed in the
286 event table using itself as the object. When using multiple inheritance
287 <b>it is imperative that the wxEvtHandler(-derived) class is the first
288 class inherited</b> such that the @c this pointer for the overall object
289 will be identical to the @c this pointer of the wxEvtHandler portion.
290
291 @library{wxbase}
292 @category{events}
293 @header{wx/event.h}
294
295 @see @ref overview_events_processing, wxEventBlocker, wxEventLoopBase
296 */
297 class wxEvtHandler : public wxObject, public wxTrackable
298 {
299 public:
300 /**
301 Constructor.
302 */
303 wxEvtHandler();
304
305 /**
306 Destructor.
307
308 If the handler is part of a chain, the destructor will unlink itself
309 (see Unlink()).
310 */
311 virtual ~wxEvtHandler();
312
313
314 /**
315 @name Event queuing and processing
316 */
317 //@{
318
319 /**
320 Queue event for a later processing.
321
322 This method is similar to ProcessEvent() but while the latter is
323 synchronous, i.e. the event is processed immediately, before the
324 function returns, this one is asynchronous and returns immediately
325 while the event will be processed at some later time (usually during
326 the next event loop iteration).
327
328 Another important difference is that this method takes ownership of the
329 @a event parameter, i.e. it will delete it itself. This implies that
330 the event should be allocated on the heap and that the pointer can't be
331 used any more after the function returns (as it can be deleted at any
332 moment).
333
334 QueueEvent() can be used for inter-thread communication from the worker
335 threads to the main thread, it is safe in the sense that it uses
336 locking internally and avoids the problem mentioned in AddPendingEvent()
337 documentation by ensuring that the @a event object is not used by the
338 calling thread any more. Care should still be taken to avoid that some
339 fields of this object are used by it, notably any wxString members of
340 the event object must not be shallow copies of another wxString object
341 as this would result in them still using the same string buffer behind
342 the scenes. For example:
343 @code
344 void FunctionInAWorkerThread(const wxString& str)
345 {
346 wxCommandEvent* evt = new wxCommandEvent;
347
348 // NOT evt->SetString(str) as this would be a shallow copy
349 evt->SetString(str.c_str()); // make a deep copy
350
351 wxTheApp->QueueEvent( evt );
352 }
353 @endcode
354
355 Note that you can use wxThreadEvent instead of wxCommandEvent
356 to avoid this problem:
357 @code
358 void FunctionInAWorkerThread(const wxString& str)
359 {
360 wxThreadEvent evt;
361 evt->SetString(str);
362
363 // wxThreadEvent::Clone() makes sure that the internal wxString
364 // member is not shared by other wxString instances:
365 wxTheApp->QueueEvent( evt.Clone() );
366 }
367 @endcode
368
369 Finally notice that this method automatically wakes up the event loop
370 if it is currently idle by calling ::wxWakeUpIdle() so there is no need
371 to do it manually when using it.
372
373 @since 2.9.0
374
375 @param event
376 A heap-allocated event to be queued, QueueEvent() takes ownership
377 of it. This parameter shouldn't be @c NULL.
378 */
379 virtual void QueueEvent(wxEvent *event);
380
381 /**
382 Post an event to be processed later.
383
384 This function is similar to QueueEvent() but can't be used to post
385 events from worker threads for the event objects with wxString fields
386 (i.e. in practice most of them) because of an unsafe use of the same
387 wxString object which happens because the wxString field in the
388 original @a event object and its copy made internally by this function
389 share the same string buffer internally. Use QueueEvent() to avoid
390 this.
391
392 A copy of @a event is made by the function, so the original can be deleted
393 as soon as function returns (it is common that the original is created
394 on the stack). This requires that the wxEvent::Clone() method be
395 implemented by event so that it can be duplicated and stored until it
396 gets processed.
397
398 @param event
399 Event to add to the pending events queue.
400 */
401 virtual void AddPendingEvent(const wxEvent& event);
402
403 /**
404 Asynchronously call the given method.
405
406 Calling this function on an object schedules an asynchronous call to
407 the method specified as CallAfter() argument at a (slightly) later
408 time. This is useful when processing some events as certain actions
409 typically can't be performed inside their handlers, e.g. you shouldn't
410 show a modal dialog from a mouse click event handler as this would
411 break the mouse capture state -- but you can call a method showing
412 this message dialog after the current event handler completes.
413
414 The method being called must be the method of the object on which
415 CallAfter() itself is called.
416
417 Notice that it is safe to use CallAfter() from other, non-GUI,
418 threads, but that the method will be always called in the main, GUI,
419 thread context.
420
421 Example of use:
422 @code
423 class MyFrame : public wxFrame {
424 void OnClick(wxMouseEvent& event) {
425 CallAfter(&MyFrame::ShowPosition, event.GetPosition());
426 }
427
428 void ShowPosition(const wxPoint& pos) {
429 if ( wxMessageBox(
430 wxString::Format("Perform click at (%d, %d)?",
431 pos.x, pos.y), "", wxYES_NO) == wxYES )
432 {
433 ... do take this click into account ...
434 }
435 }
436 };
437 @endcode
438
439 @param method The method to call.
440 @param x1 The (optional) first parameter to pass to the method.
441 @param x2 The (optional) second parameter to pass to the method.
442
443 Note that currently only up to 2 arguments can be passed.
444
445 @note This method is not available with Visual C++ 6 which doesn't
446 have the required support for C++ templates to implement it.
447
448 @since 2.9.5
449 */
450 template<typename T, typename T1, ...>
451 void CallAfter(void (T::*method)(T1, ...), T1 x1, ...);
452
453 /**
454 Processes an event, searching event tables and calling zero or more suitable
455 event handler function(s).
456
457 Normally, your application would not call this function: it is called in the
458 wxWidgets implementation to dispatch incoming user interface events to the
459 framework (and application).
460
461 However, you might need to call it if implementing new functionality
462 (such as a new control) where you define new event types, as opposed to
463 allowing the user to override virtual functions.
464
465 Notice that you don't usually need to override ProcessEvent() to
466 customize the event handling, overriding the specially provided
467 TryBefore() and TryAfter() functions is usually enough. For example,
468 wxMDIParentFrame may override TryBefore() to ensure that the menu
469 events are processed in the active child frame before being processed
470 in the parent frame itself.
471
472 The normal order of event table searching is as follows:
473 -# wxApp::FilterEvent() is called. If it returns anything but @c -1
474 (default) the processing stops here.
475 -# TryBefore() is called (this is where wxValidator are taken into
476 account for wxWindow objects). If this returns @true, the function exits.
477 -# If the object is disabled (via a call to wxEvtHandler::SetEvtHandlerEnabled)
478 the function skips to step (7).
479 -# Dynamic event table of the handlers bound using Bind<>() is
480 searched. If a handler is found, it is executed and the function
481 returns @true unless the handler used wxEvent::Skip() to indicate
482 that it didn't handle the event in which case the search continues.
483 -# Static events table of the handlers bound using event table
484 macros is searched for this event handler. If this fails, the base
485 class event table is tried, and so on until no more tables
486 exist or an appropriate function was found. If a handler is found,
487 the same logic as in the previous step applies.
488 -# The search is applied down the entire chain of event handlers (usually the
489 chain has a length of one). This chain can be formed using wxEvtHandler::SetNextHandler():
490 @image html overview_events_chain.png
491 (referring to the image, if @c A->ProcessEvent is called and it doesn't handle
492 the event, @c B->ProcessEvent will be called and so on...).
493 Note that in the case of wxWindow you can build a stack of event handlers
494 (see wxWindow::PushEventHandler() for more info).
495 If any of the handlers of the chain return @true, the function exits.
496 -# TryAfter() is called: for the wxWindow object this may propagate the
497 event to the window parent (recursively). If the event is still not
498 processed, ProcessEvent() on wxTheApp object is called as the last
499 step.
500
501 Notice that steps (2)-(6) are performed in ProcessEventLocally()
502 which is called by this function.
503
504 @param event
505 Event to process.
506 @return
507 @true if a suitable event handler function was found and executed,
508 and the function did not call wxEvent::Skip.
509
510 @see SearchEventTable()
511 */
512 virtual bool ProcessEvent(wxEvent& event);
513
514 /**
515 Try to process the event in this handler and all those chained to it.
516
517 As explained in ProcessEvent() documentation, the event handlers may be
518 chained in a doubly-linked list. This function tries to process the
519 event in this handler (including performing any pre-processing done in
520 TryBefore(), e.g. applying validators) and all those following it in
521 the chain until the event is processed or the chain is exhausted.
522
523 This function is called from ProcessEvent() and, in turn, calls
524 TryBefore() and TryAfter(). It is not virtual and so cannot be
525 overridden but can, and should, be called to forward an event to
526 another handler instead of ProcessEvent() which would result in a
527 duplicate call to TryAfter(), e.g. resulting in all unprocessed events
528 being sent to the application object multiple times.
529
530 @since 2.9.1
531
532 @param event
533 Event to process.
534 @return
535 @true if this handler of one of those chained to it processed the
536 event.
537 */
538 bool ProcessEventLocally(wxEvent& event);
539
540 /**
541 Processes an event by calling ProcessEvent() and handles any exceptions
542 that occur in the process.
543 If an exception is thrown in event handler, wxApp::OnExceptionInMainLoop is called.
544
545 @param event
546 Event to process.
547
548 @return @true if the event was processed, @false if no handler was found
549 or an exception was thrown.
550
551 @see wxWindow::HandleWindowEvent
552 */
553 bool SafelyProcessEvent(wxEvent& event);
554
555 /**
556 Processes the pending events previously queued using QueueEvent() or
557 AddPendingEvent(); you must call this function only if you are sure
558 there are pending events for this handler, otherwise a @c wxCHECK
559 will fail.
560
561 The real processing still happens in ProcessEvent() which is called by this
562 function.
563
564 Note that this function needs a valid application object (see
565 wxAppConsole::GetInstance()) because wxApp holds the list of the event
566 handlers with pending events and this function manipulates that list.
567 */
568 void ProcessPendingEvents();
569
570 /**
571 Deletes all events queued on this event handler using QueueEvent() or
572 AddPendingEvent().
573
574 Use with care because the events which are deleted are (obviously) not
575 processed and this may have unwanted consequences (e.g. user actions events
576 will be lost).
577 */
578 void DeletePendingEvents();
579
580 /**
581 Searches the event table, executing an event handler function if an appropriate
582 one is found.
583
584 @param table
585 Event table to be searched.
586 @param event
587 Event to be matched against an event table entry.
588
589 @return @true if a suitable event handler function was found and
590 executed, and the function did not call wxEvent::Skip.
591
592 @remarks This function looks through the object's event table and tries
593 to find an entry that will match the event.
594 An entry will match if:
595 @li The event type matches, and
596 @li the identifier or identifier range matches, or the event table
597 entry's identifier is zero.
598
599 If a suitable function is called but calls wxEvent::Skip, this
600 function will fail, and searching will continue.
601
602 @todo this function in the header is listed as an "implementation only" function;
603 are we sure we want to document it?
604
605 @see ProcessEvent()
606 */
607 virtual bool SearchEventTable(wxEventTable& table,
608 wxEvent& event);
609
610 //@}
611
612
613 /**
614 @name Connecting and disconnecting
615 */
616 //@{
617
618 /**
619 Connects the given function dynamically with the event handler, id and
620 event type.
621
622 Notice that Bind() provides a more flexible and safer way to do the
623 same thing as Connect(), please use it in any new code -- while
624 Connect() is not formally deprecated due to its existing widespread
625 usage, it has no advantages compared to Bind().
626
627 This is an alternative to the use of static event tables. It is more
628 flexible as it allows to connect events generated by some object to an
629 event handler defined in a different object of a different class (which
630 is impossible to do directly with the event tables -- the events can be
631 only handled in another object if they are propagated upwards to it).
632 Do make sure to specify the correct @a eventSink when connecting to an
633 event of a different object.
634
635 See @ref overview_events_bind for more detailed explanation
636 of this function and the @ref page_samples_event sample for usage
637 examples.
638
639 This specific overload allows you to connect an event handler to a @e range
640 of @e source IDs.
641 Do not confuse @e source IDs with event @e types: source IDs identify the
642 event generator objects (typically wxMenuItem or wxWindow objects) while the
643 event @e type identify which type of events should be handled by the
644 given @e function (an event generator object may generate many different
645 types of events!).
646
647 @param id
648 The first ID of the identifier range to be associated with the event
649 handler function.
650 @param lastId
651 The last ID of the identifier range to be associated with the event
652 handler function.
653 @param eventType
654 The event type to be associated with this event handler.
655 @param function
656 The event handler function. Note that this function should
657 be explicitly converted to the correct type which can be done using a macro
658 called @c wxFooEventHandler for the handler for any @c wxFooEvent.
659 @param userData
660 Optional data to be associated with the event table entry.
661 wxWidgets will take ownership of this pointer, i.e. it will be
662 destroyed when the event handler is disconnected or at the program
663 termination. This pointer can be retrieved using
664 wxEvent::GetEventUserData() later.
665 @param eventSink
666 Object whose member function should be called. It must be specified
667 when connecting an event generated by one object to a member
668 function of a different object. If it is omitted, @c this is used.
669
670 @beginWxPerlOnly
671 In wxPerl this function takes 4 arguments: @a id, @a lastid,
672 @a type, @a method; if @a method is undef, the handler is
673 disconnected.}
674 @endWxPerlOnly
675
676 @see Bind<>()
677 */
678 void Connect(int id, int lastId, wxEventType eventType,
679 wxObjectEventFunction function,
680 wxObject* userData = NULL,
681 wxEvtHandler* eventSink = NULL);
682
683 /**
684 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
685 overload for more info.
686
687 This overload can be used to attach an event handler to a single source ID:
688
689 Example:
690 @code
691 frame->Connect( wxID_EXIT,
692 wxEVT_COMMAND_MENU_SELECTED,
693 wxCommandEventHandler(MyFrame::OnQuit) );
694 @endcode
695
696 @beginWxPerlOnly
697 Not supported by wxPerl.
698 @endWxPerlOnly
699 */
700 void Connect(int id, wxEventType eventType,
701 wxObjectEventFunction function,
702 wxObject* userData = NULL,
703 wxEvtHandler* eventSink = NULL);
704
705 /**
706 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
707 overload for more info.
708
709 This overload will connect the given event handler so that regardless of the
710 ID of the event source, the handler will be called.
711
712 @beginWxPerlOnly
713 Not supported by wxPerl.
714 @endWxPerlOnly
715 */
716 void Connect(wxEventType eventType,
717 wxObjectEventFunction function,
718 wxObject* userData = NULL,
719 wxEvtHandler* eventSink = NULL);
720
721 /**
722 Disconnects the given function dynamically from the event handler, using the
723 specified parameters as search criteria and returning @true if a matching
724 function has been found and removed.
725
726 This method can only disconnect functions which have been added using the
727 Connect() method. There is no way to disconnect functions connected using
728 the (static) event tables.
729
730 @param eventType
731 The event type associated with this event handler.
732 @param function
733 The event handler function.
734 @param userData
735 Data associated with the event table entry.
736 @param eventSink
737 Object whose member function should be called.
738
739 @beginWxPerlOnly
740 Not supported by wxPerl.
741 @endWxPerlOnly
742 */
743 bool Disconnect(wxEventType eventType,
744 wxObjectEventFunction function,
745 wxObject* userData = NULL,
746 wxEvtHandler* eventSink = NULL);
747
748 /**
749 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
750 overload for more info.
751
752 This overload takes the additional @a id parameter.
753
754 @beginWxPerlOnly
755 Not supported by wxPerl.
756 @endWxPerlOnly
757 */
758 bool Disconnect(int id = wxID_ANY,
759 wxEventType eventType = wxEVT_NULL,
760 wxObjectEventFunction function = NULL,
761 wxObject* userData = NULL,
762 wxEvtHandler* eventSink = NULL);
763
764 /**
765 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*)
766 overload for more info.
767
768 This overload takes an additional range of source IDs.
769
770 @beginWxPerlOnly
771 In wxPerl this function takes 3 arguments: @a id,
772 @a lastid, @a type.
773 @endWxPerlOnly
774 */
775 bool Disconnect(int id, int lastId,
776 wxEventType eventType,
777 wxObjectEventFunction function = NULL,
778 wxObject* userData = NULL,
779 wxEvtHandler* eventSink = NULL);
780 //@}
781
782
783 /**
784 @name Binding and Unbinding
785 */
786 //@{
787
788 /**
789 Binds the given function, functor or method dynamically with the event.
790
791 This offers basically the same functionality as Connect(), but it is
792 more flexible as it also allows you to use ordinary functions and
793 arbitrary functors as event handlers. It is also less restrictive then
794 Connect() because you can use an arbitrary method as an event handler,
795 whereas Connect() requires a wxEvtHandler derived handler.
796
797 See @ref overview_events_bind for more detailed explanation
798 of this function and the @ref page_samples_event sample for usage
799 examples.
800
801 @param eventType
802 The event type to be associated with this event handler.
803 @param functor
804 The event handler functor. This can be an ordinary function but also
805 an arbitrary functor like boost::function<>.
806 @param id
807 The first ID of the identifier range to be associated with the event
808 handler.
809 @param lastId
810 The last ID of the identifier range to be associated with the event
811 handler.
812 @param userData
813 Optional data to be associated with the event table entry.
814 wxWidgets will take ownership of this pointer, i.e. it will be
815 destroyed when the event handler is disconnected or at the program
816 termination. This pointer can be retrieved using
817 wxEvent::GetEventUserData() later.
818
819 @see @ref overview_cpp_rtti_disabled
820
821 @since 2.9.0
822 */
823 template <typename EventTag, typename Functor>
824 void Bind(const EventTag& eventType,
825 Functor functor,
826 int id = wxID_ANY,
827 int lastId = wxID_ANY,
828 wxObject *userData = NULL);
829
830 /**
831 See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for
832 more info.
833
834 This overload will bind the given method as the event handler.
835
836 @param eventType
837 The event type to be associated with this event handler.
838 @param method
839 The event handler method. This can be an arbitrary method (doesn't need
840 to be from a wxEvtHandler derived class).
841 @param handler
842 Object whose method should be called. It must always be specified
843 so it can be checked at compile time whether the given method is an
844 actual member of the given handler.
845 @param id
846 The first ID of the identifier range to be associated with the event
847 handler.
848 @param lastId
849 The last ID of the identifier range to be associated with the event
850 handler.
851 @param userData
852 Optional data to be associated with the event table entry.
853 wxWidgets will take ownership of this pointer, i.e. it will be
854 destroyed when the event handler is disconnected or at the program
855 termination. This pointer can be retrieved using
856 wxEvent::GetEventUserData() later.
857
858 @see @ref overview_cpp_rtti_disabled
859
860 @since 2.9.0
861 */
862 template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
863 void Bind(const EventTag &eventType,
864 void (Class::*method)(EventArg &),
865 EventHandler *handler,
866 int id = wxID_ANY,
867 int lastId = wxID_ANY,
868 wxObject *userData = NULL);
869 /**
870 Unbinds the given function, functor or method dynamically from the
871 event handler, using the specified parameters as search criteria and
872 returning @true if a matching function has been found and removed.
873
874 This method can only unbind functions, functors or methods which have
875 been added using the Bind<>() method. There is no way to unbind
876 functions bound using the (static) event tables.
877
878 @param eventType
879 The event type associated with this event handler.
880 @param functor
881 The event handler functor. This can be an ordinary function but also
882 an arbitrary functor like boost::function<>.
883 @param id
884 The first ID of the identifier range associated with the event
885 handler.
886 @param lastId
887 The last ID of the identifier range associated with the event
888 handler.
889 @param userData
890 Data associated with the event table entry.
891
892 @see @ref overview_cpp_rtti_disabled
893
894 @since 2.9.0
895 */
896 template <typename EventTag, typename Functor>
897 bool Unbind(const EventTag& eventType,
898 Functor functor,
899 int id = wxID_ANY,
900 int lastId = wxID_ANY,
901 wxObject *userData = NULL);
902
903 /**
904 See the Unbind<>(const EventTag&, Functor, int, int, wxObject*)
905 overload for more info.
906
907 This overload unbinds the given method from the event..
908
909 @param eventType
910 The event type associated with this event handler.
911 @param method
912 The event handler method associated with this event.
913 @param handler
914 Object whose method was called.
915 @param id
916 The first ID of the identifier range associated with the event
917 handler.
918 @param lastId
919 The last ID of the identifier range associated with the event
920 handler.
921 @param userData
922 Data associated with the event table entry.
923
924 @see @ref overview_cpp_rtti_disabled
925
926 @since 2.9.0
927 */
928 template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
929 bool Unbind(const EventTag &eventType,
930 void (Class::*method)(EventArg&),
931 EventHandler *handler,
932 int id = wxID_ANY,
933 int lastId = wxID_ANY,
934 wxObject *userData = NULL );
935 //@}
936 /**
937 @name User-supplied data
938 */
939 //@{
940
941 /**
942 Returns user-supplied client data.
943
944 @remarks Normally, any extra data the programmer wishes to associate with
945 the object should be made available by deriving a new class with
946 new data members.
947
948 @see SetClientData()
949 */
950 void* GetClientData() const;
951
952 /**
953 Returns a pointer to the user-supplied client data object.
954
955 @see SetClientObject(), wxClientData
956 */
957 wxClientData* GetClientObject() const;
958
959 /**
960 Sets user-supplied client data.
961
962 @param data
963 Data to be associated with the event handler.
964
965 @remarks Normally, any extra data the programmer wishes to associate
966 with the object should be made available by deriving a new
967 class with new data members. You must not call this method
968 and SetClientObject on the same class - only one of them.
969
970 @see GetClientData()
971 */
972 void SetClientData(void* data);
973
974 /**
975 Set the client data object. Any previous object will be deleted.
976
977 @see GetClientObject(), wxClientData
978 */
979 void SetClientObject(wxClientData* data);
980
981 //@}
982
983
984 /**
985 @name Event handler chaining
986
987 wxEvtHandler can be arranged in a double-linked list of handlers
988 which is automatically iterated by ProcessEvent() if needed.
989 */
990 //@{
991
992 /**
993 Returns @true if the event handler is enabled, @false otherwise.
994
995 @see SetEvtHandlerEnabled()
996 */
997 bool GetEvtHandlerEnabled() const;
998
999 /**
1000 Returns the pointer to the next handler in the chain.
1001
1002 @see SetNextHandler(), GetPreviousHandler(), SetPreviousHandler(),
1003 wxWindow::PushEventHandler, wxWindow::PopEventHandler
1004 */
1005 wxEvtHandler* GetNextHandler() const;
1006
1007 /**
1008 Returns the pointer to the previous handler in the chain.
1009
1010 @see SetPreviousHandler(), GetNextHandler(), SetNextHandler(),
1011 wxWindow::PushEventHandler, wxWindow::PopEventHandler
1012 */
1013 wxEvtHandler* GetPreviousHandler() const;
1014
1015 /**
1016 Enables or disables the event handler.
1017
1018 @param enabled
1019 @true if the event handler is to be enabled, @false if it is to be disabled.
1020
1021 @remarks You can use this function to avoid having to remove the event
1022 handler from the chain, for example when implementing a
1023 dialog editor and changing from edit to test mode.
1024
1025 @see GetEvtHandlerEnabled()
1026 */
1027 void SetEvtHandlerEnabled(bool enabled);
1028
1029 /**
1030 Sets the pointer to the next handler.
1031
1032 @remarks
1033 See ProcessEvent() for more info about how the chains of event handlers
1034 are internally used.
1035 Also remember that wxEvtHandler uses double-linked lists and thus if you
1036 use this function, you should also call SetPreviousHandler() on the
1037 argument passed to this function:
1038 @code
1039 handlerA->SetNextHandler(handlerB);
1040 handlerB->SetPreviousHandler(handlerA);
1041 @endcode
1042
1043 @param handler
1044 The event handler to be set as the next handler.
1045 Cannot be @NULL.
1046
1047 @see @ref overview_events_processing
1048 */
1049 virtual void SetNextHandler(wxEvtHandler* handler);
1050
1051 /**
1052 Sets the pointer to the previous handler.
1053 All remarks about SetNextHandler() apply to this function as well.
1054
1055 @param handler
1056 The event handler to be set as the previous handler.
1057 Cannot be @NULL.
1058
1059 @see @ref overview_events_processing
1060 */
1061 virtual void SetPreviousHandler(wxEvtHandler* handler);
1062
1063 /**
1064 Unlinks this event handler from the chain it's part of (if any);
1065 then links the "previous" event handler to the "next" one
1066 (so that the chain won't be interrupted).
1067
1068 E.g. if before calling Unlink() you have the following chain:
1069 @image html evthandler_unlink_before.png
1070 then after calling @c B->Unlink() you'll have:
1071 @image html evthandler_unlink_after.png
1072
1073 @since 2.9.0
1074 */
1075 void Unlink();
1076
1077 /**
1078 Returns @true if the next and the previous handler pointers of this
1079 event handler instance are @NULL.
1080
1081 @since 2.9.0
1082
1083 @see SetPreviousHandler(), SetNextHandler()
1084 */
1085 bool IsUnlinked() const;
1086
1087 //@}
1088
1089 /**
1090 @name Global event filters.
1091
1092 Methods for working with the global list of event filters.
1093
1094 Event filters can be defined to pre-process all the events that happen
1095 in an application, see wxEventFilter documentation for more information.
1096 */
1097 //@{
1098
1099 /**
1100 Add an event filter whose FilterEvent() method will be called for each
1101 and every event processed by wxWidgets.
1102
1103 The filters are called in LIFO order and wxApp is registered as an
1104 event filter by default. The pointer must remain valid until it's
1105 removed with RemoveFilter() and is not deleted by wxEvtHandler.
1106
1107 @since 2.9.3
1108 */
1109 static void AddFilter(wxEventFilter* filter);
1110
1111 /**
1112 Remove a filter previously installed with AddFilter().
1113
1114 It's an error to remove a filter that hadn't been previously added or
1115 was already removed.
1116
1117 @since 2.9.3
1118 */
1119 static void RemoveFilter(wxEventFilter* filter);
1120
1121 //@}
1122
1123 protected:
1124 /**
1125 Method called by ProcessEvent() before examining this object event
1126 tables.
1127
1128 This method can be overridden to hook into the event processing logic
1129 as early as possible. You should usually call the base class version
1130 when overriding this method, even if wxEvtHandler itself does nothing
1131 here, some derived classes do use this method, e.g. wxWindow implements
1132 support for wxValidator in it.
1133
1134 Example:
1135 @code
1136 class MyClass : public BaseClass // inheriting from wxEvtHandler
1137 {
1138 ...
1139 protected:
1140 virtual bool TryBefore(wxEvent& event)
1141 {
1142 if ( MyPreProcess(event) )
1143 return true;
1144
1145 return BaseClass::TryBefore(event);
1146 }
1147 };
1148 @endcode
1149
1150 @see ProcessEvent()
1151 */
1152 virtual bool TryBefore(wxEvent& event);
1153
1154 /**
1155 Method called by ProcessEvent() as last resort.
1156
1157 This method can be overridden to implement post-processing for the
1158 events which were not processed anywhere else.
1159
1160 The base class version handles forwarding the unprocessed events to
1161 wxApp at wxEvtHandler level and propagating them upwards the window
1162 child-parent chain at wxWindow level and so should usually be called
1163 when overriding this method:
1164 @code
1165 class MyClass : public BaseClass // inheriting from wxEvtHandler
1166 {
1167 ...
1168 protected:
1169 virtual bool TryAfter(wxEvent& event)
1170 {
1171 if ( BaseClass::TryAfter(event) )
1172 return true;
1173
1174 return MyPostProcess(event);
1175 }
1176 };
1177 @endcode
1178
1179 @see ProcessEvent()
1180 */
1181 virtual bool TryAfter(wxEvent& event);
1182 };
1183
1184
1185
1186 /**
1187 See wxIdleEvent::SetMode() for more info.
1188 */
1189 enum wxIdleMode
1190 {
1191 /** Send idle events to all windows */
1192 wxIDLE_PROCESS_ALL,
1193
1194 /** Send idle events to windows that have the wxWS_EX_PROCESS_IDLE flag specified */
1195 wxIDLE_PROCESS_SPECIFIED
1196 };
1197
1198
1199 /**
1200 @class wxIdleEvent
1201
1202 This class is used for idle events, which are generated when the system becomes
1203 idle. Note that, unless you do something specifically, the idle events are not
1204 sent if the system remains idle once it has become it, e.g. only a single idle
1205 event will be generated until something else resulting in more normal events
1206 happens and only then is the next idle event sent again.
1207
1208 If you need to ensure a continuous stream of idle events, you can either use
1209 wxIdleEvent::RequestMore method in your handler or call wxWakeUpIdle() periodically
1210 (for example from a timer event handler), but note that both of these approaches
1211 (and especially the first one) increase the system load and so should be avoided
1212 if possible.
1213
1214 By default, idle events are sent to all windows, including even the hidden
1215 ones because they may be shown if some condition is met from their @c
1216 wxEVT_IDLE (or related @c wxEVT_UPDATE_UI) handler. The children of hidden
1217 windows do not receive idle events however as they can't change their state
1218 in any way noticeable by the user. Finally, the global wxApp object also
1219 receives these events, as usual, so it can be used for any global idle time
1220 processing.
1221
1222 If sending idle events to all windows is causing a significant overhead in
1223 your application, you can call wxIdleEvent::SetMode with the value
1224 wxIDLE_PROCESS_SPECIFIED, and set the wxWS_EX_PROCESS_IDLE extra window
1225 style for every window which should receive idle events, all the other ones
1226 will not receive them in this case.
1227
1228 @beginEventTable{wxIdleEvent}
1229 @event{EVT_IDLE(func)}
1230 Process a @c wxEVT_IDLE event.
1231 @endEventTable
1232
1233 @library{wxbase}
1234 @category{events}
1235 @header{wx/event.h}
1236
1237 @section sec_delayed_action Delayed Action Mechanism
1238
1239 wxIdleEvent can be used to perform some action "at slightly later time".
1240 This can be necessary in several circumstances when, for whatever reason,
1241 something can't be done in the current event handler. For example, if a
1242 mouse event handler is called with the mouse button pressed, the mouse can
1243 be currently captured and some operations with it -- notably capturing it
1244 again -- might be impossible or lead to undesirable results. If you still
1245 want to capture it, you can do it from @c wxEVT_IDLE handler when it is
1246 called the next time instead of doing it immediately.
1247
1248 This can be achieved in two different ways: when using static event tables,
1249 you will need a flag indicating to the (always connected) idle event
1250 handler whether the desired action should be performed. The originally
1251 called handler would then set it to indicate that it should indeed be done
1252 and the idle handler itself would reset it to prevent it from doing the
1253 same action again.
1254
1255 Using dynamically connected event handlers things are even simpler as the
1256 original event handler can simply wxEvtHandler::Connect() or
1257 wxEvtHandler::Bind() the idle event handler which would only be executed
1258 then and could wxEvtHandler::Disconnect() or wxEvtHandler::Unbind() itself.
1259
1260
1261 @see @ref overview_events, wxUpdateUIEvent, wxWindow::OnInternalIdle
1262 */
1263 class wxIdleEvent : public wxEvent
1264 {
1265 public:
1266 /**
1267 Constructor.
1268 */
1269 wxIdleEvent();
1270
1271 /**
1272 Static function returning a value specifying how wxWidgets will send idle
1273 events: to all windows, or only to those which specify that they
1274 will process the events.
1275
1276 @see SetMode().
1277 */
1278 static wxIdleMode GetMode();
1279
1280 /**
1281 Returns @true if the OnIdle function processing this event requested more
1282 processing time.
1283
1284 @see RequestMore()
1285 */
1286 bool MoreRequested() const;
1287
1288 /**
1289 Tells wxWidgets that more processing is required.
1290
1291 This function can be called by an OnIdle handler for a window or window event
1292 handler to indicate that wxApp::OnIdle should forward the OnIdle event once
1293 more to the application windows.
1294
1295 If no window calls this function during OnIdle, then the application will
1296 remain in a passive event loop (not calling OnIdle) until a new event is
1297 posted to the application by the windowing system.
1298
1299 @see MoreRequested()
1300 */
1301 void RequestMore(bool needMore = true);
1302
1303 /**
1304 Static function for specifying how wxWidgets will send idle events: to
1305 all windows, or only to those which specify that they will process the events.
1306
1307 @param mode
1308 Can be one of the ::wxIdleMode values.
1309 The default is wxIDLE_PROCESS_ALL.
1310 */
1311 static void SetMode(wxIdleMode mode);
1312 };
1313
1314
1315
1316 // ============================================================================
1317 // Global functions/macros
1318 // ============================================================================
1319
1320 /** @addtogroup group_funcmacro_events */
1321 //@{
1322
1323 /**
1324 A value uniquely identifying the type of the event.
1325
1326 The values of this type should only be created using wxNewEventType().
1327
1328 See the macro DEFINE_EVENT_TYPE() for more info.
1329
1330 @see @ref overview_events_introduction
1331 */
1332 typedef int wxEventType;
1333
1334 /**
1335 A special event type usually used to indicate that some wxEvent has yet
1336 no type assigned.
1337 */
1338 wxEventType wxEVT_NULL;
1339
1340 wxEventType wxEVT_ANY;
1341
1342 /**
1343 Generates a new unique event type.
1344
1345 Usually this function is only used by wxDEFINE_EVENT() and not called
1346 directly.
1347 */
1348 wxEventType wxNewEventType();
1349
1350 /**
1351 Define a new event type associated with the specified event class.
1352
1353 This macro defines a new unique event type @a name associated with the
1354 event class @a cls.
1355
1356 For example:
1357 @code
1358 wxDEFINE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);
1359
1360 class MyCustomEvent : public wxEvent { ... };
1361 wxDEFINE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
1362 @endcode
1363
1364 @see wxDECLARE_EVENT(), @ref overview_events_custom
1365 */
1366 #define wxDEFINE_EVENT(name, cls) \
1367 const wxEventTypeTag< cls > name(wxNewEventType())
1368
1369 /**
1370 Declares a custom event type.
1371
1372 This macro declares a variable called @a name which must be defined
1373 elsewhere using wxDEFINE_EVENT().
1374
1375 The class @a cls must be the wxEvent-derived class associated with the
1376 events of this type and its full declaration must be visible from the point
1377 of use of this macro.
1378
1379 For example:
1380 @code
1381 wxDECLARE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);
1382
1383 class MyCustomEvent : public wxEvent { ... };
1384 wxDECLARE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);
1385 @endcode
1386 */
1387 #define wxDECLARE_EVENT(name, cls) \
1388 wxDECLARE_EXPORTED_EVENT(wxEMPTY_PARAMETER_VALUE, name, cls)
1389
1390 /**
1391 Variant of wxDECLARE_EVENT() used for event types defined inside a shared
1392 library.
1393
1394 This is mostly used by wxWidgets internally, e.g.
1395 @code
1396 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent)
1397 @endcode
1398 */
1399 #define wxDECLARE_EXPORTED_EVENT( expdecl, name, cls ) \
1400 extern const expdecl wxEventTypeTag< cls > name;
1401
1402 /**
1403 Helper macro for definition of custom event table macros.
1404
1405 This macro must only be used if wxEVENTS_COMPATIBILITY_2_8 is 1, otherwise
1406 it is better and more clear to just use the address of the function
1407 directly as this is all this macro does in this case. However it needs to
1408 explicitly cast @a func to @a functype, which is the type of wxEvtHandler
1409 member function taking the custom event argument when
1410 wxEVENTS_COMPATIBILITY_2_8 is 0.
1411
1412 See wx__DECLARE_EVT0 for an example of use.
1413
1414 @see @ref overview_events_custom_ownclass
1415 */
1416 #define wxEVENT_HANDLER_CAST(functype, func) (&func)
1417
1418 /**
1419 This macro is used to define event table macros for handling custom
1420 events.
1421
1422 Example of use:
1423 @code
1424 class MyEvent : public wxEvent { ... };
1425
1426 // note that this is not necessary unless using old compilers: for the
1427 // reasonably new ones just use &func instead of MyEventHandler(func)
1428 typedef void (wxEvtHandler::*MyEventFunction)(MyEvent&);
1429 #define MyEventHandler(func) wxEVENT_HANDLER_CAST(MyEventFunction, func)
1430
1431 wxDEFINE_EVENT(MY_EVENT_TYPE, MyEvent);
1432
1433 #define EVT_MY(id, func) \
1434 wx__DECLARE_EVT1(MY_EVENT_TYPE, id, MyEventHandler(func))
1435
1436 ...
1437
1438 wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
1439 EVT_MY(wxID_ANY, MyFrame::OnMyEvent)
1440 wxEND_EVENT_TABLE()
1441 @endcode
1442
1443 @param evt
1444 The event type to handle.
1445 @param id
1446 The identifier of events to handle.
1447 @param fn
1448 The event handler method.
1449 */
1450 #define wx__DECLARE_EVT1(evt, id, fn) \
1451 wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
1452
1453 /**
1454 Generalized version of the wx__DECLARE_EVT1() macro taking a range of
1455 IDs instead of a single one.
1456 Argument @a id1 is the first identifier of the range, @a id2 is the
1457 second identifier of the range.
1458 */
1459 #define wx__DECLARE_EVT2(evt, id1, id2, fn) \
1460 DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
1461
1462 /**
1463 Simplified version of the wx__DECLARE_EVT1() macro, to be used when the
1464 event type must be handled regardless of the ID associated with the
1465 specific event instances.
1466 */
1467 #define wx__DECLARE_EVT0(evt, fn) \
1468 wx__DECLARE_EVT1(evt, wxID_ANY, fn)
1469
1470 /**
1471 Use this macro inside a class declaration to declare a @e static event table
1472 for that class.
1473
1474 In the implementation file you'll need to use the wxBEGIN_EVENT_TABLE()
1475 and the wxEND_EVENT_TABLE() macros, plus some additional @c EVT_xxx macro
1476 to capture events.
1477
1478 Note that this macro requires a final semicolon.
1479
1480 @see @ref overview_events_eventtables
1481 */
1482 #define wxDECLARE_EVENT_TABLE()
1483
1484 /**
1485 Use this macro in a source file to start listing @e static event handlers
1486 for a specific class.
1487
1488 Use wxEND_EVENT_TABLE() to terminate the event-declaration block.
1489
1490 @see @ref overview_events_eventtables
1491 */
1492 #define wxBEGIN_EVENT_TABLE(theClass, baseClass)
1493
1494 /**
1495 Use this macro in a source file to end listing @e static event handlers
1496 for a specific class.
1497
1498 Use wxBEGIN_EVENT_TABLE() to start the event-declaration block.
1499
1500 @see @ref overview_events_eventtables
1501 */
1502 #define wxEND_EVENT_TABLE()
1503
1504 /**
1505 In a GUI application, this function posts @a event to the specified @e dest
1506 object using wxEvtHandler::AddPendingEvent().
1507
1508 Otherwise, it dispatches @a event immediately using
1509 wxEvtHandler::ProcessEvent(). See the respective documentation for details
1510 (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent()
1511 this function is not thread-safe for event objects having wxString fields,
1512 use wxQueueEvent() instead.
1513
1514 @header{wx/event.h}
1515 */
1516 void wxPostEvent(wxEvtHandler* dest, const wxEvent& event);
1517
1518 /**
1519 Queue an event for processing on the given object.
1520
1521 This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation
1522 for more details.
1523
1524 @header{wx/event.h}
1525
1526 @param dest
1527 The object to queue the event on, can't be @c NULL.
1528 @param event
1529 The heap-allocated and non-@c NULL event to queue, the function takes
1530 ownership of it.
1531 */
1532 void wxQueueEvent(wxEvtHandler* dest, wxEvent *event);
1533
1534
1535 //@}