1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Event classes
4 // Author: Julian Smart
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/object.h"
18 #include "wx/clntdata.h"
21 #include "wx/gdicmn.h"
22 #include "wx/cursor.h"
23 #include "wx/mousestate.h"
26 #include "wx/dynarray.h"
27 #include "wx/thread.h"
28 #include "wx/tracker.h"
29 #include "wx/typeinfo.h"
32 #ifdef wxHAS_EVENT_BIND
33 #include "wx/meta/convertible.h"
36 // Currently VC6 and VC7 are known to not be able to compile CallAfter() code,
37 // so disable it for them.
38 #if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(8)
39 #include "wx/meta/removeref.h"
41 #define wxHAS_CALL_AFTER
44 // ----------------------------------------------------------------------------
45 // forward declarations
46 // ----------------------------------------------------------------------------
48 class WXDLLIMPEXP_FWD_BASE wxList
;
49 class WXDLLIMPEXP_FWD_BASE wxEvent
;
50 class WXDLLIMPEXP_FWD_BASE wxEventFilter
;
52 class WXDLLIMPEXP_FWD_CORE wxDC
;
53 class WXDLLIMPEXP_FWD_CORE wxMenu
;
54 class WXDLLIMPEXP_FWD_CORE wxWindow
;
55 class WXDLLIMPEXP_FWD_CORE wxWindowBase
;
58 // We operate with pointer to members of wxEvtHandler (such functions are used
59 // as event handlers in the event tables or as arguments to Connect()) but by
60 // default MSVC uses a restricted (but more efficient) representation of
61 // pointers to members which can't deal with multiple base classes. To avoid
62 // mysterious (as the compiler is not good enough to detect this and give a
63 // sensible error message) errors in the user code as soon as it defines
64 // classes inheriting from both wxEvtHandler (possibly indirectly, e.g. via
65 // wxWindow) and something else (including our own wxTrackable but not limited
66 // to it), we use the special MSVC keyword telling the compiler to use a more
67 // general pointer to member representation for the classes inheriting from
70 #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance
72 #define wxMSVC_FWD_MULTIPLE_BASES
75 class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler
;
76 class wxEventConnectionRef
;
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
82 typedef int wxEventType
;
84 #define wxEVT_ANY ((wxEventType)-1)
86 // this is used to make the event table entry type safe, so that for an event
87 // handler only a function with proper parameter list can be given. See also
88 // the wxEVENT_HANDLER_CAST-macro.
89 #define wxStaticCastEvent(type, val) static_cast<type>(val)
91 #define wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
92 wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj)
94 #define wxDECLARE_EVENT_TABLE_TERMINATOR() \
95 wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0)
97 // generate a new unique event type
98 extern WXDLLIMPEXP_BASE wxEventType
wxNewEventType();
100 // define macros to create new event types:
101 #ifdef wxHAS_EVENT_BIND
102 // events are represented by an instance of wxEventTypeTag and the
103 // corresponding type must be specified for type-safety checks
105 // define a new custom event type, can be used alone or after event
106 // declaration in the header using one of the macros below
107 #define wxDEFINE_EVENT( name, type ) \
108 const wxEventTypeTag< type > name( wxNewEventType() )
110 // the general version allowing exporting the event type from DLL, used by
112 #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \
113 extern const expdecl wxEventTypeTag< type > name
115 // this is the version which will normally be used in the user code
116 #define wxDECLARE_EVENT( name, type ) \
117 wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
120 // these macros are only used internally for backwards compatibility and
121 // allow to define an alias for an existing event type (this is used by
123 #define wxDEFINE_EVENT_ALIAS( name, type, value ) \
124 const wxEventTypeTag< type > name( value )
126 #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \
127 extern const expdecl wxEventTypeTag< type > name
128 #else // !wxHAS_EVENT_BIND
129 // the macros are the same ones as above but defined differently as we only
130 // use the integer event type values to identify events in this case
132 #define wxDEFINE_EVENT( name, type ) \
133 const wxEventType name( wxNewEventType() )
135 #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \
136 extern const expdecl wxEventType name
137 #define wxDECLARE_EVENT( name, type ) \
138 wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
140 #define wxDEFINE_EVENT_ALIAS( name, type, value ) \
141 const wxEventType name = value
142 #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \
143 extern const expdecl wxEventType name
144 #endif // wxHAS_EVENT_BIND/!wxHAS_EVENT_BIND
146 // Try to cast the given event handler to the correct handler type:
148 #define wxEVENT_HANDLER_CAST( functype, func ) \
149 ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func )
152 #ifdef wxHAS_EVENT_BIND
154 // The tag is a type associated to the event type (which is an integer itself,
155 // in spite of its name) value. It exists in order to be used as a template
156 // parameter and provide a mapping between the event type values and their
157 // corresponding wxEvent-derived classes.
158 template <typename T
>
162 // The class of wxEvent-derived class carried by the events of this type.
163 typedef T EventClass
;
165 wxEventTypeTag(wxEventType type
) { m_type
= type
; }
167 // Return a wxEventType reference for the initialization of the static
168 // event tables. See wxEventTableEntry::m_eventType for a more thorough
170 operator const wxEventType
&() const { return m_type
; }
176 #endif // wxHAS_EVENT_BIND
178 // These are needed for the functor definitions
179 typedef void (wxEvtHandler::*wxEventFunction
)(wxEvent
&);
181 // We had some trouble (specifically with eVC for ARM WinCE build) with using
182 // wxEventFunction in the past so we had introduced wxObjectEventFunction which
183 // used to be a typedef for a member of wxObject and not wxEvtHandler to work
184 // around this but as eVC is not really supported any longer we now only keep
185 // this for backwards compatibility and, despite its name, this is a typedef
186 // for wxEvtHandler member now -- but if we have the same problem with another
187 // compiler we can restore its old definition for it.
188 typedef wxEventFunction wxObjectEventFunction
;
190 // The event functor which is stored in the static and dynamic event tables:
191 class WXDLLIMPEXP_BASE wxEventFunctor
194 virtual ~wxEventFunctor();
196 // Invoke the actual event handler:
197 virtual void operator()(wxEvtHandler
*, wxEvent
&) = 0;
199 // this function tests whether this functor is matched, for the purpose of
200 // finding it in an event table in Unbind(), by the given functor:
201 virtual bool IsMatching(const wxEventFunctor
& functor
) const = 0;
203 // If the functor holds an wxEvtHandler, then get access to it and track
204 // its lifetime with wxEventConnectionRef:
205 virtual wxEvtHandler
*GetEvtHandler() const
208 // This is only used to maintain backward compatibility in
209 // wxAppConsoleBase::CallEventHandler and ensures that an overwritten
210 // wxAppConsoleBase::HandleEvent is still called for functors which hold an
212 virtual wxEventFunction
GetEvtMethod() const
216 WX_DECLARE_ABSTRACT_TYPEINFO(wxEventFunctor
)
219 // A plain method functor for the untyped legacy event types:
220 class WXDLLIMPEXP_BASE wxObjectEventFunctor
: public wxEventFunctor
223 wxObjectEventFunctor(wxObjectEventFunction method
, wxEvtHandler
*handler
)
224 : m_handler( handler
), m_method( method
)
227 virtual void operator()(wxEvtHandler
*handler
, wxEvent
& event
);
229 virtual bool IsMatching(const wxEventFunctor
& functor
) const
231 if ( wxTypeId(functor
) == wxTypeId(*this) )
233 const wxObjectEventFunctor
&other
=
234 static_cast< const wxObjectEventFunctor
& >( functor
);
236 // FIXME-VC6: amazing but true: replacing "m_method == 0" here
237 // with "!m_method" makes VC6 crash with an ICE in DLL build (only!)
238 // Also notice that using "NULL" instead of "0" results in warnings
239 // about "using NULL in arithmetics" from arm-linux-androideabi-g++
240 // 4.4.3 used for wxAndroid build.
242 return ( m_method
== other
.m_method
|| other
.m_method
== 0 ) &&
243 ( m_handler
== other
.m_handler
|| other
.m_handler
== NULL
);
249 virtual wxEvtHandler
*GetEvtHandler() const
250 { return m_handler
; }
252 virtual wxEventFunction
GetEvtMethod() const
256 wxEvtHandler
*m_handler
;
257 wxEventFunction m_method
;
259 // Provide a dummy default ctor for type info purposes
260 wxObjectEventFunctor() { }
262 WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor
)
265 // Create a functor for the legacy events: used by Connect()
266 inline wxObjectEventFunctor
*
267 wxNewEventFunctor(const wxEventType
& WXUNUSED(evtType
),
268 wxObjectEventFunction method
,
269 wxEvtHandler
*handler
)
271 return new wxObjectEventFunctor(method
, handler
);
274 // This version is used by wxDECLARE_EVENT_TABLE_ENTRY()
275 inline wxObjectEventFunctor
*
276 wxNewEventTableFunctor(const wxEventType
& WXUNUSED(evtType
),
277 wxObjectEventFunction method
)
279 return new wxObjectEventFunctor(method
, NULL
);
282 inline wxObjectEventFunctor
283 wxMakeEventFunctor(const wxEventType
& WXUNUSED(evtType
),
284 wxObjectEventFunction method
,
285 wxEvtHandler
*handler
)
287 return wxObjectEventFunctor(method
, handler
);
290 #ifdef wxHAS_EVENT_BIND
295 // helper template defining nested "type" typedef as the event class
296 // corresponding to the given event type
297 template <typename T
> struct EventClassOf
;
299 // the typed events provide the information about the class of the events they
301 template <typename T
>
302 struct EventClassOf
< wxEventTypeTag
<T
> >
304 typedef typename wxEventTypeTag
<T
>::EventClass type
;
307 // for the old untyped events we don't have information about the exact event
308 // class carried by them
310 struct EventClassOf
<wxEventType
>
312 typedef wxEvent type
;
316 // helper class defining operations different for method functors using an
317 // object of wxEvtHandler-derived class as handler and the others
318 template <typename T
, typename A
, bool> struct HandlerImpl
;
320 // specialization for handlers deriving from wxEvtHandler
321 template <typename T
, typename A
>
322 struct HandlerImpl
<T
, A
, true>
324 static bool IsEvtHandler()
326 static T
*ConvertFromEvtHandler(wxEvtHandler
*p
)
327 { return static_cast<T
*>(p
); }
328 static wxEvtHandler
*ConvertToEvtHandler(T
*p
)
330 static wxEventFunction
ConvertToEvtMethod(void (T::*f
)(A
&))
331 { return static_cast<wxEventFunction
>(
332 reinterpret_cast<void (T::*)(wxEvent
&)>(f
)); }
335 // specialization for handlers not deriving from wxEvtHandler
336 template <typename T
, typename A
>
337 struct HandlerImpl
<T
, A
, false>
339 static bool IsEvtHandler()
341 static T
*ConvertFromEvtHandler(wxEvtHandler
*)
343 static wxEvtHandler
*ConvertToEvtHandler(T
*)
345 static wxEventFunction
ConvertToEvtMethod(void (T::*)(A
&))
349 } // namespace wxPrivate
351 // functor forwarding the event to a method of the given object
353 // notice that the object class may be different from the class in which the
354 // method is defined but it must be convertible to this class
356 // also, the type of the handler parameter doesn't need to be exactly the same
357 // as EventTag::EventClass but it must be its base class -- this is explicitly
358 // allowed to handle different events in the same handler taking wxEvent&, for
361 <typename EventTag
, typename Class
, typename EventArg
, typename EventHandler
>
362 class wxEventFunctorMethod
363 : public wxEventFunctor
,
364 private wxPrivate::HandlerImpl
368 wxConvertibleTo
<Class
, wxEvtHandler
>::value
!= 0
372 static void CheckHandlerArgument(EventArg
*) { }
375 // the event class associated with the given event tag
376 typedef typename
wxPrivate::EventClassOf
<EventTag
>::type EventClass
;
379 wxEventFunctorMethod(void (Class::*method
)(EventArg
&), EventHandler
*handler
)
380 : m_handler( handler
), m_method( method
)
382 wxASSERT_MSG( handler
|| this->IsEvtHandler(),
383 "handlers defined in non-wxEvtHandler-derived classes "
384 "must be connected with a valid sink object" );
386 // if you get an error here it means that the signature of the handler
387 // you're trying to use is not compatible with (i.e. is not the same as
388 // or a base class of) the real event class used for this event type
389 CheckHandlerArgument(static_cast<EventClass
*>(NULL
));
392 virtual void operator()(wxEvtHandler
*handler
, wxEvent
& event
)
394 Class
* realHandler
= m_handler
;
397 realHandler
= this->ConvertFromEvtHandler(handler
);
399 // this is not supposed to happen but check for it nevertheless
400 wxCHECK_RET( realHandler
, "invalid event handler" );
403 // the real (run-time) type of event is EventClass and we checked in
404 // the ctor that EventClass can be converted to EventArg, so this cast
406 (realHandler
->*m_method
)(static_cast<EventArg
&>(event
));
409 virtual bool IsMatching(const wxEventFunctor
& functor
) const
411 if ( wxTypeId(functor
) != wxTypeId(*this) )
414 typedef wxEventFunctorMethod
<EventTag
, Class
, EventArg
, EventHandler
>
417 // the cast is valid because wxTypeId()s matched above
418 const ThisFunctor
& other
= static_cast<const ThisFunctor
&>(functor
);
420 return (m_method
== other
.m_method
|| other
.m_method
== NULL
) &&
421 (m_handler
== other
.m_handler
|| other
.m_handler
== NULL
);
424 virtual wxEvtHandler
*GetEvtHandler() const
425 { return this->ConvertToEvtHandler(m_handler
); }
427 virtual wxEventFunction
GetEvtMethod() const
428 { return this->ConvertToEvtMethod(m_method
); }
431 EventHandler
*m_handler
;
432 void (Class::*m_method
)(EventArg
&);
434 // Provide a dummy default ctor for type info purposes
435 wxEventFunctorMethod() { }
437 typedef wxEventFunctorMethod
<EventTag
, Class
,
438 EventArg
, EventHandler
> thisClass
;
439 WX_DECLARE_TYPEINFO_INLINE(thisClass
)
443 // functor forwarding the event to function (function, static method)
444 template <typename EventTag
, typename EventArg
>
445 class wxEventFunctorFunction
: public wxEventFunctor
448 static void CheckHandlerArgument(EventArg
*) { }
451 // the event class associated with the given event tag
452 typedef typename
wxPrivate::EventClassOf
<EventTag
>::type EventClass
;
454 wxEventFunctorFunction( void ( *handler
)( EventArg
& ))
455 : m_handler( handler
)
457 // if you get an error here it means that the signature of the handler
458 // you're trying to use is not compatible with (i.e. is not the same as
459 // or a base class of) the real event class used for this event type
460 CheckHandlerArgument(static_cast<EventClass
*>(NULL
));
463 virtual void operator()(wxEvtHandler
*WXUNUSED(handler
), wxEvent
& event
)
465 // If you get an error here like "must use .* or ->* to call
466 // pointer-to-member function" then you probably tried to call
467 // Bind/Unbind with a method pointer but without a handler pointer or
468 // NULL as a handler e.g.:
469 // Unbind( wxEVT_XXX, &EventHandler::method );
471 // Unbind( wxEVT_XXX, &EventHandler::method, NULL )
472 m_handler(static_cast<EventArg
&>(event
));
475 virtual bool IsMatching(const wxEventFunctor
&functor
) const
477 if ( wxTypeId(functor
) != wxTypeId(*this) )
480 typedef wxEventFunctorFunction
<EventTag
, EventArg
> ThisFunctor
;
482 const ThisFunctor
& other
= static_cast<const ThisFunctor
&>( functor
);
484 return m_handler
== other
.m_handler
;
488 void (*m_handler
)(EventArg
&);
490 // Provide a dummy default ctor for type info purposes
491 wxEventFunctorFunction() { }
493 typedef wxEventFunctorFunction
<EventTag
, EventArg
> thisClass
;
494 WX_DECLARE_TYPEINFO_INLINE(thisClass
)
498 template <typename EventTag
, typename Functor
>
499 class wxEventFunctorFunctor
: public wxEventFunctor
502 typedef typename
EventTag::EventClass EventArg
;
504 wxEventFunctorFunctor(const Functor
& handler
)
505 : m_handler(handler
), m_handlerAddr(&handler
)
508 virtual void operator()(wxEvtHandler
*WXUNUSED(handler
), wxEvent
& event
)
510 // If you get an error here like "must use '.*' or '->*' to call
511 // pointer-to-member function" then you probably tried to call
512 // Bind/Unbind with a method pointer but without a handler pointer or
513 // NULL as a handler e.g.:
514 // Unbind( wxEVT_XXX, &EventHandler::method );
516 // Unbind( wxEVT_XXX, &EventHandler::method, NULL )
517 m_handler(static_cast<EventArg
&>(event
));
520 virtual bool IsMatching(const wxEventFunctor
&functor
) const
522 if ( wxTypeId(functor
) != wxTypeId(*this) )
525 typedef wxEventFunctorFunctor
<EventTag
, Functor
> FunctorThis
;
527 const FunctorThis
& other
= static_cast<const FunctorThis
&>(functor
);
529 // The only reliable/portable way to compare two functors is by
531 return m_handlerAddr
== other
.m_handlerAddr
;
535 // Store a copy of the functor to prevent using/calling an already
536 // destroyed instance:
539 // Use the address of the original functor for comparison in IsMatching:
540 const void *m_handlerAddr
;
542 // Provide a dummy default ctor for type info purposes
543 wxEventFunctorFunctor() { }
545 typedef wxEventFunctorFunctor
<EventTag
, Functor
> thisClass
;
546 WX_DECLARE_TYPEINFO_INLINE(thisClass
)
549 // Create functors for the templatized events, either allocated on the heap for
550 // wxNewXXX() variants (this is needed in wxEvtHandler::Bind<>() to store them
551 // in dynamic event table) or just by returning them as temporary objects (this
552 // is enough for Unbind<>() and we avoid unnecessary heap allocation like this).
555 // Create functors wrapping functions:
556 template <typename EventTag
, typename EventArg
>
557 inline wxEventFunctorFunction
<EventTag
, EventArg
> *
558 wxNewEventFunctor(const EventTag
&, void (*func
)(EventArg
&))
560 return new wxEventFunctorFunction
<EventTag
, EventArg
>(func
);
563 template <typename EventTag
, typename EventArg
>
564 inline wxEventFunctorFunction
<EventTag
, EventArg
>
565 wxMakeEventFunctor(const EventTag
&, void (*func
)(EventArg
&))
567 return wxEventFunctorFunction
<EventTag
, EventArg
>(func
);
570 // Create functors wrapping other functors:
571 template <typename EventTag
, typename Functor
>
572 inline wxEventFunctorFunctor
<EventTag
, Functor
> *
573 wxNewEventFunctor(const EventTag
&, const Functor
&func
)
575 return new wxEventFunctorFunctor
<EventTag
, Functor
>(func
);
578 template <typename EventTag
, typename Functor
>
579 inline wxEventFunctorFunctor
<EventTag
, Functor
>
580 wxMakeEventFunctor(const EventTag
&, const Functor
&func
)
582 return wxEventFunctorFunctor
<EventTag
, Functor
>(func
);
585 // Create functors wrapping methods:
587 <typename EventTag
, typename Class
, typename EventArg
, typename EventHandler
>
588 inline wxEventFunctorMethod
<EventTag
, Class
, EventArg
, EventHandler
> *
589 wxNewEventFunctor(const EventTag
&,
590 void (Class::*method
)(EventArg
&),
591 EventHandler
*handler
)
593 return new wxEventFunctorMethod
<EventTag
, Class
, EventArg
, EventHandler
>(
598 <typename EventTag
, typename Class
, typename EventArg
, typename EventHandler
>
599 inline wxEventFunctorMethod
<EventTag
, Class
, EventArg
, EventHandler
>
600 wxMakeEventFunctor(const EventTag
&,
601 void (Class::*method
)(EventArg
&),
602 EventHandler
*handler
)
604 return wxEventFunctorMethod
<EventTag
, Class
, EventArg
, EventHandler
>(
608 // Create an event functor for the event table via wxDECLARE_EVENT_TABLE_ENTRY:
609 // in this case we don't have the handler (as it's always the same as the
610 // object which generated the event) so we must use Class as its type
611 template <typename EventTag
, typename Class
, typename EventArg
>
612 inline wxEventFunctorMethod
<EventTag
, Class
, EventArg
, Class
> *
613 wxNewEventTableFunctor(const EventTag
&, void (Class::*method
)(EventArg
&))
615 return new wxEventFunctorMethod
<EventTag
, Class
, EventArg
, Class
>(
619 #endif // wxHAS_EVENT_BIND
622 // many, but not all, standard event types
624 // some generic events
625 extern WXDLLIMPEXP_BASE
const wxEventType wxEVT_NULL
;
626 extern WXDLLIMPEXP_BASE
const wxEventType wxEVT_FIRST
;
627 extern WXDLLIMPEXP_BASE
const wxEventType wxEVT_USER_FIRST
;
629 // Need events declared to do this
630 class WXDLLIMPEXP_FWD_BASE wxIdleEvent
;
631 class WXDLLIMPEXP_FWD_BASE wxThreadEvent
;
632 class WXDLLIMPEXP_FWD_BASE wxAsyncMethodCallEvent
;
633 class WXDLLIMPEXP_FWD_CORE wxCommandEvent
;
634 class WXDLLIMPEXP_FWD_CORE wxMouseEvent
;
635 class WXDLLIMPEXP_FWD_CORE wxFocusEvent
;
636 class WXDLLIMPEXP_FWD_CORE wxChildFocusEvent
;
637 class WXDLLIMPEXP_FWD_CORE wxKeyEvent
;
638 class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent
;
639 class WXDLLIMPEXP_FWD_CORE wxSetCursorEvent
;
640 class WXDLLIMPEXP_FWD_CORE wxScrollEvent
;
641 class WXDLLIMPEXP_FWD_CORE wxSpinEvent
;
642 class WXDLLIMPEXP_FWD_CORE wxScrollWinEvent
;
643 class WXDLLIMPEXP_FWD_CORE wxSizeEvent
;
644 class WXDLLIMPEXP_FWD_CORE wxMoveEvent
;
645 class WXDLLIMPEXP_FWD_CORE wxCloseEvent
;
646 class WXDLLIMPEXP_FWD_CORE wxActivateEvent
;
647 class WXDLLIMPEXP_FWD_CORE wxWindowCreateEvent
;
648 class WXDLLIMPEXP_FWD_CORE wxWindowDestroyEvent
;
649 class WXDLLIMPEXP_FWD_CORE wxShowEvent
;
650 class WXDLLIMPEXP_FWD_CORE wxIconizeEvent
;
651 class WXDLLIMPEXP_FWD_CORE wxMaximizeEvent
;
652 class WXDLLIMPEXP_FWD_CORE wxMouseCaptureChangedEvent
;
653 class WXDLLIMPEXP_FWD_CORE wxMouseCaptureLostEvent
;
654 class WXDLLIMPEXP_FWD_CORE wxPaintEvent
;
655 class WXDLLIMPEXP_FWD_CORE wxEraseEvent
;
656 class WXDLLIMPEXP_FWD_CORE wxNcPaintEvent
;
657 class WXDLLIMPEXP_FWD_CORE wxMenuEvent
;
658 class WXDLLIMPEXP_FWD_CORE wxContextMenuEvent
;
659 class WXDLLIMPEXP_FWD_CORE wxSysColourChangedEvent
;
660 class WXDLLIMPEXP_FWD_CORE wxDisplayChangedEvent
;
661 class WXDLLIMPEXP_FWD_CORE wxQueryNewPaletteEvent
;
662 class WXDLLIMPEXP_FWD_CORE wxPaletteChangedEvent
;
663 class WXDLLIMPEXP_FWD_CORE wxJoystickEvent
;
664 class WXDLLIMPEXP_FWD_CORE wxDropFilesEvent
;
665 class WXDLLIMPEXP_FWD_CORE wxInitDialogEvent
;
666 class WXDLLIMPEXP_FWD_CORE wxUpdateUIEvent
;
667 class WXDLLIMPEXP_FWD_CORE wxClipboardTextEvent
;
668 class WXDLLIMPEXP_FWD_CORE wxHelpEvent
;
672 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_BUTTON
, wxCommandEvent
);
673 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHECKBOX
, wxCommandEvent
);
674 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHOICE
, wxCommandEvent
);
675 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LISTBOX
, wxCommandEvent
);
676 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LISTBOX_DCLICK
, wxCommandEvent
);
677 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHECKLISTBOX
, wxCommandEvent
);
678 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MENU
, wxCommandEvent
);
679 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SLIDER
, wxCommandEvent
);
680 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_RADIOBOX
, wxCommandEvent
);
681 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_RADIOBUTTON
, wxCommandEvent
);
683 // wxEVT_SCROLLBAR is deprecated, use wxEVT_SCROLL... events
684 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLBAR
, wxCommandEvent
);
685 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_VLBOX
, wxCommandEvent
);
686 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMBOBOX
, wxCommandEvent
);
687 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TOOL_RCLICKED
, wxCommandEvent
);
688 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TOOL_DROPDOWN
, wxCommandEvent
);
689 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TOOL_ENTER
, wxCommandEvent
);
690 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMBOBOX_DROPDOWN
, wxCommandEvent
);
691 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMBOBOX_CLOSEUP
, wxCommandEvent
);
693 // Thread and asynchronous method call events
694 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE
, wxEVT_THREAD
, wxThreadEvent
);
695 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE
, wxEVT_ASYNC_METHOD_CALL
, wxAsyncMethodCallEvent
);
698 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LEFT_DOWN
, wxMouseEvent
);
699 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LEFT_UP
, wxMouseEvent
);
700 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MIDDLE_DOWN
, wxMouseEvent
);
701 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MIDDLE_UP
, wxMouseEvent
);
702 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_RIGHT_DOWN
, wxMouseEvent
);
703 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_RIGHT_UP
, wxMouseEvent
);
704 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOTION
, wxMouseEvent
);
705 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_ENTER_WINDOW
, wxMouseEvent
);
706 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LEAVE_WINDOW
, wxMouseEvent
);
707 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_LEFT_DCLICK
, wxMouseEvent
);
708 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MIDDLE_DCLICK
, wxMouseEvent
);
709 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_RIGHT_DCLICK
, wxMouseEvent
);
710 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SET_FOCUS
, wxFocusEvent
);
711 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_KILL_FOCUS
, wxFocusEvent
);
712 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHILD_FOCUS
, wxChildFocusEvent
);
713 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOUSEWHEEL
, wxMouseEvent
);
714 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX1_DOWN
, wxMouseEvent
);
715 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX1_UP
, wxMouseEvent
);
716 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX1_DCLICK
, wxMouseEvent
);
717 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX2_DOWN
, wxMouseEvent
);
718 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX2_UP
, wxMouseEvent
);
719 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AUX2_DCLICK
, wxMouseEvent
);
721 // Character input event type
722 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHAR
, wxKeyEvent
);
723 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CHAR_HOOK
, wxKeyEvent
);
724 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_NAVIGATION_KEY
, wxNavigationKeyEvent
);
725 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_KEY_DOWN
, wxKeyEvent
);
726 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_KEY_UP
, wxKeyEvent
);
728 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_HOTKEY
, wxKeyEvent
);
730 // This is a private event used by wxMSW code only and subject to change or
731 // disappear in the future. Don't use.
732 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_AFTER_CHAR
, wxKeyEvent
);
735 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SET_CURSOR
, wxSetCursorEvent
);
737 // wxScrollBar and wxSlider event identifiers
738 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_TOP
, wxScrollEvent
);
739 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_BOTTOM
, wxScrollEvent
);
740 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_LINEUP
, wxScrollEvent
);
741 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_LINEDOWN
, wxScrollEvent
);
742 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_PAGEUP
, wxScrollEvent
);
743 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_PAGEDOWN
, wxScrollEvent
);
744 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_THUMBTRACK
, wxScrollEvent
);
745 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_THUMBRELEASE
, wxScrollEvent
);
746 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLL_CHANGED
, wxScrollEvent
);
748 // Due to a bug in older wx versions, wxSpinEvents were being sent with type of
749 // wxEVT_SCROLL_LINEUP, wxEVT_SCROLL_LINEDOWN and wxEVT_SCROLL_THUMBTRACK. But
750 // with the type-safe events in place, these event types are associated with
751 // wxScrollEvent. To allow handling of spin events, new event types have been
752 // defined in spinbutt.h/spinnbuttcmn.cpp. To maintain backward compatibility
753 // the spin event types are being initialized with the scroll event types.
757 wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE
, wxEVT_SPIN_UP
, wxSpinEvent
);
758 wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE
, wxEVT_SPIN_DOWN
, wxSpinEvent
);
759 wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE
, wxEVT_SPIN
, wxSpinEvent
);
763 // Scroll events from wxWindow
764 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_TOP
, wxScrollWinEvent
);
765 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_BOTTOM
, wxScrollWinEvent
);
766 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_LINEUP
, wxScrollWinEvent
);
767 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_LINEDOWN
, wxScrollWinEvent
);
768 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_PAGEUP
, wxScrollWinEvent
);
769 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_PAGEDOWN
, wxScrollWinEvent
);
770 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_THUMBTRACK
, wxScrollWinEvent
);
771 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SCROLLWIN_THUMBRELEASE
, wxScrollWinEvent
);
774 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SIZE
, wxSizeEvent
);
775 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOVE
, wxMoveEvent
);
776 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CLOSE_WINDOW
, wxCloseEvent
);
777 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_END_SESSION
, wxCloseEvent
);
778 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_QUERY_END_SESSION
, wxCloseEvent
);
779 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_ACTIVATE_APP
, wxActivateEvent
);
780 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_ACTIVATE
, wxActivateEvent
);
781 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CREATE
, wxWindowCreateEvent
);
782 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_DESTROY
, wxWindowDestroyEvent
);
783 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SHOW
, wxShowEvent
);
784 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_ICONIZE
, wxIconizeEvent
);
785 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MAXIMIZE
, wxMaximizeEvent
);
786 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOUSE_CAPTURE_CHANGED
, wxMouseCaptureChangedEvent
);
787 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOUSE_CAPTURE_LOST
, wxMouseCaptureLostEvent
);
788 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_PAINT
, wxPaintEvent
);
789 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_ERASE_BACKGROUND
, wxEraseEvent
);
790 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_NC_PAINT
, wxNcPaintEvent
);
791 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MENU_OPEN
, wxMenuEvent
);
792 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MENU_CLOSE
, wxMenuEvent
);
793 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MENU_HIGHLIGHT
, wxMenuEvent
);
794 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_CONTEXT_MENU
, wxContextMenuEvent
);
795 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SYS_COLOUR_CHANGED
, wxSysColourChangedEvent
);
796 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_DISPLAY_CHANGED
, wxDisplayChangedEvent
);
797 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_QUERY_NEW_PALETTE
, wxQueryNewPaletteEvent
);
798 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_PALETTE_CHANGED
, wxPaletteChangedEvent
);
799 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_JOY_BUTTON_DOWN
, wxJoystickEvent
);
800 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_JOY_BUTTON_UP
, wxJoystickEvent
);
801 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_JOY_MOVE
, wxJoystickEvent
);
802 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_JOY_ZMOVE
, wxJoystickEvent
);
803 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_DROP_FILES
, wxDropFilesEvent
);
804 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_INIT_DIALOG
, wxInitDialogEvent
);
805 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE
, wxEVT_IDLE
, wxIdleEvent
);
806 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_UPDATE_UI
, wxUpdateUIEvent
);
807 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_SIZING
, wxSizeEvent
);
808 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOVING
, wxMoveEvent
);
809 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOVE_START
, wxMoveEvent
);
810 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_MOVE_END
, wxMoveEvent
);
811 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_HIBERNATE
, wxActivateEvent
);
814 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TEXT_COPY
, wxClipboardTextEvent
);
815 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TEXT_CUT
, wxClipboardTextEvent
);
816 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TEXT_PASTE
, wxClipboardTextEvent
);
818 // Generic command events
819 // Note: a click is a higher-level event than button down/up
820 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_LEFT_CLICK
, wxCommandEvent
);
821 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_LEFT_DCLICK
, wxCommandEvent
);
822 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_RIGHT_CLICK
, wxCommandEvent
);
823 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_RIGHT_DCLICK
, wxCommandEvent
);
824 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_SET_FOCUS
, wxCommandEvent
);
825 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_KILL_FOCUS
, wxCommandEvent
);
826 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_COMMAND_ENTER
, wxCommandEvent
);
829 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_HELP
, wxHelpEvent
);
830 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_DETAILED_HELP
, wxHelpEvent
);
832 // these 2 events are the same
833 #define wxEVT_TOOL wxEVT_MENU
835 // ----------------------------------------------------------------------------
837 // ----------------------------------------------------------------------------
839 // this event is also used by wxComboBox and wxSpinCtrl which don't include
840 // wx/textctrl.h in all ports [yet], so declare it here as well
842 // still, any new code using it should include wx/textctrl.h explicitly
843 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE
, wxEVT_TEXT
, wxCommandEvent
);
846 // ----------------------------------------------------------------------------
847 // wxEvent(-derived) classes
848 // ----------------------------------------------------------------------------
850 // the predefined constants for the number of times we propagate event
851 // upwards window child-parent chain
852 enum wxEventPropagation
854 // don't propagate it at all
855 wxEVENT_PROPAGATE_NONE
= 0,
857 // propagate it until it is processed
858 wxEVENT_PROPAGATE_MAX
= INT_MAX
861 // The different categories for a wxEvent; see wxEvent::GetEventCategory.
862 // NOTE: they are used as OR-combinable flags by wxEventLoopBase::YieldFor
865 // this is the category for those events which are generated to update
866 // the appearance of the GUI but which (usually) do not comport data
867 // processing, i.e. which do not provide input or output data
868 // (e.g. size events, scroll events, etc).
869 // They are events NOT directly generated by the user's input devices.
870 wxEVT_CATEGORY_UI
= 1,
872 // this category groups those events which are generated directly from the
873 // user through input devices like mouse and keyboard and usually result in
874 // data to be processed from the application.
875 // (e.g. mouse clicks, key presses, etc)
876 wxEVT_CATEGORY_USER_INPUT
= 2,
878 // this category is for wxSocketEvent
879 wxEVT_CATEGORY_SOCKET
= 4,
881 // this category is for wxTimerEvent
882 wxEVT_CATEGORY_TIMER
= 8,
884 // this category is for any event used to send notifications from the
885 // secondary threads to the main one or in general for notifications among
886 // different threads (which may or may not be user-generated)
887 wxEVT_CATEGORY_THREAD
= 16,
890 // implementation only
892 // used in the implementations of wxEventLoopBase::YieldFor
893 wxEVT_CATEGORY_UNKNOWN
= 32,
895 // a special category used as an argument to wxEventLoopBase::YieldFor to indicate that
896 // Yield() should leave all wxEvents on the queue while emptying the native event queue
897 // (native events will be processed but the wxEvents they generate will be queued)
898 wxEVT_CATEGORY_CLIPBOARD
= 64,
903 // this category groups those events which are emitted in response to
904 // events of the native toolkit and which typically are not-"delayable".
905 wxEVT_CATEGORY_NATIVE_EVENTS
= wxEVT_CATEGORY_UI
|wxEVT_CATEGORY_USER_INPUT
,
907 // used in wxEventLoopBase::YieldFor to specify all event categories should be processed:
909 wxEVT_CATEGORY_UI
|wxEVT_CATEGORY_USER_INPUT
|wxEVT_CATEGORY_SOCKET
| \
910 wxEVT_CATEGORY_TIMER
|wxEVT_CATEGORY_THREAD
|wxEVT_CATEGORY_UNKNOWN
| \
911 wxEVT_CATEGORY_CLIPBOARD
915 * wxWidgets events, covering all interesting things that might happen
916 * (button clicking, resizing, setting text in widgets, etc.).
918 * For each completely new event type, derive a new event class.
919 * An event CLASS represents a C++ class defining a range of similar event TYPES;
920 * examples are canvas events, panel item command events.
921 * An event TYPE is a unique identifier for a particular system event,
922 * such as a button press or a listbox deselection.
926 class WXDLLIMPEXP_BASE wxEvent
: public wxObject
929 wxEvent(int winid
= 0, wxEventType commandType
= wxEVT_NULL
);
931 void SetEventType(wxEventType typ
) { m_eventType
= typ
; }
932 wxEventType
GetEventType() const { return m_eventType
; }
934 wxObject
*GetEventObject() const { return m_eventObject
; }
935 void SetEventObject(wxObject
*obj
) { m_eventObject
= obj
; }
937 long GetTimestamp() const { return m_timeStamp
; }
938 void SetTimestamp(long ts
= 0) { m_timeStamp
= ts
; }
940 int GetId() const { return m_id
; }
941 void SetId(int Id
) { m_id
= Id
; }
943 // Returns the user data optionally associated with the event handler when
944 // using Connect() or Bind().
945 wxObject
*GetEventUserData() const { return m_callbackUserData
; }
947 // Can instruct event processor that we wish to ignore this event
948 // (treat as if the event table entry had not been found): this must be done
949 // to allow the event processing by the base classes (calling event.Skip()
950 // is the analog of calling the base class version of a virtual function)
951 void Skip(bool skip
= true) { m_skipped
= skip
; }
952 bool GetSkipped() const { return m_skipped
; }
954 // This function is used to create a copy of the event polymorphically and
955 // all derived classes must implement it because otherwise wxPostEvent()
956 // for them wouldn't work (it needs to do a copy of the event)
957 virtual wxEvent
*Clone() const = 0;
959 // this function is used to selectively process events in wxEventLoopBase::YieldFor
960 // NOTE: by default it returns wxEVT_CATEGORY_UI just because the major
961 // part of wxWidgets events belong to that category.
962 virtual wxEventCategory
GetEventCategory() const
963 { return wxEVT_CATEGORY_UI
; }
965 // Implementation only: this test is explicitly anti OO and this function
966 // exists only for optimization purposes.
967 bool IsCommandEvent() const { return m_isCommandEvent
; }
969 // Determine if this event should be propagating to the parent window.
970 bool ShouldPropagate() const
971 { return m_propagationLevel
!= wxEVENT_PROPAGATE_NONE
; }
973 // Stop an event from propagating to its parent window, returns the old
974 // propagation level value
975 int StopPropagation()
977 int propagationLevel
= m_propagationLevel
;
978 m_propagationLevel
= wxEVENT_PROPAGATE_NONE
;
979 return propagationLevel
;
982 // Resume the event propagation by restoring the propagation level
983 // (returned by StopPropagation())
984 void ResumePropagation(int propagationLevel
)
986 m_propagationLevel
= propagationLevel
;
990 // This is for internal use only and is only called by
991 // wxEvtHandler::ProcessEvent() to check whether it's the first time this
992 // event is being processed
995 if ( m_wasProcessed
)
998 m_wasProcessed
= true;
1003 // This is also used only internally by ProcessEvent() to check if it
1004 // should process the event normally or only restrict the search for the
1005 // event handler to this object itself.
1006 bool ShouldProcessOnlyIn(wxEvtHandler
*h
) const
1008 return h
== m_handlerToProcessOnlyIn
;
1011 // Called to indicate that the result of ShouldProcessOnlyIn() wasn't taken
1012 // into account. The existence of this function may seem counterintuitive
1013 // but unfortunately it's needed by wxScrollHelperEvtHandler, see comments
1014 // there. Don't even think of using this in your own code, this is a gross
1015 // hack and is only needed because of wx complicated history and should
1016 // never be used anywhere else.
1017 void DidntHonourProcessOnlyIn()
1019 m_handlerToProcessOnlyIn
= NULL
;
1023 wxObject
* m_eventObject
;
1024 wxEventType m_eventType
;
1029 // m_callbackUserData is for internal usage only
1030 wxObject
* m_callbackUserData
;
1034 wxEvtHandler
*m_handlerToProcessOnlyIn
;
1037 // the propagation level: while it is positive, we propagate the event to
1038 // the parent window (if any)
1039 int m_propagationLevel
;
1042 bool m_isCommandEvent
;
1044 // initially false but becomes true as soon as WasProcessed() is called for
1045 // the first time, as this is done only by ProcessEvent() it explains the
1046 // variable name: it becomes true after ProcessEvent() was called at least
1047 // once for this event
1048 bool m_wasProcessed
;
1051 wxEvent(const wxEvent
&); // for implementing Clone()
1052 wxEvent
& operator=(const wxEvent
&); // for derived classes operator=()
1055 // it needs to access our m_propagationLevel
1056 friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce
;
1058 // and this one needs to access our m_handlerToProcessOnlyIn
1059 friend class WXDLLIMPEXP_FWD_BASE wxEventProcessInHandlerOnly
;
1062 DECLARE_ABSTRACT_CLASS(wxEvent
)
1066 * Helper class to temporarily change an event not to propagate.
1068 class WXDLLIMPEXP_BASE wxPropagationDisabler
1071 wxPropagationDisabler(wxEvent
& event
) : m_event(event
)
1073 m_propagationLevelOld
= m_event
.StopPropagation();
1076 ~wxPropagationDisabler()
1078 m_event
.ResumePropagation(m_propagationLevelOld
);
1083 int m_propagationLevelOld
;
1085 wxDECLARE_NO_COPY_CLASS(wxPropagationDisabler
);
1089 * Another one to temporarily lower propagation level.
1091 class WXDLLIMPEXP_BASE wxPropagateOnce
1094 wxPropagateOnce(wxEvent
& event
) : m_event(event
)
1096 wxASSERT_MSG( m_event
.m_propagationLevel
> 0,
1097 wxT("shouldn't be used unless ShouldPropagate()!") );
1099 m_event
.m_propagationLevel
--;
1104 m_event
.m_propagationLevel
++;
1110 wxDECLARE_NO_COPY_CLASS(wxPropagateOnce
);
1113 // A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn()
1114 // return true for the handler passed to its ctor.
1115 class wxEventProcessInHandlerOnly
1118 wxEventProcessInHandlerOnly(wxEvent
& event
, wxEvtHandler
*handler
)
1120 m_handlerToProcessOnlyInOld(event
.m_handlerToProcessOnlyIn
)
1122 m_event
.m_handlerToProcessOnlyIn
= handler
;
1125 ~wxEventProcessInHandlerOnly()
1127 m_event
.m_handlerToProcessOnlyIn
= m_handlerToProcessOnlyInOld
;
1132 wxEvtHandler
* const m_handlerToProcessOnlyInOld
;
1134 wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly
);
1138 class WXDLLIMPEXP_BASE wxEventBasicPayloadMixin
1141 wxEventBasicPayloadMixin()
1147 void SetString(const wxString
& s
) { m_cmdString
= s
; }
1148 const wxString
& GetString() const { return m_cmdString
; }
1150 void SetInt(int i
) { m_commandInt
= i
; }
1151 int GetInt() const { return m_commandInt
; }
1153 void SetExtraLong(long extraLong
) { m_extraLong
= extraLong
; }
1154 long GetExtraLong() const { return m_extraLong
; }
1157 // Note: these variables have "cmd" or "command" in their name for backward compatibility:
1158 // they used to be part of wxCommandEvent, not this mixin.
1159 wxString m_cmdString
; // String event argument
1161 long m_extraLong
; // Additional information (e.g. select/deselect)
1163 wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin
);
1166 class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin
: public wxEventBasicPayloadMixin
1169 wxEventAnyPayloadMixin() : wxEventBasicPayloadMixin() {}
1171 #if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
1172 template<typename T
>
1173 void SetPayload(const T
& payload
)
1175 m_payload
= payload
;
1178 template<typename T
>
1179 T
GetPayload() const
1181 return m_payload
.As
<T
>();
1186 #endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
1188 wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin
);
1197 // Whether to always send idle events to windows, or
1198 // to only send update events to those with the
1199 // wxWS_EX_PROCESS_IDLE style.
1203 // Send idle events to all windows
1206 // Send idle events to windows that have
1207 // the wxWS_EX_PROCESS_IDLE flag specified
1208 wxIDLE_PROCESS_SPECIFIED
1211 class WXDLLIMPEXP_BASE wxIdleEvent
: public wxEvent
1215 : wxEvent(0, wxEVT_IDLE
),
1216 m_requestMore(false)
1218 wxIdleEvent(const wxIdleEvent
& event
)
1220 m_requestMore(event
.m_requestMore
)
1223 void RequestMore(bool needMore
= true) { m_requestMore
= needMore
; }
1224 bool MoreRequested() const { return m_requestMore
; }
1226 virtual wxEvent
*Clone() const { return new wxIdleEvent(*this); }
1228 // Specify how wxWidgets will send idle events: to
1229 // all windows, or only to those which specify that they
1230 // will process the events.
1231 static void SetMode(wxIdleMode mode
) { sm_idleMode
= mode
; }
1233 // Returns the idle event mode
1234 static wxIdleMode
GetMode() { return sm_idleMode
; }
1238 static wxIdleMode sm_idleMode
;
1241 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent
)
1247 class WXDLLIMPEXP_BASE wxThreadEvent
: public wxEvent
,
1248 public wxEventAnyPayloadMixin
1251 wxThreadEvent(wxEventType eventType
= wxEVT_THREAD
, int id
= wxID_ANY
)
1252 : wxEvent(id
, eventType
)
1255 wxThreadEvent(const wxThreadEvent
& event
)
1257 wxEventAnyPayloadMixin(event
)
1259 // make sure our string member (which uses COW, aka refcounting) is not
1260 // shared by other wxString instances:
1261 SetString(GetString().Clone());
1264 virtual wxEvent
*Clone() const
1266 return new wxThreadEvent(*this);
1269 // this is important to avoid that calling wxEventLoopBase::YieldFor thread events
1270 // gets processed when this is unwanted:
1271 virtual wxEventCategory
GetEventCategory() const
1272 { return wxEVT_CATEGORY_THREAD
; }
1275 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThreadEvent
)
1279 // Asynchronous method call events: these event are processed by wxEvtHandler
1280 // itself and result in a call to its Execute() method which simply calls the
1281 // specified method. The difference with a simple method call is that this is
1282 // done asynchronously, i.e. at some later time, instead of immediately when
1283 // the event object is constructed.
1285 #ifdef wxHAS_CALL_AFTER
1287 // This is a base class used to process all method calls.
1288 class wxAsyncMethodCallEvent
: public wxEvent
1291 wxAsyncMethodCallEvent(wxObject
* object
)
1292 : wxEvent(wxID_ANY
, wxEVT_ASYNC_METHOD_CALL
)
1294 SetEventObject(object
);
1297 wxAsyncMethodCallEvent(const wxAsyncMethodCallEvent
& other
)
1302 virtual void Execute() = 0;
1305 // This is a version for calling methods without parameters.
1306 template <typename T
>
1307 class wxAsyncMethodCallEvent0
: public wxAsyncMethodCallEvent
1310 typedef T ObjectType
;
1311 typedef void (ObjectType::*MethodType
)();
1313 wxAsyncMethodCallEvent0(ObjectType
* object
,
1315 : wxAsyncMethodCallEvent(object
),
1321 wxAsyncMethodCallEvent0(const wxAsyncMethodCallEvent0
& other
)
1322 : wxAsyncMethodCallEvent(other
),
1323 m_object(other
.m_object
),
1324 m_method(other
.m_method
)
1328 virtual wxEvent
*Clone() const
1330 return new wxAsyncMethodCallEvent0(*this);
1333 virtual void Execute()
1335 (m_object
->*m_method
)();
1339 ObjectType
* const m_object
;
1340 const MethodType m_method
;
1343 // This is a version for calling methods with a single parameter.
1344 template <typename T
, typename T1
>
1345 class wxAsyncMethodCallEvent1
: public wxAsyncMethodCallEvent
1348 typedef T ObjectType
;
1349 typedef void (ObjectType::*MethodType
)(T1 x1
);
1350 typedef typename wxRemoveRef
<T1
>::type ParamType1
;
1352 wxAsyncMethodCallEvent1(ObjectType
* object
,
1354 const ParamType1
& x1
)
1355 : wxAsyncMethodCallEvent(object
),
1362 wxAsyncMethodCallEvent1(const wxAsyncMethodCallEvent1
& other
)
1363 : wxAsyncMethodCallEvent(other
),
1364 m_object(other
.m_object
),
1365 m_method(other
.m_method
),
1366 m_param1(other
.m_param1
)
1370 virtual wxEvent
*Clone() const
1372 return new wxAsyncMethodCallEvent1(*this);
1375 virtual void Execute()
1377 (m_object
->*m_method
)(m_param1
);
1381 ObjectType
* const m_object
;
1382 const MethodType m_method
;
1383 const ParamType1 m_param1
;
1386 // This is a version for calling methods with two parameters.
1387 template <typename T
, typename T1
, typename T2
>
1388 class wxAsyncMethodCallEvent2
: public wxAsyncMethodCallEvent
1391 typedef T ObjectType
;
1392 typedef void (ObjectType::*MethodType
)(T1 x1
, T2 x2
);
1393 typedef typename wxRemoveRef
<T1
>::type ParamType1
;
1394 typedef typename wxRemoveRef
<T2
>::type ParamType2
;
1396 wxAsyncMethodCallEvent2(ObjectType
* object
,
1398 const ParamType1
& x1
,
1399 const ParamType2
& x2
)
1400 : wxAsyncMethodCallEvent(object
),
1408 wxAsyncMethodCallEvent2(const wxAsyncMethodCallEvent2
& other
)
1409 : wxAsyncMethodCallEvent(other
),
1410 m_object(other
.m_object
),
1411 m_method(other
.m_method
),
1412 m_param1(other
.m_param1
),
1413 m_param2(other
.m_param2
)
1417 virtual wxEvent
*Clone() const
1419 return new wxAsyncMethodCallEvent2(*this);
1422 virtual void Execute()
1424 (m_object
->*m_method
)(m_param1
, m_param2
);
1428 ObjectType
* const m_object
;
1429 const MethodType m_method
;
1430 const ParamType1 m_param1
;
1431 const ParamType2 m_param2
;
1434 #endif // wxHAS_CALL_AFTER
1440 // Item or menu event class
1446 wxEVT_LISTBOX_DCLICK
1459 class WXDLLIMPEXP_CORE wxCommandEvent
: public wxEvent
,
1460 public wxEventBasicPayloadMixin
1463 wxCommandEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0);
1465 wxCommandEvent(const wxCommandEvent
& event
)
1467 wxEventBasicPayloadMixin(event
),
1468 m_clientData(event
.m_clientData
),
1469 m_clientObject(event
.m_clientObject
)
1471 // Because GetString() can retrieve the string text only on demand, we
1472 // need to copy it explicitly.
1473 if ( m_cmdString
.empty() )
1474 m_cmdString
= event
.GetString();
1477 // Set/Get client data from controls
1478 void SetClientData(void* clientData
) { m_clientData
= clientData
; }
1479 void *GetClientData() const { return m_clientData
; }
1481 // Set/Get client object from controls
1482 void SetClientObject(wxClientData
* clientObject
) { m_clientObject
= clientObject
; }
1483 wxClientData
*GetClientObject() const { return m_clientObject
; }
1485 // Note: this shadows wxEventBasicPayloadMixin::GetString(), because it does some
1486 // GUI-specific hacks
1487 wxString
GetString() const;
1489 // Get listbox selection if single-choice
1490 int GetSelection() const { return m_commandInt
; }
1492 // Get checkbox value
1493 bool IsChecked() const { return m_commandInt
!= 0; }
1495 // true if the listbox event was a selection.
1496 bool IsSelection() const { return (m_extraLong
!= 0); }
1498 virtual wxEvent
*Clone() const { return new wxCommandEvent(*this); }
1499 virtual wxEventCategory
GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT
; }
1502 void* m_clientData
; // Arbitrary client data
1503 wxClientData
* m_clientObject
; // Arbitrary client object
1506 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent
)
1509 // this class adds a possibility to react (from the user) code to a control
1510 // notification: allow or veto the operation being reported.
1511 class WXDLLIMPEXP_CORE wxNotifyEvent
: public wxCommandEvent
1514 wxNotifyEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
1515 : wxCommandEvent(commandType
, winid
)
1516 { m_bAllow
= true; }
1518 wxNotifyEvent(const wxNotifyEvent
& event
)
1519 : wxCommandEvent(event
)
1520 { m_bAllow
= event
.m_bAllow
; }
1522 // veto the operation (usually it's allowed by default)
1523 void Veto() { m_bAllow
= false; }
1525 // allow the operation if it was disabled by default
1526 void Allow() { m_bAllow
= true; }
1528 // for implementation code only: is the operation allowed?
1529 bool IsAllowed() const { return m_bAllow
; }
1531 virtual wxEvent
*Clone() const { return new wxNotifyEvent(*this); }
1537 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent
)
1541 // Scroll event class, derived form wxCommandEvent. wxScrollEvents are
1542 // sent by wxSlider and wxScrollBar.
1547 wxEVT_SCROLL_LINEDOWN
1549 wxEVT_SCROLL_PAGEDOWN
1550 wxEVT_SCROLL_THUMBTRACK
1551 wxEVT_SCROLL_THUMBRELEASE
1552 wxEVT_SCROLL_CHANGED
1555 class WXDLLIMPEXP_CORE wxScrollEvent
: public wxCommandEvent
1558 wxScrollEvent(wxEventType commandType
= wxEVT_NULL
,
1559 int winid
= 0, int pos
= 0, int orient
= 0);
1561 int GetOrientation() const { return (int) m_extraLong
; }
1562 int GetPosition() const { return m_commandInt
; }
1563 void SetOrientation(int orient
) { m_extraLong
= (long) orient
; }
1564 void SetPosition(int pos
) { m_commandInt
= pos
; }
1566 virtual wxEvent
*Clone() const { return new wxScrollEvent(*this); }
1569 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent
)
1572 // ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
1573 // are sent by wxWindow.
1576 wxEVT_SCROLLWIN_BOTTOM
1577 wxEVT_SCROLLWIN_LINEUP
1578 wxEVT_SCROLLWIN_LINEDOWN
1579 wxEVT_SCROLLWIN_PAGEUP
1580 wxEVT_SCROLLWIN_PAGEDOWN
1581 wxEVT_SCROLLWIN_THUMBTRACK
1582 wxEVT_SCROLLWIN_THUMBRELEASE
1585 class WXDLLIMPEXP_CORE wxScrollWinEvent
: public wxEvent
1588 wxScrollWinEvent(wxEventType commandType
= wxEVT_NULL
,
1589 int pos
= 0, int orient
= 0);
1590 wxScrollWinEvent(const wxScrollWinEvent
& event
) : wxEvent(event
)
1591 { m_commandInt
= event
.m_commandInt
;
1592 m_extraLong
= event
.m_extraLong
; }
1594 int GetOrientation() const { return (int) m_extraLong
; }
1595 int GetPosition() const { return m_commandInt
; }
1596 void SetOrientation(int orient
) { m_extraLong
= (long) orient
; }
1597 void SetPosition(int pos
) { m_commandInt
= pos
; }
1599 virtual wxEvent
*Clone() const { return new wxScrollWinEvent(*this); }
1606 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent
)
1611 // Mouse event class
1628 enum wxMouseWheelAxis
1630 wxMOUSE_WHEEL_VERTICAL
,
1631 wxMOUSE_WHEEL_HORIZONTAL
1634 class WXDLLIMPEXP_CORE wxMouseEvent
: public wxEvent
,
1638 wxMouseEvent(wxEventType mouseType
= wxEVT_NULL
);
1639 wxMouseEvent(const wxMouseEvent
& event
)
1646 // Was it a button event? (*doesn't* mean: is any button *down*?)
1647 bool IsButton() const { return Button(wxMOUSE_BTN_ANY
); }
1649 // Was it a down event from this (or any) button?
1650 bool ButtonDown(int but
= wxMOUSE_BTN_ANY
) const;
1652 // Was it a dclick event from this (or any) button?
1653 bool ButtonDClick(int but
= wxMOUSE_BTN_ANY
) const;
1655 // Was it a up event from this (or any) button?
1656 bool ButtonUp(int but
= wxMOUSE_BTN_ANY
) const;
1658 // Was this event generated by the given button?
1659 bool Button(int but
) const;
1661 // Get the button which is changing state (wxMOUSE_BTN_NONE if none)
1662 int GetButton() const;
1664 // Find which event was just generated
1665 bool LeftDown() const { return (m_eventType
== wxEVT_LEFT_DOWN
); }
1666 bool MiddleDown() const { return (m_eventType
== wxEVT_MIDDLE_DOWN
); }
1667 bool RightDown() const { return (m_eventType
== wxEVT_RIGHT_DOWN
); }
1668 bool Aux1Down() const { return (m_eventType
== wxEVT_AUX1_DOWN
); }
1669 bool Aux2Down() const { return (m_eventType
== wxEVT_AUX2_DOWN
); }
1671 bool LeftUp() const { return (m_eventType
== wxEVT_LEFT_UP
); }
1672 bool MiddleUp() const { return (m_eventType
== wxEVT_MIDDLE_UP
); }
1673 bool RightUp() const { return (m_eventType
== wxEVT_RIGHT_UP
); }
1674 bool Aux1Up() const { return (m_eventType
== wxEVT_AUX1_UP
); }
1675 bool Aux2Up() const { return (m_eventType
== wxEVT_AUX2_UP
); }
1677 bool LeftDClick() const { return (m_eventType
== wxEVT_LEFT_DCLICK
); }
1678 bool MiddleDClick() const { return (m_eventType
== wxEVT_MIDDLE_DCLICK
); }
1679 bool RightDClick() const { return (m_eventType
== wxEVT_RIGHT_DCLICK
); }
1680 bool Aux1DClick() const { return (m_eventType
== wxEVT_AUX1_DCLICK
); }
1681 bool Aux2DClick() const { return (m_eventType
== wxEVT_AUX2_DCLICK
); }
1683 // True if a button is down and the mouse is moving
1684 bool Dragging() const
1686 return (m_eventType
== wxEVT_MOTION
) && ButtonIsDown(wxMOUSE_BTN_ANY
);
1689 // True if the mouse is moving, and no button is down
1692 return (m_eventType
== wxEVT_MOTION
) && !ButtonIsDown(wxMOUSE_BTN_ANY
);
1695 // True if the mouse is just entering the window
1696 bool Entering() const { return (m_eventType
== wxEVT_ENTER_WINDOW
); }
1698 // True if the mouse is just leaving the window
1699 bool Leaving() const { return (m_eventType
== wxEVT_LEAVE_WINDOW
); }
1701 // Returns the number of mouse clicks associated with this event.
1702 int GetClickCount() const { return m_clickCount
; }
1704 // Find the logical position of the event given the DC
1705 wxPoint
GetLogicalPosition(const wxDC
& dc
) const;
1707 // Get wheel rotation, positive or negative indicates direction of
1708 // rotation. Current devices all send an event when rotation is equal to
1709 // +/-WheelDelta, but this allows for finer resolution devices to be
1710 // created in the future. Because of this you shouldn't assume that one
1711 // event is equal to 1 line or whatever, but you should be able to either
1712 // do partial line scrolling or wait until +/-WheelDelta rotation values
1713 // have been accumulated before scrolling.
1714 int GetWheelRotation() const { return m_wheelRotation
; }
1716 // Get wheel delta, normally 120. This is the threshold for action to be
1717 // taken, and one such action (for example, scrolling one increment)
1718 // should occur for each delta.
1719 int GetWheelDelta() const { return m_wheelDelta
; }
1721 // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL
1722 // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling
1723 // using e.g. a trackpad).
1724 wxMouseWheelAxis
GetWheelAxis() const { return m_wheelAxis
; }
1726 // Returns the configured number of lines (or whatever) to be scrolled per
1727 // wheel action. Defaults to one.
1728 int GetLinesPerAction() const { return m_linesPerAction
; }
1730 // Is the system set to do page scrolling?
1731 bool IsPageScroll() const { return ((unsigned int)m_linesPerAction
== UINT_MAX
); }
1733 virtual wxEvent
*Clone() const { return new wxMouseEvent(*this); }
1734 virtual wxEventCategory
GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT
; }
1736 wxMouseEvent
& operator=(const wxMouseEvent
& event
)
1746 wxMouseWheelAxis m_wheelAxis
;
1747 int m_wheelRotation
;
1749 int m_linesPerAction
;
1752 void Assign(const wxMouseEvent
& evt
);
1755 DECLARE_DYNAMIC_CLASS(wxMouseEvent
)
1764 class WXDLLIMPEXP_CORE wxSetCursorEvent
: public wxEvent
1767 wxSetCursorEvent(wxCoord x
= 0, wxCoord y
= 0)
1768 : wxEvent(0, wxEVT_SET_CURSOR
),
1769 m_x(x
), m_y(y
), m_cursor()
1772 wxSetCursorEvent(const wxSetCursorEvent
& event
)
1776 m_cursor(event
.m_cursor
)
1779 wxCoord
GetX() const { return m_x
; }
1780 wxCoord
GetY() const { return m_y
; }
1782 void SetCursor(const wxCursor
& cursor
) { m_cursor
= cursor
; }
1783 const wxCursor
& GetCursor() const { return m_cursor
; }
1784 bool HasCursor() const { return m_cursor
.IsOk(); }
1786 virtual wxEvent
*Clone() const { return new wxSetCursorEvent(*this); }
1793 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent
)
1796 // Keyboard input event class
1806 // key categories: the bit flags for IsKeyInCategory() function
1808 // the enum values used may change in future version of wx
1809 // use the named constants only, or bitwise combinations thereof
1810 enum wxKeyCategoryFlags
1812 // arrow keys, on and off numeric keypads
1813 WXK_CATEGORY_ARROW
= 1,
1815 // page up and page down keys, on and off numeric keypads
1816 WXK_CATEGORY_PAGING
= 2,
1818 // home and end keys, on and off numeric keypads
1819 WXK_CATEGORY_JUMP
= 4,
1821 // tab key, on and off numeric keypads
1822 WXK_CATEGORY_TAB
= 8,
1824 // backspace and delete keys, on and off numeric keypads
1825 WXK_CATEGORY_CUT
= 16,
1827 // all keys usually used for navigation
1828 WXK_CATEGORY_NAVIGATION
= WXK_CATEGORY_ARROW
|
1829 WXK_CATEGORY_PAGING
|
1833 class WXDLLIMPEXP_CORE wxKeyEvent
: public wxEvent
,
1834 public wxKeyboardState
1837 wxKeyEvent(wxEventType keyType
= wxEVT_NULL
);
1839 // Normal copy ctor and a ctor creating a new event for the same key as the
1840 // given one but a different event type (this is used in implementation
1841 // code only, do not use outside of the library).
1842 wxKeyEvent(const wxKeyEvent
& evt
);
1843 wxKeyEvent(wxEventType eventType
, const wxKeyEvent
& evt
);
1845 // get the key code: an ASCII7 char or an element of wxKeyCode enum
1846 int GetKeyCode() const { return (int)m_keyCode
; }
1848 // returns true iff this event's key code is of a certain type
1849 bool IsKeyInCategory(int category
) const;
1852 // get the Unicode character corresponding to this key
1853 wxChar
GetUnicodeKey() const { return m_uniChar
; }
1854 #endif // wxUSE_UNICODE
1856 // get the raw key code (platform-dependent)
1857 wxUint32
GetRawKeyCode() const { return m_rawCode
; }
1859 // get the raw key flags (platform-dependent)
1860 wxUint32
GetRawKeyFlags() const { return m_rawFlags
; }
1862 // Find the position of the event
1863 void GetPosition(wxCoord
*xpos
, wxCoord
*ypos
) const
1871 // This version if provided only for backwards compatiblity, don't use.
1872 void GetPosition(long *xpos
, long *ypos
) const
1880 wxPoint
GetPosition() const
1881 { return wxPoint(GetX(), GetY()); }
1884 wxCoord
GetX() const;
1887 wxCoord
GetY() const;
1889 // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
1890 // key events even though the event had been handled (by default they would
1891 // not be generated in this case).
1892 void DoAllowNextEvent() { m_allowNext
= true; }
1894 // Return the value of the "allow next" flag, for internal use only.
1895 bool IsNextEventAllowed() const { return m_allowNext
; }
1898 virtual wxEvent
*Clone() const { return new wxKeyEvent(*this); }
1899 virtual wxEventCategory
GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT
; }
1901 // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
1903 wxKeyEvent
& operator=(const wxKeyEvent
& evt
)
1907 wxEvent::operator=(evt
);
1909 // Borland C++ 5.82 doesn't compile an explicit call to an
1910 // implicitly defined operator=() so need to do it this way:
1911 *static_cast<wxKeyboardState
*>(this) = evt
;
1913 DoAssignMembers(evt
);
1919 // Do not use these fields directly, they are initialized on demand, so
1920 // call GetX() and GetY() or GetPosition() instead.
1926 // This contains the full Unicode character
1927 // in a character events in Unicode mode
1931 // these fields contain the platform-specific information about
1932 // key that was pressed
1934 wxUint32 m_rawFlags
;
1937 // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK
1938 // type. This is used by all ctors.
1939 void InitPropagation()
1941 if ( m_eventType
== wxEVT_CHAR_HOOK
)
1942 m_propagationLevel
= wxEVENT_PROPAGATE_MAX
;
1944 m_allowNext
= false;
1947 // Copy only the event data present in this class, this is used by
1948 // AssignKeyData() and copy ctor.
1949 void DoAssignMembers(const wxKeyEvent
& evt
)
1953 m_hasPosition
= evt
.m_hasPosition
;
1955 m_keyCode
= evt
.m_keyCode
;
1957 m_rawCode
= evt
.m_rawCode
;
1958 m_rawFlags
= evt
.m_rawFlags
;
1960 m_uniChar
= evt
.m_uniChar
;
1964 // Initialize m_x and m_y using the current mouse cursor position if
1966 void InitPositionIfNecessary() const;
1968 // If this flag is true, the normal key events should still be generated
1969 // even if wxEVT_CHAR_HOOK had been handled. By default it is false as
1970 // handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
1973 // If true, m_x and m_y were already initialized. If false, try to get them
1974 // when they're requested.
1977 DECLARE_DYNAMIC_CLASS(wxKeyEvent
)
1985 class WXDLLIMPEXP_CORE wxSizeEvent
: public wxEvent
1988 wxSizeEvent() : wxEvent(0, wxEVT_SIZE
)
1990 wxSizeEvent(const wxSize
& sz
, int winid
= 0)
1991 : wxEvent(winid
, wxEVT_SIZE
),
1994 wxSizeEvent(const wxSizeEvent
& event
)
1996 m_size(event
.m_size
), m_rect(event
.m_rect
)
1998 wxSizeEvent(const wxRect
& rect
, int id
= 0)
1999 : m_size(rect
.GetSize()), m_rect(rect
)
2000 { m_eventType
= wxEVT_SIZING
; m_id
= id
; }
2002 wxSize
GetSize() const { return m_size
; }
2003 void SetSize(wxSize size
) { m_size
= size
; }
2004 wxRect
GetRect() const { return m_rect
; }
2005 void SetRect(const wxRect
& rect
) { m_rect
= rect
; }
2007 virtual wxEvent
*Clone() const { return new wxSizeEvent(*this); }
2010 // For internal usage only. Will be converted to protected members.
2012 wxRect m_rect
; // Used for wxEVT_SIZING
2015 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent
)
2024 class WXDLLIMPEXP_CORE wxMoveEvent
: public wxEvent
2028 : wxEvent(0, wxEVT_MOVE
)
2030 wxMoveEvent(const wxPoint
& pos
, int winid
= 0)
2031 : wxEvent(winid
, wxEVT_MOVE
),
2034 wxMoveEvent(const wxMoveEvent
& event
)
2038 wxMoveEvent(const wxRect
& rect
, int id
= 0)
2039 : m_pos(rect
.GetPosition()), m_rect(rect
)
2040 { m_eventType
= wxEVT_MOVING
; m_id
= id
; }
2042 wxPoint
GetPosition() const { return m_pos
; }
2043 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2044 wxRect
GetRect() const { return m_rect
; }
2045 void SetRect(const wxRect
& rect
) { m_rect
= rect
; }
2047 virtual wxEvent
*Clone() const { return new wxMoveEvent(*this); }
2054 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent
)
2057 // Paint event class
2063 #if wxDEBUG_LEVEL && (defined(__WXMSW__) || defined(__WXPM__))
2064 #define wxHAS_PAINT_DEBUG
2066 // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
2067 extern WXDLLIMPEXP_CORE
int g_isPainting
;
2070 class WXDLLIMPEXP_CORE wxPaintEvent
: public wxEvent
2073 wxPaintEvent(int Id
= 0)
2074 : wxEvent(Id
, wxEVT_PAINT
)
2076 #ifdef wxHAS_PAINT_DEBUG
2077 // set the internal flag for the duration of redrawing
2082 // default copy ctor and dtor are normally fine, we only need them to keep
2083 // g_isPainting updated in debug build
2084 #ifdef wxHAS_PAINT_DEBUG
2085 wxPaintEvent(const wxPaintEvent
& event
)
2091 virtual ~wxPaintEvent()
2097 virtual wxEvent
*Clone() const { return new wxPaintEvent(*this); }
2100 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent
)
2103 class WXDLLIMPEXP_CORE wxNcPaintEvent
: public wxEvent
2106 wxNcPaintEvent(int winid
= 0)
2107 : wxEvent(winid
, wxEVT_NC_PAINT
)
2110 virtual wxEvent
*Clone() const { return new wxNcPaintEvent(*this); }
2113 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent
)
2116 // Erase background event class
2118 wxEVT_ERASE_BACKGROUND
2121 class WXDLLIMPEXP_CORE wxEraseEvent
: public wxEvent
2124 wxEraseEvent(int Id
= 0, wxDC
*dc
= NULL
)
2125 : wxEvent(Id
, wxEVT_ERASE_BACKGROUND
),
2129 wxEraseEvent(const wxEraseEvent
& event
)
2134 wxDC
*GetDC() const { return m_dc
; }
2136 virtual wxEvent
*Clone() const { return new wxEraseEvent(*this); }
2142 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent
)
2145 // Focus event class
2151 class WXDLLIMPEXP_CORE wxFocusEvent
: public wxEvent
2154 wxFocusEvent(wxEventType type
= wxEVT_NULL
, int winid
= 0)
2155 : wxEvent(winid
, type
)
2158 wxFocusEvent(const wxFocusEvent
& event
)
2160 { m_win
= event
.m_win
; }
2162 // The window associated with this event is the window which had focus
2163 // before for SET event and the window which will have focus for the KILL
2164 // one. NB: it may be NULL in both cases!
2165 wxWindow
*GetWindow() const { return m_win
; }
2166 void SetWindow(wxWindow
*win
) { m_win
= win
; }
2168 virtual wxEvent
*Clone() const { return new wxFocusEvent(*this); }
2174 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent
)
2177 // wxChildFocusEvent notifies the parent that a child has got the focus: unlike
2178 // wxFocusEvent it is propagated upwards the window chain
2179 class WXDLLIMPEXP_CORE wxChildFocusEvent
: public wxCommandEvent
2182 wxChildFocusEvent(wxWindow
*win
= NULL
);
2184 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
2186 virtual wxEvent
*Clone() const { return new wxChildFocusEvent(*this); }
2189 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent
)
2192 // Activate event class
2199 class WXDLLIMPEXP_CORE wxActivateEvent
: public wxEvent
2202 wxActivateEvent(wxEventType type
= wxEVT_NULL
, bool active
= true, int Id
= 0)
2204 { m_active
= active
; }
2205 wxActivateEvent(const wxActivateEvent
& event
)
2207 { m_active
= event
.m_active
; }
2209 bool GetActive() const { return m_active
; }
2211 virtual wxEvent
*Clone() const { return new wxActivateEvent(*this); }
2217 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent
)
2220 // InitDialog event class
2225 class WXDLLIMPEXP_CORE wxInitDialogEvent
: public wxEvent
2228 wxInitDialogEvent(int Id
= 0)
2229 : wxEvent(Id
, wxEVT_INIT_DIALOG
)
2232 virtual wxEvent
*Clone() const { return new wxInitDialogEvent(*this); }
2235 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent
)
2238 // Miscellaneous menu event class
2242 wxEVT_MENU_HIGHLIGHT,
2245 class WXDLLIMPEXP_CORE wxMenuEvent
: public wxEvent
2248 wxMenuEvent(wxEventType type
= wxEVT_NULL
, int winid
= 0, wxMenu
* menu
= NULL
)
2249 : wxEvent(winid
, type
)
2250 { m_menuId
= winid
; m_menu
= menu
; }
2251 wxMenuEvent(const wxMenuEvent
& event
)
2253 { m_menuId
= event
.m_menuId
; m_menu
= event
.m_menu
; }
2255 // only for wxEVT_MENU_HIGHLIGHT
2256 int GetMenuId() const { return m_menuId
; }
2258 // only for wxEVT_MENU_OPEN/CLOSE
2259 bool IsPopup() const { return m_menuId
== wxID_ANY
; }
2261 // only for wxEVT_MENU_OPEN/CLOSE
2262 wxMenu
* GetMenu() const { return m_menu
; }
2264 virtual wxEvent
*Clone() const { return new wxMenuEvent(*this); }
2270 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent
)
2273 // Window close or session close event class
2277 wxEVT_QUERY_END_SESSION
2280 class WXDLLIMPEXP_CORE wxCloseEvent
: public wxEvent
2283 wxCloseEvent(wxEventType type
= wxEVT_NULL
, int winid
= 0)
2284 : wxEvent(winid
, type
),
2286 m_veto(false), // should be false by default
2289 wxCloseEvent(const wxCloseEvent
& event
)
2291 m_loggingOff(event
.m_loggingOff
),
2292 m_veto(event
.m_veto
),
2293 m_canVeto(event
.m_canVeto
) {}
2295 void SetLoggingOff(bool logOff
) { m_loggingOff
= logOff
; }
2296 bool GetLoggingOff() const
2298 // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it
2299 // doesn't make sense for wxEVT_CLOSE_WINDOW
2300 wxASSERT_MSG( m_eventType
!= wxEVT_CLOSE_WINDOW
,
2301 wxT("this flag is for end session events only") );
2303 return m_loggingOff
;
2306 void Veto(bool veto
= true)
2308 // GetVeto() will return false anyhow...
2309 wxCHECK_RET( m_canVeto
,
2310 wxT("call to Veto() ignored (can't veto this event)") );
2314 void SetCanVeto(bool canVeto
) { m_canVeto
= canVeto
; }
2315 bool CanVeto() const { return m_canVeto
; }
2316 bool GetVeto() const { return m_canVeto
&& m_veto
; }
2318 virtual wxEvent
*Clone() const { return new wxCloseEvent(*this); }
2326 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent
)
2333 class WXDLLIMPEXP_CORE wxShowEvent
: public wxEvent
2336 wxShowEvent(int winid
= 0, bool show
= false)
2337 : wxEvent(winid
, wxEVT_SHOW
)
2339 wxShowEvent(const wxShowEvent
& event
)
2341 { m_show
= event
.m_show
; }
2343 void SetShow(bool show
) { m_show
= show
; }
2345 // return true if the window was shown, false if hidden
2346 bool IsShown() const { return m_show
; }
2348 #if WXWIN_COMPATIBILITY_2_8
2349 wxDEPRECATED( bool GetShow() const { return IsShown(); } )
2352 virtual wxEvent
*Clone() const { return new wxShowEvent(*this); }
2358 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent
)
2365 class WXDLLIMPEXP_CORE wxIconizeEvent
: public wxEvent
2368 wxIconizeEvent(int winid
= 0, bool iconized
= true)
2369 : wxEvent(winid
, wxEVT_ICONIZE
)
2370 { m_iconized
= iconized
; }
2371 wxIconizeEvent(const wxIconizeEvent
& event
)
2373 { m_iconized
= event
.m_iconized
; }
2375 #if WXWIN_COMPATIBILITY_2_8
2376 wxDEPRECATED( bool Iconized() const { return IsIconized(); } )
2378 // return true if the frame was iconized, false if restored
2379 bool IsIconized() const { return m_iconized
; }
2381 virtual wxEvent
*Clone() const { return new wxIconizeEvent(*this); }
2387 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent
)
2393 class WXDLLIMPEXP_CORE wxMaximizeEvent
: public wxEvent
2396 wxMaximizeEvent(int winid
= 0)
2397 : wxEvent(winid
, wxEVT_MAXIMIZE
)
2400 virtual wxEvent
*Clone() const { return new wxMaximizeEvent(*this); }
2403 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent
)
2406 // Joystick event class
2408 wxEVT_JOY_BUTTON_DOWN,
2409 wxEVT_JOY_BUTTON_UP,
2414 // Which joystick? Same as Windows ids so no conversion necessary.
2421 // Which button is down?
2424 wxJOY_BUTTON_ANY
= -1,
2431 class WXDLLIMPEXP_CORE wxJoystickEvent
: public wxEvent
2436 int m_buttonChange
; // Which button changed?
2437 int m_buttonState
; // Which buttons are down?
2438 int m_joyStick
; // Which joystick?
2441 wxJoystickEvent(wxEventType type
= wxEVT_NULL
,
2443 int joystick
= wxJOYSTICK1
,
2448 m_buttonChange(change
),
2449 m_buttonState(state
),
2450 m_joyStick(joystick
)
2453 wxJoystickEvent(const wxJoystickEvent
& event
)
2456 m_zPosition(event
.m_zPosition
),
2457 m_buttonChange(event
.m_buttonChange
),
2458 m_buttonState(event
.m_buttonState
),
2459 m_joyStick(event
.m_joyStick
)
2462 wxPoint
GetPosition() const { return m_pos
; }
2463 int GetZPosition() const { return m_zPosition
; }
2464 int GetButtonState() const { return m_buttonState
; }
2465 int GetButtonChange() const { return m_buttonChange
; }
2466 int GetJoystick() const { return m_joyStick
; }
2468 void SetJoystick(int stick
) { m_joyStick
= stick
; }
2469 void SetButtonState(int state
) { m_buttonState
= state
; }
2470 void SetButtonChange(int change
) { m_buttonChange
= change
; }
2471 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2472 void SetZPosition(int zPos
) { m_zPosition
= zPos
; }
2474 // Was it a button event? (*doesn't* mean: is any button *down*?)
2475 bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN
) ||
2476 (GetEventType() == wxEVT_JOY_BUTTON_UP
)); }
2478 // Was it a move event?
2479 bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE
); }
2481 // Was it a zmove event?
2482 bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE
); }
2484 // Was it a down event from button 1, 2, 3, 4 or any?
2485 bool ButtonDown(int but
= wxJOY_BUTTON_ANY
) const
2486 { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN
) &&
2487 ((but
== wxJOY_BUTTON_ANY
) || (but
== m_buttonChange
))); }
2489 // Was it a up event from button 1, 2, 3 or any?
2490 bool ButtonUp(int but
= wxJOY_BUTTON_ANY
) const
2491 { return ((GetEventType() == wxEVT_JOY_BUTTON_UP
) &&
2492 ((but
== wxJOY_BUTTON_ANY
) || (but
== m_buttonChange
))); }
2494 // Was the given button 1,2,3,4 or any in Down state?
2495 bool ButtonIsDown(int but
= wxJOY_BUTTON_ANY
) const
2496 { return (((but
== wxJOY_BUTTON_ANY
) && (m_buttonState
!= 0)) ||
2497 ((m_buttonState
& but
) == but
)); }
2499 virtual wxEvent
*Clone() const { return new wxJoystickEvent(*this); }
2502 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent
)
2505 // Drop files event class
2510 class WXDLLIMPEXP_CORE wxDropFilesEvent
: public wxEvent
2517 wxDropFilesEvent(wxEventType type
= wxEVT_NULL
,
2519 wxString
*files
= NULL
)
2526 // we need a copy ctor to avoid deleting m_files pointer twice
2527 wxDropFilesEvent(const wxDropFilesEvent
& other
)
2529 m_noFiles(other
.m_noFiles
),
2533 m_files
= new wxString
[m_noFiles
];
2534 for ( int n
= 0; n
< m_noFiles
; n
++ )
2536 m_files
[n
] = other
.m_files
[n
];
2540 virtual ~wxDropFilesEvent()
2545 wxPoint
GetPosition() const { return m_pos
; }
2546 int GetNumberOfFiles() const { return m_noFiles
; }
2547 wxString
*GetFiles() const { return m_files
; }
2549 virtual wxEvent
*Clone() const { return new wxDropFilesEvent(*this); }
2552 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent
)
2560 // Whether to always send update events to windows, or
2561 // to only send update events to those with the
2562 // wxWS_EX_PROCESS_UI_UPDATES style.
2566 // Send UI update events to all windows
2567 wxUPDATE_UI_PROCESS_ALL
,
2569 // Send UI update events to windows that have
2570 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
2571 wxUPDATE_UI_PROCESS_SPECIFIED
2574 class WXDLLIMPEXP_CORE wxUpdateUIEvent
: public wxCommandEvent
2577 wxUpdateUIEvent(wxWindowID commandId
= 0)
2578 : wxCommandEvent(wxEVT_UPDATE_UI
, commandId
)
2586 m_setChecked
= false;
2588 wxUpdateUIEvent(const wxUpdateUIEvent
& event
)
2589 : wxCommandEvent(event
),
2590 m_checked(event
.m_checked
),
2591 m_enabled(event
.m_enabled
),
2592 m_shown(event
.m_shown
),
2593 m_setEnabled(event
.m_setEnabled
),
2594 m_setShown(event
.m_setShown
),
2595 m_setText(event
.m_setText
),
2596 m_setChecked(event
.m_setChecked
),
2597 m_text(event
.m_text
)
2600 bool GetChecked() const { return m_checked
; }
2601 bool GetEnabled() const { return m_enabled
; }
2602 bool GetShown() const { return m_shown
; }
2603 wxString
GetText() const { return m_text
; }
2604 bool GetSetText() const { return m_setText
; }
2605 bool GetSetChecked() const { return m_setChecked
; }
2606 bool GetSetEnabled() const { return m_setEnabled
; }
2607 bool GetSetShown() const { return m_setShown
; }
2609 void Check(bool check
) { m_checked
= check
; m_setChecked
= true; }
2610 void Enable(bool enable
) { m_enabled
= enable
; m_setEnabled
= true; }
2611 void Show(bool show
) { m_shown
= show
; m_setShown
= true; }
2612 void SetText(const wxString
& text
) { m_text
= text
; m_setText
= true; }
2614 // Sets the interval between updates in milliseconds.
2615 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
2616 static void SetUpdateInterval(long updateInterval
) { sm_updateInterval
= updateInterval
; }
2618 // Returns the current interval between updates in milliseconds
2619 static long GetUpdateInterval() { return sm_updateInterval
; }
2621 // Can we update this window?
2622 static bool CanUpdate(wxWindowBase
*win
);
2624 // Reset the update time to provide a delay until the next
2625 // time we should update
2626 static void ResetUpdateTime();
2628 // Specify how wxWidgets will send update events: to
2629 // all windows, or only to those which specify that they
2630 // will process the events.
2631 static void SetMode(wxUpdateUIMode mode
) { sm_updateMode
= mode
; }
2633 // Returns the UI update mode
2634 static wxUpdateUIMode
GetMode() { return sm_updateMode
; }
2636 virtual wxEvent
*Clone() const { return new wxUpdateUIEvent(*this); }
2648 static wxLongLong sm_lastUpdate
;
2650 static long sm_updateInterval
;
2651 static wxUpdateUIMode sm_updateMode
;
2654 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent
)
2658 wxEVT_SYS_COLOUR_CHANGED
2661 // TODO: shouldn't all events record the window ID?
2662 class WXDLLIMPEXP_CORE wxSysColourChangedEvent
: public wxEvent
2665 wxSysColourChangedEvent()
2666 : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED
)
2669 virtual wxEvent
*Clone() const { return new wxSysColourChangedEvent(*this); }
2672 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent
)
2676 wxEVT_MOUSE_CAPTURE_CHANGED
2677 The window losing the capture receives this message
2678 (even if it released the capture itself).
2681 class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent
: public wxEvent
2684 wxMouseCaptureChangedEvent(wxWindowID winid
= 0, wxWindow
* gainedCapture
= NULL
)
2685 : wxEvent(winid
, wxEVT_MOUSE_CAPTURE_CHANGED
),
2686 m_gainedCapture(gainedCapture
)
2689 wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent
& event
)
2691 m_gainedCapture(event
.m_gainedCapture
)
2694 virtual wxEvent
*Clone() const { return new wxMouseCaptureChangedEvent(*this); }
2696 wxWindow
* GetCapturedWindow() const { return m_gainedCapture
; }
2699 wxWindow
* m_gainedCapture
;
2701 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent
)
2705 wxEVT_MOUSE_CAPTURE_LOST
2706 The window losing the capture receives this message, unless it released it
2707 it itself or unless wxWindow::CaptureMouse was called on another window
2708 (and so capture will be restored when the new capturer releases it).
2711 class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent
: public wxEvent
2714 wxMouseCaptureLostEvent(wxWindowID winid
= 0)
2715 : wxEvent(winid
, wxEVT_MOUSE_CAPTURE_LOST
)
2718 wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent
& event
)
2722 virtual wxEvent
*Clone() const { return new wxMouseCaptureLostEvent(*this); }
2724 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent
)
2728 wxEVT_DISPLAY_CHANGED
2730 class WXDLLIMPEXP_CORE wxDisplayChangedEvent
: public wxEvent
2733 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent
)
2736 wxDisplayChangedEvent()
2737 : wxEvent(0, wxEVT_DISPLAY_CHANGED
)
2740 virtual wxEvent
*Clone() const { return new wxDisplayChangedEvent(*this); }
2744 wxEVT_PALETTE_CHANGED
2747 class WXDLLIMPEXP_CORE wxPaletteChangedEvent
: public wxEvent
2750 wxPaletteChangedEvent(wxWindowID winid
= 0)
2751 : wxEvent(winid
, wxEVT_PALETTE_CHANGED
),
2752 m_changedWindow(NULL
)
2755 wxPaletteChangedEvent(const wxPaletteChangedEvent
& event
)
2757 m_changedWindow(event
.m_changedWindow
)
2760 void SetChangedWindow(wxWindow
* win
) { m_changedWindow
= win
; }
2761 wxWindow
* GetChangedWindow() const { return m_changedWindow
; }
2763 virtual wxEvent
*Clone() const { return new wxPaletteChangedEvent(*this); }
2766 wxWindow
* m_changedWindow
;
2769 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent
)
2773 wxEVT_QUERY_NEW_PALETTE
2774 Indicates the window is getting keyboard focus and should re-do its palette.
2777 class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent
: public wxEvent
2780 wxQueryNewPaletteEvent(wxWindowID winid
= 0)
2781 : wxEvent(winid
, wxEVT_QUERY_NEW_PALETTE
),
2782 m_paletteRealized(false)
2784 wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent
& event
)
2786 m_paletteRealized(event
.m_paletteRealized
)
2789 // App sets this if it changes the palette.
2790 void SetPaletteRealized(bool realized
) { m_paletteRealized
= realized
; }
2791 bool GetPaletteRealized() const { return m_paletteRealized
; }
2793 virtual wxEvent
*Clone() const { return new wxQueryNewPaletteEvent(*this); }
2796 bool m_paletteRealized
;
2799 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent
)
2803 Event generated by dialog navigation keys
2804 wxEVT_NAVIGATION_KEY
2806 // NB: don't derive from command event to avoid being propagated to the parent
2807 class WXDLLIMPEXP_CORE wxNavigationKeyEvent
: public wxEvent
2810 wxNavigationKeyEvent()
2811 : wxEvent(0, wxEVT_NAVIGATION_KEY
),
2812 m_flags(IsForward
| FromTab
), // defaults are for TAB
2815 m_propagationLevel
= wxEVENT_PROPAGATE_NONE
;
2818 wxNavigationKeyEvent(const wxNavigationKeyEvent
& event
)
2820 m_flags(event
.m_flags
),
2821 m_focus(event
.m_focus
)
2824 // direction: forward (true) or backward (false)
2825 bool GetDirection() const
2826 { return (m_flags
& IsForward
) != 0; }
2827 void SetDirection(bool bForward
)
2828 { if ( bForward
) m_flags
|= IsForward
; else m_flags
&= ~IsForward
; }
2830 // it may be a window change event (MDI, notebook pages...) or a control
2832 bool IsWindowChange() const
2833 { return (m_flags
& WinChange
) != 0; }
2834 void SetWindowChange(bool bIs
)
2835 { if ( bIs
) m_flags
|= WinChange
; else m_flags
&= ~WinChange
; }
2837 // Set to true under MSW if the event was generated using the tab key.
2838 // This is required for proper navogation over radio buttons
2839 bool IsFromTab() const
2840 { return (m_flags
& FromTab
) != 0; }
2841 void SetFromTab(bool bIs
)
2842 { if ( bIs
) m_flags
|= FromTab
; else m_flags
&= ~FromTab
; }
2844 // the child which has the focus currently (may be NULL - use
2845 // wxWindow::FindFocus then)
2846 wxWindow
* GetCurrentFocus() const { return m_focus
; }
2847 void SetCurrentFocus(wxWindow
*win
) { m_focus
= win
; }
2850 void SetFlags(long flags
) { m_flags
= flags
; }
2852 virtual wxEvent
*Clone() const { return new wxNavigationKeyEvent(*this); }
2854 enum wxNavigationKeyEventFlags
2856 IsBackward
= 0x0000,
2866 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent
)
2869 // Window creation/destruction events: the first is sent as soon as window is
2870 // created (i.e. the underlying GUI object exists), but when the C++ object is
2871 // fully initialized (so virtual functions may be called). The second,
2872 // wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
2873 // still safe to call virtual functions at this moment
2879 class WXDLLIMPEXP_CORE wxWindowCreateEvent
: public wxCommandEvent
2882 wxWindowCreateEvent(wxWindow
*win
= NULL
);
2884 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
2886 virtual wxEvent
*Clone() const { return new wxWindowCreateEvent(*this); }
2889 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent
)
2892 class WXDLLIMPEXP_CORE wxWindowDestroyEvent
: public wxCommandEvent
2895 wxWindowDestroyEvent(wxWindow
*win
= NULL
);
2897 wxWindow
*GetWindow() const { return (wxWindow
*)GetEventObject(); }
2899 virtual wxEvent
*Clone() const { return new wxWindowDestroyEvent(*this); }
2902 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent
)
2905 // A help event is sent when the user clicks on a window in context-help mode.
2911 class WXDLLIMPEXP_CORE wxHelpEvent
: public wxCommandEvent
2914 // how was this help event generated?
2917 Origin_Unknown
, // unrecognized event source
2918 Origin_Keyboard
, // event generated from F1 key press
2919 Origin_HelpButton
// event from [?] button on the title bar (Windows)
2922 wxHelpEvent(wxEventType type
= wxEVT_NULL
,
2923 wxWindowID winid
= 0,
2924 const wxPoint
& pt
= wxDefaultPosition
,
2925 Origin origin
= Origin_Unknown
)
2926 : wxCommandEvent(type
, winid
),
2928 m_origin(GuessOrigin(origin
))
2930 wxHelpEvent(const wxHelpEvent
& event
)
2931 : wxCommandEvent(event
),
2933 m_target(event
.m_target
),
2934 m_link(event
.m_link
),
2935 m_origin(event
.m_origin
)
2938 // Position of event (in screen coordinates)
2939 const wxPoint
& GetPosition() const { return m_pos
; }
2940 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2942 // Optional link to further help
2943 const wxString
& GetLink() const { return m_link
; }
2944 void SetLink(const wxString
& link
) { m_link
= link
; }
2946 // Optional target to display help in. E.g. a window specification
2947 const wxString
& GetTarget() const { return m_target
; }
2948 void SetTarget(const wxString
& target
) { m_target
= target
; }
2950 virtual wxEvent
*Clone() const { return new wxHelpEvent(*this); }
2952 // optional indication of the event source
2953 Origin
GetOrigin() const { return m_origin
; }
2954 void SetOrigin(Origin origin
) { m_origin
= origin
; }
2962 // we can try to guess the event origin ourselves, even if none is
2963 // specified in the ctor
2964 static Origin
GuessOrigin(Origin origin
);
2967 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent
)
2970 // A Clipboard Text event is sent when a window intercepts text copy/cut/paste
2971 // message, i.e. the user has cut/copied/pasted data from/into a text control
2972 // via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc.
2973 // NOTE : under windows these events are *NOT* generated automatically
2974 // for a Rich Edit text control.
2981 class WXDLLIMPEXP_CORE wxClipboardTextEvent
: public wxCommandEvent
2984 wxClipboardTextEvent(wxEventType type
= wxEVT_NULL
,
2985 wxWindowID winid
= 0)
2986 : wxCommandEvent(type
, winid
)
2988 wxClipboardTextEvent(const wxClipboardTextEvent
& event
)
2989 : wxCommandEvent(event
)
2992 virtual wxEvent
*Clone() const { return new wxClipboardTextEvent(*this); }
2995 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent
)
2998 // A Context event is sent when the user right clicks on a window or
2999 // presses Shift-F10
3000 // NOTE : Under windows this is a repackaged WM_CONTETXMENU message
3001 // Under other systems it may have to be generated from a right click event
3006 class WXDLLIMPEXP_CORE wxContextMenuEvent
: public wxCommandEvent
3009 wxContextMenuEvent(wxEventType type
= wxEVT_NULL
,
3010 wxWindowID winid
= 0,
3011 const wxPoint
& pt
= wxDefaultPosition
)
3012 : wxCommandEvent(type
, winid
),
3015 wxContextMenuEvent(const wxContextMenuEvent
& event
)
3016 : wxCommandEvent(event
),
3020 // Position of event (in screen coordinates)
3021 const wxPoint
& GetPosition() const { return m_pos
; }
3022 void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
3024 virtual wxEvent
*Clone() const { return new wxContextMenuEvent(*this); }
3030 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent
)
3035 wxEVT_MOUSE_CAPTURE_CHANGED,
3036 wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
3037 // wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate
3038 // wxEVT_FONT_CHANGED to all other windows (maybe).
3039 wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
3047 // ============================================================================
3048 // event handler and related classes
3049 // ============================================================================
3052 // struct containing the members common to static and dynamic event tables
3054 struct WXDLLIMPEXP_BASE wxEventTableEntryBase
3056 wxEventTableEntryBase(int winid
, int idLast
,
3057 wxEventFunctor
* fn
, wxObject
*data
)
3061 m_callbackUserData(data
)
3063 wxASSERT_MSG( idLast
== wxID_ANY
|| winid
<= idLast
,
3064 "invalid IDs range: lower bound > upper bound" );
3067 wxEventTableEntryBase( const wxEventTableEntryBase
&entry
)
3068 : m_id( entry
.m_id
),
3069 m_lastId( entry
.m_lastId
),
3071 m_callbackUserData( entry
.m_callbackUserData
)
3073 // This is a 'hack' to ensure that only one instance tries to delete
3074 // the functor pointer. It is safe as long as the only place where the
3075 // copy constructor is being called is when the static event tables are
3076 // being initialized (a temporary instance is created and then this
3077 // constructor is called).
3079 const_cast<wxEventTableEntryBase
&>( entry
).m_fn
= NULL
;
3082 ~wxEventTableEntryBase()
3087 // the range of ids for this entry: if m_lastId == wxID_ANY, the range
3088 // consists only of m_id, otherwise it is m_id..m_lastId inclusive
3092 // function/method/functor to call
3093 wxEventFunctor
* m_fn
;
3095 // arbitrary user data associated with the callback
3096 wxObject
* m_callbackUserData
;
3099 wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase
);
3102 // an entry from a static event table
3103 struct WXDLLIMPEXP_BASE wxEventTableEntry
: public wxEventTableEntryBase
3105 wxEventTableEntry(const int& evType
, int winid
, int idLast
,
3106 wxEventFunctor
* fn
, wxObject
*data
)
3107 : wxEventTableEntryBase(winid
, idLast
, fn
, data
),
3111 // the reference to event type: this allows us to not care about the
3112 // (undefined) order in which the event table entries and the event types
3113 // are initialized: initially the value of this reference might be
3114 // invalid, but by the time it is used for the first time, all global
3115 // objects will have been initialized (including the event type constants)
3116 // and so it will have the correct value when it is needed
3117 const int& m_eventType
;
3120 wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry
);
3123 // an entry used in dynamic event table managed by wxEvtHandler::Connect()
3124 struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry
: public wxEventTableEntryBase
3126 wxDynamicEventTableEntry(int evType
, int winid
, int idLast
,
3127 wxEventFunctor
* fn
, wxObject
*data
)
3128 : wxEventTableEntryBase(winid
, idLast
, fn
, data
),
3132 // not a reference here as we can't keep a reference to a temporary int
3133 // created to wrap the constant value typically passed to Connect() - nor
3138 wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry
);
3141 // ----------------------------------------------------------------------------
3142 // wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
3143 // ----------------------------------------------------------------------------
3145 struct WXDLLIMPEXP_BASE wxEventTable
3147 const wxEventTable
*baseTable
; // base event table (next in chain)
3148 const wxEventTableEntry
*entries
; // bottom of entry array
3151 // ----------------------------------------------------------------------------
3152 // wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
3153 // ----------------------------------------------------------------------------
3155 WX_DEFINE_ARRAY_PTR(const wxEventTableEntry
*, wxEventTableEntryPointerArray
);
3157 class WXDLLIMPEXP_BASE wxEventHashTable
3160 // Internal data structs
3161 struct EventTypeTable
3163 wxEventType eventType
;
3164 wxEventTableEntryPointerArray eventEntryTable
;
3166 typedef EventTypeTable
* EventTypeTablePointer
;
3169 // Constructor, needs the event table it needs to hash later on.
3170 // Note: hashing of the event table is not done in the constructor as it
3171 // can be that the event table is not yet full initialize, the hash
3172 // will gets initialized when handling the first event look-up request.
3173 wxEventHashTable(const wxEventTable
&table
);
3175 ~wxEventHashTable();
3177 // Handle the given event, in other words search the event table hash
3178 // and call self->ProcessEvent() if a match was found.
3179 bool HandleEvent(wxEvent
& event
, wxEvtHandler
*self
);
3184 #if wxUSE_MEMORY_TRACING
3185 // Clear all tables: only used to work around problems in memory tracing
3187 static void ClearAll();
3188 #endif // wxUSE_MEMORY_TRACING
3191 // Init the hash table with the entries of the static event table.
3192 void InitHashTable();
3193 // Helper function of InitHashTable() to insert 1 entry into the hash table.
3194 void AddEntry(const wxEventTableEntry
&entry
);
3195 // Allocate and init with null pointers the base hash table.
3196 void AllocEventTypeTable(size_t size
);
3197 // Grow the hash table in size and transfer all items currently
3198 // in the table to the correct location in the new table.
3199 void GrowEventTypeTable();
3202 const wxEventTable
&m_table
;
3206 EventTypeTablePointer
*m_eventTypeTable
;
3208 static wxEventHashTable
* sm_first
;
3209 wxEventHashTable
* m_previous
;
3210 wxEventHashTable
* m_next
;
3212 wxDECLARE_NO_COPY_CLASS(wxEventHashTable
);
3215 // ----------------------------------------------------------------------------
3216 // wxEvtHandler: the base class for all objects handling wxWidgets events
3217 // ----------------------------------------------------------------------------
3219 class WXDLLIMPEXP_BASE wxEvtHandler
: public wxObject
3220 , public wxTrackable
3224 virtual ~wxEvtHandler();
3227 // Event handler chain
3228 // -------------------
3230 wxEvtHandler
*GetNextHandler() const { return m_nextHandler
; }
3231 wxEvtHandler
*GetPreviousHandler() const { return m_previousHandler
; }
3232 virtual void SetNextHandler(wxEvtHandler
*handler
) { m_nextHandler
= handler
; }
3233 virtual void SetPreviousHandler(wxEvtHandler
*handler
) { m_previousHandler
= handler
; }
3235 void SetEvtHandlerEnabled(bool enabled
) { m_enabled
= enabled
; }
3236 bool GetEvtHandlerEnabled() const { return m_enabled
; }
3239 bool IsUnlinked() const;
3242 // Global event filters
3243 // --------------------
3245 // Add an event filter whose FilterEvent() method will be called for each
3246 // and every event processed by wxWidgets. The filters are called in LIFO
3247 // order and wxApp is registered as an event filter by default. The pointer
3248 // must remain valid until it's removed with RemoveFilter() and is not
3249 // deleted by wxEvtHandler.
3250 static void AddFilter(wxEventFilter
* filter
);
3252 // Remove a filter previously installed with AddFilter().
3253 static void RemoveFilter(wxEventFilter
* filter
);
3256 // Event queuing and processing
3257 // ----------------------------
3259 // Process an event right now: this can only be called from the main
3260 // thread, use QueueEvent() for scheduling the events for
3261 // processing from other threads.
3262 virtual bool ProcessEvent(wxEvent
& event
);
3264 // Process an event by calling ProcessEvent and handling any exceptions
3265 // thrown by event handlers. It's mostly useful when processing wx events
3266 // when called from C code (e.g. in GTK+ callback) when the exception
3267 // wouldn't correctly propagate to wxEventLoop.
3268 bool SafelyProcessEvent(wxEvent
& event
);
3269 // NOTE: uses ProcessEvent()
3271 // This method tries to process the event in this event handler, including
3272 // any preprocessing done by TryBefore() and all the handlers chained to
3273 // it, but excluding the post-processing done in TryAfter().
3275 // It is meant to be called from ProcessEvent() only and is not virtual,
3276 // additional event handlers can be hooked into the normal event processing
3277 // logic using TryBefore() and TryAfter() hooks.
3279 // You can also call it yourself to forward an event to another handler but
3280 // without propagating it upwards if it's unhandled (this is usually
3281 // unwanted when forwarding as the original handler would already do it if
3282 // needed normally).
3283 bool ProcessEventLocally(wxEvent
& event
);
3285 // Schedule the given event to be processed later. It takes ownership of
3286 // the event pointer, i.e. it will be deleted later. This is safe to call
3287 // from multiple threads although you still need to ensure that wxString
3288 // fields of the event object are deep copies and not use the same string
3289 // buffer as other wxString objects in this thread.
3290 virtual void QueueEvent(wxEvent
*event
);
3292 // Add an event to be processed later: notice that this function is not
3293 // safe to call from threads other than main, use QueueEvent()
3294 virtual void AddPendingEvent(const wxEvent
& event
)
3296 // notice that the thread-safety problem comes from the fact that
3297 // Clone() doesn't make deep copies of wxString fields of wxEvent
3298 // object and so the same wxString could be used from both threads when
3299 // the event object is destroyed in this one -- QueueEvent() avoids
3300 // this problem as the event pointer is not used any more in this
3301 // thread at all after it is called.
3302 QueueEvent(event
.Clone());
3305 void ProcessPendingEvents();
3306 // NOTE: uses ProcessEvent()
3308 void DeletePendingEvents();
3311 bool ProcessThreadEvent(const wxEvent
& event
);
3312 // NOTE: uses AddPendingEvent(); call only from secondary threads
3315 #ifdef wxHAS_CALL_AFTER
3316 // Asynchronous method calls: these methods schedule the given method
3317 // pointer for a later call (during the next idle event loop iteration).
3319 // Notice that the method is called on this object itself, so the object
3320 // CallAfter() is called on must have the correct dynamic type.
3322 // These method can be used from another thread.
3324 template <typename T
>
3325 void CallAfter(void (T::*method
)())
3328 new wxAsyncMethodCallEvent0
<T
>(static_cast<T
*>(this), method
)
3332 // Notice that we use P1 and not T1 for the parameter to allow passing
3333 // parameters that are convertible to the type taken by the method
3334 // instead of being exactly the same, to be closer to the usual method call
3336 template <typename T
, typename T1
, typename P1
>
3337 void CallAfter(void (T::*method
)(T1 x1
), P1 x1
)
3340 new wxAsyncMethodCallEvent1
<T
, T1
>(
3341 static_cast<T
*>(this), method
, x1
)
3345 template <typename T
, typename T1
, typename T2
, typename P1
, typename P2
>
3346 void CallAfter(void (T::*method
)(T1 x1
, T2 x2
), P1 x1
, P2 x2
)
3349 new wxAsyncMethodCallEvent2
<T
, T1
, T2
>(
3350 static_cast<T
*>(this), method
, x1
, x2
)
3353 #endif // wxHAS_CALL_AFTER
3356 // Connecting and disconnecting
3357 // ----------------------------
3359 // These functions are used for old, untyped, event handlers and don't
3360 // check that the type of the function passed to them actually matches the
3361 // type of the event. They also only allow connecting events to methods of
3362 // wxEvtHandler-derived classes.
3364 // The template Connect() methods below are safer and allow connecting
3365 // events to arbitrary functions or functors -- but require compiler
3366 // support for templates.
3368 // Dynamic association of a member function handler with the event handler,
3369 // winid and event type
3370 void Connect(int winid
,
3372 wxEventType eventType
,
3373 wxObjectEventFunction func
,
3374 wxObject
*userData
= NULL
,
3375 wxEvtHandler
*eventSink
= NULL
)
3377 DoBind(winid
, lastId
, eventType
,
3378 wxNewEventFunctor(eventType
, func
, eventSink
),
3382 // Convenience function: take just one id
3383 void Connect(int winid
,
3384 wxEventType eventType
,
3385 wxObjectEventFunction func
,
3386 wxObject
*userData
= NULL
,
3387 wxEvtHandler
*eventSink
= NULL
)
3388 { Connect(winid
, wxID_ANY
, eventType
, func
, userData
, eventSink
); }
3390 // Even more convenient: without id (same as using id of wxID_ANY)
3391 void Connect(wxEventType eventType
,
3392 wxObjectEventFunction func
,
3393 wxObject
*userData
= NULL
,
3394 wxEvtHandler
*eventSink
= NULL
)
3395 { Connect(wxID_ANY
, wxID_ANY
, eventType
, func
, userData
, eventSink
); }
3397 bool Disconnect(int winid
,
3399 wxEventType eventType
,
3400 wxObjectEventFunction func
= NULL
,
3401 wxObject
*userData
= NULL
,
3402 wxEvtHandler
*eventSink
= NULL
)
3404 return DoUnbind(winid
, lastId
, eventType
,
3405 wxMakeEventFunctor(eventType
, func
, eventSink
),
3409 bool Disconnect(int winid
= wxID_ANY
,
3410 wxEventType eventType
= wxEVT_NULL
,
3411 wxObjectEventFunction func
= NULL
,
3412 wxObject
*userData
= NULL
,
3413 wxEvtHandler
*eventSink
= NULL
)
3414 { return Disconnect(winid
, wxID_ANY
, eventType
, func
, userData
, eventSink
); }
3416 bool Disconnect(wxEventType eventType
,
3417 wxObjectEventFunction func
,
3418 wxObject
*userData
= NULL
,
3419 wxEvtHandler
*eventSink
= NULL
)
3420 { return Disconnect(wxID_ANY
, eventType
, func
, userData
, eventSink
); }
3422 #ifdef wxHAS_EVENT_BIND
3423 // Bind functions to an event:
3424 template <typename EventTag
, typename EventArg
>
3425 void Bind(const EventTag
& eventType
,
3426 void (*function
)(EventArg
&),
3427 int winid
= wxID_ANY
,
3428 int lastId
= wxID_ANY
,
3429 wxObject
*userData
= NULL
)
3431 DoBind(winid
, lastId
, eventType
,
3432 wxNewEventFunctor(eventType
, function
),
3437 template <typename EventTag
, typename EventArg
>
3438 bool Unbind(const EventTag
& eventType
,
3439 void (*function
)(EventArg
&),
3440 int winid
= wxID_ANY
,
3441 int lastId
= wxID_ANY
,
3442 wxObject
*userData
= NULL
)
3444 return DoUnbind(winid
, lastId
, eventType
,
3445 wxMakeEventFunctor(eventType
, function
),
3449 // Bind functors to an event:
3450 template <typename EventTag
, typename Functor
>
3451 void Bind(const EventTag
& eventType
,
3452 const Functor
&functor
,
3453 int winid
= wxID_ANY
,
3454 int lastId
= wxID_ANY
,
3455 wxObject
*userData
= NULL
)
3457 DoBind(winid
, lastId
, eventType
,
3458 wxNewEventFunctor(eventType
, functor
),
3463 template <typename EventTag
, typename Functor
>
3464 bool Unbind(const EventTag
& eventType
,
3465 const Functor
&functor
,
3466 int winid
= wxID_ANY
,
3467 int lastId
= wxID_ANY
,
3468 wxObject
*userData
= NULL
)
3470 return DoUnbind(winid
, lastId
, eventType
,
3471 wxMakeEventFunctor(eventType
, functor
),
3476 // Bind a method of a class (called on the specified handler which must
3477 // be convertible to this class) object to an event:
3479 template <typename EventTag
, typename Class
, typename EventArg
, typename EventHandler
>
3480 void Bind(const EventTag
&eventType
,
3481 void (Class::*method
)(EventArg
&),
3482 EventHandler
*handler
,
3483 int winid
= wxID_ANY
,
3484 int lastId
= wxID_ANY
,
3485 wxObject
*userData
= NULL
)
3487 DoBind(winid
, lastId
, eventType
,
3488 wxNewEventFunctor(eventType
, method
, handler
),
3492 template <typename EventTag
, typename Class
, typename EventArg
, typename EventHandler
>
3493 bool Unbind(const EventTag
&eventType
,
3494 void (Class::*method
)(EventArg
&),
3495 EventHandler
*handler
,
3496 int winid
= wxID_ANY
,
3497 int lastId
= wxID_ANY
,
3498 wxObject
*userData
= NULL
)
3500 return DoUnbind(winid
, lastId
, eventType
,
3501 wxMakeEventFunctor(eventType
, method
, handler
),
3504 #endif // wxHAS_EVENT_BIND
3506 wxList
* GetDynamicEventTable() const { return m_dynamicEvents
; }
3508 // User data can be associated with each wxEvtHandler
3509 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
3510 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
3512 void SetClientData( void *data
) { DoSetClientData(data
); }
3513 void *GetClientData() const { return DoGetClientData(); }
3516 // implementation from now on
3517 // --------------------------
3519 // check if the given event table entry matches this event by id (the check
3520 // for the event type should be done by caller) and call the handler if it
3523 // return true if the event was processed, false otherwise (no match or the
3524 // handler decided to skip the event)
3525 static bool ProcessEventIfMatchesId(const wxEventTableEntryBase
& tableEntry
,
3526 wxEvtHandler
*handler
,
3529 virtual bool SearchEventTable(wxEventTable
& table
, wxEvent
& event
);
3530 bool SearchDynamicEventTable( wxEvent
& event
);
3532 // Avoid problems at exit by cleaning up static hash table gracefully
3533 void ClearEventHashTable() { GetEventHashTable().Clear(); }
3534 void OnSinkDestroyed( wxEvtHandler
*sink
);
3538 void DoBind(int winid
,
3540 wxEventType eventType
,
3541 wxEventFunctor
*func
,
3542 wxObject
* userData
= NULL
);
3544 bool DoUnbind(int winid
,
3546 wxEventType eventType
,
3547 const wxEventFunctor
& func
,
3548 wxObject
*userData
= NULL
);
3550 static const wxEventTableEntry sm_eventTableEntries
[];
3553 // hooks for wxWindow used by ProcessEvent()
3554 // -----------------------------------------
3556 // this one is called before trying our own event table to allow plugging
3557 // in the event handlers overriding the default logic, this is used by e.g.
3559 virtual bool TryBefore(wxEvent
& event
);
3561 // This one is not a hook but just a helper which looks up the handler in
3562 // this object itself.
3564 // It is called from ProcessEventLocally() and normally shouldn't be called
3565 // directly as doing it would ignore any chained event handlers
3566 bool TryHereOnly(wxEvent
& event
);
3568 // Another helper which simply calls pre-processing hook and then tries to
3569 // handle the event at this handler level.
3570 bool TryBeforeAndHere(wxEvent
& event
)
3572 return TryBefore(event
) || TryHereOnly(event
);
3575 // this one is called after failing to find the event handle in our own
3576 // table to give a chance to the other windows to process it
3578 // base class implementation passes the event to wxTheApp
3579 virtual bool TryAfter(wxEvent
& event
);
3581 #if WXWIN_COMPATIBILITY_2_8
3582 // deprecated method: override TryBefore() instead of this one
3583 wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
3584 virtual bool TryValidator(wxEvent
& WXUNUSED(event
)), return false; )
3586 wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
3587 virtual bool TryParent(wxEvent
& event
), return DoTryApp(event
); )
3588 #endif // WXWIN_COMPATIBILITY_2_8
3591 static const wxEventTable sm_eventTable
;
3592 virtual const wxEventTable
*GetEventTable() const;
3594 static wxEventHashTable sm_eventHashTable
;
3595 virtual wxEventHashTable
& GetEventHashTable() const;
3597 wxEvtHandler
* m_nextHandler
;
3598 wxEvtHandler
* m_previousHandler
;
3599 wxList
* m_dynamicEvents
;
3600 wxList
* m_pendingEvents
;
3603 // critical section protecting m_pendingEvents
3604 wxCriticalSection m_pendingEventsLock
;
3605 #endif // wxUSE_THREADS
3607 // Is event handler enabled?
3611 // The user data: either an object which will be deleted by the container
3612 // when it's deleted or some raw pointer which we do nothing with - only
3613 // one type of data can be used with the given window (i.e. you cannot set
3614 // the void data and then associate the container with wxClientData or vice
3618 wxClientData
*m_clientObject
;
3622 // what kind of data do we have?
3623 wxClientDataType m_clientDataType
;
3625 // client data accessors
3626 virtual void DoSetClientObject( wxClientData
*data
);
3627 virtual wxClientData
*DoGetClientObject() const;
3629 virtual void DoSetClientData( void *data
);
3630 virtual void *DoGetClientData() const;
3632 // Search tracker objects for event connection with this sink
3633 wxEventConnectionRef
*FindRefInTrackerList(wxEvtHandler
*handler
);
3636 // pass the event to wxTheApp instance, called from TryAfter()
3637 bool DoTryApp(wxEvent
& event
);
3639 // try to process events in all handlers chained to this one
3640 bool DoTryChain(wxEvent
& event
);
3642 // Head of the event filter linked list.
3643 static wxEventFilter
* ms_filterList
;
3645 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler
)
3648 WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler
*, wxEvtHandlerArray
, class WXDLLIMPEXP_BASE
);
3651 // Define an inline method of wxObjectEventFunctor which couldn't be defined
3652 // before wxEvtHandler declaration: at least Sun CC refuses to compile function
3653 // calls through pointer to member for forward-declared classes (see #12452).
3654 inline void wxObjectEventFunctor::operator()(wxEvtHandler
*handler
, wxEvent
& event
)
3656 wxEvtHandler
* const realHandler
= m_handler
? m_handler
: handler
;
3658 (realHandler
->*m_method
)(event
);
3661 // ----------------------------------------------------------------------------
3662 // wxEventConnectionRef represents all connections between two event handlers
3663 // and enables automatic disconnect when an event handler sink goes out of
3664 // scope. Each connection/disconnect increases/decreases ref count, and
3665 // when it reaches zero the node goes out of scope.
3666 // ----------------------------------------------------------------------------
3668 class wxEventConnectionRef
: public wxTrackerNode
3671 wxEventConnectionRef() : m_src(NULL
), m_sink(NULL
), m_refCount(0) { }
3672 wxEventConnectionRef(wxEvtHandler
*src
, wxEvtHandler
*sink
)
3673 : m_src(src
), m_sink(sink
), m_refCount(1)
3675 m_sink
->AddNode(this);
3678 // The sink is being destroyed
3679 virtual void OnObjectDestroy( )
3682 m_src
->OnSinkDestroyed( m_sink
);
3686 virtual wxEventConnectionRef
*ToEventConnection() { return this; }
3688 void IncRef() { m_refCount
++; }
3691 if ( !--m_refCount
)
3693 // The sink holds the only external pointer to this object
3695 m_sink
->RemoveNode(this);
3701 wxEvtHandler
*m_src
,
3705 friend class wxEvtHandler
;
3707 wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef
);
3710 // Post a message to the given event handler which will be processed during the
3711 // next event loop iteration.
3713 // Notice that this one is not thread-safe, use wxQueueEvent()
3714 inline void wxPostEvent(wxEvtHandler
*dest
, const wxEvent
& event
)
3716 wxCHECK_RET( dest
, "need an object to post event to" );
3718 dest
->AddPendingEvent(event
);
3721 // Wrapper around wxEvtHandler::QueueEvent(): adds an event for later
3722 // processing, unlike wxPostEvent it is safe to use from different thread even
3723 // for events with wxString members
3724 inline void wxQueueEvent(wxEvtHandler
*dest
, wxEvent
*event
)
3726 wxCHECK_RET( dest
, "need an object to queue event for" );
3728 dest
->QueueEvent(event
);
3731 typedef void (wxEvtHandler::*wxEventFunction
)(wxEvent
&);
3732 typedef void (wxEvtHandler::*wxIdleEventFunction
)(wxIdleEvent
&);
3733 typedef void (wxEvtHandler::*wxThreadEventFunction
)(wxThreadEvent
&);
3735 #define wxEventHandler(func) \
3736 wxEVENT_HANDLER_CAST(wxEventFunction, func)
3737 #define wxIdleEventHandler(func) \
3738 wxEVENT_HANDLER_CAST(wxIdleEventFunction, func)
3739 #define wxThreadEventHandler(func) \
3740 wxEVENT_HANDLER_CAST(wxThreadEventFunction, func)
3744 // ----------------------------------------------------------------------------
3745 // wxEventBlocker: helper class to temporarily disable event handling for a window
3746 // ----------------------------------------------------------------------------
3748 class WXDLLIMPEXP_CORE wxEventBlocker
: public wxEvtHandler
3751 wxEventBlocker(wxWindow
*win
, wxEventType type
= wxEVT_ANY
);
3752 virtual ~wxEventBlocker();
3754 void Block(wxEventType type
)
3756 m_eventsToBlock
.push_back(type
);
3759 virtual bool ProcessEvent(wxEvent
& event
);
3762 wxArrayInt m_eventsToBlock
;
3765 wxDECLARE_NO_COPY_CLASS(wxEventBlocker
);
3768 typedef void (wxEvtHandler::*wxCommandEventFunction
)(wxCommandEvent
&);
3769 typedef void (wxEvtHandler::*wxScrollEventFunction
)(wxScrollEvent
&);
3770 typedef void (wxEvtHandler::*wxScrollWinEventFunction
)(wxScrollWinEvent
&);
3771 typedef void (wxEvtHandler::*wxSizeEventFunction
)(wxSizeEvent
&);
3772 typedef void (wxEvtHandler::*wxMoveEventFunction
)(wxMoveEvent
&);
3773 typedef void (wxEvtHandler::*wxPaintEventFunction
)(wxPaintEvent
&);
3774 typedef void (wxEvtHandler::*wxNcPaintEventFunction
)(wxNcPaintEvent
&);
3775 typedef void (wxEvtHandler::*wxEraseEventFunction
)(wxEraseEvent
&);
3776 typedef void (wxEvtHandler::*wxMouseEventFunction
)(wxMouseEvent
&);
3777 typedef void (wxEvtHandler::*wxCharEventFunction
)(wxKeyEvent
&);
3778 typedef void (wxEvtHandler::*wxFocusEventFunction
)(wxFocusEvent
&);
3779 typedef void (wxEvtHandler::*wxChildFocusEventFunction
)(wxChildFocusEvent
&);
3780 typedef void (wxEvtHandler::*wxActivateEventFunction
)(wxActivateEvent
&);
3781 typedef void (wxEvtHandler::*wxMenuEventFunction
)(wxMenuEvent
&);
3782 typedef void (wxEvtHandler::*wxJoystickEventFunction
)(wxJoystickEvent
&);
3783 typedef void (wxEvtHandler::*wxDropFilesEventFunction
)(wxDropFilesEvent
&);
3784 typedef void (wxEvtHandler::*wxInitDialogEventFunction
)(wxInitDialogEvent
&);
3785 typedef void (wxEvtHandler::*wxSysColourChangedEventFunction
)(wxSysColourChangedEvent
&);
3786 typedef void (wxEvtHandler::*wxDisplayChangedEventFunction
)(wxDisplayChangedEvent
&);
3787 typedef void (wxEvtHandler::*wxUpdateUIEventFunction
)(wxUpdateUIEvent
&);
3788 typedef void (wxEvtHandler::*wxCloseEventFunction
)(wxCloseEvent
&);
3789 typedef void (wxEvtHandler::*wxShowEventFunction
)(wxShowEvent
&);
3790 typedef void (wxEvtHandler::*wxIconizeEventFunction
)(wxIconizeEvent
&);
3791 typedef void (wxEvtHandler::*wxMaximizeEventFunction
)(wxMaximizeEvent
&);
3792 typedef void (wxEvtHandler::*wxNavigationKeyEventFunction
)(wxNavigationKeyEvent
&);
3793 typedef void (wxEvtHandler::*wxPaletteChangedEventFunction
)(wxPaletteChangedEvent
&);
3794 typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction
)(wxQueryNewPaletteEvent
&);
3795 typedef void (wxEvtHandler::*wxWindowCreateEventFunction
)(wxWindowCreateEvent
&);
3796 typedef void (wxEvtHandler::*wxWindowDestroyEventFunction
)(wxWindowDestroyEvent
&);
3797 typedef void (wxEvtHandler::*wxSetCursorEventFunction
)(wxSetCursorEvent
&);
3798 typedef void (wxEvtHandler::*wxNotifyEventFunction
)(wxNotifyEvent
&);
3799 typedef void (wxEvtHandler::*wxHelpEventFunction
)(wxHelpEvent
&);
3800 typedef void (wxEvtHandler::*wxContextMenuEventFunction
)(wxContextMenuEvent
&);
3801 typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction
)(wxMouseCaptureChangedEvent
&);
3802 typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction
)(wxMouseCaptureLostEvent
&);
3803 typedef void (wxEvtHandler::*wxClipboardTextEventFunction
)(wxClipboardTextEvent
&);
3806 #define wxCommandEventHandler(func) \
3807 wxEVENT_HANDLER_CAST(wxCommandEventFunction, func)
3808 #define wxScrollEventHandler(func) \
3809 wxEVENT_HANDLER_CAST(wxScrollEventFunction, func)
3810 #define wxScrollWinEventHandler(func) \
3811 wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func)
3812 #define wxSizeEventHandler(func) \
3813 wxEVENT_HANDLER_CAST(wxSizeEventFunction, func)
3814 #define wxMoveEventHandler(func) \
3815 wxEVENT_HANDLER_CAST(wxMoveEventFunction, func)
3816 #define wxPaintEventHandler(func) \
3817 wxEVENT_HANDLER_CAST(wxPaintEventFunction, func)
3818 #define wxNcPaintEventHandler(func) \
3819 wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func)
3820 #define wxEraseEventHandler(func) \
3821 wxEVENT_HANDLER_CAST(wxEraseEventFunction, func)
3822 #define wxMouseEventHandler(func) \
3823 wxEVENT_HANDLER_CAST(wxMouseEventFunction, func)
3824 #define wxCharEventHandler(func) \
3825 wxEVENT_HANDLER_CAST(wxCharEventFunction, func)
3826 #define wxKeyEventHandler(func) wxCharEventHandler(func)
3827 #define wxFocusEventHandler(func) \
3828 wxEVENT_HANDLER_CAST(wxFocusEventFunction, func)
3829 #define wxChildFocusEventHandler(func) \
3830 wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func)
3831 #define wxActivateEventHandler(func) \
3832 wxEVENT_HANDLER_CAST(wxActivateEventFunction, func)
3833 #define wxMenuEventHandler(func) \
3834 wxEVENT_HANDLER_CAST(wxMenuEventFunction, func)
3835 #define wxJoystickEventHandler(func) \
3836 wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func)
3837 #define wxDropFilesEventHandler(func) \
3838 wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func)
3839 #define wxInitDialogEventHandler(func) \
3840 wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func)
3841 #define wxSysColourChangedEventHandler(func) \
3842 wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func)
3843 #define wxDisplayChangedEventHandler(func) \
3844 wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func)
3845 #define wxUpdateUIEventHandler(func) \
3846 wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func)
3847 #define wxCloseEventHandler(func) \
3848 wxEVENT_HANDLER_CAST(wxCloseEventFunction, func)
3849 #define wxShowEventHandler(func) \
3850 wxEVENT_HANDLER_CAST(wxShowEventFunction, func)
3851 #define wxIconizeEventHandler(func) \
3852 wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func)
3853 #define wxMaximizeEventHandler(func) \
3854 wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func)
3855 #define wxNavigationKeyEventHandler(func) \
3856 wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func)
3857 #define wxPaletteChangedEventHandler(func) \
3858 wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func)
3859 #define wxQueryNewPaletteEventHandler(func) \
3860 wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func)
3861 #define wxWindowCreateEventHandler(func) \
3862 wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func)
3863 #define wxWindowDestroyEventHandler(func) \
3864 wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func)
3865 #define wxSetCursorEventHandler(func) \
3866 wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func)
3867 #define wxNotifyEventHandler(func) \
3868 wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func)
3869 #define wxHelpEventHandler(func) \
3870 wxEVENT_HANDLER_CAST(wxHelpEventFunction, func)
3871 #define wxContextMenuEventHandler(func) \
3872 wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func)
3873 #define wxMouseCaptureChangedEventHandler(func) \
3874 wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func)
3875 #define wxMouseCaptureLostEventHandler(func) \
3876 wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func)
3877 #define wxClipboardTextEventHandler(func) \
3878 wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func)
3882 // N.B. In GNU-WIN32, you *have* to take the address of a member function
3883 // (use &) or the compiler crashes...
3885 #define wxDECLARE_EVENT_TABLE() \
3887 static const wxEventTableEntry sm_eventTableEntries[]; \
3889 static const wxEventTable sm_eventTable; \
3890 virtual const wxEventTable* GetEventTable() const; \
3891 static wxEventHashTable sm_eventHashTable; \
3892 virtual wxEventHashTable& GetEventHashTable() const
3894 // N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize
3895 // sm_eventTable before using it in GetEventTable() or the compiler gives
3896 // E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews)
3898 #define wxBEGIN_EVENT_TABLE(theClass, baseClass) \
3899 const wxEventTable theClass::sm_eventTable = \
3900 { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \
3901 const wxEventTable *theClass::GetEventTable() const \
3902 { return &theClass::sm_eventTable; } \
3903 wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
3904 wxEventHashTable &theClass::GetEventHashTable() const \
3905 { return theClass::sm_eventHashTable; } \
3906 const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
3908 #define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \
3909 template<typename T1> \
3910 const wxEventTable theClass<T1>::sm_eventTable = \
3911 { &baseClass::sm_eventTable, &theClass<T1>::sm_eventTableEntries[0] }; \
3912 template<typename T1> \
3913 const wxEventTable *theClass<T1>::GetEventTable() const \
3914 { return &theClass<T1>::sm_eventTable; } \
3915 template<typename T1> \
3916 wxEventHashTable theClass<T1>::sm_eventHashTable(theClass<T1>::sm_eventTable); \
3917 template<typename T1> \
3918 wxEventHashTable &theClass<T1>::GetEventHashTable() const \
3919 { return theClass<T1>::sm_eventHashTable; } \
3920 template<typename T1> \
3921 const wxEventTableEntry theClass<T1>::sm_eventTableEntries[] = { \
3923 #define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \
3924 template<typename T1, typename T2> \
3925 const wxEventTable theClass<T1, T2>::sm_eventTable = \
3926 { &baseClass::sm_eventTable, &theClass<T1, T2>::sm_eventTableEntries[0] }; \
3927 template<typename T1, typename T2> \
3928 const wxEventTable *theClass<T1, T2>::GetEventTable() const \
3929 { return &theClass<T1, T2>::sm_eventTable; } \
3930 template<typename T1, typename T2> \
3931 wxEventHashTable theClass<T1, T2>::sm_eventHashTable(theClass<T1, T2>::sm_eventTable); \
3932 template<typename T1, typename T2> \
3933 wxEventHashTable &theClass<T1, T2>::GetEventHashTable() const \
3934 { return theClass<T1, T2>::sm_eventHashTable; } \
3935 template<typename T1, typename T2> \
3936 const wxEventTableEntry theClass<T1, T2>::sm_eventTableEntries[] = { \
3938 #define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \
3939 template<typename T1, typename T2, typename T3> \
3940 const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \
3941 { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \
3942 template<typename T1, typename T2, typename T3> \
3943 const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \
3944 { return &theClass<T1, T2, T3>::sm_eventTable; } \
3945 template<typename T1, typename T2, typename T3> \
3946 wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \
3947 template<typename T1, typename T2, typename T3> \
3948 wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \
3949 { return theClass<T1, T2, T3>::sm_eventHashTable; } \
3950 template<typename T1, typename T2, typename T3> \
3951 const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \
3953 #define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \
3954 template<typename T1, typename T2, typename T3, typename T4> \
3955 const wxEventTable theClass<T1, T2, T3, T4>::sm_eventTable = \
3956 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4>::sm_eventTableEntries[0] }; \
3957 template<typename T1, typename T2, typename T3, typename T4> \
3958 const wxEventTable *theClass<T1, T2, T3, T4>::GetEventTable() const \
3959 { return &theClass<T1, T2, T3, T4>::sm_eventTable; } \
3960 template<typename T1, typename T2, typename T3, typename T4> \
3961 wxEventHashTable theClass<T1, T2, T3, T4>::sm_eventHashTable(theClass<T1, T2, T3, T4>::sm_eventTable); \
3962 template<typename T1, typename T2, typename T3, typename T4> \
3963 wxEventHashTable &theClass<T1, T2, T3, T4>::GetEventHashTable() const \
3964 { return theClass<T1, T2, T3, T4>::sm_eventHashTable; } \
3965 template<typename T1, typename T2, typename T3, typename T4> \
3966 const wxEventTableEntry theClass<T1, T2, T3, T4>::sm_eventTableEntries[] = { \
3968 #define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \
3969 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
3970 const wxEventTable theClass<T1, T2, T3, T4, T5>::sm_eventTable = \
3971 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[0] }; \
3972 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
3973 const wxEventTable *theClass<T1, T2, T3, T4, T5>::GetEventTable() const \
3974 { return &theClass<T1, T2, T3, T4, T5>::sm_eventTable; } \
3975 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
3976 wxEventHashTable theClass<T1, T2, T3, T4, T5>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5>::sm_eventTable); \
3977 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
3978 wxEventHashTable &theClass<T1, T2, T3, T4, T5>::GetEventHashTable() const \
3979 { return theClass<T1, T2, T3, T4, T5>::sm_eventHashTable; } \
3980 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
3981 const wxEventTableEntry theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[] = { \
3983 #define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \
3984 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
3985 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable = \
3986 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[0] }; \
3987 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
3988 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventTable() const \
3989 { return &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable; } \
3990 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
3991 wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable); \
3992 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
3993 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventHashTable() const \
3994 { return theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable; } \
3995 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
3996 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[] = { \
3998 #define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \
3999 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4000 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable = \
4001 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[0] }; \
4002 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4003 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventTable() const \
4004 { return &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable; } \
4005 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4006 wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable); \
4007 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4008 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventHashTable() const \
4009 { return theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable; } \
4010 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4011 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[] = { \
4013 #define wxEND_EVENT_TABLE() \
4014 wxDECLARE_EVENT_TABLE_TERMINATOR() };
4017 * Event table macros
4020 // helpers for writing shorter code below: declare an event macro taking 2, 1
4021 // or none ids (the missing ids default to wxID_ANY)
4024 // - evt one of wxEVT_XXX constants
4025 // - id1, id2 ids of the first/last id
4026 // - fn the function (should be cast to the right type)
4027 #define wx__DECLARE_EVT2(evt, id1, id2, fn) \
4028 wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
4029 #define wx__DECLARE_EVT1(evt, id, fn) \
4030 wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
4031 #define wx__DECLARE_EVT0(evt, fn) \
4032 wx__DECLARE_EVT1(evt, wxID_ANY, fn)
4036 #define EVT_CUSTOM(event, winid, func) \
4037 wx__DECLARE_EVT1(event, winid, wxEventHandler(func))
4038 #define EVT_CUSTOM_RANGE(event, id1, id2, func) \
4039 wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func))
4042 #define EVT_COMMAND(winid, event, func) \
4043 wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func))
4045 #define EVT_COMMAND_RANGE(id1, id2, event, func) \
4046 wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func))
4048 #define EVT_NOTIFY(event, winid, func) \
4049 wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func))
4051 #define EVT_NOTIFY_RANGE(event, id1, id2, func) \
4052 wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func))
4055 #define EVT_SIZE(func) wx__DECLARE_EVT0(wxEVT_SIZE, wxSizeEventHandler(func))
4056 #define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func))
4057 #define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func))
4058 #define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func))
4059 #define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func))
4060 #define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func))
4061 #define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))
4062 #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4063 #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4064 #define EVT_PAINT(func) wx__DECLARE_EVT0(wxEVT_PAINT, wxPaintEventHandler(func))
4065 #define EVT_NC_PAINT(func) wx__DECLARE_EVT0(wxEVT_NC_PAINT, wxNcPaintEventHandler(func))
4066 #define EVT_ERASE_BACKGROUND(func) wx__DECLARE_EVT0(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(func))
4067 #define EVT_CHAR(func) wx__DECLARE_EVT0(wxEVT_CHAR, wxCharEventHandler(func))
4068 #define EVT_KEY_DOWN(func) wx__DECLARE_EVT0(wxEVT_KEY_DOWN, wxKeyEventHandler(func))
4069 #define EVT_KEY_UP(func) wx__DECLARE_EVT0(wxEVT_KEY_UP, wxKeyEventHandler(func))
4071 #define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func))
4073 #define EVT_CHAR_HOOK(func) wx__DECLARE_EVT0(wxEVT_CHAR_HOOK, wxCharEventHandler(func))
4074 #define EVT_MENU_OPEN(func) wx__DECLARE_EVT0(wxEVT_MENU_OPEN, wxMenuEventHandler(func))
4075 #define EVT_MENU_CLOSE(func) wx__DECLARE_EVT0(wxEVT_MENU_CLOSE, wxMenuEventHandler(func))
4076 #define EVT_MENU_HIGHLIGHT(winid, func) wx__DECLARE_EVT1(wxEVT_MENU_HIGHLIGHT, winid, wxMenuEventHandler(func))
4077 #define EVT_MENU_HIGHLIGHT_ALL(func) wx__DECLARE_EVT0(wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler(func))
4078 #define EVT_SET_FOCUS(func) wx__DECLARE_EVT0(wxEVT_SET_FOCUS, wxFocusEventHandler(func))
4079 #define EVT_KILL_FOCUS(func) wx__DECLARE_EVT0(wxEVT_KILL_FOCUS, wxFocusEventHandler(func))
4080 #define EVT_CHILD_FOCUS(func) wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func))
4081 #define EVT_ACTIVATE(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func))
4082 #define EVT_ACTIVATE_APP(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func))
4083 #define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func))
4084 #define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4085 #define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4086 #define EVT_DROP_FILES(func) wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func))
4087 #define EVT_INIT_DIALOG(func) wx__DECLARE_EVT0(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(func))
4088 #define EVT_SYS_COLOUR_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler(func))
4089 #define EVT_DISPLAY_CHANGED(func) wx__DECLARE_EVT0(wxEVT_DISPLAY_CHANGED, wxDisplayChangedEventHandler(func))
4090 #define EVT_SHOW(func) wx__DECLARE_EVT0(wxEVT_SHOW, wxShowEventHandler(func))
4091 #define EVT_MAXIMIZE(func) wx__DECLARE_EVT0(wxEVT_MAXIMIZE, wxMaximizeEventHandler(func))
4092 #define EVT_ICONIZE(func) wx__DECLARE_EVT0(wxEVT_ICONIZE, wxIconizeEventHandler(func))
4093 #define EVT_NAVIGATION_KEY(func) wx__DECLARE_EVT0(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(func))
4094 #define EVT_PALETTE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_PALETTE_CHANGED, wxPaletteChangedEventHandler(func))
4095 #define EVT_QUERY_NEW_PALETTE(func) wx__DECLARE_EVT0(wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEventHandler(func))
4096 #define EVT_WINDOW_CREATE(func) wx__DECLARE_EVT0(wxEVT_CREATE, wxWindowCreateEventHandler(func))
4097 #define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func))
4098 #define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func))
4099 #define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func))
4100 #define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func))
4103 #define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func))
4104 #define EVT_LEFT_UP(func) wx__DECLARE_EVT0(wxEVT_LEFT_UP, wxMouseEventHandler(func))
4105 #define EVT_MIDDLE_DOWN(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(func))
4106 #define EVT_MIDDLE_UP(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_UP, wxMouseEventHandler(func))
4107 #define EVT_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DOWN, wxMouseEventHandler(func))
4108 #define EVT_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_RIGHT_UP, wxMouseEventHandler(func))
4109 #define EVT_MOTION(func) wx__DECLARE_EVT0(wxEVT_MOTION, wxMouseEventHandler(func))
4110 #define EVT_LEFT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_LEFT_DCLICK, wxMouseEventHandler(func))
4111 #define EVT_MIDDLE_DCLICK(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(func))
4112 #define EVT_RIGHT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(func))
4113 #define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func))
4114 #define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func))
4115 #define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func))
4116 #define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func))
4117 #define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func))
4118 #define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func))
4119 #define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
4120 #define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
4121 #define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
4124 #define EVT_MOUSE_EVENTS(func) \
4125 EVT_LEFT_DOWN(func) \
4127 EVT_LEFT_DCLICK(func) \
4128 EVT_MIDDLE_DOWN(func) \
4129 EVT_MIDDLE_UP(func) \
4130 EVT_MIDDLE_DCLICK(func) \
4131 EVT_RIGHT_DOWN(func) \
4132 EVT_RIGHT_UP(func) \
4133 EVT_RIGHT_DCLICK(func) \
4134 EVT_MOUSE_AUX1_DOWN(func) \
4135 EVT_MOUSE_AUX1_UP(func) \
4136 EVT_MOUSE_AUX1_DCLICK(func) \
4137 EVT_MOUSE_AUX2_DOWN(func) \
4138 EVT_MOUSE_AUX2_UP(func) \
4139 EVT_MOUSE_AUX2_DCLICK(func) \
4141 EVT_LEAVE_WINDOW(func) \
4142 EVT_ENTER_WINDOW(func) \
4143 EVT_MOUSEWHEEL(func)
4145 // Scrolling from wxWindow (sent to wxScrolledWindow)
4146 #define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
4147 #define EVT_SCROLLWIN_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(func))
4148 #define EVT_SCROLLWIN_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(func))
4149 #define EVT_SCROLLWIN_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(func))
4150 #define EVT_SCROLLWIN_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(func))
4151 #define EVT_SCROLLWIN_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(func))
4152 #define EVT_SCROLLWIN_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(func))
4153 #define EVT_SCROLLWIN_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(func))
4155 #define EVT_SCROLLWIN(func) \
4156 EVT_SCROLLWIN_TOP(func) \
4157 EVT_SCROLLWIN_BOTTOM(func) \
4158 EVT_SCROLLWIN_LINEUP(func) \
4159 EVT_SCROLLWIN_LINEDOWN(func) \
4160 EVT_SCROLLWIN_PAGEUP(func) \
4161 EVT_SCROLLWIN_PAGEDOWN(func) \
4162 EVT_SCROLLWIN_THUMBTRACK(func) \
4163 EVT_SCROLLWIN_THUMBRELEASE(func)
4165 // Scrolling from wxSlider and wxScrollBar
4166 #define EVT_SCROLL_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_TOP, wxScrollEventHandler(func))
4167 #define EVT_SCROLL_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(func))
4168 #define EVT_SCROLL_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(func))
4169 #define EVT_SCROLL_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(func))
4170 #define EVT_SCROLL_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(func))
4171 #define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func))
4172 #define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func))
4173 #define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func))
4174 #define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func))
4176 #define EVT_SCROLL(func) \
4177 EVT_SCROLL_TOP(func) \
4178 EVT_SCROLL_BOTTOM(func) \
4179 EVT_SCROLL_LINEUP(func) \
4180 EVT_SCROLL_LINEDOWN(func) \
4181 EVT_SCROLL_PAGEUP(func) \
4182 EVT_SCROLL_PAGEDOWN(func) \
4183 EVT_SCROLL_THUMBTRACK(func) \
4184 EVT_SCROLL_THUMBRELEASE(func) \
4185 EVT_SCROLL_CHANGED(func)
4187 // Scrolling from wxSlider and wxScrollBar, with an id
4188 #define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func))
4189 #define EVT_COMMAND_SCROLL_BOTTOM(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_BOTTOM, winid, wxScrollEventHandler(func))
4190 #define EVT_COMMAND_SCROLL_LINEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxScrollEventHandler(func))
4191 #define EVT_COMMAND_SCROLL_LINEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxScrollEventHandler(func))
4192 #define EVT_COMMAND_SCROLL_PAGEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEUP, winid, wxScrollEventHandler(func))
4193 #define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func))
4194 #define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func))
4195 #define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func))
4196 #define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func))
4198 #define EVT_COMMAND_SCROLL(winid, func) \
4199 EVT_COMMAND_SCROLL_TOP(winid, func) \
4200 EVT_COMMAND_SCROLL_BOTTOM(winid, func) \
4201 EVT_COMMAND_SCROLL_LINEUP(winid, func) \
4202 EVT_COMMAND_SCROLL_LINEDOWN(winid, func) \
4203 EVT_COMMAND_SCROLL_PAGEUP(winid, func) \
4204 EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \
4205 EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \
4206 EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \
4207 EVT_COMMAND_SCROLL_CHANGED(winid, func)
4209 #if WXWIN_COMPATIBILITY_2_6
4210 // compatibility macros for the old name, deprecated in 2.8
4211 #define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED
4212 #define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED
4213 #define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED
4214 #endif // WXWIN_COMPATIBILITY_2_6
4216 // Convenience macros for commonly-used commands
4217 #define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKBOX, winid, wxCommandEventHandler(func))
4218 #define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_CHOICE, winid, wxCommandEventHandler(func))
4219 #define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX, winid, wxCommandEventHandler(func))
4220 #define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX_DCLICK, winid, wxCommandEventHandler(func))
4221 #define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_MENU, winid, wxCommandEventHandler(func))
4222 #define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_MENU, id1, id2, wxCommandEventHandler(func))
4223 #if defined(__SMARTPHONE__)
4224 # define EVT_BUTTON(winid, func) EVT_MENU(winid, func)
4226 # define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_BUTTON, winid, wxCommandEventHandler(func))
4228 #define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_SLIDER, winid, wxCommandEventHandler(func))
4229 #define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBOX, winid, wxCommandEventHandler(func))
4230 #define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBUTTON, winid, wxCommandEventHandler(func))
4231 // EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events
4232 #define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLLBAR, winid, wxCommandEventHandler(func))
4233 #define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_VLBOX, winid, wxCommandEventHandler(func))
4234 #define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX, winid, wxCommandEventHandler(func))
4235 #define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL, winid, wxCommandEventHandler(func))
4236 #define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_DROPDOWN, winid, wxCommandEventHandler(func))
4237 #define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL, id1, id2, wxCommandEventHandler(func))
4238 #define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func))
4239 #define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
4240 #define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func))
4241 #define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func))
4242 #define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func))
4243 #define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func))
4245 // Generic command events
4246 #define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))
4247 #define EVT_COMMAND_LEFT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_DCLICK, winid, wxCommandEventHandler(func))
4248 #define EVT_COMMAND_RIGHT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_CLICK, winid, wxCommandEventHandler(func))
4249 #define EVT_COMMAND_RIGHT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_DCLICK, winid, wxCommandEventHandler(func))
4250 #define EVT_COMMAND_SET_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SET_FOCUS, winid, wxCommandEventHandler(func))
4251 #define EVT_COMMAND_KILL_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_KILL_FOCUS, winid, wxCommandEventHandler(func))
4252 #define EVT_COMMAND_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_ENTER, winid, wxCommandEventHandler(func))
4256 #define EVT_JOY_BUTTON_DOWN(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_DOWN, wxJoystickEventHandler(func))
4257 #define EVT_JOY_BUTTON_UP(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_UP, wxJoystickEventHandler(func))
4258 #define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func))
4259 #define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func))
4261 // All joystick events
4262 #define EVT_JOYSTICK_EVENTS(func) \
4263 EVT_JOY_BUTTON_DOWN(func) \
4264 EVT_JOY_BUTTON_UP(func) \
4265 EVT_JOY_MOVE(func) \
4269 #define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func))
4272 #define EVT_UPDATE_UI(winid, func) wx__DECLARE_EVT1(wxEVT_UPDATE_UI, winid, wxUpdateUIEventHandler(func))
4273 #define EVT_UPDATE_UI_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_UPDATE_UI, id1, id2, wxUpdateUIEventHandler(func))
4276 #define EVT_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_HELP, winid, wxHelpEventHandler(func))
4277 #define EVT_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_HELP, id1, id2, wxHelpEventHandler(func))
4278 #define EVT_DETAILED_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_DETAILED_HELP, winid, wxHelpEventHandler(func))
4279 #define EVT_DETAILED_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_DETAILED_HELP, id1, id2, wxHelpEventHandler(func))
4281 // Context Menu Events
4282 #define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func))
4283 #define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func))
4285 // Clipboard text Events
4286 #define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_CUT, winid, wxClipboardTextEventHandler(func))
4287 #define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_COPY, winid, wxClipboardTextEventHandler(func))
4288 #define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_PASTE, winid, wxClipboardTextEventHandler(func))
4291 #define EVT_THREAD(id, func) wx__DECLARE_EVT1(wxEVT_THREAD, id, wxThreadEventHandler(func))
4293 // ----------------------------------------------------------------------------
4295 // ----------------------------------------------------------------------------
4297 // This is an ugly hack to allow the use of Bind() instead of Connect() inside
4298 // the library code if the library was built with support for it, here is how
4301 // class SomeEventHandlingClass : wxBIND_OR_CONNECT_HACK_BASE_CLASS
4302 // public SomeBaseClass
4305 // SomeEventHandlingClass(wxWindow *win)
4307 // // connect to the event for the given window
4308 // wxBIND_OR_CONNECT_HACK(win, wxEVT_SOMETHING, wxSomeEventHandler,
4309 // SomeEventHandlingClass::OnSomeEvent, this);
4313 // void OnSomeEvent(wxSomeEvent&) { ... }
4316 // This is *not* meant to be used by library users, it is only defined here
4317 // (and not in a private header) because the base class must be visible from
4318 // other public headers, please do NOT use this in your code, it will be
4319 // removed from future wx versions without warning.
4320 #ifdef wxHAS_EVENT_BIND
4321 #define wxBIND_OR_CONNECT_HACK_BASE_CLASS
4322 #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
4323 #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \
4324 win->Bind(evt, &func, obj)
4325 #else // wxHAS_EVENT_BIND
4326 #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler,
4327 #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler
4328 #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \
4329 win->Connect(evt, handler(func), NULL, obj)
4330 #endif // wxHAS_EVENT_BIND
4334 // Find a window with the focus, that is also a descendant of the given window.
4335 // This is used to determine the window to initially send commands to.
4336 WXDLLIMPEXP_CORE wxWindow
* wxFindFocusDescendant(wxWindow
* ancestor
);
4341 // ----------------------------------------------------------------------------
4342 // Compatibility macro aliases
4343 // ----------------------------------------------------------------------------
4345 // deprecated variants _not_ requiring a semicolon after them and without wx prefix
4346 // (note that also some wx-prefixed macro do _not_ require a semicolon because
4347 // it's not always possible to force the compire to require it)
4349 #define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
4350 wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj)
4351 #define DECLARE_EVENT_TABLE_TERMINATOR() wxDECLARE_EVENT_TABLE_TERMINATOR()
4352 #define DECLARE_EVENT_TABLE() wxDECLARE_EVENT_TABLE();
4353 #define BEGIN_EVENT_TABLE(a,b) wxBEGIN_EVENT_TABLE(a,b)
4354 #define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c)
4355 #define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) wxBEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d)
4356 #define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) wxBEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e)
4357 #define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) wxBEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f)
4358 #define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) wxBEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g)
4359 #define BEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) wxBEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h)
4360 #define END_EVENT_TABLE() wxEND_EVENT_TABLE()
4362 // other obsolete event declaration/definition macros; we don't need them any longer
4363 // but we keep them for compatibility as it doesn't cost us anything anyhow
4364 #define BEGIN_DECLARE_EVENT_TYPES()
4365 #define END_DECLARE_EVENT_TYPES()
4366 #define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
4367 extern expdecl const wxEventType name;
4368 #define DECLARE_EVENT_TYPE(name, value) \
4369 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
4370 #define DECLARE_LOCAL_EVENT_TYPE(name, value) \
4371 DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value)
4372 #define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
4373 #define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name)
4375 // alias for backward compatibility with 2.9.0:
4376 #define wxEVT_COMMAND_THREAD wxEVT_THREAD
4377 // other old wxEVT_COMMAND_* constants
4378 #define wxEVT_COMMAND_BUTTON_CLICKED wxEVT_BUTTON
4379 #define wxEVT_COMMAND_CHECKBOX_CLICKED wxEVT_CHECKBOX
4380 #define wxEVT_COMMAND_CHOICE_SELECTED wxEVT_CHOICE
4381 #define wxEVT_COMMAND_LISTBOX_SELECTED wxEVT_LISTBOX
4382 #define wxEVT_COMMAND_LISTBOX_DOUBLECLICKED wxEVT_LISTBOX_DCLICK
4383 #define wxEVT_COMMAND_CHECKLISTBOX_TOGGLED wxEVT_CHECKLISTBOX
4384 #define wxEVT_COMMAND_MENU_SELECTED wxEVT_MENU
4385 #define wxEVT_COMMAND_TOOL_CLICKED wxEVT_TOOL
4386 #define wxEVT_COMMAND_SLIDER_UPDATED wxEVT_SLIDER
4387 #define wxEVT_COMMAND_RADIOBOX_SELECTED wxEVT_RADIOBOX
4388 #define wxEVT_COMMAND_RADIOBUTTON_SELECTED wxEVT_RADIOBUTTON
4389 #define wxEVT_COMMAND_SCROLLBAR_UPDATED wxEVT_SCROLLBAR
4390 #define wxEVT_COMMAND_VLBOX_SELECTED wxEVT_VLBOX
4391 #define wxEVT_COMMAND_COMBOBOX_SELECTED wxEVT_COMBOBOX
4392 #define wxEVT_COMMAND_TOOL_RCLICKED wxEVT_TOOL_RCLICKED
4393 #define wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED wxEVT_TOOL_DROPDOWN
4394 #define wxEVT_COMMAND_TOOL_ENTER wxEVT_TOOL_ENTER
4395 #define wxEVT_COMMAND_COMBOBOX_DROPDOWN wxEVT_COMBOBOX_DROPDOWN
4396 #define wxEVT_COMMAND_COMBOBOX_CLOSEUP wxEVT_COMBOBOX_CLOSEUP
4397 #define wxEVT_COMMAND_TEXT_COPY wxEVT_TEXT_COPY
4398 #define wxEVT_COMMAND_TEXT_CUT wxEVT_TEXT_CUT
4399 #define wxEVT_COMMAND_TEXT_PASTE wxEVT_TEXT_PASTE
4400 #define wxEVT_COMMAND_TEXT_UPDATED wxEVT_TEXT
4402 #endif // _WX_EVENT_H_