Coverage Report

Created: 2025-09-27 06:14

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