]> git.saurik.com Git - wxWidgets.git/blame - include/wx/event.h
Document wxKill(wxSIGTERM) reliance on having an open window in wxMSW.
[wxWidgets.git] / include / wx / event.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
bd83cb56 2// Name: wx/event.h
c801d85f
KB
3// Purpose: Event classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
204abcd4
PC
12#ifndef _WX_EVENT_H_
13#define _WX_EVENT_H_
c801d85f 14
c801d85f 15#include "wx/defs.h"
bde626ce 16#include "wx/cpp.h"
c801d85f 17#include "wx/object.h"
341050e2 18#include "wx/clntdata.h"
e90c1d2a
VZ
19
20#if wxUSE_GUI
21 #include "wx/gdicmn.h"
43b5058d 22 #include "wx/cursor.h"
0e097789 23 #include "wx/mousestate.h"
e90c1d2a 24#endif
42e69d6b 25
b5a98acd 26#include "wx/dynarray.h"
8ebec7dc 27#include "wx/thread.h"
2ef989c9 28#include "wx/tracker.h"
700dcf1e 29#include "wx/typeinfo.h"
dae60aee 30#include "wx/any.h"
b5a98acd 31
890d70eb 32#ifdef wxHAS_EVENT_BIND
f3ff831f
VZ
33 #include "wx/meta/convertible.h"
34#endif
35
f0facad0
VZ
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"
cf222762 40
8f6bb260
VZ
41 #define wxHAS_CALL_AFTER
42#endif
43
e90c1d2a
VZ
44// ----------------------------------------------------------------------------
45// forward declarations
46// ----------------------------------------------------------------------------
47
b5dbe15d 48class WXDLLIMPEXP_FWD_BASE wxList;
3c778901 49class WXDLLIMPEXP_FWD_BASE wxEvent;
58cc1587 50class WXDLLIMPEXP_FWD_BASE wxEventFilter;
e90c1d2a 51#if wxUSE_GUI
b5dbe15d
VS
52 class WXDLLIMPEXP_FWD_CORE wxDC;
53 class WXDLLIMPEXP_FWD_CORE wxMenu;
54 class WXDLLIMPEXP_FWD_CORE wxWindow;
55 class WXDLLIMPEXP_FWD_CORE wxWindowBase;
e90c1d2a
VZ
56#endif // wxUSE_GUI
57
d1a64f69
VZ
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
68// wxEvtHandler.
69#ifdef __VISUALC__
70 #define wxMSVC_FWD_MULTIPLE_BASES __multiple_inheritance
71#else
72 #define wxMSVC_FWD_MULTIPLE_BASES
73#endif
74
75class WXDLLIMPEXP_FWD_BASE wxMSVC_FWD_MULTIPLE_BASES wxEvtHandler;
cc6ceca7 76class wxEventConnectionRef;
432968bf 77
e90c1d2a
VZ
78// ----------------------------------------------------------------------------
79// Event types
80// ----------------------------------------------------------------------------
64693098 81
cbee8f8d
VZ
82typedef int wxEventType;
83
c4fa5aa7
VZ
84#define wxEVT_ANY ((wxEventType)-1)
85
3a818b15 86// this is used to make the event table entry type safe, so that for an event
111d41b2
VZ
87// handler only a function with proper parameter list can be given. See also
88// the wxEVENT_HANDLER_CAST-macro.
5c33522f 89#define wxStaticCastEvent(type, val) static_cast<type>(val)
3a818b15 90
a0e9a5df 91#define wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
0fe243db 92 wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj)
3c778901 93
a0e9a5df 94#define wxDECLARE_EVENT_TABLE_TERMINATOR() \
3c778901 95 wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0)
cbee8f8d 96
cbee8f8d 97// generate a new unique event type
bddd7a8d 98extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();
cbee8f8d 99
54a9471a
VZ
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
111d41b2 104
54a9471a
VZ
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
3c778901 107 #define wxDEFINE_EVENT( name, type ) \
54a9471a 108 const wxEventTypeTag< type > name( wxNewEventType() )
3c778901 109
54a9471a
VZ
110 // the general version allowing exporting the event type from DLL, used by
111 // wxWidgets itself
3c778901 112 #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \
54a9471a 113 extern const expdecl wxEventTypeTag< type > name
111d41b2 114
54a9471a 115 // this is the version which will normally be used in the user code
579e0559 116 #define wxDECLARE_EVENT( name, type ) \
ff3fd98a 117 wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
3c778901 118
111d41b2 119
54a9471a
VZ
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
122 // wxEVT_SPIN_XXX)
dca94103 123 #define wxDEFINE_EVENT_ALIAS( name, type, value ) \
9b11752c 124 const wxEventTypeTag< type > name( value )
3c778901 125
dca94103 126 #define wxDECLARE_EXPORTED_EVENT_ALIAS( expdecl, name, type ) \
9b11752c 127 extern const expdecl wxEventTypeTag< type > name
54a9471a
VZ
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
3c778901 131
54a9471a
VZ
132 #define wxDEFINE_EVENT( name, type ) \
133 const wxEventType name( wxNewEventType() )
111d41b2 134
54a9471a
VZ
135 #define wxDECLARE_EXPORTED_EVENT( expdecl, name, type ) \
136 extern const expdecl wxEventType name
579e0559 137 #define wxDECLARE_EVENT( name, type ) \
ff3fd98a 138 wxDECLARE_EXPORTED_EVENT( wxEMPTY_PARAMETER_VALUE, name, type )
3c778901 139
54a9471a
VZ
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
3c778901 145
5293e4b7
VZ
146// Try to cast the given event handler to the correct handler type:
147
148#define wxEVENT_HANDLER_CAST( functype, func ) \
149 ( wxObjectEventFunction )( wxEventFunction )wxStaticCastEvent( functype, &func )
150
3c778901 151
890d70eb 152#ifdef wxHAS_EVENT_BIND
3c778901 153
f3ff831f
VZ
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.
158template <typename T>
159class wxEventTypeTag
3c778901
VZ
160{
161public:
f3ff831f
VZ
162 // The class of wxEvent-derived class carried by the events of this type.
163 typedef T EventClass;
3c778901 164
f3ff831f 165 wxEventTypeTag(wxEventType type) { m_type = type; }
3c778901 166
111d41b2
VZ
167 // Return a wxEventType reference for the initialization of the static
168 // event tables. See wxEventTableEntry::m_eventType for a more thorough
169 // explanation.
3c778901
VZ
170 operator const wxEventType&() const { return m_type; }
171
172private:
173 wxEventType m_type;
174};
175
890d70eb 176#endif // wxHAS_EVENT_BIND
3c778901
VZ
177
178// These are needed for the functor definitions
179typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
180
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.
188typedef wxEventFunction wxObjectEventFunction;
189
111d41b2 190// The event functor which is stored in the static and dynamic event tables:
3c778901
VZ
191class WXDLLIMPEXP_BASE wxEventFunctor
192{
193public:
194 virtual ~wxEventFunctor();
195
111d41b2 196 // Invoke the actual event handler:
f3ff831f 197 virtual void operator()(wxEvtHandler *, wxEvent&) = 0;
3c778901 198
03f3617b 199 // this function tests whether this functor is matched, for the purpose of
890d70eb
VZ
200 // finding it in an event table in Unbind(), by the given functor:
201 virtual bool IsMatching(const wxEventFunctor& functor) const = 0;
3c778901 202
890d70eb
VZ
203 // If the functor holds an wxEvtHandler, then get access to it and track
204 // its lifetime with wxEventConnectionRef:
205 virtual wxEvtHandler *GetEvtHandler() const
206 { return NULL; }
207
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
211 // wxEventFunction:
212 virtual wxEventFunction GetEvtMethod() const
213 { return NULL; }
7db064f6
JS
214
215private:
216 WX_DECLARE_ABSTRACT_TYPEINFO(wxEventFunctor)
3c778901
VZ
217};
218
890d70eb 219// A plain method functor for the untyped legacy event types:
3c778901
VZ
220class WXDLLIMPEXP_BASE wxObjectEventFunctor : public wxEventFunctor
221{
222public:
223 wxObjectEventFunctor(wxObjectEventFunction method, wxEvtHandler *handler)
890d70eb
VZ
224 : m_handler( handler ), m_method( method )
225 { }
226
8cb2c49f 227 virtual void operator()(wxEvtHandler *handler, wxEvent& event);
3c778901 228
890d70eb 229 virtual bool IsMatching(const wxEventFunctor& functor) const
3c778901 230 {
7db064f6 231 if ( wxTypeId(functor) == wxTypeId(*this) )
890d70eb
VZ
232 {
233 const wxObjectEventFunctor &other =
234 static_cast< const wxObjectEventFunctor & >( functor );
3c778901 235
1b4bff82
VZ
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.
abb7d8a3 241
1b4bff82 242 return ( m_method == other.m_method || other.m_method == 0 ) &&
890d70eb
VZ
243 ( m_handler == other.m_handler || other.m_handler == NULL );
244 }
245 else
246 return false;
3c778901
VZ
247 }
248
890d70eb
VZ
249 virtual wxEvtHandler *GetEvtHandler() const
250 { return m_handler; }
251
252 virtual wxEventFunction GetEvtMethod() const
253 { return m_method; }
3c778901
VZ
254
255private:
256 wxEvtHandler *m_handler;
abb7d8a3 257 wxEventFunction m_method;
3c778901 258
7db064f6
JS
259 // Provide a dummy default ctor for type info purposes
260 wxObjectEventFunctor() { }
261
262 WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor)
890d70eb 263};
f3ff831f 264
e1614128 265// Create a functor for the legacy events: used by Connect()
03f3617b 266inline wxObjectEventFunctor *
48def411 267wxNewEventFunctor(const wxEventType& WXUNUSED(evtType),
03f3617b 268 wxObjectEventFunction method,
e1614128 269 wxEvtHandler *handler)
03f3617b
VZ
270{
271 return new wxObjectEventFunctor(method, handler);
272}
273
a0e9a5df 274// This version is used by wxDECLARE_EVENT_TABLE_ENTRY()
e1614128 275inline wxObjectEventFunctor *
ac26ed15
VZ
276wxNewEventTableFunctor(const wxEventType& WXUNUSED(evtType),
277 wxObjectEventFunction method)
e1614128
VZ
278{
279 return new wxObjectEventFunctor(method, NULL);
280}
281
03f3617b 282inline wxObjectEventFunctor
f3ff831f 283wxMakeEventFunctor(const wxEventType& WXUNUSED(evtType),
03f3617b
VZ
284 wxObjectEventFunction method,
285 wxEvtHandler *handler)
286{
287 return wxObjectEventFunctor(method, handler);
288}
289
890d70eb 290#ifdef wxHAS_EVENT_BIND
f3ff831f 291
f3ff831f
VZ
292namespace wxPrivate
293{
294
a01ada05
VZ
295// helper template defining nested "type" typedef as the event class
296// corresponding to the given event type
297template <typename T> struct EventClassOf;
298
299// the typed events provide the information about the class of the events they
300// carry themselves:
301template <typename T>
302struct EventClassOf< wxEventTypeTag<T> >
303{
304 typedef typename wxEventTypeTag<T>::EventClass type;
305};
306
307// for the old untyped events we don't have information about the exact event
308// class carried by them
309template <>
310struct EventClassOf<wxEventType>
311{
312 typedef wxEvent type;
313};
314
315
316// helper class defining operations different for method functors using an
317// object of wxEvtHandler-derived class as handler and the others
f3ff831f
VZ
318template <typename T, typename A, bool> struct HandlerImpl;
319
320// specialization for handlers deriving from wxEvtHandler
321template <typename T, typename A>
322struct HandlerImpl<T, A, true>
323{
324 static bool IsEvtHandler()
325 { return true; }
326 static T *ConvertFromEvtHandler(wxEvtHandler *p)
327 { return static_cast<T *>(p); }
328 static wxEvtHandler *ConvertToEvtHandler(T *p)
329 { return p; }
890d70eb 330 static wxEventFunction ConvertToEvtMethod(void (T::*f)(A&))
a01ada05
VZ
331 { return static_cast<wxEventFunction>(
332 reinterpret_cast<void (T::*)(wxEvent&)>(f)); }
3c778901
VZ
333};
334
f3ff831f
VZ
335// specialization for handlers not deriving from wxEvtHandler
336template <typename T, typename A>
337struct HandlerImpl<T, A, false>
338{
339 static bool IsEvtHandler()
340 { return false; }
341 static T *ConvertFromEvtHandler(wxEvtHandler *)
342 { return NULL; }
343 static wxEvtHandler *ConvertToEvtHandler(T *)
344 { return NULL; }
890d70eb 345 static wxEventFunction ConvertToEvtMethod(void (T::*)(A&))
f3ff831f
VZ
346 { return NULL; }
347};
348
349} // namespace wxPrivate
3c778901 350
f3ff831f
VZ
351// functor forwarding the event to a method of the given object
352//
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
a01ada05
VZ
355//
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
359// example
360template
4c802fdc 361 <typename EventTag, typename Class, typename EventArg, typename EventHandler>
f3ff831f
VZ
362class wxEventFunctorMethod
363 : public wxEventFunctor,
364 private wxPrivate::HandlerImpl
365 <
366 Class,
a01ada05 367 EventArg,
c4021a79 368 wxConvertibleTo<Class, wxEvtHandler>::value != 0
f3ff831f 369 >
3c778901 370{
a01ada05
VZ
371private:
372 static void CheckHandlerArgument(EventArg *) { }
373
3c778901 374public:
a01ada05
VZ
375 // the event class associated with the given event tag
376 typedef typename wxPrivate::EventClassOf<EventTag>::type EventClass;
377
f3ff831f 378
4c802fdc 379 wxEventFunctorMethod(void (Class::*method)(EventArg&), EventHandler *handler)
890d70eb 380 : m_handler( handler ), m_method( method )
3c778901 381 {
361ba943 382 wxASSERT_MSG( handler || this->IsEvtHandler(),
f3ff831f
VZ
383 "handlers defined in non-wxEvtHandler-derived classes "
384 "must be connected with a valid sink object" );
385
a01ada05
VZ
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));
3c778901
VZ
390 }
391
f3ff831f 392 virtual void operator()(wxEvtHandler *handler, wxEvent& event)
3c778901 393 {
f3ff831f
VZ
394 Class * realHandler = m_handler;
395 if ( !realHandler )
3c778901 396 {
361ba943 397 realHandler = this->ConvertFromEvtHandler(handler);
3c778901 398
f3ff831f
VZ
399 // this is not supposed to happen but check for it nevertheless
400 wxCHECK_RET( realHandler, "invalid event handler" );
3c778901
VZ
401 }
402
a01ada05
VZ
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
405 // is always valid
f3ff831f 406 (realHandler->*m_method)(static_cast<EventArg&>(event));
3c778901
VZ
407 }
408
890d70eb 409 virtual bool IsMatching(const wxEventFunctor& functor) const
3c778901 410 {
7db064f6 411 if ( wxTypeId(functor) != wxTypeId(*this) )
f3ff831f 412 return false;
3c778901 413
890d70eb
VZ
414 typedef wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>
415 ThisFunctor;
416
7db064f6 417 // the cast is valid because wxTypeId()s matched above
890d70eb
VZ
418 const ThisFunctor& other = static_cast<const ThisFunctor &>(functor);
419
420 return (m_method == other.m_method || other.m_method == NULL) &&
421 (m_handler == other.m_handler || other.m_handler == NULL);
3c778901
VZ
422 }
423
890d70eb
VZ
424 virtual wxEvtHandler *GetEvtHandler() const
425 { return this->ConvertToEvtHandler(m_handler); }
426
427 virtual wxEventFunction GetEvtMethod() const
428 { return this->ConvertToEvtMethod(m_method); }
429
430private:
431 EventHandler *m_handler;
432 void (Class::*m_method)(EventArg&);
433
7db064f6
JS
434 // Provide a dummy default ctor for type info purposes
435 wxEventFunctorMethod() { }
436
437 typedef wxEventFunctorMethod<EventTag, Class,
438 EventArg, EventHandler> thisClass;
439 WX_DECLARE_TYPEINFO_INLINE(thisClass)
890d70eb
VZ
440};
441
442
443// functor forwarding the event to function (function, static method)
444template <typename EventTag, typename EventArg>
445class wxEventFunctorFunction : public wxEventFunctor
446{
447private:
448 static void CheckHandlerArgument(EventArg *) { }
449
450public:
451 // the event class associated with the given event tag
452 typedef typename wxPrivate::EventClassOf<EventTag>::type EventClass;
453
454 wxEventFunctorFunction( void ( *handler )( EventArg & ))
455 : m_handler( handler )
3c778901 456 {
890d70eb
VZ
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));
3c778901
VZ
461 }
462
890d70eb 463 virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event)
3c778901 464 {
890d70eb
VZ
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 );
470 // or
471 // Unbind( wxEVT_XXX, &EventHandler::method, NULL )
472 m_handler(static_cast<EventArg&>(event));
f3ff831f
VZ
473 }
474
890d70eb 475 virtual bool IsMatching(const wxEventFunctor &functor) const
f3ff831f 476 {
7db064f6 477 if ( wxTypeId(functor) != wxTypeId(*this) )
890d70eb
VZ
478 return false;
479
480 typedef wxEventFunctorFunction<EventTag, EventArg> ThisFunctor;
481
482 const ThisFunctor& other = static_cast<const ThisFunctor&>( functor );
483
484 return m_handler == other.m_handler;
3c778901
VZ
485 }
486
487private:
890d70eb
VZ
488 void (*m_handler)(EventArg&);
489
7db064f6
JS
490 // Provide a dummy default ctor for type info purposes
491 wxEventFunctorFunction() { }
492
493 typedef wxEventFunctorFunction<EventTag, EventArg> thisClass;
494 WX_DECLARE_TYPEINFO_INLINE(thisClass)
3c778901
VZ
495};
496
f3ff831f 497
890d70eb
VZ
498template <typename EventTag, typename Functor>
499class wxEventFunctorFunctor : public wxEventFunctor
500{
501public:
502 typedef typename EventTag::EventClass EventArg;
503
ca6911c3 504 wxEventFunctorFunctor(const Functor& handler)
890d70eb
VZ
505 : m_handler(handler), m_handlerAddr(&handler)
506 { }
507
508 virtual void operator()(wxEvtHandler *WXUNUSED(handler), wxEvent& event)
509 {
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 );
515 // or
516 // Unbind( wxEVT_XXX, &EventHandler::method, NULL )
517 m_handler(static_cast<EventArg&>(event));
518 }
519
520 virtual bool IsMatching(const wxEventFunctor &functor) const
521 {
7db064f6 522 if ( wxTypeId(functor) != wxTypeId(*this) )
890d70eb
VZ
523 return false;
524
525 typedef wxEventFunctorFunctor<EventTag, Functor> FunctorThis;
526
527 const FunctorThis& other = static_cast<const FunctorThis&>(functor);
528
529 // The only reliable/portable way to compare two functors is by
530 // identity:
531 return m_handlerAddr == other.m_handlerAddr;
532 }
533
890d70eb
VZ
534private:
535 // Store a copy of the functor to prevent using/calling an already
536 // destroyed instance:
537 Functor m_handler;
538
539 // Use the address of the original functor for comparison in IsMatching:
540 const void *m_handlerAddr;
541
7db064f6
JS
542 // Provide a dummy default ctor for type info purposes
543 wxEventFunctorFunctor() { }
544
545 typedef wxEventFunctorFunctor<EventTag, Functor> thisClass;
546 WX_DECLARE_TYPEINFO_INLINE(thisClass)
890d70eb
VZ
547};
548
f3ff831f 549// Create functors for the templatized events, either allocated on the heap for
03ae811e 550// wxNewXXX() variants (this is needed in wxEvtHandler::Bind<>() to store them
c0f02dab 551// in dynamic event table) or just by returning them as temporary objects (this
03ae811e 552// is enough for Unbind<>() and we avoid unnecessary heap allocation like this).
3c778901 553
3c778901 554
890d70eb
VZ
555// Create functors wrapping functions:
556template <typename EventTag, typename EventArg>
557inline wxEventFunctorFunction<EventTag, EventArg> *
558wxNewEventFunctor(const EventTag&, void (*func)(EventArg &))
3c778901 559{
890d70eb 560 return new wxEventFunctorFunction<EventTag, EventArg>(func);
3c778901
VZ
561}
562
890d70eb
VZ
563template <typename EventTag, typename EventArg>
564inline wxEventFunctorFunction<EventTag, EventArg>
565wxMakeEventFunctor(const EventTag&, void (*func)(EventArg &))
566{
567 return wxEventFunctorFunction<EventTag, EventArg>(func);
568}
569
570// Create functors wrapping other functors:
f3ff831f 571template <typename EventTag, typename Functor>
890d70eb 572inline wxEventFunctorFunctor<EventTag, Functor> *
ca6911c3 573wxNewEventFunctor(const EventTag&, const Functor &func)
3c778901 574{
890d70eb 575 return new wxEventFunctorFunctor<EventTag, Functor>(func);
3c778901
VZ
576}
577
890d70eb
VZ
578template <typename EventTag, typename Functor>
579inline wxEventFunctorFunctor<EventTag, Functor>
ca6911c3 580wxMakeEventFunctor(const EventTag&, const Functor &func)
890d70eb
VZ
581{
582 return wxEventFunctorFunctor<EventTag, Functor>(func);
583}
3c778901 584
890d70eb 585// Create functors wrapping methods:
f3ff831f 586template
4c802fdc
VZ
587 <typename EventTag, typename Class, typename EventArg, typename EventHandler>
588inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler> *
f3ff831f
VZ
589wxNewEventFunctor(const EventTag&,
590 void (Class::*method)(EventArg&),
4c802fdc 591 EventHandler *handler)
3c778901 592{
4c802fdc 593 return new wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>(
a01ada05 594 method, handler);
3c778901
VZ
595}
596
f3ff831f 597template
4c802fdc
VZ
598 <typename EventTag, typename Class, typename EventArg, typename EventHandler>
599inline wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>
f3ff831f
VZ
600wxMakeEventFunctor(const EventTag&,
601 void (Class::*method)(EventArg&),
4c802fdc 602 EventHandler *handler)
3c778901 603{
4c802fdc 604 return wxEventFunctorMethod<EventTag, Class, EventArg, EventHandler>(
a01ada05 605 method, handler);
3c778901
VZ
606}
607
a0e9a5df 608// Create an event functor for the event table via wxDECLARE_EVENT_TABLE_ENTRY:
0fe243db
VZ
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
f3ff831f 611template <typename EventTag, typename Class, typename EventArg>
a01ada05 612inline wxEventFunctorMethod<EventTag, Class, EventArg, Class> *
0fe243db 613wxNewEventTableFunctor(const EventTag&, void (Class::*method)(EventArg&))
3c778901 614{
a01ada05
VZ
615 return new wxEventFunctorMethod<EventTag, Class, EventArg, Class>(
616 method, NULL);
3c778901
VZ
617}
618
890d70eb 619#endif // wxHAS_EVENT_BIND
3c778901 620
f3ff831f 621
c058cafa
VZ
622// many, but not all, standard event types
623
624 // some generic events
625extern WXDLLIMPEXP_BASE const wxEventType wxEVT_NULL;
626extern WXDLLIMPEXP_BASE const wxEventType wxEVT_FIRST;
627extern WXDLLIMPEXP_BASE const wxEventType wxEVT_USER_FIRST;
628
3c778901 629 // Need events declared to do this
c1b293bb
VS
630class WXDLLIMPEXP_FWD_BASE wxIdleEvent;
631class WXDLLIMPEXP_FWD_BASE wxThreadEvent;
cf222762 632class WXDLLIMPEXP_FWD_BASE wxAsyncMethodCallEvent;
3c778901
VZ
633class WXDLLIMPEXP_FWD_CORE wxCommandEvent;
634class WXDLLIMPEXP_FWD_CORE wxMouseEvent;
635class WXDLLIMPEXP_FWD_CORE wxFocusEvent;
636class WXDLLIMPEXP_FWD_CORE wxChildFocusEvent;
637class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
638class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent;
639class WXDLLIMPEXP_FWD_CORE wxSetCursorEvent;
640class WXDLLIMPEXP_FWD_CORE wxScrollEvent;
dca94103 641class WXDLLIMPEXP_FWD_CORE wxSpinEvent;
3c778901
VZ
642class WXDLLIMPEXP_FWD_CORE wxScrollWinEvent;
643class WXDLLIMPEXP_FWD_CORE wxSizeEvent;
644class WXDLLIMPEXP_FWD_CORE wxMoveEvent;
645class WXDLLIMPEXP_FWD_CORE wxCloseEvent;
646class WXDLLIMPEXP_FWD_CORE wxActivateEvent;
647class WXDLLIMPEXP_FWD_CORE wxWindowCreateEvent;
648class WXDLLIMPEXP_FWD_CORE wxWindowDestroyEvent;
649class WXDLLIMPEXP_FWD_CORE wxShowEvent;
650class WXDLLIMPEXP_FWD_CORE wxIconizeEvent;
651class WXDLLIMPEXP_FWD_CORE wxMaximizeEvent;
652class WXDLLIMPEXP_FWD_CORE wxMouseCaptureChangedEvent;
653class WXDLLIMPEXP_FWD_CORE wxMouseCaptureLostEvent;
654class WXDLLIMPEXP_FWD_CORE wxPaintEvent;
655class WXDLLIMPEXP_FWD_CORE wxEraseEvent;
656class WXDLLIMPEXP_FWD_CORE wxNcPaintEvent;
657class WXDLLIMPEXP_FWD_CORE wxMenuEvent;
658class WXDLLIMPEXP_FWD_CORE wxContextMenuEvent;
659class WXDLLIMPEXP_FWD_CORE wxSysColourChangedEvent;
660class WXDLLIMPEXP_FWD_CORE wxDisplayChangedEvent;
661class WXDLLIMPEXP_FWD_CORE wxQueryNewPaletteEvent;
662class WXDLLIMPEXP_FWD_CORE wxPaletteChangedEvent;
663class WXDLLIMPEXP_FWD_CORE wxJoystickEvent;
664class WXDLLIMPEXP_FWD_CORE wxDropFilesEvent;
665class WXDLLIMPEXP_FWD_CORE wxInitDialogEvent;
3c778901
VZ
666class WXDLLIMPEXP_FWD_CORE wxUpdateUIEvent;
667class WXDLLIMPEXP_FWD_CORE wxClipboardTextEvent;
668class WXDLLIMPEXP_FWD_CORE wxHelpEvent;
669
670
c058cafa 671 // Command events
ce7fe42e
VZ
672wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_BUTTON, wxCommandEvent);
673wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKBOX, wxCommandEvent);
674wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHOICE, wxCommandEvent);
675wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX, wxCommandEvent);
676wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LISTBOX_DCLICK, wxCommandEvent);
677wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHECKLISTBOX, wxCommandEvent);
678wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU, wxCommandEvent);
679wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SLIDER, wxCommandEvent);
680wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBOX, wxCommandEvent);
681wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RADIOBUTTON, wxCommandEvent);
682
683// wxEVT_SCROLLBAR is deprecated, use wxEVT_SCROLL... events
684wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLBAR, wxCommandEvent);
685wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_VLBOX, wxCommandEvent);
686wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX, wxCommandEvent);
687wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_RCLICKED, wxCommandEvent);
688wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_DROPDOWN, wxCommandEvent);
689wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TOOL_ENTER, wxCommandEvent);
690wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent);
691wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent);
c058cafa 692
cf222762 693 // Thread and asynchronous method call events
c1b293bb 694wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_THREAD, wxThreadEvent);
cf222762 695wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_ASYNC_METHOD_CALL, wxAsyncMethodCallEvent);
d48b06bd 696
c058cafa 697 // Mouse event types
9b11752c
VZ
698wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DOWN, wxMouseEvent);
699wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_UP, wxMouseEvent);
700wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DOWN, wxMouseEvent);
701wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_UP, wxMouseEvent);
702wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DOWN, wxMouseEvent);
703wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_UP, wxMouseEvent);
704wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOTION, wxMouseEvent);
705wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ENTER_WINDOW, wxMouseEvent);
706wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEAVE_WINDOW, wxMouseEvent);
707wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_LEFT_DCLICK, wxMouseEvent);
708wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MIDDLE_DCLICK, wxMouseEvent);
709wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_RIGHT_DCLICK, wxMouseEvent);
710wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_FOCUS, wxFocusEvent);
711wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KILL_FOCUS, wxFocusEvent);
712wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHILD_FOCUS, wxChildFocusEvent);
713wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSEWHEEL, wxMouseEvent);
714wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DOWN, wxMouseEvent);
715wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_UP, wxMouseEvent);
716wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX1_DCLICK, wxMouseEvent);
717wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent);
718wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent);
719wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent);
c058cafa
VZ
720
721 // Character input event type
9b11752c
VZ
722wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent);
723wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR_HOOK, wxKeyEvent);
724wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent);
725wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_DOWN, wxKeyEvent);
726wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent);
5048c832 727#if wxUSE_HOTKEY
9b11752c 728wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent);
5048c832 729#endif
1afe4f9b
VZ
730// This is a private event used by wxMSW code only and subject to change or
731// disappear in the future. Don't use.
732wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AFTER_CHAR, wxKeyEvent);
733
c058cafa 734 // Set cursor event
9b11752c 735wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent);
c058cafa
VZ
736
737 // wxScrollBar and wxSlider event identifiers
9b11752c
VZ
738wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_TOP, wxScrollEvent);
739wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_BOTTOM, wxScrollEvent);
740wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEUP, wxScrollEvent);
741wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_LINEDOWN, wxScrollEvent);
742wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEUP, wxScrollEvent);
743wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_PAGEDOWN, wxScrollEvent);
744wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBTRACK, wxScrollEvent);
745wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_THUMBRELEASE, wxScrollEvent);
746wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLL_CHANGED, wxScrollEvent);
c058cafa 747
dca94103
VZ
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.
754
755#if wxUSE_SPINBTN
756
9b11752c
VZ
757wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent );
758wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent );
759wxDECLARE_EXPORTED_EVENT_ALIAS( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent );
dca94103
VZ
760
761#endif
762
c058cafa 763 // Scroll events from wxWindow
9b11752c
VZ
764wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_TOP, wxScrollWinEvent);
765wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEvent);
766wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEUP, wxScrollWinEvent);
767wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEvent);
768wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEvent);
769wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEvent);
770wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEvent);
771wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEvent);
c058cafa
VZ
772
773 // System events
9b11752c
VZ
774wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZE, wxSizeEvent);
775wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE, wxMoveEvent);
776wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CLOSE_WINDOW, wxCloseEvent);
777wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_END_SESSION, wxCloseEvent);
778wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_END_SESSION, wxCloseEvent);
779wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE_APP, wxActivateEvent);
780wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ACTIVATE, wxActivateEvent);
781wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CREATE, wxWindowCreateEvent);
782wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DESTROY, wxWindowDestroyEvent);
783wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SHOW, wxShowEvent);
784wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ICONIZE, wxIconizeEvent);
785wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAXIMIZE, wxMaximizeEvent);
786wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEvent);
787wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEvent);
788wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PAINT, wxPaintEvent);
789wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_ERASE_BACKGROUND, wxEraseEvent);
790wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_NC_PAINT, wxNcPaintEvent);
791wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_OPEN, wxMenuEvent);
792wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_CLOSE, wxMenuEvent);
793wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MENU_HIGHLIGHT, wxMenuEvent);
794wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CONTEXT_MENU, wxContextMenuEvent);
795wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEvent);
796wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DISPLAY_CHANGED, wxDisplayChangedEvent);
797wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEvent);
798wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_PALETTE_CHANGED, wxPaletteChangedEvent);
799wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_DOWN, wxJoystickEvent);
800wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_BUTTON_UP, wxJoystickEvent);
801wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_MOVE, wxJoystickEvent);
802wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_JOY_ZMOVE, wxJoystickEvent);
803wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DROP_FILES, wxDropFilesEvent);
804wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_INIT_DIALOG, wxInitDialogEvent);
805wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_BASE, wxEVT_IDLE, wxIdleEvent);
806wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_UPDATE_UI, wxUpdateUIEvent);
807wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SIZING, wxSizeEvent);
808wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVING, wxMoveEvent);
809wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_START, wxMoveEvent);
810wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MOVE_END, wxMoveEvent);
811wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HIBERNATE, wxActivateEvent);
c058cafa
VZ
812
813 // Clipboard events
ce7fe42e
VZ
814wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_COPY, wxClipboardTextEvent);
815wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_CUT, wxClipboardTextEvent);
816wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT_PASTE, wxClipboardTextEvent);
c058cafa
VZ
817
818 // Generic command events
819 // Note: a click is a higher-level event than button down/up
9b11752c
VZ
820wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_CLICK, wxCommandEvent);
821wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_LEFT_DCLICK, wxCommandEvent);
822wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEvent);
823wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_RIGHT_DCLICK, wxCommandEvent);
824wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SET_FOCUS, wxCommandEvent);
825wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_KILL_FOCUS, wxCommandEvent);
826wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_ENTER, wxCommandEvent);
c058cafa
VZ
827
828 // Help events
9b11752c
VZ
829wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HELP, wxHelpEvent);
830wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_DETAILED_HELP, wxHelpEvent);
96f6c703 831
cbee8f8d 832// these 2 events are the same
ce7fe42e 833#define wxEVT_TOOL wxEVT_MENU
96f6c703 834
ad0bae85 835// ----------------------------------------------------------------------------
77d4384e 836// Compatibility
ad0bae85
VZ
837// ----------------------------------------------------------------------------
838
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
841//
842// still, any new code using it should include wx/textctrl.h explicitly
ce7fe42e 843wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_TEXT, wxCommandEvent);
c801d85f 844
d48b06bd
FM
845
846// ----------------------------------------------------------------------------
847// wxEvent(-derived) classes
848// ----------------------------------------------------------------------------
849
1648d51b
VZ
850// the predefined constants for the number of times we propagate event
851// upwards window child-parent chain
d48b06bd 852enum wxEventPropagation
1648d51b
VZ
853{
854 // don't propagate it at all
855 wxEVENT_PROPAGATE_NONE = 0,
856
857 // propagate it until it is processed
858 wxEVENT_PROPAGATE_MAX = INT_MAX
859};
860
d48b06bd 861// The different categories for a wxEvent; see wxEvent::GetEventCategory.
dde19c21 862// NOTE: they are used as OR-combinable flags by wxEventLoopBase::YieldFor
d48b06bd
FM
863enum wxEventCategory
864{
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,
871
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,
877
878 // this category is for wxSocketEvent
879 wxEVT_CATEGORY_SOCKET = 4,
880
881 // this category is for wxTimerEvent
882 wxEVT_CATEGORY_TIMER = 8,
883
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,
888
889
890 // implementation only
891
dde19c21 892 // used in the implementations of wxEventLoopBase::YieldFor
d48b06bd
FM
893 wxEVT_CATEGORY_UNKNOWN = 32,
894
dde19c21 895 // a special category used as an argument to wxEventLoopBase::YieldFor to indicate that
d48b06bd
FM
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,
899
900
901 // shortcut masks
902
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,
906
dde19c21 907 // used in wxEventLoopBase::YieldFor to specify all event categories should be processed:
d48b06bd
FM
908 wxEVT_CATEGORY_ALL =
909 wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_SOCKET| \
6547c6ba
FM
910 wxEVT_CATEGORY_TIMER|wxEVT_CATEGORY_THREAD|wxEVT_CATEGORY_UNKNOWN| \
911 wxEVT_CATEGORY_CLIPBOARD
d48b06bd
FM
912};
913
c801d85f 914/*
77ffb593 915 * wxWidgets events, covering all interesting things that might happen
c801d85f
KB
916 * (button clicking, resizing, setting text in widgets, etc.).
917 *
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.
923 *
924 */
925
bddd7a8d 926class WXDLLIMPEXP_BASE wxEvent : public wxObject
c801d85f 927{
c801d85f 928public:
d9e2e4c2 929 wxEvent(int winid = 0, wxEventType commandType = wxEVT_NULL );
2b854a32
VZ
930
931 void SetEventType(wxEventType typ) { m_eventType = typ; }
932 wxEventType GetEventType() const { return m_eventType; }
d48b06bd 933
2b854a32
VZ
934 wxObject *GetEventObject() const { return m_eventObject; }
935 void SetEventObject(wxObject *obj) { m_eventObject = obj; }
d48b06bd 936
2b854a32
VZ
937 long GetTimestamp() const { return m_timeStamp; }
938 void SetTimestamp(long ts = 0) { m_timeStamp = ts; }
d48b06bd 939
2b854a32
VZ
940 int GetId() const { return m_id; }
941 void SetId(int Id) { m_id = Id; }
942
685d0d73
VZ
943 // Returns the user data optionally associated with the event handler when
944 // using Connect() or Bind().
945 wxObject *GetEventUserData() const { return m_callbackUserData; }
946
2b854a32
VZ
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()
a0d9c6cb
WS
950 // is the analog of calling the base class version of a virtual function)
951 void Skip(bool skip = true) { m_skipped = skip; }
47b378bd 952 bool GetSkipped() const { return m_skipped; }
c801d85f 953
29de6f40 954 // This function is used to create a copy of the event polymorphically and
acd15a3f
VZ
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;
a737331d 958
dde19c21 959 // this function is used to selectively process events in wxEventLoopBase::YieldFor
d48b06bd
FM
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; }
964
87b6002d 965 // Implementation only: this test is explicitly anti OO and this function
1648d51b
VZ
966 // exists only for optimization purposes.
967 bool IsCommandEvent() const { return m_isCommandEvent; }
968
969 // Determine if this event should be propagating to the parent window.
970 bool ShouldPropagate() const
971 { return m_propagationLevel != wxEVENT_PROPAGATE_NONE; }
972
973 // Stop an event from propagating to its parent window, returns the old
974 // propagation level value
975 int StopPropagation()
976 {
977 int propagationLevel = m_propagationLevel;
978 m_propagationLevel = wxEVENT_PROPAGATE_NONE;
979 return propagationLevel;
980 }
981
982 // Resume the event propagation by restoring the propagation level
983 // (returned by StopPropagation())
984 void ResumePropagation(int propagationLevel)
985 {
986 m_propagationLevel = propagationLevel;
987 }
988
5ac5e40e
VZ
989 // This method is for internal use only and allows to get the object that
990 // is propagating this event upwards the window hierarchy, if any.
991 wxEvtHandler* GetPropagatedFrom() const { return m_propagatedFrom; }
29de6f40
VZ
992
993 // This is for internal use only and is only called by
994 // wxEvtHandler::ProcessEvent() to check whether it's the first time this
995 // event is being processed
996 bool WasProcessed()
997 {
998 if ( m_wasProcessed )
999 return true;
1000
1001 m_wasProcessed = true;
1002
1003 return false;
1004 }
1005
3bad8c39
VZ
1006 // This is for internal use only and is used for setting, testing and
1007 // resetting of m_willBeProcessedAgain flag.
1008 void SetWillBeProcessedAgain()
1009 {
1010 m_willBeProcessedAgain = true;
1011 }
1012
1013 bool WillBeProcessedAgain()
1014 {
1015 if ( m_willBeProcessedAgain )
1016 {
1017 m_willBeProcessedAgain = false;
1018 return true;
1019 }
1020
1021 return false;
1022 }
1023
3cbb9df8
VZ
1024 // This is also used only internally by ProcessEvent() to check if it
1025 // should process the event normally or only restrict the search for the
1026 // event handler to this object itself.
bbdee10d
VZ
1027 bool ShouldProcessOnlyIn(wxEvtHandler *h) const
1028 {
1029 return h == m_handlerToProcessOnlyIn;
1030 }
1031
1032 // Called to indicate that the result of ShouldProcessOnlyIn() wasn't taken
1033 // into account. The existence of this function may seem counterintuitive
1034 // but unfortunately it's needed by wxScrollHelperEvtHandler, see comments
1035 // there. Don't even think of using this in your own code, this is a gross
1036 // hack and is only needed because of wx complicated history and should
1037 // never be used anywhere else.
1038 void DidntHonourProcessOnlyIn()
1039 {
1040 m_handlerToProcessOnlyIn = NULL;
1041 }
3cbb9df8 1042
b4b76d61 1043protected:
2b854a32 1044 wxObject* m_eventObject;
2b854a32
VZ
1045 wxEventType m_eventType;
1046 long m_timeStamp;
1047 int m_id;
b4b76d61
KH
1048
1049public:
1050 // m_callbackUserData is for internal usage only
2b854a32 1051 wxObject* m_callbackUserData;
1648d51b 1052
bbdee10d
VZ
1053private:
1054 // If this handler
1055 wxEvtHandler *m_handlerToProcessOnlyIn;
1056
1648d51b
VZ
1057protected:
1058 // the propagation level: while it is positive, we propagate the event to
1059 // the parent window (if any)
1648d51b
VZ
1060 int m_propagationLevel;
1061
5ac5e40e
VZ
1062 // The object that the event is being propagated from, initially NULL and
1063 // only set by wxPropagateOnce.
1064 wxEvtHandler* m_propagatedFrom;
1065
42e69d6b 1066 bool m_skipped;
193bf013 1067 bool m_isCommandEvent;
1c624631 1068
29de6f40
VZ
1069 // initially false but becomes true as soon as WasProcessed() is called for
1070 // the first time, as this is done only by ProcessEvent() it explains the
1071 // variable name: it becomes true after ProcessEvent() was called at least
1072 // once for this event
1073 bool m_wasProcessed;
1074
3bad8c39
VZ
1075 // This one is initially false too, but can be set to true to indicate that
1076 // the event will be passed to another handler if it's not processed in
1077 // this one.
1078 bool m_willBeProcessedAgain;
1079
0e097789
VZ
1080protected:
1081 wxEvent(const wxEvent&); // for implementing Clone()
1082 wxEvent& operator=(const wxEvent&); // for derived classes operator=()
1083
8e72b8b5 1084private:
5ac5e40e 1085 // It needs to access our m_propagationLevel and m_propagatedFrom fields.
b5dbe15d 1086 friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce;
1648d51b 1087
bbdee10d
VZ
1088 // and this one needs to access our m_handlerToProcessOnlyIn
1089 friend class WXDLLIMPEXP_FWD_BASE wxEventProcessInHandlerOnly;
3cbb9df8
VZ
1090
1091
8e72b8b5 1092 DECLARE_ABSTRACT_CLASS(wxEvent)
c801d85f
KB
1093};
1094
1648d51b
VZ
1095/*
1096 * Helper class to temporarily change an event not to propagate.
1097 */
1098class WXDLLIMPEXP_BASE wxPropagationDisabler
1099{
1100public:
1101 wxPropagationDisabler(wxEvent& event) : m_event(event)
1102 {
1103 m_propagationLevelOld = m_event.StopPropagation();
1104 }
1105
1106 ~wxPropagationDisabler()
1107 {
1108 m_event.ResumePropagation(m_propagationLevelOld);
1109 }
1110
1111private:
1112 wxEvent& m_event;
1113 int m_propagationLevelOld;
fc7a2a60 1114
c0c133e1 1115 wxDECLARE_NO_COPY_CLASS(wxPropagationDisabler);
1648d51b
VZ
1116};
1117
1118/*
5ac5e40e
VZ
1119 * Helper used to indicate that an event is propagated upwards the window
1120 * hierarchy by the given window.
1648d51b
VZ
1121 */
1122class WXDLLIMPEXP_BASE wxPropagateOnce
1123{
1124public:
5ac5e40e
VZ
1125 // The handler argument should normally be non-NULL to allow the parent
1126 // event handler to know that it's being used to process an event coming
1127 // from the child, it's only NULL by default for backwards compatibility.
1128 wxPropagateOnce(wxEvent& event, wxEvtHandler* handler = NULL)
1129 : m_event(event),
1130 m_propagatedFromOld(event.m_propagatedFrom)
1648d51b
VZ
1131 {
1132 wxASSERT_MSG( m_event.m_propagationLevel > 0,
9a83f860 1133 wxT("shouldn't be used unless ShouldPropagate()!") );
1648d51b
VZ
1134
1135 m_event.m_propagationLevel--;
5ac5e40e 1136 m_event.m_propagatedFrom = handler;
1648d51b
VZ
1137 }
1138
1139 ~wxPropagateOnce()
1140 {
5ac5e40e 1141 m_event.m_propagatedFrom = m_propagatedFromOld;
1648d51b
VZ
1142 m_event.m_propagationLevel++;
1143 }
1144
1145private:
1146 wxEvent& m_event;
5ac5e40e 1147 wxEvtHandler* const m_propagatedFromOld;
fc7a2a60 1148
c0c133e1 1149 wxDECLARE_NO_COPY_CLASS(wxPropagateOnce);
1648d51b
VZ
1150};
1151
bbdee10d
VZ
1152// A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn()
1153// return true for the handler passed to its ctor.
1154class wxEventProcessInHandlerOnly
3cbb9df8
VZ
1155{
1156public:
bbdee10d
VZ
1157 wxEventProcessInHandlerOnly(wxEvent& event, wxEvtHandler *handler)
1158 : m_event(event),
1159 m_handlerToProcessOnlyInOld(event.m_handlerToProcessOnlyIn)
3cbb9df8 1160 {
bbdee10d 1161 m_event.m_handlerToProcessOnlyIn = handler;
3cbb9df8
VZ
1162 }
1163
bbdee10d 1164 ~wxEventProcessInHandlerOnly()
3cbb9df8 1165 {
bbdee10d 1166 m_event.m_handlerToProcessOnlyIn = m_handlerToProcessOnlyInOld;
3cbb9df8
VZ
1167 }
1168
1169private:
1170 wxEvent& m_event;
bbdee10d 1171 wxEvtHandler * const m_handlerToProcessOnlyInOld;
3cbb9df8 1172
bbdee10d 1173 wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly);
3cbb9df8 1174};
c4fa5aa7 1175
c1b293bb
VS
1176
1177class WXDLLIMPEXP_BASE wxEventBasicPayloadMixin
1178{
1179public:
1180 wxEventBasicPayloadMixin()
1181 : m_commandInt(0),
1182 m_extraLong(0)
1183 {
1184 }
1185
1186 void SetString(const wxString& s) { m_cmdString = s; }
1187 const wxString& GetString() const { return m_cmdString; }
1188
1189 void SetInt(int i) { m_commandInt = i; }
1190 int GetInt() const { return m_commandInt; }
1191
1192 void SetExtraLong(long extraLong) { m_extraLong = extraLong; }
1193 long GetExtraLong() const { return m_extraLong; }
1194
1195protected:
1196 // Note: these variables have "cmd" or "command" in their name for backward compatibility:
1197 // they used to be part of wxCommandEvent, not this mixin.
1198 wxString m_cmdString; // String event argument
1199 int m_commandInt;
1200 long m_extraLong; // Additional information (e.g. select/deselect)
1201
1202 wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin);
1203};
1204
1205class WXDLLIMPEXP_BASE wxEventAnyPayloadMixin : public wxEventBasicPayloadMixin
1206{
1207public:
1208 wxEventAnyPayloadMixin() : wxEventBasicPayloadMixin() {}
1209
1210#if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
1211 template<typename T>
1212 void SetPayload(const T& payload)
1213 {
1214 m_payload = payload;
1215 }
1216
1217 template<typename T>
1218 T GetPayload() const
1219 {
1220 return m_payload.As<T>();
1221 }
1222
1223protected:
1224 wxAny m_payload;
1225#endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7))
1226
1227 wxDECLARE_NO_ASSIGN_CLASS(wxEventBasicPayloadMixin);
1228};
1229
1230
1231// Idle event
1232/*
1233 wxEVT_IDLE
1234 */
1235
1236// Whether to always send idle events to windows, or
1237// to only send update events to those with the
1238// wxWS_EX_PROCESS_IDLE style.
1239
1240enum wxIdleMode
1241{
1242 // Send idle events to all windows
1243 wxIDLE_PROCESS_ALL,
1244
1245 // Send idle events to windows that have
1246 // the wxWS_EX_PROCESS_IDLE flag specified
1247 wxIDLE_PROCESS_SPECIFIED
1248};
1249
1250class WXDLLIMPEXP_BASE wxIdleEvent : public wxEvent
1251{
1252public:
1253 wxIdleEvent()
1254 : wxEvent(0, wxEVT_IDLE),
1255 m_requestMore(false)
1256 { }
1257 wxIdleEvent(const wxIdleEvent& event)
1258 : wxEvent(event),
1259 m_requestMore(event.m_requestMore)
1260 { }
1261
1262 void RequestMore(bool needMore = true) { m_requestMore = needMore; }
1263 bool MoreRequested() const { return m_requestMore; }
1264
1265 virtual wxEvent *Clone() const { return new wxIdleEvent(*this); }
1266
1267 // Specify how wxWidgets will send idle events: to
1268 // all windows, or only to those which specify that they
1269 // will process the events.
1270 static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
1271
1272 // Returns the idle event mode
1273 static wxIdleMode GetMode() { return sm_idleMode; }
1274
1275protected:
1276 bool m_requestMore;
1277 static wxIdleMode sm_idleMode;
1278
1279private:
1280 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIdleEvent)
1281};
1282
1283
1284// Thread event
1285
1286class WXDLLIMPEXP_BASE wxThreadEvent : public wxEvent,
1287 public wxEventAnyPayloadMixin
1288{
1289public:
1290 wxThreadEvent(wxEventType eventType = wxEVT_THREAD, int id = wxID_ANY)
1291 : wxEvent(id, eventType)
1292 { }
1293
1294 wxThreadEvent(const wxThreadEvent& event)
1295 : wxEvent(event),
1296 wxEventAnyPayloadMixin(event)
1297 {
1298 // make sure our string member (which uses COW, aka refcounting) is not
1299 // shared by other wxString instances:
9bd5c5fc 1300 SetString(GetString().Clone());
c1b293bb
VS
1301 }
1302
1303 virtual wxEvent *Clone() const
1304 {
1305 return new wxThreadEvent(*this);
1306 }
1307
1308 // this is important to avoid that calling wxEventLoopBase::YieldFor thread events
1309 // gets processed when this is unwanted:
1310 virtual wxEventCategory GetEventCategory() const
1311 { return wxEVT_CATEGORY_THREAD; }
1312
1313private:
1314 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThreadEvent)
1315};
1316
1317
cf222762
VZ
1318// Asynchronous method call events: these event are processed by wxEvtHandler
1319// itself and result in a call to its Execute() method which simply calls the
1320// specified method. The difference with a simple method call is that this is
1321// done asynchronously, i.e. at some later time, instead of immediately when
1322// the event object is constructed.
1323
8f6bb260
VZ
1324#ifdef wxHAS_CALL_AFTER
1325
cf222762
VZ
1326// This is a base class used to process all method calls.
1327class wxAsyncMethodCallEvent : public wxEvent
1328{
1329public:
1330 wxAsyncMethodCallEvent(wxObject* object)
1331 : wxEvent(wxID_ANY, wxEVT_ASYNC_METHOD_CALL)
1332 {
1333 SetEventObject(object);
1334 }
1335
1336 wxAsyncMethodCallEvent(const wxAsyncMethodCallEvent& other)
1337 : wxEvent(other)
1338 {
1339 }
1340
1341 virtual void Execute() = 0;
1342};
1343
1344// This is a version for calling methods without parameters.
1345template <typename T>
1346class wxAsyncMethodCallEvent0 : public wxAsyncMethodCallEvent
1347{
1348public:
1349 typedef T ObjectType;
1350 typedef void (ObjectType::*MethodType)();
1351
1352 wxAsyncMethodCallEvent0(ObjectType* object,
1353 MethodType method)
1354 : wxAsyncMethodCallEvent(object),
1355 m_object(object),
1356 m_method(method)
1357 {
1358 }
1359
1360 wxAsyncMethodCallEvent0(const wxAsyncMethodCallEvent0& other)
1361 : wxAsyncMethodCallEvent(other),
1362 m_object(other.m_object),
1363 m_method(other.m_method)
1364 {
1365 }
1366
1367 virtual wxEvent *Clone() const
1368 {
1369 return new wxAsyncMethodCallEvent0(*this);
1370 }
1371
1372 virtual void Execute()
1373 {
1374 (m_object->*m_method)();
1375 }
1376
1377private:
1378 ObjectType* const m_object;
1379 const MethodType m_method;
1380};
1381
1382// This is a version for calling methods with a single parameter.
1383template <typename T, typename T1>
1384class wxAsyncMethodCallEvent1 : public wxAsyncMethodCallEvent
1385{
1386public:
1387 typedef T ObjectType;
1388 typedef void (ObjectType::*MethodType)(T1 x1);
1389 typedef typename wxRemoveRef<T1>::type ParamType1;
1390
1391 wxAsyncMethodCallEvent1(ObjectType* object,
1392 MethodType method,
1393 const ParamType1& x1)
1394 : wxAsyncMethodCallEvent(object),
1395 m_object(object),
1396 m_method(method),
1397 m_param1(x1)
1398 {
1399 }
1400
1401 wxAsyncMethodCallEvent1(const wxAsyncMethodCallEvent1& other)
1402 : wxAsyncMethodCallEvent(other),
1403 m_object(other.m_object),
1404 m_method(other.m_method),
1405 m_param1(other.m_param1)
1406 {
1407 }
1408
1409 virtual wxEvent *Clone() const
1410 {
1411 return new wxAsyncMethodCallEvent1(*this);
1412 }
1413
1414 virtual void Execute()
1415 {
1416 (m_object->*m_method)(m_param1);
1417 }
1418
1419private:
1420 ObjectType* const m_object;
1421 const MethodType m_method;
1422 const ParamType1 m_param1;
1423};
1424
1425// This is a version for calling methods with two parameters.
1426template <typename T, typename T1, typename T2>
1427class wxAsyncMethodCallEvent2 : public wxAsyncMethodCallEvent
1428{
1429public:
1430 typedef T ObjectType;
1431 typedef void (ObjectType::*MethodType)(T1 x1, T2 x2);
1432 typedef typename wxRemoveRef<T1>::type ParamType1;
1433 typedef typename wxRemoveRef<T2>::type ParamType2;
1434
1435 wxAsyncMethodCallEvent2(ObjectType* object,
1436 MethodType method,
1437 const ParamType1& x1,
1438 const ParamType2& x2)
1439 : wxAsyncMethodCallEvent(object),
1440 m_object(object),
1441 m_method(method),
1442 m_param1(x1),
1443 m_param2(x2)
1444 {
1445 }
1446
1447 wxAsyncMethodCallEvent2(const wxAsyncMethodCallEvent2& other)
1448 : wxAsyncMethodCallEvent(other),
1449 m_object(other.m_object),
1450 m_method(other.m_method),
1451 m_param1(other.m_param1),
1452 m_param2(other.m_param2)
1453 {
1454 }
1455
1456 virtual wxEvent *Clone() const
1457 {
1458 return new wxAsyncMethodCallEvent2(*this);
1459 }
1460
1461 virtual void Execute()
1462 {
1463 (m_object->*m_method)(m_param1, m_param2);
1464 }
1465
1466private:
1467 ObjectType* const m_object;
1468 const MethodType m_method;
1469 const ParamType1 m_param1;
1470 const ParamType2 m_param2;
1471};
1472
cbc8576a
VS
1473// This is a version for calling any functors
1474template <typename T>
1475class wxAsyncMethodCallEventFunctor : public wxAsyncMethodCallEvent
1476{
1477public:
1478 typedef T FunctorType;
1479
1480 wxAsyncMethodCallEventFunctor(wxObject *object, const FunctorType& fn)
1481 : wxAsyncMethodCallEvent(object),
1482 m_fn(fn)
1483 {
1484 }
1485
1486 wxAsyncMethodCallEventFunctor(const wxAsyncMethodCallEventFunctor& other)
1487 : wxAsyncMethodCallEvent(other),
1488 m_fn(other.m_fn)
1489 {
1490 }
1491
1492 virtual wxEvent *Clone() const
1493 {
1494 return new wxAsyncMethodCallEventFunctor(*this);
1495 }
1496
1497 virtual void Execute()
1498 {
1499 m_fn();
1500 }
1501
1502private:
1503 FunctorType m_fn;
1504};
1505
8f6bb260
VZ
1506#endif // wxHAS_CALL_AFTER
1507
1508
e90c1d2a
VZ
1509#if wxUSE_GUI
1510
1648d51b 1511
c801d85f
KB
1512// Item or menu event class
1513/*
ce7fe42e
VZ
1514 wxEVT_BUTTON
1515 wxEVT_CHECKBOX
1516 wxEVT_CHOICE
1517 wxEVT_LISTBOX
1518 wxEVT_LISTBOX_DCLICK
1519 wxEVT_TEXT
1520 wxEVT_TEXT_ENTER
1521 wxEVT_MENU
1522 wxEVT_SLIDER
1523 wxEVT_RADIOBOX
1524 wxEVT_RADIOBUTTON
1525 wxEVT_SCROLLBAR
1526 wxEVT_VLBOX
1527 wxEVT_COMBOBOX
1528 wxEVT_TOGGLEBUTTON
c801d85f
KB
1529*/
1530
c1b293bb
VS
1531class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent,
1532 public wxEventBasicPayloadMixin
c801d85f 1533{
2b854a32 1534public:
d9e2e4c2 1535 wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
c801d85f 1536
e6a6feba 1537 wxCommandEvent(const wxCommandEvent& event)
497dbbd3 1538 : wxEvent(event),
c1b293bb 1539 wxEventBasicPayloadMixin(event),
497dbbd3
VZ
1540 m_clientData(event.m_clientData),
1541 m_clientObject(event.m_clientObject)
34af6cfc
VZ
1542 {
1543 // Because GetString() can retrieve the string text only on demand, we
1544 // need to copy it explicitly.
1545 if ( m_cmdString.empty() )
1546 m_cmdString = event.GetString();
1547 }
e6a6feba 1548
2b854a32
VZ
1549 // Set/Get client data from controls
1550 void SetClientData(void* clientData) { m_clientData = clientData; }
1551 void *GetClientData() const { return m_clientData; }
c801d85f 1552
2b854a32
VZ
1553 // Set/Get client object from controls
1554 void SetClientObject(wxClientData* clientObject) { m_clientObject = clientObject; }
88eadcf2 1555 wxClientData *GetClientObject() const { return m_clientObject; }
f5e27805 1556
c1b293bb
VS
1557 // Note: this shadows wxEventBasicPayloadMixin::GetString(), because it does some
1558 // GUI-specific hacks
1559 wxString GetString() const;
1560
2b854a32
VZ
1561 // Get listbox selection if single-choice
1562 int GetSelection() const { return m_commandInt; }
c801d85f 1563
2b854a32 1564 // Get checkbox value
3ca6a5f0 1565 bool IsChecked() const { return m_commandInt != 0; }
c801d85f 1566
a0d9c6cb 1567 // true if the listbox event was a selection.
2b854a32 1568 bool IsSelection() const { return (m_extraLong != 0); }
c801d85f 1569
8e72b8b5 1570 virtual wxEvent *Clone() const { return new wxCommandEvent(*this); }
d48b06bd 1571 virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
aadbdf11 1572
b4b76d61 1573protected:
2b854a32
VZ
1574 void* m_clientData; // Arbitrary client data
1575 wxClientData* m_clientObject; // Arbitrary client object
f97500b8 1576
8e72b8b5 1577private:
fc7a2a60 1578 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent)
c801d85f
KB
1579};
1580
fd3f686c
VZ
1581// this class adds a possibility to react (from the user) code to a control
1582// notification: allow or veto the operation being reported.
bddd7a8d 1583class WXDLLIMPEXP_CORE wxNotifyEvent : public wxCommandEvent
fd3f686c
VZ
1584{
1585public:
d9e2e4c2
DE
1586 wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
1587 : wxCommandEvent(commandType, winid)
a0d9c6cb 1588 { m_bAllow = true; }
e6a6feba
GD
1589
1590 wxNotifyEvent(const wxNotifyEvent& event)
1591 : wxCommandEvent(event)
497dbbd3 1592 { m_bAllow = event.m_bAllow; }
fd3f686c 1593
23f681ec 1594 // veto the operation (usually it's allowed by default)
a0d9c6cb 1595 void Veto() { m_bAllow = false; }
fd3f686c 1596
23f681ec 1597 // allow the operation if it was disabled by default
a0d9c6cb 1598 void Allow() { m_bAllow = true; }
23f681ec 1599
fd3f686c
VZ
1600 // for implementation code only: is the operation allowed?
1601 bool IsAllowed() const { return m_bAllow; }
1602
8e72b8b5 1603 virtual wxEvent *Clone() const { return new wxNotifyEvent(*this); }
924ef850 1604
fd3f686c
VZ
1605private:
1606 bool m_bAllow;
1607
8e72b8b5 1608private:
fc7a2a60 1609 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotifyEvent)
fd3f686c
VZ
1610};
1611
d48b06bd 1612
d1367c3d 1613// Scroll event class, derived form wxCommandEvent. wxScrollEvents are
e8b669d3 1614// sent by wxSlider and wxScrollBar.
c801d85f
KB
1615/*
1616 wxEVT_SCROLL_TOP
1617 wxEVT_SCROLL_BOTTOM
1618 wxEVT_SCROLL_LINEUP
1619 wxEVT_SCROLL_LINEDOWN
1620 wxEVT_SCROLL_PAGEUP
1621 wxEVT_SCROLL_PAGEDOWN
1622 wxEVT_SCROLL_THUMBTRACK
7d56fb8f 1623 wxEVT_SCROLL_THUMBRELEASE
cbc85508 1624 wxEVT_SCROLL_CHANGED
c801d85f
KB
1625*/
1626
bddd7a8d 1627class WXDLLIMPEXP_CORE wxScrollEvent : public wxCommandEvent
c801d85f 1628{
2b854a32
VZ
1629public:
1630 wxScrollEvent(wxEventType commandType = wxEVT_NULL,
d9e2e4c2 1631 int winid = 0, int pos = 0, int orient = 0);
2b854a32 1632
a7bc03c9
VZ
1633 int GetOrientation() const { return (int) m_extraLong; }
1634 int GetPosition() const { return m_commandInt; }
2b854a32
VZ
1635 void SetOrientation(int orient) { m_extraLong = (long) orient; }
1636 void SetPosition(int pos) { m_commandInt = pos; }
f97500b8 1637
8e72b8b5 1638 virtual wxEvent *Clone() const { return new wxScrollEvent(*this); }
f97500b8 1639
8e72b8b5 1640private:
fc7a2a60 1641 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollEvent)
c801d85f
KB
1642};
1643
d1367c3d
RR
1644// ScrollWin event class, derived fom wxEvent. wxScrollWinEvents
1645// are sent by wxWindow.
1646/*
1647 wxEVT_SCROLLWIN_TOP
1648 wxEVT_SCROLLWIN_BOTTOM
1649 wxEVT_SCROLLWIN_LINEUP
1650 wxEVT_SCROLLWIN_LINEDOWN
1651 wxEVT_SCROLLWIN_PAGEUP
1652 wxEVT_SCROLLWIN_PAGEDOWN
1653 wxEVT_SCROLLWIN_THUMBTRACK
7d56fb8f 1654 wxEVT_SCROLLWIN_THUMBRELEASE
d1367c3d
RR
1655*/
1656
bddd7a8d 1657class WXDLLIMPEXP_CORE wxScrollWinEvent : public wxEvent
d1367c3d 1658{
d1367c3d
RR
1659public:
1660 wxScrollWinEvent(wxEventType commandType = wxEVT_NULL,
1661 int pos = 0, int orient = 0);
f3ff831f 1662 wxScrollWinEvent(const wxScrollWinEvent& event) : wxEvent(event)
b2697d42
VZ
1663 { m_commandInt = event.m_commandInt;
1664 m_extraLong = event.m_extraLong; }
d1367c3d 1665
a7bc03c9
VZ
1666 int GetOrientation() const { return (int) m_extraLong; }
1667 int GetPosition() const { return m_commandInt; }
d1367c3d
RR
1668 void SetOrientation(int orient) { m_extraLong = (long) orient; }
1669 void SetPosition(int pos) { m_commandInt = pos; }
1670
8e72b8b5 1671 virtual wxEvent *Clone() const { return new wxScrollWinEvent(*this); }
1e6feb95 1672
b4b76d61 1673protected:
8e72b8b5 1674 int m_commandInt;
20947e08 1675 long m_extraLong;
1e6feb95 1676
8e72b8b5 1677private:
fc7a2a60 1678 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent)
d1367c3d
RR
1679};
1680
d48b06bd
FM
1681
1682
c801d85f
KB
1683// Mouse event class
1684
1685/*
1686 wxEVT_LEFT_DOWN
1687 wxEVT_LEFT_UP
1688 wxEVT_MIDDLE_DOWN
1689 wxEVT_MIDDLE_UP
1690 wxEVT_RIGHT_DOWN
1691 wxEVT_RIGHT_UP
1692 wxEVT_MOTION
1693 wxEVT_ENTER_WINDOW
1694 wxEVT_LEAVE_WINDOW
1695 wxEVT_LEFT_DCLICK
1696 wxEVT_MIDDLE_DCLICK
1697 wxEVT_RIGHT_DCLICK
c801d85f
KB
1698*/
1699
41469c9e
VZ
1700enum wxMouseWheelAxis
1701{
1702 wxMOUSE_WHEEL_VERTICAL,
1703 wxMOUSE_WHEEL_HORIZONTAL
1704};
1705
0e097789
VZ
1706class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent,
1707 public wxMouseState
c801d85f 1708{
2b854a32
VZ
1709public:
1710 wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
0e097789
VZ
1711 wxMouseEvent(const wxMouseEvent& event)
1712 : wxEvent(event),
1713 wxMouseState(event)
1714 {
1715 Assign(event);
1716 }
c801d85f 1717
2b854a32 1718 // Was it a button event? (*doesn't* mean: is any button *down*?)
497dbbd3 1719 bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
c801d85f 1720
3e89999c 1721 // Was it a down event from this (or any) button?
497dbbd3 1722 bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
c801d85f 1723
3e89999c 1724 // Was it a dclick event from this (or any) button?
497dbbd3 1725 bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
c801d85f 1726
3e89999c 1727 // Was it a up event from this (or any) button?
497dbbd3 1728 bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
c801d85f 1729
ab826fd8 1730 // Was this event generated by the given button?
2b854a32 1731 bool Button(int but) const;
c801d85f 1732
497dbbd3 1733 // Get the button which is changing state (wxMOUSE_BTN_NONE if none)
1e6feb95
VZ
1734 int GetButton() const;
1735
2b854a32
VZ
1736 // Find which event was just generated
1737 bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); }
1738 bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); }
1739 bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); }
01101e2d
VZ
1740 bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); }
1741 bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); }
c801d85f 1742
2b854a32
VZ
1743 bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); }
1744 bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); }
1745 bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); }
01101e2d
VZ
1746 bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); }
1747 bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); }
c801d85f 1748
2b854a32
VZ
1749 bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); }
1750 bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); }
1751 bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); }
4e32015c
VZ
1752 bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); }
1753 bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
c801d85f 1754
2b854a32
VZ
1755 // True if a button is down and the mouse is moving
1756 bool Dragging() const
1757 {
5b66d31a 1758 return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY);
2b854a32 1759 }
c801d85f 1760
2b854a32 1761 // True if the mouse is moving, and no button is down
6f63704f
VZ
1762 bool Moving() const
1763 {
5b66d31a 1764 return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY);
6f63704f 1765 }
c801d85f 1766
2b854a32
VZ
1767 // True if the mouse is just entering the window
1768 bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); }
c801d85f 1769
2b854a32
VZ
1770 // True if the mouse is just leaving the window
1771 bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
c801d85f 1772
8866abbb
VZ
1773 // Returns the number of mouse clicks associated with this event.
1774 int GetClickCount() const { return m_clickCount; }
1775
2b854a32 1776 // Find the logical position of the event given the DC
a7bc03c9 1777 wxPoint GetLogicalPosition(const wxDC& dc) const;
c801d85f 1778
d2c52078
RD
1779 // Get wheel rotation, positive or negative indicates direction of
1780 // rotation. Current devices all send an event when rotation is equal to
1781 // +/-WheelDelta, but this allows for finer resolution devices to be
1782 // created in the future. Because of this you shouldn't assume that one
1783 // event is equal to 1 line or whatever, but you should be able to either
1784 // do partial line scrolling or wait until +/-WheelDelta rotation values
1785 // have been accumulated before scrolling.
1786 int GetWheelRotation() const { return m_wheelRotation; }
1787
1788 // Get wheel delta, normally 120. This is the threshold for action to be
1789 // taken, and one such action (for example, scrolling one increment)
1790 // should occur for each delta.
1791 int GetWheelDelta() const { return m_wheelDelta; }
1792
41469c9e
VZ
1793 // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL
1794 // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling
1795 // using e.g. a trackpad).
1796 wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; }
aea37008 1797
d2c52078 1798 // Returns the configured number of lines (or whatever) to be scrolled per
5833988c 1799 // wheel action. Defaults to three.
d2c52078 1800 int GetLinesPerAction() const { return m_linesPerAction; }
aa767a45 1801
5833988c
VZ
1802 // Returns the configured number of columns (or whatever) to be scrolled per
1803 // wheel action. Defaults to three.
1804 int GetColumnsPerAction() const { return m_columnsPerAction; }
1805
9b9337da 1806 // Is the system set to do page scrolling?
c2bbeff0 1807 bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
9b9337da 1808
8e72b8b5 1809 virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
d48b06bd 1810 virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
aadbdf11 1811
0e097789
VZ
1812 wxMouseEvent& operator=(const wxMouseEvent& event)
1813 {
1814 if (&event != this)
1815 Assign(event);
1816 return *this;
1817 }
c7d176e2 1818
c801d85f 1819public:
8866abbb
VZ
1820 int m_clickCount;
1821
41469c9e 1822 wxMouseWheelAxis m_wheelAxis;
d2c52078
RD
1823 int m_wheelRotation;
1824 int m_wheelDelta;
1825 int m_linesPerAction;
5833988c 1826 int m_columnsPerAction;
1e6feb95 1827
abcbaea7
VZ
1828protected:
1829 void Assign(const wxMouseEvent& evt);
1830
1e6feb95
VZ
1831private:
1832 DECLARE_DYNAMIC_CLASS(wxMouseEvent)
c801d85f
KB
1833};
1834
43b5058d
VZ
1835// Cursor set event
1836
1837/*
1838 wxEVT_SET_CURSOR
1839 */
1840
bddd7a8d 1841class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent
43b5058d
VZ
1842{
1843public:
8e72b8b5 1844 wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0)
497dbbd3
VZ
1845 : wxEvent(0, wxEVT_SET_CURSOR),
1846 m_x(x), m_y(y), m_cursor()
e6a6feba 1847 { }
43b5058d 1848
f3ff831f 1849 wxSetCursorEvent(const wxSetCursorEvent& event)
b2697d42
VZ
1850 : wxEvent(event),
1851 m_x(event.m_x),
1852 m_y(event.m_y),
1853 m_cursor(event.m_cursor)
1854 { }
1d2eddff 1855
43b5058d
VZ
1856 wxCoord GetX() const { return m_x; }
1857 wxCoord GetY() const { return m_y; }
1858
1859 void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
1860 const wxCursor& GetCursor() const { return m_cursor; }
a1b806b9 1861 bool HasCursor() const { return m_cursor.IsOk(); }
43b5058d 1862
8e72b8b5 1863 virtual wxEvent *Clone() const { return new wxSetCursorEvent(*this); }
f97500b8 1864
43b5058d
VZ
1865private:
1866 wxCoord m_x, m_y;
1867 wxCursor m_cursor;
f97500b8 1868
8e72b8b5 1869private:
fc7a2a60 1870 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent)
43b5058d
VZ
1871};
1872
c801d85f
KB
1873// Keyboard input event class
1874
1875/*
1876 wxEVT_CHAR
1877 wxEVT_CHAR_HOOK
4ce81a75 1878 wxEVT_KEY_DOWN
c801d85f 1879 wxEVT_KEY_UP
5048c832 1880 wxEVT_HOTKEY
c801d85f
KB
1881 */
1882
7a34307e
VZ
1883// key categories: the bit flags for IsKeyInCategory() function
1884//
1885// the enum values used may change in future version of wx
1886// use the named constants only, or bitwise combinations thereof
1887enum wxKeyCategoryFlags
1888{
1889 // arrow keys, on and off numeric keypads
1890 WXK_CATEGORY_ARROW = 1,
1891
1892 // page up and page down keys, on and off numeric keypads
1893 WXK_CATEGORY_PAGING = 2,
1894
1895 // home and end keys, on and off numeric keypads
1896 WXK_CATEGORY_JUMP = 4,
1897
4f742042 1898 // tab key, on and off numeric keypads
7a34307e
VZ
1899 WXK_CATEGORY_TAB = 8,
1900
1901 // backspace and delete keys, on and off numeric keypads
1902 WXK_CATEGORY_CUT = 16,
1903
1904 // all keys usually used for navigation
1905 WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW |
1906 WXK_CATEGORY_PAGING |
1907 WXK_CATEGORY_JUMP
1908};
1909
0e097789
VZ
1910class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent,
1911 public wxKeyboardState
c801d85f 1912{
c801d85f 1913public:
2b854a32 1914 wxKeyEvent(wxEventType keyType = wxEVT_NULL);
e45d9090
VZ
1915
1916 // Normal copy ctor and a ctor creating a new event for the same key as the
1917 // given one but a different event type (this is used in implementation
1918 // code only, do not use outside of the library).
b2697d42 1919 wxKeyEvent(const wxKeyEvent& evt);
e45d9090 1920 wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt);
c801d85f 1921
f6bcfd97
BP
1922 // get the key code: an ASCII7 char or an element of wxKeyCode enum
1923 int GetKeyCode() const { return (int)m_keyCode; }
c801d85f 1924
7a34307e
VZ
1925 // returns true iff this event's key code is of a certain type
1926 bool IsKeyInCategory(int category) const;
1927
a3db5254
VZ
1928#if wxUSE_UNICODE
1929 // get the Unicode character corresponding to this key
1930 wxChar GetUnicodeKey() const { return m_uniChar; }
1931#endif // wxUSE_UNICODE
1932
9c7df356
VZ
1933 // get the raw key code (platform-dependent)
1934 wxUint32 GetRawKeyCode() const { return m_rawCode; }
1935
1936 // get the raw key flags (platform-dependent)
1937 wxUint32 GetRawKeyFlags() const { return m_rawFlags; }
1938
2b854a32 1939 // Find the position of the event
b02da6b1
VZ
1940 void GetPosition(wxCoord *xpos, wxCoord *ypos) const
1941 {
e0e6f3dc
VZ
1942 if (xpos)
1943 *xpos = GetX();
1944 if (ypos)
1945 *ypos = GetY();
b02da6b1
VZ
1946 }
1947
e0e6f3dc 1948 // This version if provided only for backwards compatiblity, don't use.
bf57d1ad 1949 void GetPosition(long *xpos, long *ypos) const
b02da6b1 1950 {
e0e6f3dc
VZ
1951 if (xpos)
1952 *xpos = GetX();
1953 if (ypos)
1954 *ypos = GetY();
b02da6b1 1955 }
803ef874
JS
1956
1957 wxPoint GetPosition() const
e0e6f3dc 1958 { return wxPoint(GetX(), GetY()); }
c801d85f 1959
2b854a32 1960 // Get X position
2f7baaec 1961 wxCoord GetX() const;
c801d85f 1962
2b854a32 1963 // Get Y position
2f7baaec 1964 wxCoord GetY() const;
c801d85f 1965
4cf1a9bf
VZ
1966 // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
1967 // key events even though the event had been handled (by default they would
1968 // not be generated in this case).
1969 void DoAllowNextEvent() { m_allowNext = true; }
1970
1971 // Return the value of the "allow next" flag, for internal use only.
1972 bool IsNextEventAllowed() const { return m_allowNext; }
1973
1974
8e72b8b5 1975 virtual wxEvent *Clone() const { return new wxKeyEvent(*this); }
d48b06bd 1976 virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
f97500b8
VZ
1977
1978 // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
1979 // example)
1980 wxKeyEvent& operator=(const wxKeyEvent& evt)
1981 {
3232da9d 1982 if ( &evt != this )
162e998c 1983 {
0e097789 1984 wxEvent::operator=(evt);
3232da9d
VZ
1985
1986 // Borland C++ 5.82 doesn't compile an explicit call to an
1987 // implicitly defined operator=() so need to do it this way:
1988 *static_cast<wxKeyboardState *>(this) = evt;
0e097789 1989
dfc7216d 1990 DoAssignMembers(evt);
162e998c 1991 }
f97500b8
VZ
1992 return *this;
1993 }
1994
2b854a32 1995public:
e0e6f3dc
VZ
1996 // Do not use these fields directly, they are initialized on demand, so
1997 // call GetX() and GetY() or GetPosition() instead.
b02da6b1
VZ
1998 wxCoord m_x, m_y;
1999
2b854a32 2000 long m_keyCode;
b02da6b1 2001
2b5f62a0
VZ
2002#if wxUSE_UNICODE
2003 // This contains the full Unicode character
2004 // in a character events in Unicode mode
2005 wxChar m_uniChar;
2006#endif
2007
2008 // these fields contain the platform-specific information about
2009 // key that was pressed
9c7df356
VZ
2010 wxUint32 m_rawCode;
2011 wxUint32 m_rawFlags;
2012
8e72b8b5 2013private:
3a95f73c
VZ
2014 // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK
2015 // type. This is used by all ctors.
2016 void InitPropagation()
2017 {
2018 if ( m_eventType == wxEVT_CHAR_HOOK )
2019 m_propagationLevel = wxEVENT_PROPAGATE_MAX;
4cf1a9bf
VZ
2020
2021 m_allowNext = false;
3a95f73c
VZ
2022 }
2023
dfc7216d
VZ
2024 // Copy only the event data present in this class, this is used by
2025 // AssignKeyData() and copy ctor.
2026 void DoAssignMembers(const wxKeyEvent& evt)
2027 {
2028 m_x = evt.m_x;
2029 m_y = evt.m_y;
2f7baaec 2030 m_hasPosition = evt.m_hasPosition;
dfc7216d
VZ
2031
2032 m_keyCode = evt.m_keyCode;
2033
2034 m_rawCode = evt.m_rawCode;
2035 m_rawFlags = evt.m_rawFlags;
2036#if wxUSE_UNICODE
2037 m_uniChar = evt.m_uniChar;
2038#endif
2039 }
2040
2f7baaec
VZ
2041 // Initialize m_x and m_y using the current mouse cursor position if
2042 // necessary.
2043 void InitPositionIfNecessary() const;
2044
4cf1a9bf
VZ
2045 // If this flag is true, the normal key events should still be generated
2046 // even if wxEVT_CHAR_HOOK had been handled. By default it is false as
2047 // handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
2048 bool m_allowNext;
2049
2f7baaec
VZ
2050 // If true, m_x and m_y were already initialized. If false, try to get them
2051 // when they're requested.
2052 bool m_hasPosition;
2053
8e72b8b5 2054 DECLARE_DYNAMIC_CLASS(wxKeyEvent)
c801d85f
KB
2055};
2056
2057// Size event class
2058/*
2059 wxEVT_SIZE
2060 */
2061
bddd7a8d 2062class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
c801d85f 2063{
2b854a32 2064public:
497dbbd3 2065 wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
e6a6feba 2066 { }
d9e2e4c2
DE
2067 wxSizeEvent(const wxSize& sz, int winid = 0)
2068 : wxEvent(winid, wxEVT_SIZE),
497dbbd3 2069 m_size(sz)
e6a6feba 2070 { }
f3ff831f 2071 wxSizeEvent(const wxSizeEvent& event)
b2697d42 2072 : wxEvent(event),
5706de1c 2073 m_size(event.m_size), m_rect(event.m_rect)
b2697d42 2074 { }
5706de1c 2075 wxSizeEvent(const wxRect& rect, int id = 0)
e00865fa 2076 : m_size(rect.GetSize()), m_rect(rect)
5706de1c 2077 { m_eventType = wxEVT_SIZING; m_id = id; }
c2bbeff0 2078
2b854a32 2079 wxSize GetSize() const { return m_size; }
b702a833 2080 void SetSize(wxSize size) { m_size = size; }
5706de1c 2081 wxRect GetRect() const { return m_rect; }
fbfb8bcc 2082 void SetRect(const wxRect& rect) { m_rect = rect; }
aadbdf11 2083
8e72b8b5
RR
2084 virtual wxEvent *Clone() const { return new wxSizeEvent(*this); }
2085
2086public:
b4b76d61 2087 // For internal usage only. Will be converted to protected members.
8e72b8b5 2088 wxSize m_size;
5706de1c 2089 wxRect m_rect; // Used for wxEVT_SIZING
8e72b8b5 2090
f97500b8 2091private:
fc7a2a60 2092 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent)
c801d85f
KB
2093};
2094
2095// Move event class
2096
2097/*
2098 wxEVT_MOVE
2099 */
2100
bddd7a8d 2101class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
c801d85f 2102{
2b854a32 2103public:
e6a6feba
GD
2104 wxMoveEvent()
2105 : wxEvent(0, wxEVT_MOVE)
e6a6feba 2106 { }
d9e2e4c2
DE
2107 wxMoveEvent(const wxPoint& pos, int winid = 0)
2108 : wxEvent(winid, wxEVT_MOVE),
497dbbd3 2109 m_pos(pos)
e6a6feba 2110 { }
1d2eddff
JS
2111 wxMoveEvent(const wxMoveEvent& event)
2112 : wxEvent(event),
b2697d42
VZ
2113 m_pos(event.m_pos)
2114 { }
5706de1c
JS
2115 wxMoveEvent(const wxRect& rect, int id = 0)
2116 : m_pos(rect.GetPosition()), m_rect(rect)
2117 { m_eventType = wxEVT_MOVING; m_id = id; }
c2bbeff0 2118
2b854a32 2119 wxPoint GetPosition() const { return m_pos; }
d7f03cae 2120 void SetPosition(const wxPoint& pos) { m_pos = pos; }
5706de1c 2121 wxRect GetRect() const { return m_rect; }
fbfb8bcc 2122 void SetRect(const wxRect& rect) { m_rect = rect; }
aadbdf11 2123
8e72b8b5 2124 virtual wxEvent *Clone() const { return new wxMoveEvent(*this); }
f97500b8 2125
b4b76d61 2126protected:
8e72b8b5 2127 wxPoint m_pos;
5706de1c 2128 wxRect m_rect;
f97500b8 2129
8e72b8b5 2130private:
fc7a2a60 2131 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent)
c801d85f
KB
2132};
2133
2134// Paint event class
2135/*
2136 wxEVT_PAINT
2137 wxEVT_NC_PAINT
c801d85f
KB
2138 */
2139
657a8a35
VZ
2140#if wxDEBUG_LEVEL && (defined(__WXMSW__) || defined(__WXPM__))
2141 #define wxHAS_PAINT_DEBUG
2142
b078fa02 2143 // see comments in src/msw|os2/dcclient.cpp where g_isPainting is defined
bddd7a8d 2144 extern WXDLLIMPEXP_CORE int g_isPainting;
edccf428
VZ
2145#endif // debug
2146
bddd7a8d 2147class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
c801d85f 2148{
2b854a32 2149public:
edccf428 2150 wxPaintEvent(int Id = 0)
e6a6feba 2151 : wxEvent(Id, wxEVT_PAINT)
edccf428 2152 {
657a8a35
VZ
2153#ifdef wxHAS_PAINT_DEBUG
2154 // set the internal flag for the duration of redrawing
edccf428
VZ
2155 g_isPainting++;
2156#endif // debug
2157 }
2158
4e689ecd
VZ
2159 // default copy ctor and dtor are normally fine, we only need them to keep
2160 // g_isPainting updated in debug build
657a8a35 2161#ifdef wxHAS_PAINT_DEBUG
4e689ecd
VZ
2162 wxPaintEvent(const wxPaintEvent& event)
2163 : wxEvent(event)
2164 {
2165 g_isPainting++;
2166 }
2167
d3c7fc99 2168 virtual ~wxPaintEvent()
edccf428
VZ
2169 {
2170 g_isPainting--;
2171 }
2172#endif // debug
8e72b8b5
RR
2173
2174 virtual wxEvent *Clone() const { return new wxPaintEvent(*this); }
f97500b8 2175
8e72b8b5 2176private:
fc7a2a60 2177 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaintEvent)
c801d85f
KB
2178};
2179
bddd7a8d 2180class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
1e6feb95
VZ
2181{
2182public:
d9e2e4c2
DE
2183 wxNcPaintEvent(int winid = 0)
2184 : wxEvent(winid, wxEVT_NC_PAINT)
e6a6feba 2185 { }
f97500b8 2186
8e72b8b5 2187 virtual wxEvent *Clone() const { return new wxNcPaintEvent(*this); }
1e6feb95
VZ
2188
2189private:
fc7a2a60 2190 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNcPaintEvent)
1e6feb95
VZ
2191};
2192
c801d85f
KB
2193// Erase background event class
2194/*
2195 wxEVT_ERASE_BACKGROUND
2196 */
2197
bddd7a8d 2198class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
c801d85f 2199{
2b854a32 2200public:
03f3617b 2201 wxEraseEvent(int Id = 0, wxDC *dc = NULL)
497dbbd3
VZ
2202 : wxEvent(Id, wxEVT_ERASE_BACKGROUND),
2203 m_dc(dc)
e6a6feba
GD
2204 { }
2205
2206 wxEraseEvent(const wxEraseEvent& event)
497dbbd3
VZ
2207 : wxEvent(event),
2208 m_dc(event.m_dc)
e6a6feba 2209 { }
f97500b8 2210
2b854a32 2211 wxDC *GetDC() const { return m_dc; }
aadbdf11 2212
8e72b8b5 2213 virtual wxEvent *Clone() const { return new wxEraseEvent(*this); }
f97500b8 2214
b4b76d61 2215protected:
8e72b8b5
RR
2216 wxDC *m_dc;
2217
2218private:
fc7a2a60 2219 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent)
c801d85f
KB
2220};
2221
2222// Focus event class
2223/*
2224 wxEVT_SET_FOCUS
2225 wxEVT_KILL_FOCUS
2226 */
2227
bddd7a8d 2228class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
c801d85f 2229{
2b854a32 2230public:
d9e2e4c2
DE
2231 wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0)
2232 : wxEvent(winid, type)
497dbbd3 2233 { m_win = NULL; }
e6a6feba
GD
2234
2235 wxFocusEvent(const wxFocusEvent& event)
2236 : wxEvent(event)
497dbbd3 2237 { m_win = event.m_win; }
1e6feb95 2238
8e72b8b5 2239 // The window associated with this event is the window which had focus
1e6feb95 2240 // before for SET event and the window which will have focus for the KILL
8e72b8b5 2241 // one. NB: it may be NULL in both cases!
1e6feb95
VZ
2242 wxWindow *GetWindow() const { return m_win; }
2243 void SetWindow(wxWindow *win) { m_win = win; }
2244
8e72b8b5 2245 virtual wxEvent *Clone() const { return new wxFocusEvent(*this); }
f97500b8 2246
1e6feb95
VZ
2247private:
2248 wxWindow *m_win;
2249
8e72b8b5 2250private:
fc7a2a60 2251 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent)
c801d85f
KB
2252};
2253
456bc6d9 2254// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
1648d51b 2255// wxFocusEvent it is propagated upwards the window chain
bddd7a8d 2256class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent
456bc6d9
VZ
2257{
2258public:
2259 wxChildFocusEvent(wxWindow *win = NULL);
2260
2261 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
2262
8e72b8b5 2263 virtual wxEvent *Clone() const { return new wxChildFocusEvent(*this); }
f97500b8 2264
8e72b8b5 2265private:
fc7a2a60 2266 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChildFocusEvent)
456bc6d9
VZ
2267};
2268
c801d85f
KB
2269// Activate event class
2270/*
2271 wxEVT_ACTIVATE
2272 wxEVT_ACTIVATE_APP
afafd942 2273 wxEVT_HIBERNATE
c801d85f
KB
2274 */
2275
bddd7a8d 2276class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent
c801d85f 2277{
2b854a32 2278public:
a0d9c6cb 2279 wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true, int Id = 0)
e6a6feba 2280 : wxEvent(Id, type)
497dbbd3 2281 { m_active = active; }
1d2eddff
JS
2282 wxActivateEvent(const wxActivateEvent& event)
2283 : wxEvent(event)
b2697d42 2284 { m_active = event.m_active; }
c2bbeff0 2285
2b854a32 2286 bool GetActive() const { return m_active; }
c801d85f 2287
8e72b8b5 2288 virtual wxEvent *Clone() const { return new wxActivateEvent(*this); }
aadbdf11 2289
2b854a32
VZ
2290private:
2291 bool m_active;
8e72b8b5
RR
2292
2293private:
fc7a2a60 2294 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent)
c801d85f
KB
2295};
2296
2297// InitDialog event class
2298/*
2299 wxEVT_INIT_DIALOG
2300 */
2301
bddd7a8d 2302class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent
c801d85f 2303{
2b854a32
VZ
2304public:
2305 wxInitDialogEvent(int Id = 0)
e6a6feba
GD
2306 : wxEvent(Id, wxEVT_INIT_DIALOG)
2307 { }
8e72b8b5
RR
2308
2309 virtual wxEvent *Clone() const { return new wxInitDialogEvent(*this); }
f97500b8
VZ
2310
2311private:
fc7a2a60 2312 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxInitDialogEvent)
c801d85f
KB
2313};
2314
2315// Miscellaneous menu event class
2316/*
ccef86c7
VZ
2317 wxEVT_MENU_OPEN,
2318 wxEVT_MENU_CLOSE,
c801d85f 2319 wxEVT_MENU_HIGHLIGHT,
c801d85f
KB
2320*/
2321
bddd7a8d 2322class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent
c801d85f 2323{
c801d85f 2324public:
92f1a59c 2325 wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = NULL)
d9e2e4c2 2326 : wxEvent(winid, type)
fc7a2a60 2327 { m_menuId = winid; m_menu = menu; }
f3ff831f 2328 wxMenuEvent(const wxMenuEvent& event)
1d2eddff 2329 : wxEvent(event)
92f1a59c 2330 { m_menuId = event.m_menuId; m_menu = event.m_menu; }
c2bbeff0 2331
ccef86c7 2332 // only for wxEVT_MENU_HIGHLIGHT
aadbdf11 2333 int GetMenuId() const { return m_menuId; }
c801d85f 2334
ccef86c7 2335 // only for wxEVT_MENU_OPEN/CLOSE
1a18887b 2336 bool IsPopup() const { return m_menuId == wxID_ANY; }
ccef86c7 2337
92f1a59c
JS
2338 // only for wxEVT_MENU_OPEN/CLOSE
2339 wxMenu* GetMenu() const { return m_menu; }
2340
8e72b8b5 2341 virtual wxEvent *Clone() const { return new wxMenuEvent(*this); }
f97500b8 2342
2b854a32 2343private:
92f1a59c
JS
2344 int m_menuId;
2345 wxMenu* m_menu;
f97500b8 2346
fc7a2a60 2347 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent)
c801d85f
KB
2348};
2349
2350// Window close or session close event class
2351/*
2352 wxEVT_CLOSE_WINDOW,
2353 wxEVT_END_SESSION,
2354 wxEVT_QUERY_END_SESSION
2355 */
2356
bddd7a8d 2357class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent
c801d85f 2358{
c801d85f 2359public:
d9e2e4c2
DE
2360 wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0)
2361 : wxEvent(winid, type),
a0d9c6cb
WS
2362 m_loggingOff(true),
2363 m_veto(false), // should be false by default
2364 m_canVeto(true) {}
a3bf7524 2365
f3ff831f 2366 wxCloseEvent(const wxCloseEvent& event)
1d2eddff 2367 : wxEvent(event),
b2697d42
VZ
2368 m_loggingOff(event.m_loggingOff),
2369 m_veto(event.m_veto),
a3bf7524 2370 m_canVeto(event.m_canVeto) {}
c2bbeff0 2371
2b854a32 2372 void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
4bcfcdef
VZ
2373 bool GetLoggingOff() const
2374 {
2375 // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it
2376 // doesn't make sense for wxEVT_CLOSE_WINDOW
2377 wxASSERT_MSG( m_eventType != wxEVT_CLOSE_WINDOW,
9a83f860 2378 wxT("this flag is for end session events only") );
4bcfcdef
VZ
2379
2380 return m_loggingOff;
2381 }
2b854a32 2382
a0d9c6cb 2383 void Veto(bool veto = true)
fe4e9e6c 2384 {
a0d9c6cb 2385 // GetVeto() will return false anyhow...
fe4e9e6c 2386 wxCHECK_RET( m_canVeto,
223d09f6 2387 wxT("call to Veto() ignored (can't veto this event)") );
fe4e9e6c
VZ
2388
2389 m_veto = veto;
2390 }
2b854a32
VZ
2391 void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
2392 bool CanVeto() const { return m_canVeto; }
fe4e9e6c 2393 bool GetVeto() const { return m_canVeto && m_veto; }
c801d85f 2394
8e72b8b5 2395 virtual wxEvent *Clone() const { return new wxCloseEvent(*this); }
aadbdf11 2396
2b854a32 2397protected:
4bcfcdef
VZ
2398 bool m_loggingOff,
2399 m_veto,
2400 m_canVeto;
2b854a32 2401
8e72b8b5 2402private:
fc7a2a60 2403 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent)
c801d85f
KB
2404};
2405
2406/*
2407 wxEVT_SHOW
2408 */
2409
bddd7a8d 2410class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent
c801d85f 2411{
c801d85f 2412public:
a0d9c6cb 2413 wxShowEvent(int winid = 0, bool show = false)
d9e2e4c2 2414 : wxEvent(winid, wxEVT_SHOW)
497dbbd3 2415 { m_show = show; }
f3ff831f 2416 wxShowEvent(const wxShowEvent& event)
1d2eddff 2417 : wxEvent(event)
b2697d42 2418 { m_show = event.m_show; }
c2bbeff0 2419
2b854a32 2420 void SetShow(bool show) { m_show = show; }
d317fdeb
VZ
2421
2422 // return true if the window was shown, false if hidden
2423 bool IsShown() const { return m_show; }
2424
831b64f3 2425#if WXWIN_COMPATIBILITY_2_8
d317fdeb
VZ
2426 wxDEPRECATED( bool GetShow() const { return IsShown(); } )
2427#endif
c801d85f 2428
8e72b8b5 2429 virtual wxEvent *Clone() const { return new wxShowEvent(*this); }
aadbdf11 2430
c801d85f 2431protected:
2b854a32 2432 bool m_show;
3dd9b88a 2433
8e72b8b5 2434private:
fc7a2a60 2435 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent)
c801d85f
KB
2436};
2437
2438/*
2439 wxEVT_ICONIZE
2440 */
2441
bddd7a8d 2442class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent
c801d85f 2443{
2b854a32 2444public:
a0d9c6cb 2445 wxIconizeEvent(int winid = 0, bool iconized = true)
d9e2e4c2 2446 : wxEvent(winid, wxEVT_ICONIZE)
497dbbd3 2447 { m_iconized = iconized; }
f3ff831f 2448 wxIconizeEvent(const wxIconizeEvent& event)
1d2eddff 2449 : wxEvent(event)
b2697d42 2450 { m_iconized = event.m_iconized; }
c2bbeff0 2451
831b64f3 2452#if WXWIN_COMPATIBILITY_2_8
d317fdeb
VZ
2453 wxDEPRECATED( bool Iconized() const { return IsIconized(); } )
2454#endif
3dd9b88a 2455 // return true if the frame was iconized, false if restored
d317fdeb 2456 bool IsIconized() const { return m_iconized; }
3dd9b88a 2457
8e72b8b5 2458 virtual wxEvent *Clone() const { return new wxIconizeEvent(*this); }
f97500b8 2459
3dd9b88a
VZ
2460protected:
2461 bool m_iconized;
2462
8e72b8b5 2463private:
fc7a2a60 2464 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent)
c801d85f 2465};
c801d85f
KB
2466/*
2467 wxEVT_MAXIMIZE
2468 */
2469
bddd7a8d 2470class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent
c801d85f 2471{
2b854a32 2472public:
d9e2e4c2
DE
2473 wxMaximizeEvent(int winid = 0)
2474 : wxEvent(winid, wxEVT_MAXIMIZE)
e6a6feba 2475 { }
3dd9b88a 2476
8e72b8b5 2477 virtual wxEvent *Clone() const { return new wxMaximizeEvent(*this); }
f97500b8 2478
8e72b8b5 2479private:
fc7a2a60 2480 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMaximizeEvent)
c801d85f
KB
2481};
2482
2483// Joystick event class
2484/*
2485 wxEVT_JOY_BUTTON_DOWN,
2486 wxEVT_JOY_BUTTON_UP,
2487 wxEVT_JOY_MOVE,
2488 wxEVT_JOY_ZMOVE
2489*/
2490
2491// Which joystick? Same as Windows ids so no conversion necessary.
497dbbd3
VZ
2492enum
2493{
2494 wxJOYSTICK1,
2495 wxJOYSTICK2
2496};
c801d85f
KB
2497
2498// Which button is down?
497dbbd3
VZ
2499enum
2500{
2501 wxJOY_BUTTON_ANY = -1,
2502 wxJOY_BUTTON1 = 1,
2503 wxJOY_BUTTON2 = 2,
2504 wxJOY_BUTTON3 = 4,
2505 wxJOY_BUTTON4 = 8
2506};
c801d85f 2507
bddd7a8d 2508class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent
c801d85f 2509{
b4b76d61 2510protected:
2b854a32
VZ
2511 wxPoint m_pos;
2512 int m_zPosition;
497dbbd3
VZ
2513 int m_buttonChange; // Which button changed?
2514 int m_buttonState; // Which buttons are down?
2515 int m_joyStick; // Which joystick?
2b854a32 2516
b4b76d61 2517public:
2b854a32
VZ
2518 wxJoystickEvent(wxEventType type = wxEVT_NULL,
2519 int state = 0,
2520 int joystick = wxJOYSTICK1,
2521 int change = 0)
497dbbd3 2522 : wxEvent(0, type),
8b5d5223 2523 m_pos(),
497dbbd3
VZ
2524 m_zPosition(0),
2525 m_buttonChange(change),
2526 m_buttonState(state),
2527 m_joyStick(joystick)
2b854a32 2528 {
2b854a32 2529 }
f3ff831f 2530 wxJoystickEvent(const wxJoystickEvent& event)
b2697d42
VZ
2531 : wxEvent(event),
2532 m_pos(event.m_pos),
2533 m_zPosition(event.m_zPosition),
2534 m_buttonChange(event.m_buttonChange),
2535 m_buttonState(event.m_buttonState),
2536 m_joyStick(event.m_joyStick)
1d2eddff 2537 { }
c2bbeff0 2538
2b854a32
VZ
2539 wxPoint GetPosition() const { return m_pos; }
2540 int GetZPosition() const { return m_zPosition; }
2541 int GetButtonState() const { return m_buttonState; }
2542 int GetButtonChange() const { return m_buttonChange; }
2543 int GetJoystick() const { return m_joyStick; }
2544
2545 void SetJoystick(int stick) { m_joyStick = stick; }
2546 void SetButtonState(int state) { m_buttonState = state; }
2547 void SetButtonChange(int change) { m_buttonChange = change; }
2548 void SetPosition(const wxPoint& pos) { m_pos = pos; }
2549 void SetZPosition(int zPos) { m_zPosition = zPos; }
2550
2551 // Was it a button event? (*doesn't* mean: is any button *down*?)
2552 bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) ||
b70ababc 2553 (GetEventType() == wxEVT_JOY_BUTTON_UP)); }
2b854a32
VZ
2554
2555 // Was it a move event?
a7bc03c9 2556 bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); }
2b854a32
VZ
2557
2558 // Was it a zmove event?
a7bc03c9 2559 bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); }
2b854a32
VZ
2560
2561 // Was it a down event from button 1, 2, 3, 4 or any?
2562 bool ButtonDown(int but = wxJOY_BUTTON_ANY) const
c801d85f 2563 { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) &&
2b854a32 2564 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
c801d85f 2565
2b854a32
VZ
2566 // Was it a up event from button 1, 2, 3 or any?
2567 bool ButtonUp(int but = wxJOY_BUTTON_ANY) const
c801d85f 2568 { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) &&
2b854a32 2569 ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
c801d85f 2570
2b854a32
VZ
2571 // Was the given button 1,2,3,4 or any in Down state?
2572 bool ButtonIsDown(int but = wxJOY_BUTTON_ANY) const
c801d85f 2573 { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) ||
2b854a32 2574 ((m_buttonState & but) == but)); }
f305c661 2575
8e72b8b5 2576 virtual wxEvent *Clone() const { return new wxJoystickEvent(*this); }
f97500b8 2577
8e72b8b5 2578private:
fc7a2a60 2579 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent)
c801d85f
KB
2580};
2581
2582// Drop files event class
2583/*
2584 wxEVT_DROP_FILES
2585 */
2586
bddd7a8d 2587class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent
c801d85f 2588{
2b854a32
VZ
2589public:
2590 int m_noFiles;
2591 wxPoint m_pos;
c3c39620 2592 wxString* m_files;
2b854a32
VZ
2593
2594 wxDropFilesEvent(wxEventType type = wxEVT_NULL,
2595 int noFiles = 0,
03f3617b 2596 wxString *files = NULL)
497dbbd3
VZ
2597 : wxEvent(0, type),
2598 m_noFiles(noFiles),
2599 m_pos(),
2600 m_files(files)
e6a6feba 2601 { }
2b854a32 2602
c3c39620
VZ
2603 // we need a copy ctor to avoid deleting m_files pointer twice
2604 wxDropFilesEvent(const wxDropFilesEvent& other)
497dbbd3
VZ
2605 : wxEvent(other),
2606 m_noFiles(other.m_noFiles),
2607 m_pos(other.m_pos),
2608 m_files(NULL)
c3c39620 2609 {
c3c39620
VZ
2610 m_files = new wxString[m_noFiles];
2611 for ( int n = 0; n < m_noFiles; n++ )
2612 {
2613 m_files[n] = other.m_files[n];
2614 }
2615 }
2616
2617 virtual ~wxDropFilesEvent()
2618 {
2619 delete [] m_files;
2620 }
2621
2b854a32
VZ
2622 wxPoint GetPosition() const { return m_pos; }
2623 int GetNumberOfFiles() const { return m_noFiles; }
2624 wxString *GetFiles() const { return m_files; }
f305c661 2625
c3c39620 2626 virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); }
f97500b8 2627
8e72b8b5 2628private:
fc7a2a60 2629 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent)
c801d85f
KB
2630};
2631
c801d85f
KB
2632// Update UI event
2633/*
2634 wxEVT_UPDATE_UI
2635 */
2636
e39af974
JS
2637// Whether to always send update events to windows, or
2638// to only send update events to those with the
2639// wxWS_EX_PROCESS_UI_UPDATES style.
2640
2641enum wxUpdateUIMode
2642{
2643 // Send UI update events to all windows
2644 wxUPDATE_UI_PROCESS_ALL,
2645
2646 // Send UI update events to windows that have
2647 // the wxWS_EX_PROCESS_UI_UPDATES flag specified
2648 wxUPDATE_UI_PROCESS_SPECIFIED
2649};
2650
bddd7a8d 2651class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
c801d85f 2652{
2b854a32
VZ
2653public:
2654 wxUpdateUIEvent(wxWindowID commandId = 0)
e6a6feba 2655 : wxCommandEvent(wxEVT_UPDATE_UI, commandId)
497dbbd3
VZ
2656 {
2657 m_checked =
2658 m_enabled =
a3a4105d 2659 m_shown =
497dbbd3 2660 m_setEnabled =
a3a4105d 2661 m_setShown =
9b9337da 2662 m_setText =
a0d9c6cb 2663 m_setChecked = false;
497dbbd3 2664 }
f3ff831f 2665 wxUpdateUIEvent(const wxUpdateUIEvent& event)
1d2eddff 2666 : wxCommandEvent(event),
b2697d42
VZ
2667 m_checked(event.m_checked),
2668 m_enabled(event.m_enabled),
a3a4105d 2669 m_shown(event.m_shown),
b2697d42 2670 m_setEnabled(event.m_setEnabled),
a3a4105d 2671 m_setShown(event.m_setShown),
b2697d42
VZ
2672 m_setText(event.m_setText),
2673 m_setChecked(event.m_setChecked),
2674 m_text(event.m_text)
2675 { }
c2bbeff0 2676
2b854a32
VZ
2677 bool GetChecked() const { return m_checked; }
2678 bool GetEnabled() const { return m_enabled; }
a3a4105d 2679 bool GetShown() const { return m_shown; }
2b854a32
VZ
2680 wxString GetText() const { return m_text; }
2681 bool GetSetText() const { return m_setText; }
2682 bool GetSetChecked() const { return m_setChecked; }
2683 bool GetSetEnabled() const { return m_setEnabled; }
a3a4105d 2684 bool GetSetShown() const { return m_setShown; }
2b854a32 2685
a0d9c6cb
WS
2686 void Check(bool check) { m_checked = check; m_setChecked = true; }
2687 void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; }
a3a4105d 2688 void Show(bool show) { m_shown = show; m_setShown = true; }
a0d9c6cb 2689 void SetText(const wxString& text) { m_text = text; m_setText = true; }
c801d85f 2690
0b30bb0b
JS
2691 // Sets the interval between updates in milliseconds.
2692 // Set to -1 to disable updates, or to 0 to update as frequently as possible.
e39af974 2693 static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
0b30bb0b
JS
2694
2695 // Returns the current interval between updates in milliseconds
a7bc03c9 2696 static long GetUpdateInterval() { return sm_updateInterval; }
0b30bb0b 2697
e39af974 2698 // Can we update this window?
a7bc03c9 2699 static bool CanUpdate(wxWindowBase *win);
0b30bb0b
JS
2700
2701 // Reset the update time to provide a delay until the next
2702 // time we should update
a7bc03c9 2703 static void ResetUpdateTime();
0b30bb0b 2704
77ffb593 2705 // Specify how wxWidgets will send update events: to
e39af974
JS
2706 // all windows, or only to those which specify that they
2707 // will process the events.
2708 static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
2709
2710 // Returns the UI update mode
a7bc03c9 2711 static wxUpdateUIMode GetMode() { return sm_updateMode; }
e39af974 2712
8e72b8b5 2713 virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); }
f305c661 2714
2b854a32
VZ
2715protected:
2716 bool m_checked;
2717 bool m_enabled;
a3a4105d 2718 bool m_shown;
2b854a32 2719 bool m_setEnabled;
a3a4105d 2720 bool m_setShown;
2b854a32
VZ
2721 bool m_setText;
2722 bool m_setChecked;
2723 wxString m_text;
0b30bb0b 2724#if wxUSE_LONGLONG
e39af974 2725 static wxLongLong sm_lastUpdate;
0b30bb0b 2726#endif
e39af974
JS
2727 static long sm_updateInterval;
2728 static wxUpdateUIMode sm_updateMode;
f97500b8 2729
8e72b8b5 2730private:
fc7a2a60 2731 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent)
c801d85f
KB
2732};
2733
2734/*
2735 wxEVT_SYS_COLOUR_CHANGED
2736 */
2737
2738// TODO: shouldn't all events record the window ID?
bddd7a8d 2739class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent
c801d85f 2740{
2b854a32
VZ
2741public:
2742 wxSysColourChangedEvent()
e6a6feba
GD
2743 : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED)
2744 { }
f97500b8 2745
8e72b8b5 2746 virtual wxEvent *Clone() const { return new wxSysColourChangedEvent(*this); }
f97500b8 2747
8e72b8b5 2748private:
fc7a2a60 2749 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSysColourChangedEvent)
c801d85f
KB
2750};
2751
a5e84126
JS
2752/*
2753 wxEVT_MOUSE_CAPTURE_CHANGED
2754 The window losing the capture receives this message
2755 (even if it released the capture itself).
2756 */
2757
bddd7a8d 2758class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent
a5e84126
JS
2759{
2760public:
d9e2e4c2
DE
2761 wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = NULL)
2762 : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED),
497dbbd3 2763 m_gainedCapture(gainedCapture)
e6a6feba
GD
2764 { }
2765
2766 wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event)
497dbbd3
VZ
2767 : wxEvent(event),
2768 m_gainedCapture(event.m_gainedCapture)
e6a6feba 2769 { }
a5e84126
JS
2770
2771 virtual wxEvent *Clone() const { return new wxMouseCaptureChangedEvent(*this); }
2772
47b378bd 2773 wxWindow* GetCapturedWindow() const { return m_gainedCapture; }
a5e84126
JS
2774
2775private:
2776 wxWindow* m_gainedCapture;
fc7a2a60
VZ
2777
2778 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent)
a5e84126
JS
2779};
2780
63e819f2
VS
2781/*
2782 wxEVT_MOUSE_CAPTURE_LOST
2783 The window losing the capture receives this message, unless it released it
2784 it itself or unless wxWindow::CaptureMouse was called on another window
2785 (and so capture will be restored when the new capturer releases it).
2786 */
2787
2788class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent
2789{
2790public:
2791 wxMouseCaptureLostEvent(wxWindowID winid = 0)
2792 : wxEvent(winid, wxEVT_MOUSE_CAPTURE_LOST)
2793 {}
2794
2795 wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent& event)
2796 : wxEvent(event)
2797 {}
2798
2799 virtual wxEvent *Clone() const { return new wxMouseCaptureLostEvent(*this); }
2800
2801 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent)
2802};
2803
574c939e
KB
2804/*
2805 wxEVT_DISPLAY_CHANGED
2806 */
bddd7a8d 2807class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent
574c939e
KB
2808{
2809private:
fc7a2a60 2810 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDisplayChangedEvent)
574c939e
KB
2811
2812public:
2813 wxDisplayChangedEvent()
e6a6feba
GD
2814 : wxEvent(0, wxEVT_DISPLAY_CHANGED)
2815 { }
574c939e
KB
2816
2817 virtual wxEvent *Clone() const { return new wxDisplayChangedEvent(*this); }
2818};
2819
f7bd2698
JS
2820/*
2821 wxEVT_PALETTE_CHANGED
2822 */
2823
bddd7a8d 2824class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent
f7bd2698 2825{
f7bd2698 2826public:
d9e2e4c2
DE
2827 wxPaletteChangedEvent(wxWindowID winid = 0)
2828 : wxEvent(winid, wxEVT_PALETTE_CHANGED),
03f3617b 2829 m_changedWindow(NULL)
497dbbd3 2830 { }
e6a6feba
GD
2831
2832 wxPaletteChangedEvent(const wxPaletteChangedEvent& event)
497dbbd3
VZ
2833 : wxEvent(event),
2834 m_changedWindow(event.m_changedWindow)
e6a6feba 2835 { }
f7bd2698 2836
2b854a32
VZ
2837 void SetChangedWindow(wxWindow* win) { m_changedWindow = win; }
2838 wxWindow* GetChangedWindow() const { return m_changedWindow; }
f7bd2698 2839
8e72b8b5 2840 virtual wxEvent *Clone() const { return new wxPaletteChangedEvent(*this); }
f305c661 2841
f7bd2698 2842protected:
2b854a32 2843 wxWindow* m_changedWindow;
8e72b8b5
RR
2844
2845private:
fc7a2a60 2846 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent)
f7bd2698
JS
2847};
2848
2849/*
2850 wxEVT_QUERY_NEW_PALETTE
2851 Indicates the window is getting keyboard focus and should re-do its palette.
2852 */
2853
bddd7a8d 2854class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent
f7bd2698 2855{
f7bd2698 2856public:
d9e2e4c2
DE
2857 wxQueryNewPaletteEvent(wxWindowID winid = 0)
2858 : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE),
a0d9c6cb 2859 m_paletteRealized(false)
e6a6feba 2860 { }
f3ff831f 2861 wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent& event)
1d2eddff 2862 : wxEvent(event),
b2697d42
VZ
2863 m_paletteRealized(event.m_paletteRealized)
2864 { }
c2bbeff0 2865
2b854a32
VZ
2866 // App sets this if it changes the palette.
2867 void SetPaletteRealized(bool realized) { m_paletteRealized = realized; }
2868 bool GetPaletteRealized() const { return m_paletteRealized; }
f7bd2698 2869
8e72b8b5 2870 virtual wxEvent *Clone() const { return new wxQueryNewPaletteEvent(*this); }
f305c661 2871
f7bd2698 2872protected:
2b854a32 2873 bool m_paletteRealized;
f97500b8 2874
8e72b8b5 2875private:
fc7a2a60 2876 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent)
f7bd2698
JS
2877};
2878
7fdefd57
VZ
2879/*
2880 Event generated by dialog navigation keys
2881 wxEVT_NAVIGATION_KEY
2882 */
d9506e77 2883// NB: don't derive from command event to avoid being propagated to the parent
bddd7a8d 2884class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent
7fdefd57 2885{
7fdefd57 2886public:
d9506e77 2887 wxNavigationKeyEvent()
497dbbd3 2888 : wxEvent(0, wxEVT_NAVIGATION_KEY),
298ca00c 2889 m_flags(IsForward | FromTab), // defaults are for TAB
03f3617b 2890 m_focus(NULL)
aef35d0e
VZ
2891 {
2892 m_propagationLevel = wxEVENT_PROPAGATE_NONE;
2893 }
d9506e77 2894
e6a6feba 2895 wxNavigationKeyEvent(const wxNavigationKeyEvent& event)
497dbbd3
VZ
2896 : wxEvent(event),
2897 m_flags(event.m_flags),
2898 m_focus(event.m_focus)
e6a6feba 2899 { }
7fdefd57 2900
2b854a32 2901 // direction: forward (true) or backward (false)
d9506e77
VZ
2902 bool GetDirection() const
2903 { return (m_flags & IsForward) != 0; }
2904 void SetDirection(bool bForward)
2905 { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; }
7fdefd57 2906
2b854a32
VZ
2907 // it may be a window change event (MDI, notebook pages...) or a control
2908 // change event
d9506e77
VZ
2909 bool IsWindowChange() const
2910 { return (m_flags & WinChange) != 0; }
2911 void SetWindowChange(bool bIs)
2912 { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; }
2913
298ca00c
VZ
2914 // Set to true under MSW if the event was generated using the tab key.
2915 // This is required for proper navogation over radio buttons
2916 bool IsFromTab() const
2917 { return (m_flags & FromTab) != 0; }
2918 void SetFromTab(bool bIs)
2919 { if ( bIs ) m_flags |= FromTab; else m_flags &= ~FromTab; }
2920
2b854a32
VZ
2921 // the child which has the focus currently (may be NULL - use
2922 // wxWindow::FindFocus then)
d9506e77
VZ
2923 wxWindow* GetCurrentFocus() const { return m_focus; }
2924 void SetCurrentFocus(wxWindow *win) { m_focus = win; }
2925
54a69edf
JS
2926 // Set flags
2927 void SetFlags(long flags) { m_flags = flags; }
2928
8e72b8b5
RR
2929 virtual wxEvent *Clone() const { return new wxNavigationKeyEvent(*this); }
2930
1e8af825 2931 enum wxNavigationKeyEventFlags
d9506e77 2932 {
f2de9fee 2933 IsBackward = 0x0000,
d9506e77 2934 IsForward = 0x0001,
298ca00c
VZ
2935 WinChange = 0x0002,
2936 FromTab = 0x0004
d9506e77
VZ
2937 };
2938
2939 long m_flags;
2940 wxWindow *m_focus;
2941
8e72b8b5 2942private:
fc7a2a60 2943 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent)
7fdefd57
VZ
2944};
2945
42e69d6b
VZ
2946// Window creation/destruction events: the first is sent as soon as window is
2947// created (i.e. the underlying GUI object exists), but when the C++ object is
2948// fully initialized (so virtual functions may be called). The second,
2949// wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
2950// still safe to call virtual functions at this moment
2951/*
2952 wxEVT_CREATE
2953 wxEVT_DESTROY
2954 */
2955
bddd7a8d 2956class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent
42e69d6b 2957{
42e69d6b
VZ
2958public:
2959 wxWindowCreateEvent(wxWindow *win = NULL);
2960
2961 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
f97500b8 2962
8e72b8b5 2963 virtual wxEvent *Clone() const { return new wxWindowCreateEvent(*this); }
f97500b8 2964
8e72b8b5 2965private:
fc7a2a60 2966 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowCreateEvent)
42e69d6b
VZ
2967};
2968
bddd7a8d 2969class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent
42e69d6b 2970{
42e69d6b
VZ
2971public:
2972 wxWindowDestroyEvent(wxWindow *win = NULL);
2973
2974 wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
f97500b8 2975
8e72b8b5
RR
2976 virtual wxEvent *Clone() const { return new wxWindowDestroyEvent(*this); }
2977
2978private:
fc7a2a60 2979 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowDestroyEvent)
42e69d6b
VZ
2980};
2981
bd83cb56 2982// A help event is sent when the user clicks on a window in context-help mode.
b96340e6 2983/*
bd83cb56
VZ
2984 wxEVT_HELP
2985 wxEVT_DETAILED_HELP
2986*/
b96340e6 2987
bddd7a8d 2988class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent
b96340e6 2989{
b96340e6 2990public:
b107e8d5
VZ
2991 // how was this help event generated?
2992 enum Origin
2993 {
2994 Origin_Unknown, // unrecognized event source
2995 Origin_Keyboard, // event generated from F1 key press
2996 Origin_HelpButton // event from [?] button on the title bar (Windows)
2997 };
2998
bd83cb56 2999 wxHelpEvent(wxEventType type = wxEVT_NULL,
d9e2e4c2 3000 wxWindowID winid = 0,
b107e8d5
VZ
3001 const wxPoint& pt = wxDefaultPosition,
3002 Origin origin = Origin_Unknown)
d9e2e4c2 3003 : wxCommandEvent(type, winid),
b107e8d5
VZ
3004 m_pos(pt),
3005 m_origin(GuessOrigin(origin))
e6a6feba 3006 { }
f3ff831f 3007 wxHelpEvent(const wxHelpEvent& event)
1d2eddff 3008 : wxCommandEvent(event),
b2697d42
VZ
3009 m_pos(event.m_pos),
3010 m_target(event.m_target),
b107e8d5
VZ
3011 m_link(event.m_link),
3012 m_origin(event.m_origin)
1d2eddff 3013 { }
c2bbeff0 3014
bd83cb56
VZ
3015 // Position of event (in screen coordinates)
3016 const wxPoint& GetPosition() const { return m_pos; }
3017 void SetPosition(const wxPoint& pos) { m_pos = pos; }
b96340e6 3018
bd83cb56
VZ
3019 // Optional link to further help
3020 const wxString& GetLink() const { return m_link; }
3021 void SetLink(const wxString& link) { m_link = link; }
fb6261e9 3022
bd83cb56
VZ
3023 // Optional target to display help in. E.g. a window specification
3024 const wxString& GetTarget() const { return m_target; }
3025 void SetTarget(const wxString& target) { m_target = target; }
fb6261e9 3026
8e72b8b5 3027 virtual wxEvent *Clone() const { return new wxHelpEvent(*this); }
f97500b8 3028
b107e8d5
VZ
3029 // optional indication of the event source
3030 Origin GetOrigin() const { return m_origin; }
3031 void SetOrigin(Origin origin) { m_origin = origin; }
3032
bd83cb56
VZ
3033protected:
3034 wxPoint m_pos;
3035 wxString m_target;
3036 wxString m_link;
b107e8d5
VZ
3037 Origin m_origin;
3038
3039 // we can try to guess the event origin ourselves, even if none is
3040 // specified in the ctor
3041 static Origin GuessOrigin(Origin origin);
bd83cb56
VZ
3042
3043private:
fc7a2a60 3044 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent)
b96340e6
JS
3045};
3046
78c91815
VZ
3047// A Clipboard Text event is sent when a window intercepts text copy/cut/paste
3048// message, i.e. the user has cut/copied/pasted data from/into a text control
3049// via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc.
3050// NOTE : under windows these events are *NOT* generated automatically
3051// for a Rich Edit text control.
3052/*
ce7fe42e
VZ
3053wxEVT_TEXT_COPY
3054wxEVT_TEXT_CUT
3055wxEVT_TEXT_PASTE
78c91815
VZ
3056*/
3057
3058class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent
3059{
3060public:
3061 wxClipboardTextEvent(wxEventType type = wxEVT_NULL,
3062 wxWindowID winid = 0)
3063 : wxCommandEvent(type, winid)
3064 { }
f3ff831f 3065 wxClipboardTextEvent(const wxClipboardTextEvent& event)
78c91815
VZ
3066 : wxCommandEvent(event)
3067 { }
3068
3069 virtual wxEvent *Clone() const { return new wxClipboardTextEvent(*this); }
3070
3071private:
3072 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent)
3073};
3074
69231000
JS
3075// A Context event is sent when the user right clicks on a window or
3076// presses Shift-F10
3077// NOTE : Under windows this is a repackaged WM_CONTETXMENU message
3078// Under other systems it may have to be generated from a right click event
3079/*
3080 wxEVT_CONTEXT_MENU
3081*/
3082
bddd7a8d 3083class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent
69231000
JS
3084{
3085public:
3086 wxContextMenuEvent(wxEventType type = wxEVT_NULL,
d9e2e4c2 3087 wxWindowID winid = 0,
e6a6feba 3088 const wxPoint& pt = wxDefaultPosition)
d9e2e4c2 3089 : wxCommandEvent(type, winid),
497dbbd3 3090 m_pos(pt)
e6a6feba 3091 { }
f3ff831f 3092 wxContextMenuEvent(const wxContextMenuEvent& event)
1d2eddff 3093 : wxCommandEvent(event),
b2697d42 3094 m_pos(event.m_pos)
1d2eddff 3095 { }
c2bbeff0 3096
69231000
JS
3097 // Position of event (in screen coordinates)
3098 const wxPoint& GetPosition() const { return m_pos; }
3099 void SetPosition(const wxPoint& pos) { m_pos = pos; }
3100
8e72b8b5 3101 virtual wxEvent *Clone() const { return new wxContextMenuEvent(*this); }
f97500b8 3102
69231000
JS
3103protected:
3104 wxPoint m_pos;
3105
3106private:
fc7a2a60 3107 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent)
69231000
JS
3108};
3109
e90c1d2a 3110
e5fb7191 3111/* TODO
c801d85f
KB
3112 wxEVT_MOUSE_CAPTURE_CHANGED,
3113 wxEVT_SETTING_CHANGED, // WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
c801d85f
KB
3114// wxEVT_FONT_CHANGED, // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate
3115 // wxEVT_FONT_CHANGED to all other windows (maybe).
3116 wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
3117 wxEVT_MEASURE_ITEM,
3118 wxEVT_COMPARE_ITEM
3119*/
3120
c1b293bb 3121#endif // wxUSE_GUI
88a9f974 3122
d48b06bd 3123
8e193f38
VZ
3124// ============================================================================
3125// event handler and related classes
3126// ============================================================================
3127
c801d85f 3128
6164f93c
VZ
3129// struct containing the members common to static and dynamic event tables
3130// entries
bddd7a8d 3131struct WXDLLIMPEXP_BASE wxEventTableEntryBase
77d4384e 3132{
d9e2e4c2 3133 wxEventTableEntryBase(int winid, int idLast,
3c778901 3134 wxEventFunctor* fn, wxObject *data)
d9e2e4c2 3135 : m_id(winid),
497dbbd3
VZ
3136 m_lastId(idLast),
3137 m_fn(fn),
3138 m_callbackUserData(data)
58791ef8
VS
3139 {
3140 wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast,
3141 "invalid IDs range: lower bound > upper bound" );
3142 }
e6a6feba 3143
3c778901
VZ
3144 wxEventTableEntryBase( const wxEventTableEntryBase &entry )
3145 : m_id( entry.m_id ),
3146 m_lastId( entry.m_lastId ),
3147 m_fn( entry.m_fn ),
3148 m_callbackUserData( entry.m_callbackUserData )
3149 {
3150 // This is a 'hack' to ensure that only one instance tries to delete
3151 // the functor pointer. It is safe as long as the only place where the
3152 // copy constructor is being called is when the static event tables are
3153 // being initialized (a temporary instance is created and then this
3154 // constructor is called).
3155
f3ff831f 3156 const_cast<wxEventTableEntryBase&>( entry ).m_fn = NULL;
3c778901
VZ
3157 }
3158
3159 ~wxEventTableEntryBase()
3160 {
0b632977 3161 delete m_fn;
3c778901 3162 }
6164f93c 3163
497dbbd3
VZ
3164 // the range of ids for this entry: if m_lastId == wxID_ANY, the range
3165 // consists only of m_id, otherwise it is m_id..m_lastId inclusive
3166 int m_id,
3167 m_lastId;
82a5f02c 3168
3c778901
VZ
3169 // function/method/functor to call
3170 wxEventFunctor* m_fn;
77d4384e 3171
3c778901 3172 // arbitrary user data associated with the callback
77d4384e 3173 wxObject* m_callbackUserData;
3c778901
VZ
3174
3175private:
c0c133e1 3176 wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase);
77d4384e
RR
3177};
3178
6164f93c 3179// an entry from a static event table
bddd7a8d 3180struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase
c801d85f 3181{
d9e2e4c2 3182 wxEventTableEntry(const int& evType, int winid, int idLast,
3c778901 3183 wxEventFunctor* fn, wxObject *data)
d9e2e4c2 3184 : wxEventTableEntryBase(winid, idLast, fn, data),
e6a6feba
GD
3185 m_eventType(evType)
3186 { }
6164f93c
VZ
3187
3188 // the reference to event type: this allows us to not care about the
3189 // (undefined) order in which the event table entries and the event types
3190 // are initialized: initially the value of this reference might be
3191 // invalid, but by the time it is used for the first time, all global
3192 // objects will have been initialized (including the event type constants)
3193 // and so it will have the correct value when it is needed
3194 const int& m_eventType;
fc7a2a60
VZ
3195
3196private:
c0c133e1 3197 wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntry);
6164f93c
VZ
3198};
3199
3200// an entry used in dynamic event table managed by wxEvtHandler::Connect()
bddd7a8d 3201struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
6164f93c 3202{
d9e2e4c2 3203 wxDynamicEventTableEntry(int evType, int winid, int idLast,
3c778901 3204 wxEventFunctor* fn, wxObject *data)
d9e2e4c2 3205 : wxEventTableEntryBase(winid, idLast, fn, data),
3c778901 3206 m_eventType(evType)
e6a6feba 3207 { }
6164f93c
VZ
3208
3209 // not a reference here as we can't keep a reference to a temporary int
3210 // created to wrap the constant value typically passed to Connect() - nor
3211 // do we need it
3212 int m_eventType;
65b17727 3213
3c778901 3214private:
c0c133e1 3215 wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry);
c801d85f
KB
3216};
3217
2e4df4bf
VZ
3218// ----------------------------------------------------------------------------
3219// wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
3220// ----------------------------------------------------------------------------
886dd7d2 3221
bddd7a8d 3222struct WXDLLIMPEXP_BASE wxEventTable
c801d85f 3223{
0b5eceb6
VZ
3224 const wxEventTable *baseTable; // base event table (next in chain)
3225 const wxEventTableEntry *entries; // bottom of entry array
c801d85f
KB
3226};
3227
b5a98acd
VZ
3228// ----------------------------------------------------------------------------
3229// wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
3230// ----------------------------------------------------------------------------
3231
d5d29b8a 3232WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray);
b5a98acd
VZ
3233
3234class WXDLLIMPEXP_BASE wxEventHashTable
3235{
3236private:
3237 // Internal data structs
3238 struct EventTypeTable
3239 {
3240 wxEventType eventType;
3241 wxEventTableEntryPointerArray eventEntryTable;
3242 };
3243 typedef EventTypeTable* EventTypeTablePointer;
3244
3245public:
3246 // Constructor, needs the event table it needs to hash later on.
1c624631
VZ
3247 // Note: hashing of the event table is not done in the constructor as it
3248 // can be that the event table is not yet full initialize, the hash
b5a98acd
VZ
3249 // will gets initialized when handling the first event look-up request.
3250 wxEventHashTable(const wxEventTable &table);
3251 // Destructor.
3252 ~wxEventHashTable();
3253
1c624631 3254 // Handle the given event, in other words search the event table hash
b5a98acd 3255 // and call self->ProcessEvent() if a match was found.
f3ff831f 3256 bool HandleEvent(wxEvent& event, wxEvtHandler *self);
b5a98acd 3257
afa039f9
JS
3258 // Clear table
3259 void Clear();
3260
657a8a35
VZ
3261#if wxUSE_MEMORY_TRACING
3262 // Clear all tables: only used to work around problems in memory tracing
3263 // code
afa039f9 3264 static void ClearAll();
657a8a35 3265#endif // wxUSE_MEMORY_TRACING
afa039f9 3266
b5a98acd
VZ
3267protected:
3268 // Init the hash table with the entries of the static event table.
3269 void InitHashTable();
105b2ca7 3270 // Helper function of InitHashTable() to insert 1 entry into the hash table.
b5a98acd
VZ
3271 void AddEntry(const wxEventTableEntry &entry);
3272 // Allocate and init with null pointers the base hash table.
3273 void AllocEventTypeTable(size_t size);
1c624631 3274 // Grow the hash table in size and transfer all items currently
b5a98acd
VZ
3275 // in the table to the correct location in the new table.
3276 void GrowEventTypeTable();
3277
3278protected:
3279 const wxEventTable &m_table;
3280 bool m_rebuildHash;
3281
3282 size_t m_size;
3283 EventTypeTablePointer *m_eventTypeTable;
fc7a2a60 3284
afa039f9
JS
3285 static wxEventHashTable* sm_first;
3286 wxEventHashTable* m_previous;
3287 wxEventHashTable* m_next;
3288
c0c133e1 3289 wxDECLARE_NO_COPY_CLASS(wxEventHashTable);
b5a98acd
VZ
3290};
3291
6164f93c 3292// ----------------------------------------------------------------------------
77ffb593 3293// wxEvtHandler: the base class for all objects handling wxWidgets events
6164f93c
VZ
3294// ----------------------------------------------------------------------------
3295
4732e2dc 3296class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
4732e2dc 3297 , public wxTrackable
c801d85f 3298{
2b854a32
VZ
3299public:
3300 wxEvtHandler();
6164f93c 3301 virtual ~wxEvtHandler();
2b854a32 3302
7f853dd0
FM
3303
3304 // Event handler chain
3305 // -------------------
3306
2b854a32
VZ
3307 wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
3308 wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
7f853dd0
FM
3309 virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
3310 virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
2b854a32 3311
8e193f38 3312 void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
2b854a32
VZ
3313 bool GetEvtHandlerEnabled() const { return m_enabled; }
3314
7f853dd0
FM
3315 void Unlink();
3316 bool IsUnlinked() const;
3317
3318
58cc1587
VZ
3319 // Global event filters
3320 // --------------------
3321
3322 // Add an event filter whose FilterEvent() method will be called for each
3323 // and every event processed by wxWidgets. The filters are called in LIFO
3324 // order and wxApp is registered as an event filter by default. The pointer
3325 // must remain valid until it's removed with RemoveFilter() and is not
3326 // deleted by wxEvtHandler.
3327 static void AddFilter(wxEventFilter* filter);
3328
3329 // Remove a filter previously installed with AddFilter().
3330 static void RemoveFilter(wxEventFilter* filter);
3331
7f853dd0
FM
3332
3333 // Event queuing and processing
3334 // ----------------------------
3335
c3f94162
VZ
3336 // Process an event right now: this can only be called from the main
3337 // thread, use QueueEvent() for scheduling the events for
3338 // processing from other threads.
8e193f38 3339 virtual bool ProcessEvent(wxEvent& event);
2b854a32 3340
937013e0
VS
3341 // Process an event by calling ProcessEvent and handling any exceptions
3342 // thrown by event handlers. It's mostly useful when processing wx events
3343 // when called from C code (e.g. in GTK+ callback) when the exception
3344 // wouldn't correctly propagate to wxEventLoop.
3345 bool SafelyProcessEvent(wxEvent& event);
7f853dd0 3346 // NOTE: uses ProcessEvent()
937013e0 3347
3cbb9df8
VZ
3348 // This method tries to process the event in this event handler, including
3349 // any preprocessing done by TryBefore() and all the handlers chained to
3350 // it, but excluding the post-processing done in TryAfter().
3351 //
3352 // It is meant to be called from ProcessEvent() only and is not virtual,
3353 // additional event handlers can be hooked into the normal event processing
3354 // logic using TryBefore() and TryAfter() hooks.
3355 //
3356 // You can also call it yourself to forward an event to another handler but
3357 // without propagating it upwards if it's unhandled (this is usually
3358 // unwanted when forwarding as the original handler would already do it if
3359 // needed normally).
3360 bool ProcessEventLocally(wxEvent& event);
3361
c3f94162
VZ
3362 // Schedule the given event to be processed later. It takes ownership of
3363 // the event pointer, i.e. it will be deleted later. This is safe to call
3364 // from multiple threads although you still need to ensure that wxString
3365 // fields of the event object are deep copies and not use the same string
3366 // buffer as other wxString objects in this thread.
3367 virtual void QueueEvent(wxEvent *event);
3368
3369 // Add an event to be processed later: notice that this function is not
3370 // safe to call from threads other than main, use QueueEvent()
3371 virtual void AddPendingEvent(const wxEvent& event)
3372 {
3373 // notice that the thread-safety problem comes from the fact that
3374 // Clone() doesn't make deep copies of wxString fields of wxEvent
3375 // object and so the same wxString could be used from both threads when
3376 // the event object is destroyed in this one -- QueueEvent() avoids
3377 // this problem as the event pointer is not used any more in this
3378 // thread at all after it is called.
3379 QueueEvent(event.Clone());
3380 }
2b854a32 3381
8e193f38 3382 void ProcessPendingEvents();
7f853dd0 3383 // NOTE: uses ProcessEvent()
2b854a32 3384
cae9e7b1
FM
3385 void DeletePendingEvents();
3386
7214297d 3387#if wxUSE_THREADS
76bfdc9a 3388 bool ProcessThreadEvent(const wxEvent& event);
cae9e7b1 3389 // NOTE: uses AddPendingEvent(); call only from secondary threads
7214297d 3390#endif
2b854a32 3391
8f6bb260 3392#ifdef wxHAS_CALL_AFTER
cf222762
VZ
3393 // Asynchronous method calls: these methods schedule the given method
3394 // pointer for a later call (during the next idle event loop iteration).
3395 //
3396 // Notice that the method is called on this object itself, so the object
3397 // CallAfter() is called on must have the correct dynamic type.
3398 //
3399 // These method can be used from another thread.
3400
3401 template <typename T>
3402 void CallAfter(void (T::*method)())
3403 {
3404 QueueEvent(
3405 new wxAsyncMethodCallEvent0<T>(static_cast<T*>(this), method)
3406 );
3407 }
3408
3409 // Notice that we use P1 and not T1 for the parameter to allow passing
856cad9a 3410 // parameters that are convertible to the type taken by the method
cf222762
VZ
3411 // instead of being exactly the same, to be closer to the usual method call
3412 // semantics.
3413 template <typename T, typename T1, typename P1>
3414 void CallAfter(void (T::*method)(T1 x1), P1 x1)
3415 {
3416 QueueEvent(
3417 new wxAsyncMethodCallEvent1<T, T1>(
3418 static_cast<T*>(this), method, x1)
3419 );
3420 }
3421
3422 template <typename T, typename T1, typename T2, typename P1, typename P2>
3423 void CallAfter(void (T::*method)(T1 x1, T2 x2), P1 x1, P2 x2)
3424 {
3425 QueueEvent(
3426 new wxAsyncMethodCallEvent2<T, T1, T2>(
3427 static_cast<T*>(this), method, x1, x2)
3428 );
3429 }
cbc8576a
VS
3430
3431 template <typename T>
3432 void CallAfter(const T& fn)
3433 {
3434 QueueEvent(new wxAsyncMethodCallEventFunctor<T>(this, fn));
3435 }
8f6bb260 3436#endif // wxHAS_CALL_AFTER
cf222762 3437
7f853dd0
FM
3438
3439 // Connecting and disconnecting
3440 // ----------------------------
3441
f3ff831f
VZ
3442 // These functions are used for old, untyped, event handlers and don't
3443 // check that the type of the function passed to them actually matches the
3444 // type of the event. They also only allow connecting events to methods of
3445 // wxEvtHandler-derived classes.
3446 //
3447 // The template Connect() methods below are safer and allow connecting
3448 // events to arbitrary functions or functors -- but require compiler
3449 // support for templates.
3450
2b854a32 3451 // Dynamic association of a member function handler with the event handler,
d9e2e4c2 3452 // winid and event type
7fa03f04
VZ
3453 void Connect(int winid,
3454 int lastId,
c9c1faa4 3455 wxEventType eventType,
7fa03f04 3456 wxObjectEventFunction func,
03f3617b
VZ
3457 wxObject *userData = NULL,
3458 wxEvtHandler *eventSink = NULL)
3c778901 3459 {
890d70eb 3460 DoBind(winid, lastId, eventType,
f3ff831f
VZ
3461 wxNewEventFunctor(eventType, func, eventSink),
3462 userData);
3c778901 3463 }
2b854a32
VZ
3464
3465 // Convenience function: take just one id
7fa03f04 3466 void Connect(int winid,
c9c1faa4 3467 wxEventType eventType,
7fa03f04 3468 wxObjectEventFunction func,
03f3617b
VZ
3469 wxObject *userData = NULL,
3470 wxEvtHandler *eventSink = NULL)
65b17727 3471 { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }
2b854a32 3472
7fa03f04 3473 // Even more convenient: without id (same as using id of wxID_ANY)
c9c1faa4 3474 void Connect(wxEventType eventType,
7fa03f04 3475 wxObjectEventFunction func,
03f3617b
VZ
3476 wxObject *userData = NULL,
3477 wxEvtHandler *eventSink = NULL)
7fa03f04
VZ
3478 { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); }
3479
3480 bool Disconnect(int winid,
3481 int lastId,
3482 wxEventType eventType,
3483 wxObjectEventFunction func = NULL,
03f3617b
VZ
3484 wxObject *userData = NULL,
3485 wxEvtHandler *eventSink = NULL)
3c778901 3486 {
890d70eb 3487 return DoUnbind(winid, lastId, eventType,
f3ff831f
VZ
3488 wxMakeEventFunctor(eventType, func, eventSink),
3489 userData );
3c778901 3490 }
7fa03f04 3491
e554d626 3492 bool Disconnect(int winid = wxID_ANY,
7fa03f04
VZ
3493 wxEventType eventType = wxEVT_NULL,
3494 wxObjectEventFunction func = NULL,
03f3617b
VZ
3495 wxObject *userData = NULL,
3496 wxEvtHandler *eventSink = NULL)
65b17727 3497 { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }
98243fed 3498
bdbe28fa 3499 bool Disconnect(wxEventType eventType,
e0685bb0 3500 wxObjectEventFunction func,
03f3617b
VZ
3501 wxObject *userData = NULL,
3502 wxEvtHandler *eventSink = NULL)
bdbe28fa 3503 { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); }
f3ff831f 3504
890d70eb
VZ
3505#ifdef wxHAS_EVENT_BIND
3506 // Bind functions to an event:
3507 template <typename EventTag, typename EventArg>
3508 void Bind(const EventTag& eventType,
3509 void (*function)(EventArg &),
3510 int winid = wxID_ANY,
3511 int lastId = wxID_ANY,
3512 wxObject *userData = NULL)
3513 {
3514 DoBind(winid, lastId, eventType,
3515 wxNewEventFunctor(eventType, function),
3516 userData);
3517 }
3518
3519
3520 template <typename EventTag, typename EventArg>
3521 bool Unbind(const EventTag& eventType,
3522 void (*function)(EventArg &),
3523 int winid = wxID_ANY,
3524 int lastId = wxID_ANY,
3525 wxObject *userData = NULL)
3526 {
3527 return DoUnbind(winid, lastId, eventType,
3528 wxMakeEventFunctor(eventType, function),
3529 userData);
3530 }
3531
3532 // Bind functors to an event:
f3ff831f 3533 template <typename EventTag, typename Functor>
5293e4b7 3534 void Bind(const EventTag& eventType,
ca6911c3 3535 const Functor &functor,
5293e4b7
VZ
3536 int winid = wxID_ANY,
3537 int lastId = wxID_ANY,
3538 wxObject *userData = NULL)
f3ff831f 3539 {
890d70eb 3540 DoBind(winid, lastId, eventType,
03ae811e 3541 wxNewEventFunctor(eventType, functor),
f3ff831f 3542 userData);
111d41b2
VZ
3543 }
3544
111d41b2 3545
5293e4b7
VZ
3546 template <typename EventTag, typename Functor>
3547 bool Unbind(const EventTag& eventType,
ca6911c3 3548 const Functor &functor,
5293e4b7
VZ
3549 int winid = wxID_ANY,
3550 int lastId = wxID_ANY,
3551 wxObject *userData = NULL)
3c778901 3552 {
890d70eb 3553 return DoUnbind(winid, lastId, eventType,
03ae811e 3554 wxMakeEventFunctor(eventType, functor),
f3ff831f 3555 userData);
3c778901 3556 }
3c778901 3557
f3ff831f 3558
4c802fdc 3559 // Bind a method of a class (called on the specified handler which must
5293e4b7 3560 // be convertible to this class) object to an event:
3c778901 3561
4c802fdc 3562 template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
5293e4b7 3563 void Bind(const EventTag &eventType,
03ae811e 3564 void (Class::*method)(EventArg &),
4c802fdc 3565 EventHandler *handler,
5293e4b7
VZ
3566 int winid = wxID_ANY,
3567 int lastId = wxID_ANY,
3568 wxObject *userData = NULL)
f3ff831f 3569 {
890d70eb 3570 DoBind(winid, lastId, eventType,
4c802fdc 3571 wxNewEventFunctor(eventType, method, handler),
f3ff831f 3572 userData);
3c778901
VZ
3573 }
3574
4c802fdc 3575 template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
5293e4b7 3576 bool Unbind(const EventTag &eventType,
03ae811e 3577 void (Class::*method)(EventArg&),
4c802fdc 3578 EventHandler *handler,
5293e4b7
VZ
3579 int winid = wxID_ANY,
3580 int lastId = wxID_ANY,
3581 wxObject *userData = NULL )
f3ff831f 3582 {
890d70eb 3583 return DoUnbind(winid, lastId, eventType,
4c802fdc 3584 wxMakeEventFunctor(eventType, method, handler),
f3ff831f
VZ
3585 userData);
3586 }
890d70eb 3587#endif // wxHAS_EVENT_BIND
3c778901 3588
10da6a8f 3589 wxList* GetDynamicEventTable() const { return m_dynamicEvents ; }
b88c44e7
RD
3590
3591 // User data can be associated with each wxEvtHandler
3592 void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
3593 wxClientData *GetClientObject() const { return DoGetClientObject(); }
3594
3595 void SetClientData( void *data ) { DoSetClientData(data); }
3596 void *GetClientData() const { return DoGetClientData(); }
3597
25250d33
VZ
3598
3599 // implementation from now on
3600 // --------------------------
3601
03f3617b
VZ
3602 // check if the given event table entry matches this event by id (the check
3603 // for the event type should be done by caller) and call the handler if it
3604 // does
1c624631
VZ
3605 //
3606 // return true if the event was processed, false otherwise (no match or the
3607 // handler decided to skip the event)
03f3617b
VZ
3608 static bool ProcessEventIfMatchesId(const wxEventTableEntryBase& tableEntry,
3609 wxEvtHandler *handler,
3610 wxEvent& event);
b88c44e7 3611
8e193f38 3612 virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
2b854a32 3613 bool SearchDynamicEventTable( wxEvent& event );
c801d85f 3614
afa039f9
JS
3615 // Avoid problems at exit by cleaning up static hash table gracefully
3616 void ClearEventHashTable() { GetEventHashTable().Clear(); }
2ef989c9 3617 void OnSinkDestroyed( wxEvtHandler *sink );
afa039f9 3618
25250d33 3619
c801d85f 3620private:
890d70eb 3621 void DoBind(int winid,
3c778901
VZ
3622 int lastId,
3623 wxEventType eventType,
3624 wxEventFunctor *func,
f3ff831f 3625 wxObject* userData = NULL);
3c778901 3626
890d70eb 3627 bool DoUnbind(int winid,
f3ff831f
VZ
3628 int lastId,
3629 wxEventType eventType,
3630 const wxEventFunctor& func,
3631 wxObject *userData = NULL);
3c778901 3632
8e193f38 3633 static const wxEventTableEntry sm_eventTableEntries[];
2b854a32 3634
c801d85f 3635protected:
4caf847c
VZ
3636 // hooks for wxWindow used by ProcessEvent()
3637 // -----------------------------------------
3638
8cc208e3
VZ
3639 // this one is called before trying our own event table to allow plugging
3640 // in the event handlers overriding the default logic, this is used by e.g.
3641 // validators.
2d8c0c2c 3642 virtual bool TryBefore(wxEvent& event);
4caf847c 3643
4b6d82c7
VZ
3644 // This one is not a hook but just a helper which looks up the handler in
3645 // this object itself.
3646 //
3647 // It is called from ProcessEventLocally() and normally shouldn't be called
3648 // directly as doing it would ignore any chained event handlers
3649 bool TryHereOnly(wxEvent& event);
3650
3651 // Another helper which simply calls pre-processing hook and then tries to
3652 // handle the event at this handler level.
3653 bool TryBeforeAndHere(wxEvent& event)
3654 {
3655 return TryBefore(event) || TryHereOnly(event);
3656 }
512220b6 3657
4caf847c
VZ
3658 // this one is called after failing to find the event handle in our own
3659 // table to give a chance to the other windows to process it
3660 //
3661 // base class implementation passes the event to wxTheApp
2d8c0c2c 3662 virtual bool TryAfter(wxEvent& event);
8cc208e3 3663
7bc57fd9 3664#if WXWIN_COMPATIBILITY_2_8
8cc208e3
VZ
3665 // deprecated method: override TryBefore() instead of this one
3666 wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
3667 virtual bool TryValidator(wxEvent& WXUNUSED(event)), return false; )
3668
3669 wxDEPRECATED_BUT_USED_INTERNALLY_INLINE(
3670 virtual bool TryParent(wxEvent& event), return DoTryApp(event); )
3671#endif // WXWIN_COMPATIBILITY_2_8
4caf847c
VZ
3672
3673
1c624631 3674 static const wxEventTable sm_eventTable;
193bf013
VZ
3675 virtual const wxEventTable *GetEventTable() const;
3676
b5a98acd
VZ
3677 static wxEventHashTable sm_eventHashTable;
3678 virtual wxEventHashTable& GetEventHashTable() const;
3679
63863e09
JS
3680 wxEvtHandler* m_nextHandler;
3681 wxEvtHandler* m_previousHandler;
63863e09 3682 wxList* m_dynamicEvents;
42e69d6b 3683 wxList* m_pendingEvents;
6164f93c 3684
7214297d 3685#if wxUSE_THREADS
8ebec7dc
VZ
3686 // critical section protecting m_pendingEvents
3687 wxCriticalSection m_pendingEventsLock;
3688#endif // wxUSE_THREADS
193bf013 3689
8e193f38
VZ
3690 // Is event handler enabled?
3691 bool m_enabled;
6164f93c 3692
b88c44e7
RD
3693
3694 // The user data: either an object which will be deleted by the container
3695 // when it's deleted or some raw pointer which we do nothing with - only
3696 // one type of data can be used with the given window (i.e. you cannot set
3697 // the void data and then associate the container with wxClientData or vice
3698 // versa)
3699 union
3700 {
3701 wxClientData *m_clientObject;
3702 void *m_clientData;
3703 };
3704
3705 // what kind of data do we have?
3706 wxClientDataType m_clientDataType;
3707
3708 // client data accessors
3709 virtual void DoSetClientObject( wxClientData *data );
3710 virtual wxClientData *DoGetClientObject() const;
3711
3712 virtual void DoSetClientData( void *data );
3713 virtual void *DoGetClientData() const;
3714
2ef989c9 3715 // Search tracker objects for event connection with this sink
4c802fdc 3716 wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *handler);
2ef989c9 3717
6164f93c 3718private:
8cc208e3
VZ
3719 // pass the event to wxTheApp instance, called from TryAfter()
3720 bool DoTryApp(wxEvent& event);
3721
3cbb9df8
VZ
3722 // try to process events in all handlers chained to this one
3723 bool DoTryChain(wxEvent& event);
3724
58cc1587
VZ
3725 // Head of the event filter linked list.
3726 static wxEventFilter* ms_filterList;
3727
fc7a2a60 3728 DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler)
c801d85f
KB
3729};
3730
a405cd89 3731WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE);
d48b06bd 3732
8cb2c49f
VZ
3733
3734// Define an inline method of wxObjectEventFunctor which couldn't be defined
3735// before wxEvtHandler declaration: at least Sun CC refuses to compile function
3736// calls through pointer to member for forward-declared classes (see #12452).
3737inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event)
3738{
3739 wxEvtHandler * const realHandler = m_handler ? m_handler : handler;
3740
3741 (realHandler->*m_method)(event);
3742}
3743
cc6ceca7
VZ
3744// ----------------------------------------------------------------------------
3745// wxEventConnectionRef represents all connections between two event handlers
3746// and enables automatic disconnect when an event handler sink goes out of
3747// scope. Each connection/disconnect increases/decreases ref count, and
3748// when it reaches zero the node goes out of scope.
3749// ----------------------------------------------------------------------------
3750
3751class wxEventConnectionRef : public wxTrackerNode
3752{
3753public:
3754 wxEventConnectionRef() : m_src(NULL), m_sink(NULL), m_refCount(0) { }
3755 wxEventConnectionRef(wxEvtHandler *src, wxEvtHandler *sink)
3756 : m_src(src), m_sink(sink), m_refCount(1)
3757 {
3758 m_sink->AddNode(this);
3759 }
3760
3761 // The sink is being destroyed
3762 virtual void OnObjectDestroy( )
3763 {
3764 if ( m_src )
3765 m_src->OnSinkDestroyed( m_sink );
3766 delete this;
3767 }
3768
3769 virtual wxEventConnectionRef *ToEventConnection() { return this; }
3770
3771 void IncRef() { m_refCount++; }
3772 void DecRef()
3773 {
3774 if ( !--m_refCount )
3775 {
3776 // The sink holds the only external pointer to this object
3777 if ( m_sink )
3778 m_sink->RemoveNode(this);
3779 delete this;
3780 }
3781 }
3782
3783private:
3784 wxEvtHandler *m_src,
3785 *m_sink;
3786 int m_refCount;
3787
3788 friend class wxEvtHandler;
3789
c0c133e1 3790 wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef);
cc6ceca7
VZ
3791};
3792
c3f94162
VZ
3793// Post a message to the given event handler which will be processed during the
3794// next event loop iteration.
3795//
3796// Notice that this one is not thread-safe, use wxQueueEvent()
76bfdc9a 3797inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event)
e2478fde 3798{
c3f94162 3799 wxCHECK_RET( dest, "need an object to post event to" );
e2478fde
VZ
3800
3801 dest->AddPendingEvent(event);
3802}
3803
c3f94162
VZ
3804// Wrapper around wxEvtHandler::QueueEvent(): adds an event for later
3805// processing, unlike wxPostEvent it is safe to use from different thread even
3806// for events with wxString members
3807inline void wxQueueEvent(wxEvtHandler *dest, wxEvent *event)
3808{
3809 wxCHECK_RET( dest, "need an object to queue event for" );
3810
3811 dest->QueueEvent(event);
3812}
3813
96d38c7e 3814typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
85ee6241 3815typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
c1b293bb 3816typedef void (wxEvtHandler::*wxThreadEventFunction)(wxThreadEvent&);
96d38c7e 3817
7fa03f04 3818#define wxEventHandler(func) \
3c778901 3819 wxEVENT_HANDLER_CAST(wxEventFunction, func)
85ee6241 3820#define wxIdleEventHandler(func) \
3c778901 3821 wxEVENT_HANDLER_CAST(wxIdleEventFunction, func)
c1b293bb
VS
3822#define wxThreadEventHandler(func) \
3823 wxEVENT_HANDLER_CAST(wxThreadEventFunction, func)
7fa03f04 3824
e90c1d2a 3825#if wxUSE_GUI
7fa03f04 3826
c4fa5aa7
VZ
3827// ----------------------------------------------------------------------------
3828// wxEventBlocker: helper class to temporarily disable event handling for a window
3829// ----------------------------------------------------------------------------
3830
b483f5fe 3831class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler
c4fa5aa7
VZ
3832{
3833public:
3834 wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY);
3835 virtual ~wxEventBlocker();
3836
3837 void Block(wxEventType type)
3838 {
3839 m_eventsToBlock.push_back(type);
3840 }
3841
3842 virtual bool ProcessEvent(wxEvent& event);
3843
3844protected:
3845 wxArrayInt m_eventsToBlock;
3846 wxWindow *m_window;
3847
c0c133e1 3848 wxDECLARE_NO_COPY_CLASS(wxEventBlocker);
c4fa5aa7
VZ
3849};
3850
c801d85f
KB
3851typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
3852typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&);
c5b42c87 3853typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&);
c801d85f
KB
3854typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&);
3855typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&);
3856typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&);
7309deea 3857typedef void (wxEvtHandler::*wxNcPaintEventFunction)(wxNcPaintEvent&);
c801d85f
KB
3858typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&);
3859typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&);
3860typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&);
3861typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&);
456bc6d9 3862typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&);
c801d85f
KB
3863typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&);
3864typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&);
3865typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&);
3866typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&);
3867typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&);
7fa03f04
VZ
3868typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&);
3869typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&);
c801d85f 3870typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
c801d85f
KB
3871typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
3872typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&);
9bc13858 3873typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&);
98e78a5e 3874typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxMaximizeEvent&);
81d66cf3 3875typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&);
f7bd2698
JS
3876typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&);
3877typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&);
43b5058d
VZ
3878typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&);
3879typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&);
3880typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
669f7a11 3881typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&);
b96340e6 3882typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&);
69231000 3883typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
a5e84126 3884typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&);
63e819f2 3885typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&);
78c91815 3886typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&);
7fa03f04 3887
7fa03f04
VZ
3888
3889#define wxCommandEventHandler(func) \
3c778901 3890 wxEVENT_HANDLER_CAST(wxCommandEventFunction, func)
7fa03f04 3891#define wxScrollEventHandler(func) \
3c778901 3892 wxEVENT_HANDLER_CAST(wxScrollEventFunction, func)
7fa03f04 3893#define wxScrollWinEventHandler(func) \
3c778901 3894 wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func)
7fa03f04 3895#define wxSizeEventHandler(func) \
3c778901 3896 wxEVENT_HANDLER_CAST(wxSizeEventFunction, func)
7fa03f04 3897#define wxMoveEventHandler(func) \
3c778901 3898 wxEVENT_HANDLER_CAST(wxMoveEventFunction, func)
7fa03f04 3899#define wxPaintEventHandler(func) \
3c778901 3900 wxEVENT_HANDLER_CAST(wxPaintEventFunction, func)
7fa03f04 3901#define wxNcPaintEventHandler(func) \
3c778901 3902 wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func)
7fa03f04 3903#define wxEraseEventHandler(func) \
3c778901 3904 wxEVENT_HANDLER_CAST(wxEraseEventFunction, func)
7fa03f04 3905#define wxMouseEventHandler(func) \
3c778901 3906 wxEVENT_HANDLER_CAST(wxMouseEventFunction, func)
7fa03f04 3907#define wxCharEventHandler(func) \
3c778901 3908 wxEVENT_HANDLER_CAST(wxCharEventFunction, func)
7fa03f04
VZ
3909#define wxKeyEventHandler(func) wxCharEventHandler(func)
3910#define wxFocusEventHandler(func) \
3c778901 3911 wxEVENT_HANDLER_CAST(wxFocusEventFunction, func)
7fa03f04 3912#define wxChildFocusEventHandler(func) \
3c778901 3913 wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func)
7fa03f04 3914#define wxActivateEventHandler(func) \
3c778901 3915 wxEVENT_HANDLER_CAST(wxActivateEventFunction, func)
7fa03f04 3916#define wxMenuEventHandler(func) \
3c778901 3917 wxEVENT_HANDLER_CAST(wxMenuEventFunction, func)
7fa03f04 3918#define wxJoystickEventHandler(func) \
3c778901 3919 wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func)
7fa03f04 3920#define wxDropFilesEventHandler(func) \
3c778901 3921 wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func)
7fa03f04 3922#define wxInitDialogEventHandler(func) \
3c778901 3923 wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func)
7fa03f04 3924#define wxSysColourChangedEventHandler(func) \
3c778901 3925 wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func)
7fa03f04 3926#define wxDisplayChangedEventHandler(func) \
3c778901 3927 wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func)
7fa03f04 3928#define wxUpdateUIEventHandler(func) \
3c778901 3929 wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func)
7fa03f04 3930#define wxCloseEventHandler(func) \
3c778901 3931 wxEVENT_HANDLER_CAST(wxCloseEventFunction, func)
7fa03f04 3932#define wxShowEventHandler(func) \
3c778901 3933 wxEVENT_HANDLER_CAST(wxShowEventFunction, func)
7fa03f04 3934#define wxIconizeEventHandler(func) \
3c778901 3935 wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func)
7fa03f04 3936#define wxMaximizeEventHandler(func) \
3c778901 3937 wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func)
7fa03f04 3938#define wxNavigationKeyEventHandler(func) \
3c778901 3939 wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func)
7fa03f04 3940#define wxPaletteChangedEventHandler(func) \
3c778901 3941 wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func)
7fa03f04 3942#define wxQueryNewPaletteEventHandler(func) \
3c778901 3943 wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func)
7fa03f04 3944#define wxWindowCreateEventHandler(func) \
3c778901 3945 wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func)
7fa03f04 3946#define wxWindowDestroyEventHandler(func) \
3c778901 3947 wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func)
7fa03f04 3948#define wxSetCursorEventHandler(func) \
3c778901 3949 wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func)
7fa03f04 3950#define wxNotifyEventHandler(func) \
3c778901 3951 wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func)
7fa03f04 3952#define wxHelpEventHandler(func) \
3c778901 3953 wxEVENT_HANDLER_CAST(wxHelpEventFunction, func)
7fa03f04 3954#define wxContextMenuEventHandler(func) \
3c778901 3955 wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func)
7fa03f04 3956#define wxMouseCaptureChangedEventHandler(func) \
3c778901 3957 wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func)
63e819f2 3958#define wxMouseCaptureLostEventHandler(func) \
3c778901 3959 wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func)
78c91815 3960#define wxClipboardTextEventHandler(func) \
3c778901 3961 wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func)
7fa03f04 3962
e90c1d2a 3963#endif // wxUSE_GUI
c801d85f
KB
3964
3965// N.B. In GNU-WIN32, you *have* to take the address of a member function
3966// (use &) or the compiler crashes...
3967
a0e9a5df
FM
3968#define wxDECLARE_EVENT_TABLE() \
3969 private: \
3970 static const wxEventTableEntry sm_eventTableEntries[]; \
3971 protected: \
3972 static const wxEventTable sm_eventTable; \
3973 virtual const wxEventTable* GetEventTable() const; \
3974 static wxEventHashTable sm_eventHashTable; \
3975 virtual wxEventHashTable& GetEventHashTable() const
c801d85f 3976
48276300
VZ
3977// N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize
3978// sm_eventTable before using it in GetEventTable() or the compiler gives
3979// E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews)
b5a98acd 3980
a0e9a5df 3981#define wxBEGIN_EVENT_TABLE(theClass, baseClass) \
2e4df4bf
VZ
3982 const wxEventTable theClass::sm_eventTable = \
3983 { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \
48276300
VZ
3984 const wxEventTable *theClass::GetEventTable() const \
3985 { return &theClass::sm_eventTable; } \
b5a98acd
VZ
3986 wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
3987 wxEventHashTable &theClass::GetEventHashTable() const \
3988 { return theClass::sm_eventHashTable; } \
2e4df4bf 3989 const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
c801d85f 3990
a0e9a5df 3991#define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \
f96a9d34
JS
3992 template<typename T1> \
3993 const wxEventTable theClass<T1>::sm_eventTable = \
3994 { &baseClass::sm_eventTable, &theClass<T1>::sm_eventTableEntries[0] }; \
3995 template<typename T1> \
3996 const wxEventTable *theClass<T1>::GetEventTable() const \
3997 { return &theClass<T1>::sm_eventTable; } \
3998 template<typename T1> \
3999 wxEventHashTable theClass<T1>::sm_eventHashTable(theClass<T1>::sm_eventTable); \
4000 template<typename T1> \
4001 wxEventHashTable &theClass<T1>::GetEventHashTable() const \
4002 { return theClass<T1>::sm_eventHashTable; } \
4003 template<typename T1> \
4004 const wxEventTableEntry theClass<T1>::sm_eventTableEntries[] = { \
4005
a0e9a5df 4006#define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \
f96a9d34
JS
4007 template<typename T1, typename T2> \
4008 const wxEventTable theClass<T1, T2>::sm_eventTable = \
4009 { &baseClass::sm_eventTable, &theClass<T1, T2>::sm_eventTableEntries[0] }; \
4010 template<typename T1, typename T2> \
4011 const wxEventTable *theClass<T1, T2>::GetEventTable() const \
4012 { return &theClass<T1, T2>::sm_eventTable; } \
4013 template<typename T1, typename T2> \
4014 wxEventHashTable theClass<T1, T2>::sm_eventHashTable(theClass<T1, T2>::sm_eventTable); \
4015 template<typename T1, typename T2> \
4016 wxEventHashTable &theClass<T1, T2>::GetEventHashTable() const \
4017 { return theClass<T1, T2>::sm_eventHashTable; } \
4018 template<typename T1, typename T2> \
4019 const wxEventTableEntry theClass<T1, T2>::sm_eventTableEntries[] = { \
4020
a0e9a5df 4021#define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \
f96a9d34
JS
4022 template<typename T1, typename T2, typename T3> \
4023 const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \
4024 { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \
4025 template<typename T1, typename T2, typename T3> \
4026 const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \
4027 { return &theClass<T1, T2, T3>::sm_eventTable; } \
4028 template<typename T1, typename T2, typename T3> \
4029 wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \
4030 template<typename T1, typename T2, typename T3> \
4031 wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \
4032 { return theClass<T1, T2, T3>::sm_eventHashTable; } \
4033 template<typename T1, typename T2, typename T3> \
4034 const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \
4035
a0e9a5df 4036#define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \
f96a9d34
JS
4037 template<typename T1, typename T2, typename T3, typename T4> \
4038 const wxEventTable theClass<T1, T2, T3, T4>::sm_eventTable = \
4039 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4>::sm_eventTableEntries[0] }; \
4040 template<typename T1, typename T2, typename T3, typename T4> \
4041 const wxEventTable *theClass<T1, T2, T3, T4>::GetEventTable() const \
4042 { return &theClass<T1, T2, T3, T4>::sm_eventTable; } \
4043 template<typename T1, typename T2, typename T3, typename T4> \
4044 wxEventHashTable theClass<T1, T2, T3, T4>::sm_eventHashTable(theClass<T1, T2, T3, T4>::sm_eventTable); \
4045 template<typename T1, typename T2, typename T3, typename T4> \
4046 wxEventHashTable &theClass<T1, T2, T3, T4>::GetEventHashTable() const \
4047 { return theClass<T1, T2, T3, T4>::sm_eventHashTable; } \
4048 template<typename T1, typename T2, typename T3, typename T4> \
4049 const wxEventTableEntry theClass<T1, T2, T3, T4>::sm_eventTableEntries[] = { \
4050
a0e9a5df 4051#define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \
f96a9d34
JS
4052 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4053 const wxEventTable theClass<T1, T2, T3, T4, T5>::sm_eventTable = \
4054 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[0] }; \
4055 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4056 const wxEventTable *theClass<T1, T2, T3, T4, T5>::GetEventTable() const \
4057 { return &theClass<T1, T2, T3, T4, T5>::sm_eventTable; } \
4058 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4059 wxEventHashTable theClass<T1, T2, T3, T4, T5>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5>::sm_eventTable); \
4060 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4061 wxEventHashTable &theClass<T1, T2, T3, T4, T5>::GetEventHashTable() const \
4062 { return theClass<T1, T2, T3, T4, T5>::sm_eventHashTable; } \
4063 template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4064 const wxEventTableEntry theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[] = { \
4065
a0e9a5df 4066#define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \
f96a9d34
JS
4067 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4068 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable = \
4069 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[0] }; \
4070 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4071 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventTable() const \
4072 { return &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable; } \
4073 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4074 wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable); \
4075 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4076 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventHashTable() const \
4077 { return theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable; } \
4078 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4079 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[] = { \
4080
a0e9a5df 4081#define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \
f96a9d34
JS
4082 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4083 const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable = \
4084 { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[0] }; \
4085 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4086 const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventTable() const \
4087 { return &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable; } \
4088 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4089 wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable); \
4090 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4091 wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventHashTable() const \
4092 { return theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable; } \
4093 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4094 const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[] = { \
4095
a0e9a5df
FM
4096#define wxEND_EVENT_TABLE() \
4097 wxDECLARE_EVENT_TABLE_TERMINATOR() };
2b854a32 4098
c801d85f
KB
4099/*
4100 * Event table macros
4101 */
4102
7fa03f04
VZ
4103// helpers for writing shorter code below: declare an event macro taking 2, 1
4104// or none ids (the missing ids default to wxID_ANY)
4105//
4106// macro arguments:
4107// - evt one of wxEVT_XXX constants
4108// - id1, id2 ids of the first/last id
4109// - fn the function (should be cast to the right type)
4110#define wx__DECLARE_EVT2(evt, id1, id2, fn) \
a0e9a5df 4111 wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
7fa03f04
VZ
4112#define wx__DECLARE_EVT1(evt, id, fn) \
4113 wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
4114#define wx__DECLARE_EVT0(evt, fn) \
4115 wx__DECLARE_EVT1(evt, wxID_ANY, fn)
4116
4117
c801d85f 4118// Generic events
7fa03f04
VZ
4119#define EVT_CUSTOM(event, winid, func) \
4120 wx__DECLARE_EVT1(event, winid, wxEventHandler(func))
4121#define EVT_CUSTOM_RANGE(event, id1, id2, func) \
4122 wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func))
c801d85f 4123
265accbe 4124// EVT_COMMAND
96eb51bb 4125#define EVT_COMMAND(winid, event, func) \
7fa03f04 4126 wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func))
3c778901 4127
96eb51bb 4128#define EVT_COMMAND_RANGE(id1, id2, event, func) \
7fa03f04 4129 wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func))
265accbe 4130
7fa03f04
VZ
4131#define EVT_NOTIFY(event, winid, func) \
4132 wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func))
3c778901 4133
7fa03f04
VZ
4134#define EVT_NOTIFY_RANGE(event, id1, id2, func) \
4135 wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func))
265accbe 4136
c801d85f 4137// Miscellaneous
7fa03f04
VZ
4138#define EVT_SIZE(func) wx__DECLARE_EVT0(wxEVT_SIZE, wxSizeEventHandler(func))
4139#define EVT_SIZING(func) wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func))
4140#define EVT_MOVE(func) wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func))
4141#define EVT_MOVING(func) wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func))
aa767a45
JS
4142#define EVT_MOVE_START(func) wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func))
4143#define EVT_MOVE_END(func) wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func))
7fa03f04
VZ
4144#define EVT_CLOSE(func) wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))
4145#define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4146#define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4147#define EVT_PAINT(func) wx__DECLARE_EVT0(wxEVT_PAINT, wxPaintEventHandler(func))
4148#define EVT_NC_PAINT(func) wx__DECLARE_EVT0(wxEVT_NC_PAINT, wxNcPaintEventHandler(func))
4149#define EVT_ERASE_BACKGROUND(func) wx__DECLARE_EVT0(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(func))
4150#define EVT_CHAR(func) wx__DECLARE_EVT0(wxEVT_CHAR, wxCharEventHandler(func))
4151#define EVT_KEY_DOWN(func) wx__DECLARE_EVT0(wxEVT_KEY_DOWN, wxKeyEventHandler(func))
4152#define EVT_KEY_UP(func) wx__DECLARE_EVT0(wxEVT_KEY_UP, wxKeyEventHandler(func))
5048c832 4153#if wxUSE_HOTKEY
7fa03f04 4154#define EVT_HOTKEY(winid, func) wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func))
5048c832 4155#endif
7fa03f04
VZ
4156#define EVT_CHAR_HOOK(func) wx__DECLARE_EVT0(wxEVT_CHAR_HOOK, wxCharEventHandler(func))
4157#define EVT_MENU_OPEN(func) wx__DECLARE_EVT0(wxEVT_MENU_OPEN, wxMenuEventHandler(func))
4158#define EVT_MENU_CLOSE(func) wx__DECLARE_EVT0(wxEVT_MENU_CLOSE, wxMenuEventHandler(func))
4159#define EVT_MENU_HIGHLIGHT(winid, func) wx__DECLARE_EVT1(wxEVT_MENU_HIGHLIGHT, winid, wxMenuEventHandler(func))
4160#define EVT_MENU_HIGHLIGHT_ALL(func) wx__DECLARE_EVT0(wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler(func))
4161#define EVT_SET_FOCUS(func) wx__DECLARE_EVT0(wxEVT_SET_FOCUS, wxFocusEventHandler(func))
4162#define EVT_KILL_FOCUS(func) wx__DECLARE_EVT0(wxEVT_KILL_FOCUS, wxFocusEventHandler(func))
4163#define EVT_CHILD_FOCUS(func) wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func))
4164#define EVT_ACTIVATE(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func))
4165#define EVT_ACTIVATE_APP(func) wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func))
afafd942 4166#define EVT_HIBERNATE(func) wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func))
7fa03f04
VZ
4167#define EVT_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4168#define EVT_QUERY_END_SESSION(func) wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4169#define EVT_DROP_FILES(func) wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func))
4170#define EVT_INIT_DIALOG(func) wx__DECLARE_EVT0(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(func))
4171#define EVT_SYS_COLOUR_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler(func))
4172#define EVT_DISPLAY_CHANGED(func) wx__DECLARE_EVT0(wxEVT_DISPLAY_CHANGED, wxDisplayChangedEventHandler(func))
4173#define EVT_SHOW(func) wx__DECLARE_EVT0(wxEVT_SHOW, wxShowEventHandler(func))
4174#define EVT_MAXIMIZE(func) wx__DECLARE_EVT0(wxEVT_MAXIMIZE, wxMaximizeEventHandler(func))
4175#define EVT_ICONIZE(func) wx__DECLARE_EVT0(wxEVT_ICONIZE, wxIconizeEventHandler(func))
4176#define EVT_NAVIGATION_KEY(func) wx__DECLARE_EVT0(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(func))
4177#define EVT_PALETTE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_PALETTE_CHANGED, wxPaletteChangedEventHandler(func))
4178#define EVT_QUERY_NEW_PALETTE(func) wx__DECLARE_EVT0(wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEventHandler(func))
4179#define EVT_WINDOW_CREATE(func) wx__DECLARE_EVT0(wxEVT_CREATE, wxWindowCreateEventHandler(func))
4180#define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func))
4181#define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func))
4182#define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func))
63e819f2 4183#define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func))
c801d85f
KB
4184
4185// Mouse events
7fa03f04
VZ
4186#define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func))
4187#define EVT_LEFT_UP(func) wx__DECLARE_EVT0(wxEVT_LEFT_UP, wxMouseEventHandler(func))
4188#define EVT_MIDDLE_DOWN(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(func))
4189#define EVT_MIDDLE_UP(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_UP, wxMouseEventHandler(func))
4190#define EVT_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DOWN, wxMouseEventHandler(func))
4191#define EVT_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_RIGHT_UP, wxMouseEventHandler(func))
4192#define EVT_MOTION(func) wx__DECLARE_EVT0(wxEVT_MOTION, wxMouseEventHandler(func))
4193#define EVT_LEFT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_LEFT_DCLICK, wxMouseEventHandler(func))
4194#define EVT_MIDDLE_DCLICK(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(func))
4195#define EVT_RIGHT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(func))
4196#define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func))
4197#define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func))
4198#define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func))
01101e2d
VZ
4199#define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func))
4200#define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func))
4201#define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func))
4202#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
4203#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
4204#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
c801d85f
KB
4205
4206// All mouse events
4207#define EVT_MOUSE_EVENTS(func) \
7fa03f04
VZ
4208 EVT_LEFT_DOWN(func) \
4209 EVT_LEFT_UP(func) \
01101e2d 4210 EVT_LEFT_DCLICK(func) \
7fa03f04
VZ
4211 EVT_MIDDLE_DOWN(func) \
4212 EVT_MIDDLE_UP(func) \
01101e2d 4213 EVT_MIDDLE_DCLICK(func) \
7fa03f04
VZ
4214 EVT_RIGHT_DOWN(func) \
4215 EVT_RIGHT_UP(func) \
7fa03f04 4216 EVT_RIGHT_DCLICK(func) \
01101e2d
VZ
4217 EVT_MOUSE_AUX1_DOWN(func) \
4218 EVT_MOUSE_AUX1_UP(func) \
4219 EVT_MOUSE_AUX1_DCLICK(func) \
4220 EVT_MOUSE_AUX2_DOWN(func) \
4221 EVT_MOUSE_AUX2_UP(func) \
4222 EVT_MOUSE_AUX2_DCLICK(func) \
4223 EVT_MOTION(func) \
7fa03f04
VZ
4224 EVT_LEAVE_WINDOW(func) \
4225 EVT_ENTER_WINDOW(func) \
4226 EVT_MOUSEWHEEL(func)
c801d85f 4227
c5b42c87 4228// Scrolling from wxWindow (sent to wxScrolledWindow)
7fa03f04
VZ
4229#define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
4230#define EVT_SCROLLWIN_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(func))
4231#define EVT_SCROLLWIN_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(func))
4232#define EVT_SCROLLWIN_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(func))
4233#define EVT_SCROLLWIN_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(func))
4234#define EVT_SCROLLWIN_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(func))
4235#define EVT_SCROLLWIN_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(func))
4236#define EVT_SCROLLWIN_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(func))
4237
c5b42c87 4238#define EVT_SCROLLWIN(func) \
7fa03f04
VZ
4239 EVT_SCROLLWIN_TOP(func) \
4240 EVT_SCROLLWIN_BOTTOM(func) \
4241 EVT_SCROLLWIN_LINEUP(func) \
4242 EVT_SCROLLWIN_LINEDOWN(func) \
4243 EVT_SCROLLWIN_PAGEUP(func) \
4244 EVT_SCROLLWIN_PAGEDOWN(func) \
4245 EVT_SCROLLWIN_THUMBTRACK(func) \
4246 EVT_SCROLLWIN_THUMBRELEASE(func)
c5b42c87
RR
4247
4248// Scrolling from wxSlider and wxScrollBar
7fa03f04
VZ
4249#define EVT_SCROLL_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_TOP, wxScrollEventHandler(func))
4250#define EVT_SCROLL_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(func))
4251#define EVT_SCROLL_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(func))
4252#define EVT_SCROLL_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(func))
4253#define EVT_SCROLL_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(func))
4254#define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func))
4255#define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func))
4256#define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func))
cbc85508 4257#define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func))
7fa03f04 4258
c801d85f 4259#define EVT_SCROLL(func) \
7fa03f04
VZ
4260 EVT_SCROLL_TOP(func) \
4261 EVT_SCROLL_BOTTOM(func) \
4262 EVT_SCROLL_LINEUP(func) \
4263 EVT_SCROLL_LINEDOWN(func) \
4264 EVT_SCROLL_PAGEUP(func) \
4265 EVT_SCROLL_PAGEDOWN(func) \
4266 EVT_SCROLL_THUMBTRACK(func) \
e8739575 4267 EVT_SCROLL_THUMBRELEASE(func) \
84006e65 4268 EVT_SCROLL_CHANGED(func)
c801d85f 4269
c5b42c87 4270// Scrolling from wxSlider and wxScrollBar, with an id
7fa03f04
VZ
4271#define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func))
4272#define EVT_COMMAND_SCROLL_BOTTOM(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_BOTTOM, winid, wxScrollEventHandler(func))
4273#define EVT_COMMAND_SCROLL_LINEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxScrollEventHandler(func))
4274#define EVT_COMMAND_SCROLL_LINEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxScrollEventHandler(func))
4275#define EVT_COMMAND_SCROLL_PAGEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEUP, winid, wxScrollEventHandler(func))
4276#define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func))
4277#define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func))
4278#define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func))
cbc85508 4279#define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func))
7fa03f04 4280
d9e2e4c2 4281#define EVT_COMMAND_SCROLL(winid, func) \
7fa03f04
VZ
4282 EVT_COMMAND_SCROLL_TOP(winid, func) \
4283 EVT_COMMAND_SCROLL_BOTTOM(winid, func) \
4284 EVT_COMMAND_SCROLL_LINEUP(winid, func) \
4285 EVT_COMMAND_SCROLL_LINEDOWN(winid, func) \
4286 EVT_COMMAND_SCROLL_PAGEUP(winid, func) \
4287 EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \
4288 EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \
e8739575 4289 EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \
84006e65 4290 EVT_COMMAND_SCROLL_CHANGED(winid, func)
cbc85508 4291
ca3e85cf
WS
4292#if WXWIN_COMPATIBILITY_2_6
4293 // compatibility macros for the old name, deprecated in 2.8
4294 #define wxEVT_SCROLL_ENDSCROLL wxEVT_SCROLL_CHANGED
4295 #define EVT_COMMAND_SCROLL_ENDSCROLL EVT_COMMAND_SCROLL_CHANGED
4296 #define EVT_SCROLL_ENDSCROLL EVT_SCROLL_CHANGED
4297#endif // WXWIN_COMPATIBILITY_2_6
c801d85f
KB
4298
4299// Convenience macros for commonly-used commands
ce7fe42e
VZ
4300#define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKBOX, winid, wxCommandEventHandler(func))
4301#define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_CHOICE, winid, wxCommandEventHandler(func))
4302#define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX, winid, wxCommandEventHandler(func))
4303#define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX_DCLICK, winid, wxCommandEventHandler(func))
4304#define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_MENU, winid, wxCommandEventHandler(func))
4305#define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_MENU, id1, id2, wxCommandEventHandler(func))
119727ad 4306#if defined(__SMARTPHONE__)
7fa03f04 4307# define EVT_BUTTON(winid, func) EVT_MENU(winid, func)
119727ad 4308#else
ce7fe42e 4309# define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_BUTTON, winid, wxCommandEventHandler(func))
119727ad 4310#endif
ce7fe42e
VZ
4311#define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_SLIDER, winid, wxCommandEventHandler(func))
4312#define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBOX, winid, wxCommandEventHandler(func))
4313#define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBUTTON, winid, wxCommandEventHandler(func))
c801d85f 4314// EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events
ce7fe42e
VZ
4315#define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLLBAR, winid, wxCommandEventHandler(func))
4316#define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_VLBOX, winid, wxCommandEventHandler(func))
4317#define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX, winid, wxCommandEventHandler(func))
4318#define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL, winid, wxCommandEventHandler(func))
4319#define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_DROPDOWN, winid, wxCommandEventHandler(func))
4320#define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL, id1, id2, wxCommandEventHandler(func))
4321#define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func))
4322#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
4323#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func))
4324#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func))
4325#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func))
4326#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func))
c801d85f
KB
4327
4328// Generic command events
7fa03f04
VZ
4329#define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))
4330#define EVT_COMMAND_LEFT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_DCLICK, winid, wxCommandEventHandler(func))
4331#define EVT_COMMAND_RIGHT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_CLICK, winid, wxCommandEventHandler(func))
4332#define EVT_COMMAND_RIGHT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_DCLICK, winid, wxCommandEventHandler(func))
4333#define EVT_COMMAND_SET_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SET_FOCUS, winid, wxCommandEventHandler(func))
4334#define EVT_COMMAND_KILL_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_KILL_FOCUS, winid, wxCommandEventHandler(func))
4335#define EVT_COMMAND_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_ENTER, winid, wxCommandEventHandler(func))
c801d85f
KB
4336
4337// Joystick events
1241ab8b 4338
7fa03f04
VZ
4339#define EVT_JOY_BUTTON_DOWN(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_DOWN, wxJoystickEventHandler(func))
4340#define EVT_JOY_BUTTON_UP(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_UP, wxJoystickEventHandler(func))
4341#define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func))
4342#define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func))
c801d85f
KB
4343
4344// All joystick events
4345#define EVT_JOYSTICK_EVENTS(func) \
7fa03f04
VZ
4346 EVT_JOY_BUTTON_DOWN(func) \
4347 EVT_JOY_BUTTON_UP(func) \
4348 EVT_JOY_MOVE(func) \
4349 EVT_JOY_ZMOVE(func)
c801d85f
KB
4350
4351// Idle event
7fa03f04 4352#define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func))
c801d85f
KB
4353
4354// Update UI event
7fa03f04
VZ
4355#define EVT_UPDATE_UI(winid, func) wx__DECLARE_EVT1(wxEVT_UPDATE_UI, winid, wxUpdateUIEventHandler(func))
4356#define EVT_UPDATE_UI_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_UPDATE_UI, id1, id2, wxUpdateUIEventHandler(func))
c801d85f 4357
b96340e6 4358// Help events
7fa03f04
VZ
4359#define EVT_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_HELP, winid, wxHelpEventHandler(func))
4360#define EVT_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_HELP, id1, id2, wxHelpEventHandler(func))
4361#define EVT_DETAILED_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_DETAILED_HELP, winid, wxHelpEventHandler(func))
4362#define EVT_DETAILED_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_DETAILED_HELP, id1, id2, wxHelpEventHandler(func))
fb6261e9 4363
69231000 4364// Context Menu Events
7fa03f04 4365#define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func))
5cd2a6ae 4366#define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func))
69231000 4367
78c91815 4368// Clipboard text Events
ce7fe42e
VZ
4369#define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_CUT, winid, wxClipboardTextEventHandler(func))
4370#define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_COPY, winid, wxClipboardTextEventHandler(func))
4371#define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_PASTE, winid, wxClipboardTextEventHandler(func))
78c91815 4372
d48b06bd 4373// Thread events
c1b293bb 4374#define EVT_THREAD(id, func) wx__DECLARE_EVT1(wxEVT_THREAD, id, wxThreadEventHandler(func))
d48b06bd 4375
e90c1d2a
VZ
4376// ----------------------------------------------------------------------------
4377// Helper functions
4378// ----------------------------------------------------------------------------
4379
23172836
VZ
4380// This is an ugly hack to allow the use of Bind() instead of Connect() inside
4381// the library code if the library was built with support for it, here is how
4382// it is used:
4383//
4384// class SomeEventHandlingClass : wxBIND_OR_CONNECT_HACK_BASE_CLASS
4385// public SomeBaseClass
4386// {
4387// public:
4388// SomeEventHandlingClass(wxWindow *win)
4389// {
4390// // connect to the event for the given window
4391// wxBIND_OR_CONNECT_HACK(win, wxEVT_SOMETHING, wxSomeEventHandler,
4392// SomeEventHandlingClass::OnSomeEvent, this);
4393// }
4394//
4395// private:
4396// void OnSomeEvent(wxSomeEvent&) { ... }
4397// };
4398//
4399// This is *not* meant to be used by library users, it is only defined here
4400// (and not in a private header) because the base class must be visible from
4401// other public headers, please do NOT use this in your code, it will be
4402// removed from future wx versions without warning.
54a9471a 4403#ifdef wxHAS_EVENT_BIND
23172836
VZ
4404 #define wxBIND_OR_CONNECT_HACK_BASE_CLASS
4405 #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS
03ef5fef 4406 #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \
23172836 4407 win->Bind(evt, &func, obj)
54a9471a
VZ
4408#else // wxHAS_EVENT_BIND
4409 #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler,
4410 #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler
03ef5fef 4411 #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \
54a9471a 4412 win->Connect(evt, handler(func), NULL, obj)
890d70eb 4413#endif // wxHAS_EVENT_BIND
23172836 4414
e90c1d2a 4415#if wxUSE_GUI
e702ff0f
JS
4416
4417// Find a window with the focus, that is also a descendant of the given window.
4418// This is used to determine the window to initially send commands to.
9f8b9d9c 4419WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor);
e702ff0f 4420
e90c1d2a
VZ
4421#endif // wxUSE_GUI
4422
a0e9a5df
FM
4423
4424// ----------------------------------------------------------------------------
4425// Compatibility macro aliases
4426// ----------------------------------------------------------------------------
4427
4428// deprecated variants _not_ requiring a semicolon after them and without wx prefix
4429// (note that also some wx-prefixed macro do _not_ require a semicolon because
4430// it's not always possible to force the compire to require it)
4431
4432#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
4433 wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj)
4434#define DECLARE_EVENT_TABLE_TERMINATOR() wxDECLARE_EVENT_TABLE_TERMINATOR()
4435#define DECLARE_EVENT_TABLE() wxDECLARE_EVENT_TABLE();
4436#define BEGIN_EVENT_TABLE(a,b) wxBEGIN_EVENT_TABLE(a,b)
4437#define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c)
4cf8e24b
VZ
4438#define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) wxBEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d)
4439#define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) wxBEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e)
4440#define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) wxBEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f)
4441#define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) wxBEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g)
4442#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)
a0e9a5df
FM
4443#define END_EVENT_TABLE() wxEND_EVENT_TABLE()
4444
4445// other obsolete event declaration/definition macros; we don't need them any longer
4446// but we keep them for compatibility as it doesn't cost us anything anyhow
4447#define BEGIN_DECLARE_EVENT_TYPES()
4448#define END_DECLARE_EVENT_TYPES()
4449#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
4450 extern expdecl const wxEventType name;
4451#define DECLARE_EVENT_TYPE(name, value) \
4452 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
4453#define DECLARE_LOCAL_EVENT_TYPE(name, value) \
4454 DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value)
4455#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
4456#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name)
4457
ce7fe42e
VZ
4458// alias for backward compatibility with 2.9.0:
4459#define wxEVT_COMMAND_THREAD wxEVT_THREAD
4460// other old wxEVT_COMMAND_* constants
4461#define wxEVT_COMMAND_BUTTON_CLICKED wxEVT_BUTTON
4462#define wxEVT_COMMAND_CHECKBOX_CLICKED wxEVT_CHECKBOX
4463#define wxEVT_COMMAND_CHOICE_SELECTED wxEVT_CHOICE
4464#define wxEVT_COMMAND_LISTBOX_SELECTED wxEVT_LISTBOX
4465#define wxEVT_COMMAND_LISTBOX_DOUBLECLICKED wxEVT_LISTBOX_DCLICK
4466#define wxEVT_COMMAND_CHECKLISTBOX_TOGGLED wxEVT_CHECKLISTBOX
4467#define wxEVT_COMMAND_MENU_SELECTED wxEVT_MENU
4468#define wxEVT_COMMAND_TOOL_CLICKED wxEVT_TOOL
4469#define wxEVT_COMMAND_SLIDER_UPDATED wxEVT_SLIDER
4470#define wxEVT_COMMAND_RADIOBOX_SELECTED wxEVT_RADIOBOX
4471#define wxEVT_COMMAND_RADIOBUTTON_SELECTED wxEVT_RADIOBUTTON
4472#define wxEVT_COMMAND_SCROLLBAR_UPDATED wxEVT_SCROLLBAR
4473#define wxEVT_COMMAND_VLBOX_SELECTED wxEVT_VLBOX
4474#define wxEVT_COMMAND_COMBOBOX_SELECTED wxEVT_COMBOBOX
4475#define wxEVT_COMMAND_TOOL_RCLICKED wxEVT_TOOL_RCLICKED
4476#define wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED wxEVT_TOOL_DROPDOWN
4477#define wxEVT_COMMAND_TOOL_ENTER wxEVT_TOOL_ENTER
4478#define wxEVT_COMMAND_COMBOBOX_DROPDOWN wxEVT_COMBOBOX_DROPDOWN
4479#define wxEVT_COMMAND_COMBOBOX_CLOSEUP wxEVT_COMBOBOX_CLOSEUP
4480#define wxEVT_COMMAND_TEXT_COPY wxEVT_TEXT_COPY
4481#define wxEVT_COMMAND_TEXT_CUT wxEVT_TEXT_CUT
4482#define wxEVT_COMMAND_TEXT_PASTE wxEVT_TEXT_PASTE
4483#define wxEVT_COMMAND_TEXT_UPDATED wxEVT_TEXT
4484
204abcd4 4485#endif // _WX_EVENT_H_