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