Coverage Report

Created: 2026-02-14 06:52

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
    {
1750
        m_commandInt = event.m_commandInt;
1751
        m_extraLong = event.m_extraLong;
1752
        m_pixelOffset = event.m_pixelOffset;
1753
    }
1754
1755
    int GetOrientation() const { return (int) m_extraLong; }
1756
    int GetPosition() const { return m_commandInt; }
1757
    int GetPixelOffset() const { return m_pixelOffset; }
1758
    void SetOrientation(int orient) { m_extraLong = (long) orient; }
1759
    void SetPosition(int pos) { m_commandInt = pos; }
1760
    void SetPixelOffset(int pixelOffset) { m_pixelOffset = pixelOffset; }
1761
1762
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxScrollWinEvent(*this); }
1763
1764
protected:
1765
    int               m_commandInt;
1766
    long              m_extraLong;
1767
    int               m_pixelOffset;
1768
1769
private:
1770
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxScrollWinEvent);
1771
};
1772
1773
1774
1775
// Mouse event class
1776
1777
/*
1778
 wxEVT_LEFT_DOWN
1779
 wxEVT_LEFT_UP
1780
 wxEVT_MIDDLE_DOWN
1781
 wxEVT_MIDDLE_UP
1782
 wxEVT_RIGHT_DOWN
1783
 wxEVT_RIGHT_UP
1784
 wxEVT_MOTION
1785
 wxEVT_ENTER_WINDOW
1786
 wxEVT_LEAVE_WINDOW
1787
 wxEVT_LEFT_DCLICK
1788
 wxEVT_MIDDLE_DCLICK
1789
 wxEVT_RIGHT_DCLICK
1790
*/
1791
1792
enum wxMouseWheelAxis
1793
{
1794
    wxMOUSE_WHEEL_VERTICAL,
1795
    wxMOUSE_WHEEL_HORIZONTAL
1796
};
1797
1798
class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent,
1799
                                      public wxMouseState
1800
{
1801
public:
1802
    wxMouseEvent(wxEventType mouseType = wxEVT_NULL);
1803
    wxMouseEvent(const wxMouseEvent& event)
1804
        : wxEvent(event),
1805
          wxMouseState(event)
1806
    {
1807
        Assign(event);
1808
    }
1809
1810
    // Was it a button event? (*doesn't* mean: is any button *down*?)
1811
    bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
1812
1813
    // Was it a down event from this (or any) button?
1814
    bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
1815
1816
    // Was it a dclick event from this (or any) button?
1817
    bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
1818
1819
    // Was it a up event from this (or any) button?
1820
    bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
1821
1822
    // Was this event generated by the given button?
1823
    bool Button(int but) const;
1824
1825
    // Get the button which is changing state (wxMOUSE_BTN_NONE if none)
1826
    int GetButton() const;
1827
1828
    // Find which event was just generated
1829
    bool LeftDown() const { return (m_eventType == wxEVT_LEFT_DOWN); }
1830
    bool MiddleDown() const { return (m_eventType == wxEVT_MIDDLE_DOWN); }
1831
    bool RightDown() const { return (m_eventType == wxEVT_RIGHT_DOWN); }
1832
    bool Aux1Down() const { return (m_eventType == wxEVT_AUX1_DOWN); }
1833
    bool Aux2Down() const { return (m_eventType == wxEVT_AUX2_DOWN); }
1834
1835
    bool LeftUp() const { return (m_eventType == wxEVT_LEFT_UP); }
1836
    bool MiddleUp() const { return (m_eventType == wxEVT_MIDDLE_UP); }
1837
    bool RightUp() const { return (m_eventType == wxEVT_RIGHT_UP); }
1838
    bool Aux1Up() const { return (m_eventType == wxEVT_AUX1_UP); }
1839
    bool Aux2Up() const { return (m_eventType == wxEVT_AUX2_UP); }
1840
1841
    bool LeftDClick() const { return (m_eventType == wxEVT_LEFT_DCLICK); }
1842
    bool MiddleDClick() const { return (m_eventType == wxEVT_MIDDLE_DCLICK); }
1843
    bool RightDClick() const { return (m_eventType == wxEVT_RIGHT_DCLICK); }
1844
    bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); }
1845
    bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
1846
1847
    bool Magnify() const { return (m_eventType == wxEVT_MAGNIFY); }
1848
1849
    // True if a button is down and the mouse is moving
1850
    bool Dragging() const
1851
    {
1852
        return (m_eventType == wxEVT_MOTION) && ButtonIsDown(wxMOUSE_BTN_ANY);
1853
    }
1854
1855
    // True if the mouse is moving, and no button is down
1856
    bool Moving() const
1857
    {
1858
        return (m_eventType == wxEVT_MOTION) && !ButtonIsDown(wxMOUSE_BTN_ANY);
1859
    }
1860
1861
    // True if the mouse is just entering the window
1862
    bool Entering() const { return (m_eventType == wxEVT_ENTER_WINDOW); }
1863
1864
    // True if the mouse is just leaving the window
1865
    bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); }
1866
1867
    // Returns the number of mouse clicks associated with this event.
1868
    int GetClickCount() const { return m_clickCount; }
1869
1870
    // Find the logical position of the event given the DC
1871
    wxPoint GetLogicalPosition(const wxReadOnlyDC& dc) const;
1872
1873
    // Get wheel rotation, positive or negative indicates direction of
1874
    // rotation.  Current devices all send an event when rotation is equal to
1875
    // +/-WheelDelta, but this allows for finer resolution devices to be
1876
    // created in the future.  Because of this you shouldn't assume that one
1877
    // event is equal to 1 line or whatever, but you should be able to either
1878
    // do partial line scrolling or wait until +/-WheelDelta rotation values
1879
    // have been accumulated before scrolling.
1880
    int GetWheelRotation() const { return m_wheelRotation; }
1881
1882
    // Get wheel delta, normally 120.  This is the threshold for action to be
1883
    // taken, and one such action (for example, scrolling one increment)
1884
    // should occur for each delta.
1885
    int GetWheelDelta() const { return m_wheelDelta; }
1886
1887
    // On Mac, has the user selected "Natural" scrolling in their System
1888
    // Preferences? Currently false on all other OS's.
1889
    bool IsWheelInverted() const { return m_wheelInverted; }
1890
1891
    // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL
1892
    // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling
1893
    // using e.g. a trackpad).
1894
    wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; }
1895
1896
    // Returns the configured number of lines (or whatever) to be scrolled per
1897
    // wheel action. Defaults to three.
1898
    int GetLinesPerAction() const { return m_linesPerAction; }
1899
1900
    // Returns the configured number of columns (or whatever) to be scrolled per
1901
    // wheel action. Defaults to three.
1902
    int GetColumnsPerAction() const { return m_columnsPerAction; }
1903
1904
    // Is the system set to do page scrolling?
1905
    bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
1906
1907
    // Check if the event was synthesized from a touch event.
1908
    bool IsSynthesized() const { return m_synthesized; }
1909
1910
    float GetMagnification() const { return m_magnification; }
1911
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMouseEvent(*this); }
1912
    virtual wxEventCategory GetEventCategory() const override { return wxEVT_CATEGORY_USER_INPUT; }
1913
1914
    wxMouseEvent& operator=(const wxMouseEvent& event)
1915
    {
1916
        if (&event != this)
1917
            Assign(event);
1918
        return *this;
1919
    }
1920
1921
public:
1922
    int           m_clickCount;
1923
1924
    wxMouseWheelAxis m_wheelAxis;
1925
    int           m_wheelRotation;
1926
    int           m_wheelDelta;
1927
    bool          m_wheelInverted;
1928
    int           m_linesPerAction;
1929
    int           m_columnsPerAction;
1930
    float         m_magnification;
1931
    bool          m_synthesized;
1932
1933
protected:
1934
    void Assign(const wxMouseEvent& evt);
1935
1936
private:
1937
    wxDECLARE_DYNAMIC_CLASS(wxMouseEvent);
1938
};
1939
1940
// Cursor set event
1941
1942
/*
1943
   wxEVT_SET_CURSOR
1944
 */
1945
1946
class WXDLLIMPEXP_CORE wxSetCursorEvent : public wxEvent
1947
{
1948
public:
1949
    wxSetCursorEvent(wxCoord x = 0, wxCoord y = 0)
1950
        : wxEvent(0, wxEVT_SET_CURSOR),
1951
          m_x(x), m_y(y), m_cursor()
1952
        { }
1953
1954
    wxSetCursorEvent(const wxSetCursorEvent& event)
1955
        : wxEvent(event),
1956
          m_x(event.m_x),
1957
          m_y(event.m_y),
1958
          m_cursor(event.m_cursor)
1959
        { }
1960
1961
    wxPoint GetPosition() const { return wxPoint(m_x, m_y); }
1962
    wxCoord GetX() const { return m_x; }
1963
    wxCoord GetY() const { return m_y; }
1964
1965
    void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
1966
    const wxCursor& GetCursor() const { return m_cursor; }
1967
    bool HasCursor() const { return m_cursor.IsOk(); }
1968
1969
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxSetCursorEvent(*this); }
1970
1971
private:
1972
    wxCoord  m_x, m_y;
1973
    wxCursor m_cursor;
1974
1975
private:
1976
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSetCursorEvent);
1977
};
1978
1979
// MultiTouch Event
1980
1981
class wxTouchSequenceId : public wxItemId<void*>
1982
{
1983
public:
1984
    using wxItemId::wxItemId;
1985
};
1986
1987
class WXDLLIMPEXP_CORE wxMultiTouchEvent : public wxEvent
1988
{
1989
public:
1990
    wxMultiTouchEvent(wxWindowID winid = 0, wxEventType type = wxEVT_NULL)
1991
        : wxEvent(winid, type)
1992
    {
1993
    }
1994
1995
    wxMultiTouchEvent(const wxMultiTouchEvent& event) = default;
1996
1997
    const wxPoint2DDouble& GetPosition() const { return m_pos; }
1998
    void SetPosition(const wxPoint2DDouble& pos) { m_pos = pos; }
1999
    bool IsPrimary() const { return m_isPrimary; }
2000
    void SetPrimary(bool primary) { m_isPrimary = primary; }
2001
    const wxTouchSequenceId& GetSequenceId() const { return m_sequence; }
2002
    void SetSequenceId(const wxTouchSequenceId& sequence) { m_sequence = sequence; }
2003
2004
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMultiTouchEvent(*this); }
2005
2006
protected:
2007
    wxPoint2DDouble m_pos;
2008
    wxTouchSequenceId m_sequence;
2009
    bool m_isPrimary = false;
2010
2011
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMultiTouchEvent);
2012
2013
};
2014
2015
 // Gesture Event
2016
2017
const unsigned int wxTwoFingerTimeInterval = 200;
2018
2019
class WXDLLIMPEXP_CORE wxGestureEvent : public wxEvent
2020
{
2021
public:
2022
    wxGestureEvent(wxWindowID winid = 0, wxEventType type = wxEVT_NULL)
2023
        : wxEvent(winid, type)
2024
    {
2025
        m_isStart = false;
2026
        m_isEnd = false;
2027
    }
2028
2029
    wxGestureEvent(const wxGestureEvent& event) : wxEvent(event)
2030
        , m_pos(event.m_pos)
2031
    {
2032
        m_isStart = event.m_isStart;
2033
        m_isEnd = event.m_isEnd;
2034
    }
2035
2036
    const wxPoint& GetPosition() const { return m_pos; }
2037
    void SetPosition(const wxPoint& pos) { m_pos = pos; }
2038
    bool IsGestureStart() const { return m_isStart; }
2039
    void SetGestureStart(bool isStart = true) { m_isStart = isStart; }
2040
    bool IsGestureEnd() const { return m_isEnd; }
2041
    void SetGestureEnd(bool isEnd = true) { m_isEnd = isEnd; }
2042
2043
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxGestureEvent(*this); }
2044
2045
protected:
2046
    wxPoint m_pos;
2047
    bool m_isStart, m_isEnd;
2048
2049
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGestureEvent);
2050
2051
};
2052
2053
 // Pan Gesture Event
2054
2055
 /*
2056
  wxEVT_GESTURE_PAN
2057
  */
2058
2059
class WXDLLIMPEXP_CORE wxPanGestureEvent : public wxGestureEvent
2060
{
2061
public:
2062
    wxPanGestureEvent(wxWindowID winid = 0)
2063
        : wxGestureEvent(winid, wxEVT_GESTURE_PAN)
2064
    {
2065
    }
2066
2067
    wxPanGestureEvent(const wxPanGestureEvent& event)
2068
        : wxGestureEvent(event),
2069
          m_delta(event.m_delta)
2070
    {
2071
    }
2072
2073
    wxPoint GetDelta() const { return m_delta; }
2074
    void SetDelta(const wxPoint& delta) { m_delta = delta; }
2075
2076
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxPanGestureEvent(*this); }
2077
2078
private:
2079
    wxPoint m_delta;
2080
2081
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPanGestureEvent);
2082
};
2083
2084
 // Zoom Gesture Event
2085
2086
 /*
2087
  wxEVT_GESTURE_ZOOM
2088
  */
2089
2090
class WXDLLIMPEXP_CORE wxZoomGestureEvent : public wxGestureEvent
2091
{
2092
public:
2093
    wxZoomGestureEvent(wxWindowID winid = 0)
2094
        : wxGestureEvent(winid, wxEVT_GESTURE_ZOOM)
2095
        { m_zoomFactor = 1.0; }
2096
2097
    wxZoomGestureEvent(const wxZoomGestureEvent& event) : wxGestureEvent(event)
2098
    {
2099
        m_zoomFactor = event.m_zoomFactor;
2100
    }
2101
2102
    double GetZoomFactor() const { return m_zoomFactor; }
2103
    void SetZoomFactor(double zoomFactor) { m_zoomFactor = zoomFactor; }
2104
2105
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxZoomGestureEvent(*this); }
2106
2107
private:
2108
    double m_zoomFactor;
2109
2110
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxZoomGestureEvent);
2111
};
2112
2113
 // Rotate Gesture Event
2114
2115
 /*
2116
  wxEVT_GESTURE_ROTATE
2117
  */
2118
2119
class WXDLLIMPEXP_CORE wxRotateGestureEvent : public wxGestureEvent
2120
{
2121
public:
2122
    wxRotateGestureEvent(wxWindowID winid = 0)
2123
        : wxGestureEvent(winid, wxEVT_GESTURE_ROTATE)
2124
        { m_rotationAngle = 0.0; }
2125
2126
    wxRotateGestureEvent(const wxRotateGestureEvent& event) : wxGestureEvent(event)
2127
    {
2128
        m_rotationAngle = event.m_rotationAngle;
2129
    }
2130
2131
    double GetRotationAngle() const { return m_rotationAngle; }
2132
    void SetRotationAngle(double rotationAngle) { m_rotationAngle = rotationAngle; }
2133
2134
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxRotateGestureEvent(*this); }
2135
2136
private:
2137
    double m_rotationAngle;
2138
2139
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRotateGestureEvent);
2140
};
2141
2142
 // Two Finger Tap Gesture Event
2143
2144
 /*
2145
  wxEVT_TWO_FINGER_TAP
2146
  */
2147
2148
class WXDLLIMPEXP_CORE wxTwoFingerTapEvent : public wxGestureEvent
2149
{
2150
public:
2151
    wxTwoFingerTapEvent(wxWindowID winid = 0)
2152
        : wxGestureEvent(winid, wxEVT_TWO_FINGER_TAP)
2153
        { }
2154
2155
    wxTwoFingerTapEvent(const wxTwoFingerTapEvent& event) : wxGestureEvent(event)
2156
    { }
2157
2158
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxTwoFingerTapEvent(*this); }
2159
2160
private:
2161
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTwoFingerTapEvent);
2162
};
2163
2164
 // Long Press Gesture Event
2165
2166
 /*
2167
  wxEVT_LONG_PRESS
2168
  */
2169
2170
class WXDLLIMPEXP_CORE wxLongPressEvent : public wxGestureEvent
2171
{
2172
public:
2173
    wxLongPressEvent(wxWindowID winid = 0)
2174
        : wxGestureEvent(winid, wxEVT_LONG_PRESS)
2175
        { }
2176
2177
    wxLongPressEvent(const wxLongPressEvent& event) : wxGestureEvent(event)
2178
    { }
2179
2180
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxLongPressEvent(*this); }
2181
private:
2182
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxLongPressEvent);
2183
};
2184
2185
 // Press And Tap Gesture Event
2186
2187
 /*
2188
  wxEVT_PRESS_AND_TAP
2189
  */
2190
2191
class WXDLLIMPEXP_CORE wxPressAndTapEvent : public wxGestureEvent
2192
{
2193
public:
2194
    wxPressAndTapEvent(wxWindowID winid = 0)
2195
        : wxGestureEvent(winid, wxEVT_PRESS_AND_TAP)
2196
        { }
2197
2198
    wxPressAndTapEvent(const wxPressAndTapEvent& event) : wxGestureEvent(event)
2199
    { }
2200
2201
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxPressAndTapEvent(*this); }
2202
private:
2203
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPressAndTapEvent);
2204
};
2205
2206
// Keyboard input event class
2207
2208
/*
2209
 wxEVT_CHAR
2210
 wxEVT_CHAR_HOOK
2211
 wxEVT_KEY_DOWN
2212
 wxEVT_KEY_UP
2213
 wxEVT_HOTKEY
2214
 */
2215
2216
// key categories: the bit flags for IsKeyInCategory() function
2217
//
2218
// the enum values used may change in future version of wx
2219
// use the named constants only, or bitwise combinations thereof
2220
enum wxKeyCategoryFlags
2221
{
2222
    // arrow keys, on and off numeric keypads
2223
    WXK_CATEGORY_ARROW  = 1,
2224
2225
    // page up and page down keys, on and off numeric keypads
2226
    WXK_CATEGORY_PAGING = 2,
2227
2228
    // home and end keys, on and off numeric keypads
2229
    WXK_CATEGORY_JUMP   = 4,
2230
2231
    // tab key, on and off numeric keypads
2232
    WXK_CATEGORY_TAB    = 8,
2233
2234
    // backspace and delete keys, on and off numeric keypads
2235
    WXK_CATEGORY_CUT    = 16,
2236
2237
    // all keys usually used for navigation
2238
    WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW |
2239
                              WXK_CATEGORY_PAGING |
2240
                              WXK_CATEGORY_JUMP
2241
};
2242
2243
class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent,
2244
                                    public wxKeyboardState
2245
{
2246
public:
2247
    wxKeyEvent(wxEventType keyType = wxEVT_NULL);
2248
2249
    // Normal copy ctor and a ctor creating a new event for the same key as the
2250
    // given one but a different event type (this is used in implementation
2251
    // code only, do not use outside of the library).
2252
    wxKeyEvent(const wxKeyEvent& evt);
2253
    wxKeyEvent(wxEventType eventType, const wxKeyEvent& evt);
2254
2255
    // get the key code: an ASCII7 char or an element of wxKeyCode enum
2256
    int GetKeyCode() const { return (int)m_keyCode; }
2257
2258
    // returns true iff this event's key code is of a certain type
2259
    bool IsKeyInCategory(int category) const;
2260
2261
    // get the Unicode character corresponding to this key
2262
    wxChar GetUnicodeKey() const { return m_uniChar; }
2263
2264
    // get the raw key code (platform-dependent)
2265
    wxUint32 GetRawKeyCode() const { return m_rawCode; }
2266
2267
    // get the raw key flags (platform-dependent)
2268
    wxUint32 GetRawKeyFlags() const { return m_rawFlags; }
2269
2270
    // returns true if this is a key auto repeat event
2271
    bool IsAutoRepeat() const { return m_isRepeat; }
2272
2273
    // Find the position of the event
2274
    void GetPosition(wxCoord *xpos, wxCoord *ypos) const
2275
    {
2276
        if (xpos)
2277
            *xpos = GetX();
2278
        if (ypos)
2279
            *ypos = GetY();
2280
    }
2281
2282
    // This version if provided only for backwards compatibility, don't use.
2283
    void GetPosition(long *xpos, long *ypos) const
2284
    {
2285
        if (xpos)
2286
            *xpos = GetX();
2287
        if (ypos)
2288
            *ypos = GetY();
2289
    }
2290
2291
    wxPoint GetPosition() const
2292
        { return wxPoint(GetX(), GetY()); }
2293
2294
    // Get X position
2295
    wxCoord GetX() const;
2296
2297
    // Get Y position
2298
    wxCoord GetY() const;
2299
2300
    // Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
2301
    // key events even though the event had been handled (by default they would
2302
    // not be generated in this case).
2303
    void DoAllowNextEvent() { m_allowNext = true; }
2304
2305
    // Return the value of the "allow next" flag, for internal use only.
2306
    bool IsNextEventAllowed() const { return m_allowNext; }
2307
2308
2309
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxKeyEvent(*this); }
2310
    virtual wxEventCategory GetEventCategory() const override { return wxEVT_CATEGORY_USER_INPUT; }
2311
2312
    // we do need to copy wxKeyEvent sometimes (in wxTreeCtrl code, for
2313
    // example)
2314
    wxKeyEvent& operator=(const wxKeyEvent& evt);
2315
2316
public:
2317
    // Do not use these fields directly, they are initialized on demand, so
2318
    // call GetX() and GetY() or GetPosition() instead.
2319
    wxCoord       m_x, m_y;
2320
2321
    long          m_keyCode;
2322
2323
    // This contains the full Unicode character
2324
    // in a character events in Unicode mode
2325
    wxChar        m_uniChar;
2326
2327
    // these fields contain the platform-specific information about
2328
    // key that was pressed
2329
    wxUint32      m_rawCode;
2330
    wxUint32      m_rawFlags;
2331
2332
    // Indicates whether the key event is a repeat
2333
    bool          m_isRepeat = false;
2334
2335
private:
2336
    // Set the event to propagate if necessary, i.e. if it's of wxEVT_CHAR_HOOK
2337
    // type. This is used by all ctors.
2338
    void InitPropagation()
2339
    {
2340
        if ( m_eventType == wxEVT_CHAR_HOOK )
2341
            m_propagationLevel = wxEVENT_PROPAGATE_MAX;
2342
    }
2343
2344
    // Copy only the event data present in this class, this is used by
2345
    // AssignKeyData() and copy ctor.
2346
    void DoAssignMembers(const wxKeyEvent& evt)
2347
    {
2348
        m_x = evt.m_x;
2349
        m_y = evt.m_y;
2350
        m_hasPosition = evt.m_hasPosition;
2351
2352
        m_keyCode = evt.m_keyCode;
2353
2354
        m_rawCode = evt.m_rawCode;
2355
        m_rawFlags = evt.m_rawFlags;
2356
        m_uniChar = evt.m_uniChar;
2357
        m_isRepeat = evt.m_isRepeat;
2358
    }
2359
2360
    // Initialize m_x and m_y using the current mouse cursor position if
2361
    // necessary.
2362
    void InitPositionIfNecessary() const;
2363
2364
    // If this flag is true, the normal key events should still be generated
2365
    // even if wxEVT_CHAR_HOOK had been handled. By default it is false as
2366
    // handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
2367
    bool m_allowNext = false;
2368
2369
    // If true, m_x and m_y were already initialized. If false, try to get them
2370
    // when they're requested.
2371
    bool m_hasPosition = false;
2372
2373
    wxDECLARE_DYNAMIC_CLASS(wxKeyEvent);
2374
};
2375
2376
// Size event class
2377
/*
2378
 wxEVT_SIZE
2379
 */
2380
2381
class WXDLLIMPEXP_CORE wxSizeEvent : public wxEvent
2382
{
2383
public:
2384
    wxSizeEvent() : wxEvent(0, wxEVT_SIZE)
2385
        { }
2386
    wxSizeEvent(const wxSize& sz, int winid = 0)
2387
        : wxEvent(winid, wxEVT_SIZE),
2388
          m_size(sz)
2389
        { }
2390
    wxSizeEvent(const wxSizeEvent& event)
2391
        : wxEvent(event),
2392
          m_size(event.m_size), m_rect(event.m_rect)
2393
        { }
2394
    wxSizeEvent(const wxRect& rect, int id = 0)
2395
        : m_size(rect.GetSize()), m_rect(rect)
2396
        { m_eventType = wxEVT_SIZING; m_id = id; }
2397
2398
    wxSize GetSize() const { return m_size; }
2399
    void SetSize(wxSize size) { m_size = size; }
2400
    wxRect GetRect() const { return m_rect; }
2401
    void SetRect(const wxRect& rect) { m_rect = rect; }
2402
2403
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxSizeEvent(*this); }
2404
2405
public:
2406
    // For internal usage only. Will be converted to protected members.
2407
    wxSize m_size;
2408
    wxRect m_rect; // Used for wxEVT_SIZING
2409
2410
private:
2411
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSizeEvent);
2412
};
2413
2414
// Move event class
2415
2416
/*
2417
 wxEVT_MOVE
2418
 */
2419
2420
class WXDLLIMPEXP_CORE wxMoveEvent : public wxEvent
2421
{
2422
public:
2423
    wxMoveEvent()
2424
        : wxEvent(0, wxEVT_MOVE)
2425
        { }
2426
    wxMoveEvent(const wxPoint& pos, int winid = 0)
2427
        : wxEvent(winid, wxEVT_MOVE),
2428
          m_pos(pos)
2429
        { }
2430
    wxMoveEvent(const wxMoveEvent& event)
2431
        : wxEvent(event),
2432
          m_pos(event.m_pos)
2433
    { }
2434
    wxMoveEvent(const wxRect& rect, int id = 0)
2435
        : m_pos(rect.GetPosition()), m_rect(rect)
2436
        { m_eventType = wxEVT_MOVING; m_id = id; }
2437
2438
    wxPoint GetPosition() const { return m_pos; }
2439
    void SetPosition(const wxPoint& pos) { m_pos = pos; }
2440
    wxRect GetRect() const { return m_rect; }
2441
    void SetRect(const wxRect& rect) { m_rect = rect; }
2442
2443
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMoveEvent(*this); }
2444
2445
protected:
2446
    wxPoint m_pos;
2447
    wxRect m_rect;
2448
2449
private:
2450
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMoveEvent);
2451
};
2452
2453
// Paint event class
2454
/*
2455
 wxEVT_PAINT
2456
 wxEVT_NC_PAINT
2457
 */
2458
2459
class WXDLLIMPEXP_CORE wxPaintEvent : public wxEvent
2460
{
2461
    // This ctor is only intended to be used by wxWidgets itself, so it's
2462
    // intentionally declared as private when not building the library itself.
2463
#ifdef WXBUILDING
2464
public:
2465
#endif // WXBUILDING
2466
    explicit wxPaintEvent(wxWindowBase* window = nullptr);
2467
2468
public:
2469
    // default copy ctor and dtor are fine
2470
2471
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxPaintEvent(*this); }
2472
2473
private:
2474
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxPaintEvent);
2475
};
2476
2477
class WXDLLIMPEXP_CORE wxNcPaintEvent : public wxEvent
2478
{
2479
    // This ctor is only intended to be used by wxWidgets itself, so it's
2480
    // intentionally declared as private when not building the library itself.
2481
#ifdef WXBUILDING
2482
public:
2483
#endif // WXBUILDING
2484
    explicit wxNcPaintEvent(wxWindowBase* window = nullptr);
2485
2486
public:
2487
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxNcPaintEvent(*this); }
2488
2489
private:
2490
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxNcPaintEvent);
2491
};
2492
2493
// Erase background event class
2494
/*
2495
 wxEVT_ERASE_BACKGROUND
2496
 */
2497
2498
class WXDLLIMPEXP_CORE wxEraseEvent : public wxEvent
2499
{
2500
public:
2501
    wxEraseEvent(int Id = 0, wxDC *dc = nullptr)
2502
        : wxEvent(Id, wxEVT_ERASE_BACKGROUND),
2503
          m_dc(dc)
2504
        { }
2505
2506
    wxEraseEvent(const wxEraseEvent& event)
2507
        : wxEvent(event),
2508
          m_dc(event.m_dc)
2509
        { }
2510
2511
    wxDC *GetDC() const { return m_dc; }
2512
2513
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxEraseEvent(*this); }
2514
2515
protected:
2516
    wxDC *m_dc;
2517
2518
private:
2519
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxEraseEvent);
2520
};
2521
2522
// Focus event class
2523
/*
2524
 wxEVT_SET_FOCUS
2525
 wxEVT_KILL_FOCUS
2526
 */
2527
2528
class WXDLLIMPEXP_CORE wxFocusEvent : public wxEvent
2529
{
2530
public:
2531
    wxFocusEvent(wxEventType type = wxEVT_NULL, int winid = 0)
2532
        : wxEvent(winid, type)
2533
        { m_win = nullptr; }
2534
2535
    wxFocusEvent(const wxFocusEvent& event)
2536
        : wxEvent(event)
2537
        { m_win = event.m_win; }
2538
2539
    // The window associated with this event is the window which had focus
2540
    // before for SET event and the window which will have focus for the KILL
2541
    // one. NB: it may be null in both cases!
2542
    wxWindow *GetWindow() const { return m_win; }
2543
    void SetWindow(wxWindow *win) { m_win = win; }
2544
2545
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxFocusEvent(*this); }
2546
2547
private:
2548
    wxWindow *m_win;
2549
2550
private:
2551
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFocusEvent);
2552
};
2553
2554
// wxChildFocusEvent notifies the parent that a child has got the focus: unlike
2555
// wxFocusEvent it is propagated upwards the window chain
2556
class WXDLLIMPEXP_CORE wxChildFocusEvent : public wxCommandEvent
2557
{
2558
public:
2559
    wxChildFocusEvent(wxWindow *win = nullptr);
2560
2561
    wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
2562
2563
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxChildFocusEvent(*this); }
2564
2565
private:
2566
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxChildFocusEvent);
2567
};
2568
2569
// Activate event class
2570
/*
2571
 wxEVT_ACTIVATE
2572
 wxEVT_ACTIVATE_APP
2573
 wxEVT_HIBERNATE
2574
 */
2575
2576
class WXDLLIMPEXP_CORE wxActivateEvent : public wxEvent
2577
{
2578
public:
2579
    // Type of activation. For now we can only detect if it was by mouse or by
2580
    // some other method and even this is only available under wxMSW.
2581
    enum Reason
2582
    {
2583
        Reason_Mouse,
2584
        Reason_Unknown
2585
    };
2586
2587
    wxActivateEvent(wxEventType type = wxEVT_NULL, bool active = true,
2588
                    int Id = 0, Reason activationReason = Reason_Unknown)
2589
        : wxEvent(Id, type),
2590
        m_activationReason(activationReason)
2591
    {
2592
        m_active = active;
2593
    }
2594
    wxActivateEvent(const wxActivateEvent& event)
2595
        : wxEvent(event)
2596
    {
2597
        m_active = event.m_active;
2598
        m_activationReason = event.m_activationReason;
2599
    }
2600
2601
    bool GetActive() const { return m_active; }
2602
    Reason GetActivationReason() const { return m_activationReason;}
2603
2604
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxActivateEvent(*this); }
2605
2606
private:
2607
    bool m_active;
2608
    Reason m_activationReason;
2609
2610
private:
2611
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxActivateEvent);
2612
};
2613
2614
// InitDialog event class
2615
/*
2616
 wxEVT_INIT_DIALOG
2617
 */
2618
2619
class WXDLLIMPEXP_CORE wxInitDialogEvent : public wxEvent
2620
{
2621
public:
2622
    wxInitDialogEvent(int Id = 0)
2623
        : wxEvent(Id, wxEVT_INIT_DIALOG)
2624
        { }
2625
2626
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxInitDialogEvent(*this); }
2627
2628
private:
2629
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxInitDialogEvent);
2630
};
2631
2632
// Miscellaneous menu event class
2633
/*
2634
 wxEVT_MENU_OPEN,
2635
 wxEVT_MENU_CLOSE,
2636
 wxEVT_MENU_HIGHLIGHT,
2637
*/
2638
2639
class WXDLLIMPEXP_CORE wxMenuEvent : public wxEvent
2640
{
2641
public:
2642
    wxMenuEvent(wxEventType type = wxEVT_NULL, int winid = 0, wxMenu* menu = nullptr, wxMenuItem* menuItem = nullptr)
2643
        : wxEvent(winid, type)
2644
        { m_menuId = winid; m_menu = menu; m_menuItem = menuItem; }
2645
    wxMenuEvent(const wxMenuEvent& event)
2646
        : wxEvent(event)
2647
    { m_menuId = event.m_menuId; m_menu = event.m_menu; m_menuItem = event.m_menuItem; }
2648
2649
    // only for wxEVT_MENU_HIGHLIGHT
2650
    int GetMenuId() const { return m_menuId; }
2651
2652
    // only for wxEVT_MENU_OPEN/CLOSE
2653
    bool IsPopup() const { return m_menuId == wxID_ANY; }
2654
2655
    // only for wxEVT_MENU_OPEN/CLOSE
2656
    wxMenu* GetMenu() const { return m_menu; }
2657
2658
    wxMenuItem* GetMenuItem() const { return m_menuItem; }
2659
2660
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMenuEvent(*this); }
2661
2662
private:
2663
    int         m_menuId;
2664
    wxMenu*     m_menu;
2665
    wxMenuItem* m_menuItem;
2666
2667
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMenuEvent);
2668
};
2669
2670
// Window close or session close event class
2671
/*
2672
 wxEVT_CLOSE_WINDOW,
2673
 wxEVT_END_SESSION,
2674
 wxEVT_QUERY_END_SESSION
2675
 */
2676
2677
class WXDLLIMPEXP_CORE wxCloseEvent : public wxEvent
2678
{
2679
public:
2680
    wxCloseEvent(wxEventType type = wxEVT_NULL, int winid = 0)
2681
        : wxEvent(winid, type),
2682
          m_loggingOff(true),
2683
          m_veto(false),      // should be false by default
2684
          m_canVeto(true) {}
2685
2686
    wxCloseEvent(const wxCloseEvent& event)
2687
        : wxEvent(event),
2688
        m_loggingOff(event.m_loggingOff),
2689
        m_veto(event.m_veto),
2690
        m_canVeto(event.m_canVeto) {}
2691
2692
    void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
2693
    bool GetLoggingOff() const
2694
    {
2695
        // m_loggingOff flag is only used by wxEVT_[QUERY_]END_SESSION, it
2696
        // doesn't make sense for wxEVT_CLOSE_WINDOW
2697
        wxASSERT_MSG( m_eventType != wxEVT_CLOSE_WINDOW,
2698
                      wxT("this flag is for end session events only") );
2699
2700
        return m_loggingOff;
2701
    }
2702
2703
    void Veto(bool veto = true)
2704
    {
2705
        // GetVeto() will return false anyhow...
2706
        wxCHECK_RET( m_canVeto,
2707
                     wxT("call to Veto() ignored (can't veto this event)") );
2708
2709
        m_veto = veto;
2710
    }
2711
    void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
2712
    bool CanVeto() const { return m_canVeto; }
2713
    bool GetVeto() const { return m_canVeto && m_veto; }
2714
2715
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxCloseEvent(*this); }
2716
2717
protected:
2718
    bool m_loggingOff,
2719
         m_veto,
2720
         m_canVeto;
2721
2722
private:
2723
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCloseEvent);
2724
};
2725
2726
/*
2727
 wxEVT_SHOW
2728
 */
2729
2730
class WXDLLIMPEXP_CORE wxShowEvent : public wxEvent
2731
{
2732
public:
2733
    wxShowEvent(int winid = 0, bool show = false)
2734
        : wxEvent(winid, wxEVT_SHOW)
2735
        { m_show = show; }
2736
    wxShowEvent(const wxShowEvent& event)
2737
        : wxEvent(event)
2738
    { m_show = event.m_show; }
2739
2740
    void SetShow(bool show) { m_show = show; }
2741
2742
    // return true if the window was shown, false if hidden
2743
    bool IsShown() const { return m_show; }
2744
2745
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxShowEvent(*this); }
2746
2747
protected:
2748
    bool m_show;
2749
2750
private:
2751
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxShowEvent);
2752
};
2753
2754
/*
2755
 wxEVT_ICONIZE
2756
 */
2757
2758
class WXDLLIMPEXP_CORE wxIconizeEvent : public wxEvent
2759
{
2760
public:
2761
    wxIconizeEvent(int winid = 0, bool iconized = true)
2762
        : wxEvent(winid, wxEVT_ICONIZE)
2763
        { m_iconized = iconized; }
2764
    wxIconizeEvent(const wxIconizeEvent& event)
2765
        : wxEvent(event)
2766
    { m_iconized = event.m_iconized; }
2767
2768
    // return true if the frame was iconized, false if restored
2769
    bool IsIconized() const { return m_iconized; }
2770
2771
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxIconizeEvent(*this); }
2772
2773
protected:
2774
    bool m_iconized;
2775
2776
private:
2777
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxIconizeEvent);
2778
};
2779
/*
2780
 wxEVT_MAXIMIZE
2781
 */
2782
2783
class WXDLLIMPEXP_CORE wxMaximizeEvent : public wxEvent
2784
{
2785
public:
2786
    wxMaximizeEvent(int winid = 0)
2787
        : wxEvent(winid, wxEVT_MAXIMIZE)
2788
        { }
2789
2790
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMaximizeEvent(*this); }
2791
2792
private:
2793
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxMaximizeEvent);
2794
};
2795
2796
/*
2797
 wxEVT_FULLSCREEN
2798
 */
2799
class WXDLLIMPEXP_CORE wxFullScreenEvent : public wxEvent
2800
{
2801
public:
2802
    wxFullScreenEvent(int winid = 0, bool fullscreen = true)
2803
        : wxEvent(winid, wxEVT_FULLSCREEN)
2804
        { m_fullscreen = fullscreen; }
2805
    wxFullScreenEvent(const wxFullScreenEvent& event)
2806
        : wxEvent(event)
2807
        { m_fullscreen = event.m_fullscreen; }
2808
2809
    bool IsFullScreen() const { return m_fullscreen; }
2810
2811
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxFullScreenEvent(*this); }
2812
2813
protected:
2814
    bool m_fullscreen;
2815
2816
private:
2817
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxFullScreenEvent);
2818
};
2819
2820
// Joystick event class
2821
/*
2822
 wxEVT_JOY_BUTTON_DOWN,
2823
 wxEVT_JOY_BUTTON_UP,
2824
 wxEVT_JOY_MOVE,
2825
 wxEVT_JOY_ZMOVE
2826
*/
2827
2828
// Which joystick? Same as Windows ids so no conversion necessary.
2829
enum
2830
{
2831
    wxJOYSTICK1,
2832
    wxJOYSTICK2
2833
};
2834
2835
// Which button is down?
2836
enum
2837
{
2838
    wxJOY_BUTTON_ANY = -1,
2839
    wxJOY_BUTTON1    = 1,
2840
    wxJOY_BUTTON2    = 2,
2841
    wxJOY_BUTTON3    = 4,
2842
    wxJOY_BUTTON4    = 8
2843
};
2844
2845
class WXDLLIMPEXP_CORE wxJoystickEvent : public wxEvent
2846
{
2847
protected:
2848
    wxPoint   m_pos;
2849
    int       m_zPosition;
2850
    int       m_buttonChange;   // Which button changed?
2851
    int       m_buttonState;    // Which buttons are down?
2852
    int       m_joyStick;       // Which joystick?
2853
2854
public:
2855
    wxJoystickEvent(wxEventType type = wxEVT_NULL,
2856
                    int state = 0,
2857
                    int joystick = wxJOYSTICK1,
2858
                    int change = 0)
2859
        : wxEvent(0, type),
2860
          m_pos(),
2861
          m_zPosition(0),
2862
          m_buttonChange(change),
2863
          m_buttonState(state),
2864
          m_joyStick(joystick)
2865
    {
2866
    }
2867
    wxJoystickEvent(const wxJoystickEvent& event)
2868
        : wxEvent(event),
2869
          m_pos(event.m_pos),
2870
          m_zPosition(event.m_zPosition),
2871
          m_buttonChange(event.m_buttonChange),
2872
          m_buttonState(event.m_buttonState),
2873
          m_joyStick(event.m_joyStick)
2874
    { }
2875
2876
    wxPoint GetPosition() const { return m_pos; }
2877
    int GetZPosition() const { return m_zPosition; }
2878
    int GetButtonState() const { return m_buttonState; }
2879
    int GetButtonChange() const { return m_buttonChange; }
2880
    int GetButtonOrdinal() const { return wxCTZ(m_buttonChange); }
2881
    int GetJoystick() const { return m_joyStick; }
2882
2883
    void SetJoystick(int stick) { m_joyStick = stick; }
2884
    void SetButtonState(int state) { m_buttonState = state; }
2885
    void SetButtonChange(int change) { m_buttonChange = change; }
2886
    void SetPosition(const wxPoint& pos) { m_pos = pos; }
2887
    void SetZPosition(int zPos) { m_zPosition = zPos; }
2888
2889
    // Was it a button event? (*doesn't* mean: is any button *down*?)
2890
    bool IsButton() const { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) ||
2891
            (GetEventType() == wxEVT_JOY_BUTTON_UP)); }
2892
2893
    // Was it a move event?
2894
    bool IsMove() const { return (GetEventType() == wxEVT_JOY_MOVE); }
2895
2896
    // Was it a zmove event?
2897
    bool IsZMove() const { return (GetEventType() == wxEVT_JOY_ZMOVE); }
2898
2899
    // Was it a down event from button 1, 2, 3, 4 or any?
2900
    bool ButtonDown(int but = wxJOY_BUTTON_ANY) const
2901
    { return ((GetEventType() == wxEVT_JOY_BUTTON_DOWN) &&
2902
            ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
2903
2904
    // Was it a up event from button 1, 2, 3 or any?
2905
    bool ButtonUp(int but = wxJOY_BUTTON_ANY) const
2906
    { return ((GetEventType() == wxEVT_JOY_BUTTON_UP) &&
2907
            ((but == wxJOY_BUTTON_ANY) || (but == m_buttonChange))); }
2908
2909
    // Was the given button 1,2,3,4 or any in Down state?
2910
    bool ButtonIsDown(int but =  wxJOY_BUTTON_ANY) const
2911
    { return (((but == wxJOY_BUTTON_ANY) && (m_buttonState != 0)) ||
2912
            ((m_buttonState & but) == but)); }
2913
2914
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxJoystickEvent(*this); }
2915
2916
private:
2917
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxJoystickEvent);
2918
};
2919
2920
// Drop files event class
2921
/*
2922
 wxEVT_DROP_FILES
2923
 */
2924
2925
class WXDLLIMPEXP_CORE wxDropFilesEvent : public wxEvent
2926
{
2927
public:
2928
    int       m_noFiles;
2929
    wxPoint   m_pos;
2930
    wxString* m_files;
2931
2932
    wxDropFilesEvent(wxEventType type = wxEVT_NULL,
2933
                     int noFiles = 0,
2934
                     wxString *files = nullptr)
2935
        : wxEvent(0, type),
2936
          m_noFiles(noFiles),
2937
          m_pos(),
2938
          m_files(files)
2939
        { }
2940
2941
    // we need a copy ctor to avoid deleting m_files pointer twice
2942
    wxDropFilesEvent(const wxDropFilesEvent& other)
2943
        : wxEvent(other),
2944
          m_noFiles(other.m_noFiles),
2945
          m_pos(other.m_pos),
2946
          m_files(nullptr)
2947
    {
2948
        m_files = new wxString[m_noFiles];
2949
        for ( int n = 0; n < m_noFiles; n++ )
2950
        {
2951
            m_files[n] = other.m_files[n];
2952
        }
2953
    }
2954
2955
    virtual ~wxDropFilesEvent()
2956
    {
2957
        delete [] m_files;
2958
    }
2959
2960
    wxPoint GetPosition() const { return m_pos; }
2961
    int GetNumberOfFiles() const { return m_noFiles; }
2962
    wxString *GetFiles() const { return m_files; }
2963
2964
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxDropFilesEvent(*this); }
2965
2966
private:
2967
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDropFilesEvent);
2968
};
2969
2970
// Update UI event
2971
/*
2972
 wxEVT_UPDATE_UI
2973
 */
2974
2975
// Whether to always send update events to windows, or
2976
// to only send update events to those with the
2977
// wxWS_EX_PROCESS_UI_UPDATES style.
2978
2979
enum wxUpdateUIMode
2980
{
2981
        // Send UI update events to all windows
2982
    wxUPDATE_UI_PROCESS_ALL,
2983
2984
        // Send UI update events to windows that have
2985
        // the wxWS_EX_PROCESS_UI_UPDATES flag specified
2986
    wxUPDATE_UI_PROCESS_SPECIFIED
2987
};
2988
2989
class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
2990
{
2991
public:
2992
    wxUpdateUIEvent(wxWindowID commandId = 0)
2993
        : wxCommandEvent(wxEVT_UPDATE_UI, commandId)
2994
    {
2995
        m_3checked = wxCHK_UNCHECKED;
2996
        m_enabled =
2997
        m_shown =
2998
        m_setEnabled =
2999
        m_setShown =
3000
        m_setText =
3001
        m_setChecked = false;
3002
        m_isCheckable = true;
3003
        m_is3State = false;
3004
    }
3005
    wxUpdateUIEvent(const wxUpdateUIEvent& event)
3006
        : wxCommandEvent(event),
3007
          m_3checked(event.m_3checked),
3008
          m_enabled(event.m_enabled),
3009
          m_shown(event.m_shown),
3010
          m_setEnabled(event.m_setEnabled),
3011
          m_setShown(event.m_setShown),
3012
          m_setText(event.m_setText),
3013
          m_setChecked(event.m_setChecked),
3014
          m_isCheckable(event.m_isCheckable),
3015
          m_is3State(event.m_is3State),
3016
          m_text(event.m_text)
3017
    { }
3018
3019
    bool GetChecked() const { return Get3StateValue() != wxCHK_UNCHECKED; }
3020
    wxCheckBoxState Get3StateValue() const { return m_3checked; }
3021
    bool GetEnabled() const { return m_enabled; }
3022
    bool GetShown() const { return m_shown; }
3023
    wxString GetText() const { return m_text; }
3024
    bool GetSetText() const { return m_setText; }
3025
    bool GetSetChecked() const { return m_setChecked; }
3026
    bool GetSetEnabled() const { return m_setEnabled; }
3027
    bool GetSetShown() const { return m_setShown; }
3028
3029
    void Check(bool check) { Set3StateValue(check ? wxCHK_CHECKED : wxCHK_UNCHECKED); }
3030
    void Set3StateValue(wxCheckBoxState check);
3031
    void Enable(bool enable) { m_enabled = enable; m_setEnabled = true; }
3032
    void Show(bool show) { m_shown = show; m_setShown = true; }
3033
    void SetText(const wxString& text) { m_text = text; m_setText = true; }
3034
3035
    // A flag saying if the item can be checked. True by default.
3036
    bool IsCheckable() const { return m_isCheckable; }
3037
    void DisallowCheck();
3038
    // A flag saying if the item can be wxCHK_UNDETERMINED. False by default.
3039
    bool Is3State() const { return m_is3State; }
3040
    void Allow3rdState(bool b = true);
3041
3042
    // Sets the interval between updates in milliseconds.
3043
    // Set to -1 to disable updates, or to 0 to update as frequently as possible.
3044
    static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
3045
3046
    // Returns the current interval between updates in milliseconds
3047
    static long GetUpdateInterval() { return sm_updateInterval; }
3048
3049
    // Can we update this window?
3050
    static bool CanUpdate(wxWindowBase *win);
3051
3052
    // Reset the update time to provide a delay until the next
3053
    // time we should update
3054
    static void ResetUpdateTime();
3055
3056
    // Specify how wxWidgets will send update events: to
3057
    // all windows, or only to those which specify that they
3058
    // will process the events.
3059
    static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
3060
3061
    // Returns the UI update mode
3062
    static wxUpdateUIMode GetMode() { return sm_updateMode; }
3063
3064
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxUpdateUIEvent(*this); }
3065
3066
protected:
3067
    wxCheckBoxState m_3checked;
3068
    bool          m_enabled;
3069
    bool          m_shown;
3070
    bool          m_setEnabled;
3071
    bool          m_setShown;
3072
    bool          m_setText;
3073
    bool          m_setChecked;
3074
    bool          m_isCheckable;
3075
    bool          m_is3State;
3076
    wxString      m_text;
3077
    static wxLongLong       sm_lastUpdate;
3078
    static long             sm_updateInterval;
3079
    static wxUpdateUIMode   sm_updateMode;
3080
3081
private:
3082
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxUpdateUIEvent);
3083
};
3084
3085
/*
3086
 wxEVT_SYS_COLOUR_CHANGED
3087
 */
3088
3089
class WXDLLIMPEXP_CORE wxSysColourChangedEvent : public wxEvent
3090
{
3091
public:
3092
    wxSysColourChangedEvent()
3093
        : wxEvent(0, wxEVT_SYS_COLOUR_CHANGED)
3094
        { }
3095
3096
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxSysColourChangedEvent(*this); }
3097
3098
private:
3099
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxSysColourChangedEvent);
3100
};
3101
3102
/*
3103
 wxEVT_SYS_METRIC_CHANGED
3104
 */
3105
3106
enum class wxSysMetric
3107
{
3108
    Other,
3109
    CursorSize
3110
};
3111
3112
class WXDLLIMPEXP_CORE wxSysMetricChangedEvent : public wxEvent
3113
{
3114
public:
3115
    explicit wxSysMetricChangedEvent(wxSysMetric metric = wxSysMetric::Other)
3116
        : wxEvent(0, wxEVT_SYS_METRIC_CHANGED),
3117
          m_metric(metric)
3118
        { }
3119
3120
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxSysMetricChangedEvent(*this); }
3121
3122
    wxSysMetric GetMetric() const { return m_metric; }
3123
3124
private:
3125
    const wxSysMetric m_metric;
3126
3127
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxSysMetricChangedEvent);
3128
};
3129
3130
/*
3131
 wxEVT_MOUSE_CAPTURE_CHANGED
3132
 The window losing the capture receives this message
3133
 (even if it released the capture itself).
3134
 */
3135
3136
class WXDLLIMPEXP_CORE wxMouseCaptureChangedEvent : public wxEvent
3137
{
3138
public:
3139
    wxMouseCaptureChangedEvent(wxWindowID winid = 0, wxWindow* gainedCapture = nullptr)
3140
        : wxEvent(winid, wxEVT_MOUSE_CAPTURE_CHANGED),
3141
          m_gainedCapture(gainedCapture)
3142
        { }
3143
3144
    wxMouseCaptureChangedEvent(const wxMouseCaptureChangedEvent& event)
3145
        : wxEvent(event),
3146
          m_gainedCapture(event.m_gainedCapture)
3147
        { }
3148
3149
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMouseCaptureChangedEvent(*this); }
3150
3151
    wxWindow* GetCapturedWindow() const { return m_gainedCapture; }
3152
3153
private:
3154
    wxWindow* m_gainedCapture;
3155
3156
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureChangedEvent);
3157
};
3158
3159
/*
3160
 wxEVT_MOUSE_CAPTURE_LOST
3161
 The window losing the capture receives this message, unless it released
3162
 it itself or unless wxWindow::CaptureMouse was called on another window
3163
 (and so capture will be restored when the new capturer releases it).
3164
 */
3165
3166
class WXDLLIMPEXP_CORE wxMouseCaptureLostEvent : public wxEvent
3167
{
3168
public:
3169
    wxMouseCaptureLostEvent(wxWindowID winid = 0)
3170
        : wxEvent(winid, wxEVT_MOUSE_CAPTURE_LOST)
3171
    {}
3172
3173
    wxMouseCaptureLostEvent(const wxMouseCaptureLostEvent& event)
3174
        : wxEvent(event)
3175
    {}
3176
3177
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxMouseCaptureLostEvent(*this); }
3178
3179
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxMouseCaptureLostEvent);
3180
};
3181
3182
/*
3183
 wxEVT_DISPLAY_CHANGED
3184
 */
3185
class WXDLLIMPEXP_CORE wxDisplayChangedEvent : public wxEvent
3186
{
3187
public:
3188
    wxDisplayChangedEvent()
3189
        : wxEvent(0, wxEVT_DISPLAY_CHANGED)
3190
        { }
3191
3192
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxDisplayChangedEvent(*this); }
3193
3194
private:
3195
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDisplayChangedEvent);
3196
};
3197
3198
/*
3199
 wxEVT_DPI_CHANGED
3200
 */
3201
class WXDLLIMPEXP_CORE wxDPIChangedEvent : public wxEvent
3202
{
3203
public:
3204
    explicit
3205
    wxDPIChangedEvent(const wxSize& oldDPI = wxDefaultSize,
3206
                      const wxSize& newDPI = wxDefaultSize)
3207
        : wxEvent(0, wxEVT_DPI_CHANGED),
3208
          m_oldDPI(oldDPI),
3209
          m_newDPI(newDPI)
3210
        { }
3211
3212
    wxSize GetOldDPI() const { return m_oldDPI; }
3213
    wxSize GetNewDPI() const { return m_newDPI; }
3214
3215
    // Scale the value by the ratio between new and old DPIs carried by this
3216
    // event.
3217
    wxPoint Scale(wxPoint pt) const;
3218
    wxSize Scale(wxSize sz) const;
3219
    wxRect Scale(wxRect r) const
3220
    {
3221
        return wxRect(Scale(r.GetPosition()), Scale(r.GetSize()));
3222
    }
3223
3224
    int ScaleX(int x) const { return Scale(wxSize(x, -1)).x; }
3225
    int ScaleY(int y) const { return Scale(wxSize(-1, y)).y; }
3226
3227
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxDPIChangedEvent(*this); }
3228
3229
private:
3230
    wxSize m_oldDPI;
3231
    wxSize m_newDPI;
3232
3233
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxDPIChangedEvent);
3234
};
3235
3236
/*
3237
 wxEVT_PALETTE_CHANGED
3238
 */
3239
3240
class WXDLLIMPEXP_CORE wxPaletteChangedEvent : public wxEvent
3241
{
3242
public:
3243
    wxPaletteChangedEvent(wxWindowID winid = 0)
3244
        : wxEvent(winid, wxEVT_PALETTE_CHANGED),
3245
          m_changedWindow(nullptr)
3246
        { }
3247
3248
    wxPaletteChangedEvent(const wxPaletteChangedEvent& event)
3249
        : wxEvent(event),
3250
          m_changedWindow(event.m_changedWindow)
3251
        { }
3252
3253
    void SetChangedWindow(wxWindow* win) { m_changedWindow = win; }
3254
    wxWindow* GetChangedWindow() const { return m_changedWindow; }
3255
3256
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxPaletteChangedEvent(*this); }
3257
3258
protected:
3259
    wxWindow*     m_changedWindow;
3260
3261
private:
3262
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPaletteChangedEvent);
3263
};
3264
3265
/*
3266
 wxEVT_QUERY_NEW_PALETTE
3267
 Indicates the window is getting keyboard focus and should re-do its palette.
3268
 */
3269
3270
class WXDLLIMPEXP_CORE wxQueryNewPaletteEvent : public wxEvent
3271
{
3272
public:
3273
    wxQueryNewPaletteEvent(wxWindowID winid = 0)
3274
        : wxEvent(winid, wxEVT_QUERY_NEW_PALETTE),
3275
          m_paletteRealized(false)
3276
        { }
3277
    wxQueryNewPaletteEvent(const wxQueryNewPaletteEvent& event)
3278
        : wxEvent(event),
3279
        m_paletteRealized(event.m_paletteRealized)
3280
    { }
3281
3282
    // App sets this if it changes the palette.
3283
    void SetPaletteRealized(bool realized) { m_paletteRealized = realized; }
3284
    bool GetPaletteRealized() const { return m_paletteRealized; }
3285
3286
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxQueryNewPaletteEvent(*this); }
3287
3288
protected:
3289
    bool m_paletteRealized;
3290
3291
private:
3292
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxQueryNewPaletteEvent);
3293
};
3294
3295
/*
3296
 Event generated by dialog navigation keys
3297
 wxEVT_NAVIGATION_KEY
3298
 */
3299
// NB: don't derive from command event to avoid being propagated to the parent
3300
class WXDLLIMPEXP_CORE wxNavigationKeyEvent : public wxEvent
3301
{
3302
public:
3303
    wxNavigationKeyEvent()
3304
        : wxEvent(0, wxEVT_NAVIGATION_KEY),
3305
          m_flags(IsForward | FromTab),    // defaults are for TAB
3306
          m_focus(nullptr)
3307
        {
3308
            m_propagationLevel = wxEVENT_PROPAGATE_NONE;
3309
        }
3310
3311
    wxNavigationKeyEvent(const wxNavigationKeyEvent& event)
3312
        : wxEvent(event),
3313
          m_flags(event.m_flags),
3314
          m_focus(event.m_focus)
3315
        { }
3316
3317
    // direction: forward (true) or backward (false)
3318
    bool GetDirection() const
3319
        { return (m_flags & IsForward) != 0; }
3320
    void SetDirection(bool bForward)
3321
        { if ( bForward ) m_flags |= IsForward; else m_flags &= ~IsForward; }
3322
3323
    // it may be a window change event (MDI, notebook pages...) or a control
3324
    // change event
3325
    bool IsWindowChange() const
3326
        { return (m_flags & WinChange) != 0; }
3327
    void SetWindowChange(bool bIs)
3328
        { if ( bIs ) m_flags |= WinChange; else m_flags &= ~WinChange; }
3329
3330
    // Set to true under MSW if the event was generated using the tab key.
3331
    // This is required for proper navogation over radio buttons
3332
    bool IsFromTab() const
3333
        { return (m_flags & FromTab) != 0; }
3334
    void SetFromTab(bool bIs)
3335
        { if ( bIs ) m_flags |= FromTab; else m_flags &= ~FromTab; }
3336
3337
    // the child which has the focus currently (may be null - use
3338
    // wxWindow::FindFocus then)
3339
    wxWindow* GetCurrentFocus() const { return m_focus; }
3340
    void SetCurrentFocus(wxWindow *win) { m_focus = win; }
3341
3342
    // Set flags
3343
    void SetFlags(long flags) { m_flags = flags; }
3344
3345
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxNavigationKeyEvent(*this); }
3346
3347
    enum wxNavigationKeyEventFlags
3348
    {
3349
        IsBackward = 0x0000,
3350
        IsForward = 0x0001,
3351
        WinChange = 0x0002,
3352
        FromTab = 0x0004
3353
    };
3354
3355
    long m_flags;
3356
    wxWindow *m_focus;
3357
3358
private:
3359
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNavigationKeyEvent);
3360
};
3361
3362
// Window creation/destruction events: the first is sent as soon as window is
3363
// created (i.e. the underlying GUI object exists), but when the C++ object is
3364
// fully initialized (so virtual functions may be called). The second,
3365
// wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
3366
// still safe to call virtual functions at this moment
3367
/*
3368
 wxEVT_CREATE
3369
 wxEVT_DESTROY
3370
 */
3371
3372
class WXDLLIMPEXP_CORE wxWindowCreateEvent : public wxCommandEvent
3373
{
3374
public:
3375
    wxWindowCreateEvent(wxWindow *win = nullptr);
3376
3377
    wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
3378
3379
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxWindowCreateEvent(*this); }
3380
3381
private:
3382
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWindowCreateEvent);
3383
};
3384
3385
class WXDLLIMPEXP_CORE wxWindowDestroyEvent : public wxCommandEvent
3386
{
3387
public:
3388
    wxWindowDestroyEvent(wxWindow *win = nullptr);
3389
3390
    wxWindow *GetWindow() const { return (wxWindow *)GetEventObject(); }
3391
3392
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxWindowDestroyEvent(*this); }
3393
3394
private:
3395
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY(wxWindowDestroyEvent);
3396
};
3397
3398
// A help event is sent when the user clicks on a window in context-help mode.
3399
/*
3400
 wxEVT_HELP
3401
 wxEVT_DETAILED_HELP
3402
*/
3403
3404
class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent
3405
{
3406
public:
3407
    // how was this help event generated?
3408
    enum Origin
3409
    {
3410
        Origin_Unknown,    // unrecognized event source
3411
        Origin_Keyboard,   // event generated from F1 key press
3412
        Origin_HelpButton  // event from [?] button on the title bar (Windows)
3413
    };
3414
3415
    wxHelpEvent(wxEventType type = wxEVT_NULL,
3416
                wxWindowID winid = 0,
3417
                const wxPoint& pt = wxDefaultPosition,
3418
                Origin origin = Origin_Unknown)
3419
        : wxCommandEvent(type, winid),
3420
          m_pos(pt),
3421
          m_origin(GuessOrigin(origin))
3422
    { }
3423
    wxHelpEvent(const wxHelpEvent& event)
3424
        : wxCommandEvent(event),
3425
          m_pos(event.m_pos),
3426
          m_target(event.m_target),
3427
          m_link(event.m_link),
3428
          m_origin(event.m_origin)
3429
    { }
3430
3431
    // Position of event (in screen coordinates)
3432
    const wxPoint& GetPosition() const { return m_pos; }
3433
    void SetPosition(const wxPoint& pos) { m_pos = pos; }
3434
3435
    // Optional link to further help
3436
    const wxString& GetLink() const { return m_link; }
3437
    void SetLink(const wxString& link) { m_link = link; }
3438
3439
    // Optional target to display help in. E.g. a window specification
3440
    const wxString& GetTarget() const { return m_target; }
3441
    void SetTarget(const wxString& target) { m_target = target; }
3442
3443
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxHelpEvent(*this); }
3444
3445
    // optional indication of the event source
3446
    Origin GetOrigin() const { return m_origin; }
3447
    void SetOrigin(Origin origin) { m_origin = origin; }
3448
3449
protected:
3450
    wxPoint   m_pos;
3451
    wxString  m_target;
3452
    wxString  m_link;
3453
    Origin    m_origin;
3454
3455
    // we can try to guess the event origin ourselves, even if none is
3456
    // specified in the ctor
3457
    static Origin GuessOrigin(Origin origin);
3458
3459
private:
3460
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent);
3461
};
3462
3463
// A Clipboard Text event is sent when a window intercepts text copy/cut/paste
3464
// message, i.e. the user has cut/copied/pasted data from/into a text control
3465
// via ctrl-C/X/V, ctrl/shift-del/insert, a popup menu command, etc.
3466
// NOTE : under windows these events are *NOT* generated automatically
3467
// for a Rich Edit text control.
3468
/*
3469
wxEVT_TEXT_COPY
3470
wxEVT_TEXT_CUT
3471
wxEVT_TEXT_PASTE
3472
*/
3473
3474
class WXDLLIMPEXP_CORE wxClipboardTextEvent : public wxCommandEvent
3475
{
3476
public:
3477
    wxClipboardTextEvent(wxEventType type = wxEVT_NULL,
3478
                     wxWindowID winid = 0)
3479
        : wxCommandEvent(type, winid)
3480
    { }
3481
    wxClipboardTextEvent(const wxClipboardTextEvent& event)
3482
        : wxCommandEvent(event)
3483
    { }
3484
3485
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxClipboardTextEvent(*this); }
3486
3487
private:
3488
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxClipboardTextEvent);
3489
};
3490
3491
// A Context event is sent when the user right clicks on a window or
3492
// presses Shift-F10
3493
// NOTE : Under windows this is a repackaged WM_CONTETXMENU message
3494
//        Under other systems it may have to be generated from a right click event
3495
/*
3496
 wxEVT_CONTEXT_MENU
3497
*/
3498
3499
class WXDLLIMPEXP_CORE wxContextMenuEvent : public wxCommandEvent
3500
{
3501
public:
3502
    wxContextMenuEvent(wxEventType type = wxEVT_NULL,
3503
                       wxWindowID winid = 0,
3504
                       const wxPoint& pt = wxDefaultPosition)
3505
        : wxCommandEvent(type, winid),
3506
          m_pos(pt)
3507
    { }
3508
    wxContextMenuEvent(const wxContextMenuEvent& event)
3509
        : wxCommandEvent(event),
3510
        m_pos(event.m_pos)
3511
    { }
3512
3513
    // Position of event (in screen coordinates)
3514
    const wxPoint& GetPosition() const { return m_pos; }
3515
    void SetPosition(const wxPoint& pos) { m_pos = pos; }
3516
3517
    wxNODISCARD virtual wxEvent *Clone() const override { return new wxContextMenuEvent(*this); }
3518
3519
protected:
3520
    wxPoint   m_pos;
3521
3522
private:
3523
    wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxContextMenuEvent);
3524
};
3525
3526
3527
/* TODO
3528
 wxEVT_SETTING_CHANGED, // WM_WININICHANGE
3529
// wxEVT_FONT_CHANGED,  // WM_FONTCHANGE: roll into wxEVT_SETTING_CHANGED, but remember to propagate
3530
                        // wxEVT_FONT_CHANGED to all other windows (maybe).
3531
 wxEVT_DRAW_ITEM, // Leave these three as virtual functions in wxControl?? Platform-specific.
3532
 wxEVT_MEASURE_ITEM,
3533
 wxEVT_COMPARE_ITEM
3534
*/
3535
3536
#endif // wxUSE_GUI
3537
3538
3539
// ============================================================================
3540
// event handler and related classes
3541
// ============================================================================
3542
3543
3544
// struct containing the members common to static and dynamic event tables
3545
// entries
3546
struct WXDLLIMPEXP_BASE wxEventTableEntryBase
3547
{
3548
    wxEventTableEntryBase(int winid, int idLast,
3549
                          wxEventFunctor* fn, wxObject *data)
3550
2
        : m_id(winid),
3551
2
          m_lastId(idLast),
3552
2
          m_fn(fn),
3553
2
          m_callbackUserData(data)
3554
2
    {
3555
2
        wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast,
3556
2
                      "invalid IDs range: lower bound > upper bound" );
3557
2
    }
3558
3559
    wxEventTableEntryBase( const wxEventTableEntryBase &entry )
3560
        : m_id( entry.m_id ),
3561
          m_lastId( entry.m_lastId ),
3562
          m_fn( entry.m_fn ),
3563
          m_callbackUserData( entry.m_callbackUserData )
3564
0
    {
3565
0
        // This is a 'hack' to ensure that only one instance tries to delete
3566
0
        // the functor pointer. It is safe as long as the only place where the
3567
0
        // copy constructor is being called is when the static event tables are
3568
0
        // being initialized (a temporary instance is created and then this
3569
0
        // constructor is called).
3570
0
3571
0
        const_cast<wxEventTableEntryBase&>( entry ).m_fn = nullptr;
3572
0
    }
3573
3574
    ~wxEventTableEntryBase()
3575
0
    {
3576
0
        delete m_fn;
3577
0
    }
3578
3579
    // the range of ids for this entry: if m_lastId == wxID_ANY, the range
3580
    // consists only of m_id, otherwise it is m_id..m_lastId inclusive
3581
    int m_id,
3582
        m_lastId;
3583
3584
    // function/method/functor to call
3585
    wxEventFunctor* m_fn;
3586
3587
    // arbitrary user data associated with the callback
3588
    wxObject* m_callbackUserData;
3589
3590
private:
3591
    wxDECLARE_NO_ASSIGN_CLASS(wxEventTableEntryBase);
3592
};
3593
3594
// an entry from a static event table
3595
struct WXDLLIMPEXP_BASE wxEventTableEntry : public wxEventTableEntryBase
3596
{
3597
    wxEventTableEntry(const int& evType, int winid, int idLast,
3598
                      wxEventFunctor* fn, wxObject *data)
3599
2
        : wxEventTableEntryBase(winid, idLast, fn, data),
3600
2
        m_eventType(evType)
3601
2
    { }
3602
3603
    // the reference to event type: this allows us to not care about the
3604
    // (undefined) order in which the event table entries and the event types
3605
    // are initialized: initially the value of this reference might be
3606
    // invalid, but by the time it is used for the first time, all global
3607
    // objects will have been initialized (including the event type constants)
3608
    // and so it will have the correct value when it is needed
3609
    const int& m_eventType;
3610
3611
private:
3612
    wxDECLARE_NO_ASSIGN_DEF_COPY(wxEventTableEntry);
3613
};
3614
3615
// an entry used in dynamic event table managed by wxEvtHandler::Connect()
3616
struct WXDLLIMPEXP_BASE wxDynamicEventTableEntry : public wxEventTableEntryBase
3617
{
3618
    wxDynamicEventTableEntry(int evType, int winid, int idLast,
3619
                             wxEventFunctor* fn, wxObject *data)
3620
0
        : wxEventTableEntryBase(winid, idLast, fn, data),
3621
0
          m_eventType(evType)
3622
0
    { }
3623
3624
    // not a reference here as we can't keep a reference to a temporary int
3625
    // created to wrap the constant value typically passed to Connect() - nor
3626
    // do we need it
3627
    int m_eventType;
3628
3629
private:
3630
    wxDECLARE_NO_ASSIGN_CLASS(wxDynamicEventTableEntry);
3631
};
3632
3633
// ----------------------------------------------------------------------------
3634
// wxEventTable: an array of event entries terminated with {0, 0, 0, 0, 0}
3635
// ----------------------------------------------------------------------------
3636
3637
struct WXDLLIMPEXP_BASE wxEventTable
3638
{
3639
    const wxEventTable *baseTable;    // base event table (next in chain)
3640
    const wxEventTableEntry *entries; // bottom of entry array
3641
};
3642
3643
// ----------------------------------------------------------------------------
3644
// wxEventHashTable: a helper of wxEvtHandler to speed up wxEventTable lookups.
3645
// ----------------------------------------------------------------------------
3646
3647
WX_DEFINE_ARRAY_PTR(const wxEventTableEntry*, wxEventTableEntryPointerArray);
3648
3649
class WXDLLIMPEXP_BASE wxEventHashTable
3650
{
3651
private:
3652
    // Internal data structs
3653
    struct EventTypeTable
3654
    {
3655
        wxEventType                   eventType;
3656
        wxEventTableEntryPointerArray eventEntryTable;
3657
    };
3658
    typedef EventTypeTable* EventTypeTablePointer;
3659
3660
public:
3661
    // Constructor, needs the event table it needs to hash later on.
3662
    // Note: hashing of the event table is not done in the constructor as it
3663
    //       can be that the event table is not yet full initialize, the hash
3664
    //       will gets initialized when handling the first event look-up request.
3665
    wxEventHashTable(const wxEventTable &table);
3666
    // Destructor.
3667
    ~wxEventHashTable();
3668
3669
    // Handle the given event, in other words search the event table hash
3670
    // and call self->ProcessEvent() if a match was found.
3671
    bool HandleEvent(wxEvent& event, wxEvtHandler *self);
3672
3673
    // Clear table
3674
    void Clear();
3675
3676
protected:
3677
    // Init the hash table with the entries of the static event table.
3678
    void InitHashTable();
3679
    // Helper function of InitHashTable() to insert 1 entry into the hash table.
3680
    void AddEntry(const wxEventTableEntry &entry);
3681
    // Allocate and init with null pointers the base hash table.
3682
    void AllocEventTypeTable(size_t size);
3683
    // Grow the hash table in size and transfer all items currently
3684
    // in the table to the correct location in the new table.
3685
    void GrowEventTypeTable();
3686
3687
protected:
3688
    const wxEventTable    &m_table;
3689
    bool                   m_rebuildHash;
3690
3691
    size_t                 m_size;
3692
    EventTypeTablePointer *m_eventTypeTable;
3693
3694
    static wxEventHashTable* sm_first;
3695
    wxEventHashTable* m_previous;
3696
    wxEventHashTable* m_next;
3697
3698
    wxDECLARE_NO_COPY_CLASS(wxEventHashTable);
3699
};
3700
3701
// ----------------------------------------------------------------------------
3702
// wxEvtHandler: the base class for all objects handling wxWidgets events
3703
// ----------------------------------------------------------------------------
3704
3705
class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
3706
                                    , public wxTrackable
3707
{
3708
public:
3709
    wxEvtHandler();
3710
    virtual ~wxEvtHandler();
3711
3712
3713
    // Event handler chain
3714
    // -------------------
3715
3716
0
    wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
3717
0
    wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
3718
0
    virtual void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
3719
0
    virtual void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }
3720
3721
0
    void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
3722
0
    bool GetEvtHandlerEnabled() const { return m_enabled; }
3723
3724
    void Unlink();
3725
    bool IsUnlinked() const;
3726
3727
3728
    // Global event filters
3729
    // --------------------
3730
3731
    // Add an event filter whose FilterEvent() method will be called for each
3732
    // and every event processed by wxWidgets. The filters are called in LIFO
3733
    // order and wxApp is registered as an event filter by default. The pointer
3734
    // must remain valid until it's removed with RemoveFilter() and is not
3735
    // deleted by wxEvtHandler.
3736
    static void AddFilter(wxEventFilter* filter);
3737
3738
    // Remove a filter previously installed with AddFilter().
3739
    static void RemoveFilter(wxEventFilter* filter);
3740
3741
3742
    // Event queuing and processing
3743
    // ----------------------------
3744
3745
    // Process an event right now: this can only be called from the main
3746
    // thread, use QueueEvent() for scheduling the events for
3747
    // processing from other threads.
3748
    virtual bool ProcessEvent(wxEvent& event);
3749
3750
    // Process an event by calling ProcessEvent and handling any exceptions
3751
    // thrown by event handlers. It's mostly useful when processing wx events
3752
    // when called from C code (e.g. in GTK+ callback) when the exception
3753
    // wouldn't correctly propagate to wxEventLoop.
3754
    bool SafelyProcessEvent(wxEvent& event);
3755
        // NOTE: uses ProcessEvent()
3756
3757
    // This method tries to process the event in this event handler, including
3758
    // any preprocessing done by TryBefore() and all the handlers chained to
3759
    // it, but excluding the post-processing done in TryAfter().
3760
    //
3761
    // It is meant to be called from ProcessEvent() only and is not virtual,
3762
    // additional event handlers can be hooked into the normal event processing
3763
    // logic using TryBefore() and TryAfter() hooks.
3764
    //
3765
    // You can also call it yourself to forward an event to another handler but
3766
    // without propagating it upwards if it's unhandled (this is usually
3767
    // unwanted when forwarding as the original handler would already do it if
3768
    // needed normally).
3769
    bool ProcessEventLocally(wxEvent& event);
3770
3771
    // Schedule the given event to be processed later. It takes ownership of
3772
    // the event pointer, i.e. it will be deleted later. This is safe to call
3773
    // from multiple threads although you still need to ensure that wxString
3774
    // fields of the event object are deep copies and not use the same string
3775
    // buffer as other wxString objects in this thread.
3776
    virtual void QueueEvent(wxEvent *event);
3777
3778
    // Add an event to be processed later: notice that this function is not
3779
    // safe to call from threads other than main, use QueueEvent()
3780
    virtual void AddPendingEvent(const wxEvent& event)
3781
0
    {
3782
        // notice that the thread-safety problem comes from the fact that
3783
        // Clone() doesn't make deep copies of wxString fields of wxEvent
3784
        // object and so the same wxString could be used from both threads when
3785
        // the event object is destroyed in this one -- QueueEvent() avoids
3786
        // this problem as the event pointer is not used any more in this
3787
        // thread at all after it is called.
3788
0
        QueueEvent(event.Clone());
3789
0
    }
3790
3791
    void ProcessPendingEvents();
3792
        // NOTE: uses ProcessEvent()
3793
3794
    void DeletePendingEvents();
3795
3796
#if wxUSE_THREADS
3797
    bool ProcessThreadEvent(const wxEvent& event);
3798
        // NOTE: uses AddPendingEvent(); call only from secondary threads
3799
#endif
3800
3801
#if wxUSE_EXCEPTIONS
3802
    // This is a private function which handles any exceptions arising during
3803
    // the execution of user-defined code called in the event loop context by
3804
    // forwarding them to wxApp::OnExceptionInMainLoop() and, if it rethrows,
3805
    // to wxApp::OnUnhandledException(). In any case this function ensures that
3806
    // no exceptions ever escape from it and so is useful to call at module
3807
    // boundary.
3808
    //
3809
    // It must be only called when handling an active exception.
3810
    static void WXConsumeException();
3811
#endif // wxUSE_EXCEPTIONS
3812
3813
    // Asynchronous method calls: these methods schedule the given method
3814
    // pointer for a later call (during the next idle event loop iteration).
3815
    //
3816
    // Notice that the method is called on this object itself, so the object
3817
    // CallAfter() is called on must have the correct dynamic type.
3818
    //
3819
    // These method can be used from another thread.
3820
3821
    template <typename T>
3822
    void CallAfter(void (T::*method)())
3823
    {
3824
        QueueEvent(
3825
            new wxAsyncMethodCallEvent0<T>(static_cast<T*>(this), method)
3826
        );
3827
    }
3828
3829
    // Notice that we use P1 and not T1 for the parameter to allow passing
3830
    // parameters that are convertible to the type taken by the method
3831
    // instead of being exactly the same, to be closer to the usual method call
3832
    // semantics.
3833
    template <typename T, typename T1, typename P1>
3834
    void CallAfter(void (T::*method)(T1 x1), P1 x1)
3835
    {
3836
        QueueEvent(
3837
            new wxAsyncMethodCallEvent1<T, T1>(
3838
                static_cast<T*>(this), method, x1)
3839
        );
3840
    }
3841
3842
    template <typename T, typename T1, typename T2, typename P1, typename P2>
3843
    void CallAfter(void (T::*method)(T1 x1, T2 x2), P1 x1, P2 x2)
3844
    {
3845
        QueueEvent(
3846
            new wxAsyncMethodCallEvent2<T, T1, T2>(
3847
                static_cast<T*>(this), method, x1, x2)
3848
        );
3849
    }
3850
3851
    template <typename T>
3852
    void CallAfter(const T& fn)
3853
    {
3854
        QueueEvent(new wxAsyncMethodCallEventFunctor<T>(this, fn));
3855
    }
3856
3857
3858
    // Connecting and disconnecting
3859
    // ----------------------------
3860
3861
    // These functions are used for old, untyped, event handlers and don't
3862
    // check that the type of the function passed to them actually matches the
3863
    // type of the event. They also only allow connecting events to methods of
3864
    // wxEvtHandler-derived classes.
3865
    //
3866
    // The template Connect() methods below are safer and allow connecting
3867
    // events to arbitrary functions or functors -- but require compiler
3868
    // support for templates.
3869
3870
    // Dynamic association of a member function handler with the event handler,
3871
    // winid and event type
3872
    void Connect(int winid,
3873
                 int lastId,
3874
                 wxEventType eventType,
3875
                 wxObjectEventFunction func,
3876
                 wxObject *userData = nullptr,
3877
                 wxEvtHandler *eventSink = nullptr)
3878
0
    {
3879
0
        DoBind(winid, lastId, eventType,
3880
0
                  wxNewEventFunctor(eventType, func, eventSink),
3881
0
                  userData);
3882
0
    }
3883
3884
    // Convenience function: take just one id
3885
    void Connect(int winid,
3886
                 wxEventType eventType,
3887
                 wxObjectEventFunction func,
3888
                 wxObject *userData = nullptr,
3889
                 wxEvtHandler *eventSink = nullptr)
3890
0
        { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }
3891
3892
    // Even more convenient: without id (same as using id of wxID_ANY)
3893
    void Connect(wxEventType eventType,
3894
                 wxObjectEventFunction func,
3895
                 wxObject *userData = nullptr,
3896
                 wxEvtHandler *eventSink = nullptr)
3897
0
        { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); }
3898
3899
    bool Disconnect(int winid,
3900
                    int lastId,
3901
                    wxEventType eventType,
3902
                    wxObjectEventFunction func = nullptr,
3903
                    wxObject *userData = nullptr,
3904
                    wxEvtHandler *eventSink = nullptr)
3905
0
    {
3906
0
        return DoUnbind(winid, lastId, eventType,
3907
0
                            wxMakeEventFunctor(eventType, func, eventSink),
3908
0
                            userData );
3909
0
    }
3910
3911
    bool Disconnect(int winid = wxID_ANY,
3912
                    wxEventType eventType = wxEVT_NULL,
3913
                    wxObjectEventFunction func = nullptr,
3914
                    wxObject *userData = nullptr,
3915
                    wxEvtHandler *eventSink = nullptr)
3916
0
        { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }
3917
3918
    bool Disconnect(wxEventType eventType,
3919
                    wxObjectEventFunction func,
3920
                    wxObject *userData = nullptr,
3921
                    wxEvtHandler *eventSink = nullptr)
3922
0
        { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); }
3923
3924
    // Bind functions to an event:
3925
    template <typename EventTag, typename EventArg>
3926
    void Bind(const EventTag& eventType,
3927
              void (*function)(EventArg &),
3928
              int winid = wxID_ANY,
3929
              int lastId = wxID_ANY,
3930
              wxObject *userData = nullptr)
3931
    {
3932
        DoBind(winid, lastId, eventType,
3933
                  wxNewEventFunctor(eventType, function),
3934
                  userData);
3935
    }
3936
3937
3938
    template <typename EventTag, typename EventArg>
3939
    bool Unbind(const EventTag& eventType,
3940
                void (*function)(EventArg &),
3941
                int winid = wxID_ANY,
3942
                int lastId = wxID_ANY,
3943
                wxObject *userData = nullptr)
3944
    {
3945
        return DoUnbind(winid, lastId, eventType,
3946
                            wxMakeEventFunctor(eventType, function),
3947
                            userData);
3948
    }
3949
3950
    // Bind functors to an event:
3951
    template <typename EventTag, typename Functor>
3952
    void Bind(const EventTag& eventType,
3953
              const Functor &functor,
3954
              int winid = wxID_ANY,
3955
              int lastId = wxID_ANY,
3956
              wxObject *userData = nullptr)
3957
    {
3958
        DoBind(winid, lastId, eventType,
3959
                  wxNewEventFunctor(eventType, functor),
3960
                  userData);
3961
    }
3962
3963
3964
    template <typename EventTag, typename Functor>
3965
    bool Unbind(const EventTag& eventType,
3966
                const Functor &functor,
3967
                int winid = wxID_ANY,
3968
                int lastId = wxID_ANY,
3969
                wxObject *userData = nullptr)
3970
    {
3971
        return DoUnbind(winid, lastId, eventType,
3972
                            wxMakeEventFunctor(eventType, functor),
3973
                            userData);
3974
    }
3975
3976
3977
    // Bind a method of a class (called on the specified handler which must
3978
    // be convertible to this class) object to an event:
3979
3980
    template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
3981
    void Bind(const EventTag &eventType,
3982
              void (Class::*method)(EventArg &),
3983
              EventHandler *handler,
3984
              int winid = wxID_ANY,
3985
              int lastId = wxID_ANY,
3986
              wxObject *userData = nullptr)
3987
    {
3988
        DoBind(winid, lastId, eventType,
3989
                  wxNewEventFunctor(eventType, method, handler),
3990
                  userData);
3991
    }
3992
3993
    template <typename EventTag, typename Class, typename EventArg, typename EventHandler>
3994
    bool Unbind(const EventTag &eventType,
3995
                void (Class::*method)(EventArg&),
3996
                EventHandler *handler,
3997
                int winid = wxID_ANY,
3998
                int lastId = wxID_ANY,
3999
                wxObject *userData = nullptr )
4000
    {
4001
        return DoUnbind(winid, lastId, eventType,
4002
                            wxMakeEventFunctor(eventType, method, handler),
4003
                            userData);
4004
    }
4005
4006
    // User data can be associated with each wxEvtHandler
4007
0
    void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
4008
0
    wxClientData *GetClientObject() const { return DoGetClientObject(); }
4009
4010
0
    void SetClientData( void *data ) { DoSetClientData(data); }
4011
0
    void *GetClientData() const { return DoGetClientData(); }
4012
4013
4014
    // implementation from now on
4015
    // --------------------------
4016
4017
    // check if the given event table entry matches this event by id (the check
4018
    // for the event type should be done by caller) and call the handler if it
4019
    // does
4020
    //
4021
    // return true if the event was processed, false otherwise (no match or the
4022
    // handler decided to skip the event)
4023
    static bool ProcessEventIfMatchesId(const wxEventTableEntryBase& tableEntry,
4024
                                        wxEvtHandler *handler,
4025
                                        wxEvent& event);
4026
4027
    // Allow iterating over all connected dynamic event handlers: you must pass
4028
    // the same "cookie" to GetFirst() and GetNext() and call them until null
4029
    // is returned.
4030
    //
4031
    // These functions are for internal use only.
4032
    wxDynamicEventTableEntry* GetFirstDynamicEntry(size_t& cookie) const;
4033
    wxDynamicEventTableEntry* GetNextDynamicEntry(size_t& cookie) const;
4034
4035
    virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
4036
    bool SearchDynamicEventTable( wxEvent& event );
4037
4038
    // Avoid problems at exit by cleaning up static hash table gracefully
4039
0
    void ClearEventHashTable() { GetEventHashTable().Clear(); }
4040
    void OnSinkDestroyed( wxEvtHandler *sink );
4041
4042
4043
private:
4044
    void DoBind(int winid,
4045
                   int lastId,
4046
                   wxEventType eventType,
4047
                   wxEventFunctor *func,
4048
                   wxObject* userData = nullptr);
4049
4050
    bool DoUnbind(int winid,
4051
                      int lastId,
4052
                      wxEventType eventType,
4053
                      const wxEventFunctor& func,
4054
                      wxObject *userData = nullptr);
4055
4056
    static const wxEventTableEntry sm_eventTableEntries[];
4057
4058
protected:
4059
    // hooks for wxWindow used by ProcessEvent()
4060
    // -----------------------------------------
4061
4062
    // this one is called before trying our own event table to allow plugging
4063
    // in the event handlers overriding the default logic, this is used by e.g.
4064
    // validators.
4065
    virtual bool TryBefore(wxEvent& event);
4066
4067
    // This one is not a hook but just a helper which looks up the handler in
4068
    // this object itself.
4069
    //
4070
    // It is called from ProcessEventLocally() and normally shouldn't be called
4071
    // directly as doing it would ignore any chained event handlers
4072
    bool TryHereOnly(wxEvent& event);
4073
4074
    // Another helper which simply calls pre-processing hook and then tries to
4075
    // handle the event at this handler level.
4076
    bool TryBeforeAndHere(wxEvent& event)
4077
0
    {
4078
0
        return TryBefore(event) || TryHereOnly(event);
4079
0
    }
4080
4081
    // this one is called after failing to find the event handle in our own
4082
    // table to give a chance to the other windows to process it
4083
    //
4084
    // base class implementation passes the event to wxTheApp
4085
    virtual bool TryAfter(wxEvent& event);
4086
4087
    // Overriding this method allows filtering the event handlers dynamically
4088
    // connected to this object. If this method returns false, the handler is
4089
    // not connected at all. If it returns true, it is connected using the
4090
    // possibly modified fields of the given entry.
4091
    virtual bool OnDynamicBind(wxDynamicEventTableEntry& WXUNUSED(entry))
4092
0
    {
4093
0
        return true;
4094
0
    }
4095
4096
4097
    static const wxEventTable sm_eventTable;
4098
    virtual const wxEventTable *GetEventTable() const;
4099
4100
    static wxEventHashTable   sm_eventHashTable;
4101
    virtual wxEventHashTable& GetEventHashTable() const;
4102
4103
    wxEvtHandler*       m_nextHandler;
4104
    wxEvtHandler*       m_previousHandler;
4105
4106
    struct DynamicEvents
4107
    {
4108
        wxVector<wxDynamicEventTableEntry*> m_entries;
4109
        wxRecursionGuardFlag m_flag = 0;
4110
    };
4111
    // use wxSharedPtr so that SearchDynamicEventTable() can use another
4112
    // instance of wxSharedPtr to extend the life of the wxRecursionGuardFlag
4113
    // to outlive wxRecursionGuard
4114
    wxSharedPtr<DynamicEvents> m_dynamicEvents;
4115
4116
    wxList*             m_pendingEvents;
4117
4118
#if wxUSE_THREADS
4119
    // critical section protecting m_pendingEvents
4120
    wxCriticalSection m_pendingEventsLock;
4121
#endif // wxUSE_THREADS
4122
4123
    // Is event handler enabled?
4124
    bool                m_enabled;
4125
4126
4127
    // The user data: either an object which will be deleted by the container
4128
    // when it's deleted or some raw pointer which we do nothing with - only
4129
    // one type of data can be used with the given window (i.e. you cannot set
4130
    // the void data and then associate the container with wxClientData or vice
4131
    // versa)
4132
    union
4133
    {
4134
        wxClientData *m_clientObject;
4135
        void         *m_clientData;
4136
    };
4137
4138
    // what kind of data do we have?
4139
    wxClientDataType m_clientDataType;
4140
4141
    // client data accessors
4142
    virtual void DoSetClientObject( wxClientData *data );
4143
    virtual wxClientData *DoGetClientObject() const;
4144
4145
    virtual void DoSetClientData( void *data );
4146
    virtual void *DoGetClientData() const;
4147
4148
    // Search tracker objects for event connection with this sink
4149
    wxEventConnectionRef *FindRefInTrackerList(wxEvtHandler *handler);
4150
4151
private:
4152
    // pass the event to wxTheApp instance, called from TryAfter()
4153
    bool DoTryApp(wxEvent& event);
4154
4155
    // try to process events in all handlers chained to this one
4156
    bool DoTryChain(wxEvent& event);
4157
4158
    // Head of the event filter linked list.
4159
    static wxEventFilter* ms_filterList;
4160
4161
    wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler);
4162
};
4163
4164
WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE);
4165
4166
4167
// Define an inline method of wxObjectEventFunctor which couldn't be defined
4168
// before wxEvtHandler declaration: at least Sun CC refuses to compile function
4169
// calls through pointer to member for forward-declared classes (see #12452).
4170
inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event)
4171
0
{
4172
0
    wxEvtHandler * const realHandler = m_handler ? m_handler : handler;
4173
4174
0
    (realHandler->*m_method)(event);
4175
0
}
4176
4177
// ----------------------------------------------------------------------------
4178
// wxEventConnectionRef represents all connections between two event handlers
4179
// and enables automatic disconnect when an event handler sink goes out of
4180
// scope. Each connection/disconnect increases/decreases ref count, and
4181
// when it reaches zero the node goes out of scope.
4182
// ----------------------------------------------------------------------------
4183
4184
class wxEventConnectionRef : public wxTrackerNode
4185
{
4186
public:
4187
0
    wxEventConnectionRef() : m_src(nullptr), m_sink(nullptr), m_refCount(0) { }
4188
    wxEventConnectionRef(wxEvtHandler *src, wxEvtHandler *sink)
4189
0
        : m_src(src), m_sink(sink), m_refCount(1)
4190
0
    {
4191
0
        m_sink->AddNode(this);
4192
0
    }
4193
4194
    // The sink is being destroyed
4195
    virtual void OnObjectDestroy( ) override
4196
0
    {
4197
0
        if ( m_src )
4198
0
            m_src->OnSinkDestroyed( m_sink );
4199
0
        delete this;
4200
0
    }
4201
4202
0
    virtual wxEventConnectionRef *ToEventConnection() override { return this; }
4203
4204
0
    void IncRef() { m_refCount++; }
4205
    void DecRef()
4206
0
    {
4207
0
        if ( !--m_refCount )
4208
0
        {
4209
            // The sink holds the only external pointer to this object
4210
0
            if ( m_sink )
4211
0
                m_sink->RemoveNode(this);
4212
0
            delete this;
4213
0
        }
4214
0
    }
4215
4216
private:
4217
    wxEvtHandler *m_src,
4218
                 *m_sink;
4219
    int m_refCount;
4220
4221
    friend class wxEvtHandler;
4222
4223
    wxDECLARE_NO_ASSIGN_CLASS(wxEventConnectionRef);
4224
};
4225
4226
// Post a message to the given event handler which will be processed during the
4227
// next event loop iteration.
4228
//
4229
// Notice that this one is not thread-safe, use wxQueueEvent()
4230
inline void wxPostEvent(wxEvtHandler *dest, const wxEvent& event)
4231
0
{
4232
0
    wxCHECK_RET( dest, "need an object to post event to" );
4233
0
4234
0
    dest->AddPendingEvent(event);
4235
0
}
4236
4237
// Wrapper around wxEvtHandler::QueueEvent(): adds an event for later
4238
// processing, unlike wxPostEvent it is safe to use from different thread even
4239
// for events with wxString members
4240
inline void wxQueueEvent(wxEvtHandler *dest, wxEvent *event)
4241
0
{
4242
0
    wxCHECK_RET( dest, "need an object to queue event for" );
4243
0
4244
0
    dest->QueueEvent(event);
4245
0
}
4246
4247
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
4248
typedef void (wxEvtHandler::*wxIdleEventFunction)(wxIdleEvent&);
4249
typedef void (wxEvtHandler::*wxThreadEventFunction)(wxThreadEvent&);
4250
4251
#define wxEventHandler(func) \
4252
    wxEVENT_HANDLER_CAST(wxEventFunction, func)
4253
#define wxIdleEventHandler(func) \
4254
    wxEVENT_HANDLER_CAST(wxIdleEventFunction, func)
4255
#define wxThreadEventHandler(func) \
4256
    wxEVENT_HANDLER_CAST(wxThreadEventFunction, func)
4257
4258
#if wxUSE_GUI
4259
4260
// ----------------------------------------------------------------------------
4261
// wxEventBlocker: helper class to temporarily disable event handling for a window
4262
// ----------------------------------------------------------------------------
4263
4264
class WXDLLIMPEXP_CORE wxEventBlocker : public wxEvtHandler
4265
{
4266
public:
4267
    wxEventBlocker(wxWindow *win, wxEventType type = wxEVT_ANY);
4268
    virtual ~wxEventBlocker();
4269
4270
    void Block(wxEventType type)
4271
    {
4272
        m_eventsToBlock.push_back(type);
4273
    }
4274
4275
    virtual bool ProcessEvent(wxEvent& event) override;
4276
4277
protected:
4278
    wxArrayInt m_eventsToBlock;
4279
    wxWindow *m_window;
4280
4281
    wxDECLARE_NO_COPY_CLASS(wxEventBlocker);
4282
};
4283
4284
typedef void (wxEvtHandler::*wxCommandEventFunction)(wxCommandEvent&);
4285
typedef void (wxEvtHandler::*wxScrollEventFunction)(wxScrollEvent&);
4286
typedef void (wxEvtHandler::*wxScrollWinEventFunction)(wxScrollWinEvent&);
4287
typedef void (wxEvtHandler::*wxSizeEventFunction)(wxSizeEvent&);
4288
typedef void (wxEvtHandler::*wxMoveEventFunction)(wxMoveEvent&);
4289
typedef void (wxEvtHandler::*wxPaintEventFunction)(wxPaintEvent&);
4290
typedef void (wxEvtHandler::*wxNcPaintEventFunction)(wxNcPaintEvent&);
4291
typedef void (wxEvtHandler::*wxEraseEventFunction)(wxEraseEvent&);
4292
typedef void (wxEvtHandler::*wxMouseEventFunction)(wxMouseEvent&);
4293
typedef void (wxEvtHandler::*wxCharEventFunction)(wxKeyEvent&);
4294
typedef void (wxEvtHandler::*wxFocusEventFunction)(wxFocusEvent&);
4295
typedef void (wxEvtHandler::*wxChildFocusEventFunction)(wxChildFocusEvent&);
4296
typedef void (wxEvtHandler::*wxActivateEventFunction)(wxActivateEvent&);
4297
typedef void (wxEvtHandler::*wxMenuEventFunction)(wxMenuEvent&);
4298
typedef void (wxEvtHandler::*wxJoystickEventFunction)(wxJoystickEvent&);
4299
typedef void (wxEvtHandler::*wxDropFilesEventFunction)(wxDropFilesEvent&);
4300
typedef void (wxEvtHandler::*wxInitDialogEventFunction)(wxInitDialogEvent&);
4301
typedef void (wxEvtHandler::*wxSysColourChangedEventFunction)(wxSysColourChangedEvent&);
4302
typedef void (wxEvtHandler::*wxSysMetricChangedEventFunction)(wxSysMetricChangedEvent&);
4303
typedef void (wxEvtHandler::*wxDisplayChangedEventFunction)(wxDisplayChangedEvent&);
4304
typedef void (wxEvtHandler::*wxDPIChangedEventFunction)(wxDPIChangedEvent&);
4305
typedef void (wxEvtHandler::*wxUpdateUIEventFunction)(wxUpdateUIEvent&);
4306
typedef void (wxEvtHandler::*wxCloseEventFunction)(wxCloseEvent&);
4307
typedef void (wxEvtHandler::*wxShowEventFunction)(wxShowEvent&);
4308
typedef void (wxEvtHandler::*wxIconizeEventFunction)(wxIconizeEvent&);
4309
typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxMaximizeEvent&);
4310
typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&);
4311
typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&);
4312
typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&);
4313
typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&);
4314
typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&);
4315
typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
4316
typedef void (wxEvtHandler::*wxNotifyEventFunction)(wxNotifyEvent&);
4317
typedef void (wxEvtHandler::*wxHelpEventFunction)(wxHelpEvent&);
4318
typedef void (wxEvtHandler::*wxContextMenuEventFunction)(wxContextMenuEvent&);
4319
typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureChangedEvent&);
4320
typedef void (wxEvtHandler::*wxMouseCaptureLostEventFunction)(wxMouseCaptureLostEvent&);
4321
typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent&);
4322
typedef void (wxEvtHandler::*wxMultiTouchEventFunction)(wxMultiTouchEvent&);
4323
typedef void (wxEvtHandler::*wxPanGestureEventFunction)(wxPanGestureEvent&);
4324
typedef void (wxEvtHandler::*wxZoomGestureEventFunction)(wxZoomGestureEvent&);
4325
typedef void (wxEvtHandler::*wxRotateGestureEventFunction)(wxRotateGestureEvent&);
4326
typedef void (wxEvtHandler::*wxTwoFingerTapEventFunction)(wxTwoFingerTapEvent&);
4327
typedef void (wxEvtHandler::*wxLongPressEventFunction)(wxLongPressEvent&);
4328
typedef void (wxEvtHandler::*wxPressAndTapEventFunction)(wxPressAndTapEvent&);
4329
typedef void (wxEvtHandler::*wxFullScreenEventFunction)(wxFullScreenEvent&);
4330
4331
#define wxCommandEventHandler(func) \
4332
    wxEVENT_HANDLER_CAST(wxCommandEventFunction, func)
4333
#define wxScrollEventHandler(func) \
4334
    wxEVENT_HANDLER_CAST(wxScrollEventFunction, func)
4335
#define wxScrollWinEventHandler(func) \
4336
    wxEVENT_HANDLER_CAST(wxScrollWinEventFunction, func)
4337
#define wxSizeEventHandler(func) \
4338
    wxEVENT_HANDLER_CAST(wxSizeEventFunction, func)
4339
#define wxMoveEventHandler(func) \
4340
    wxEVENT_HANDLER_CAST(wxMoveEventFunction, func)
4341
#define wxPaintEventHandler(func) \
4342
    wxEVENT_HANDLER_CAST(wxPaintEventFunction, func)
4343
#define wxNcPaintEventHandler(func) \
4344
    wxEVENT_HANDLER_CAST(wxNcPaintEventFunction, func)
4345
#define wxEraseEventHandler(func) \
4346
    wxEVENT_HANDLER_CAST(wxEraseEventFunction, func)
4347
#define wxMouseEventHandler(func) \
4348
    wxEVENT_HANDLER_CAST(wxMouseEventFunction, func)
4349
#define wxCharEventHandler(func) \
4350
    wxEVENT_HANDLER_CAST(wxCharEventFunction, func)
4351
#define wxKeyEventHandler(func) wxCharEventHandler(func)
4352
#define wxFocusEventHandler(func) \
4353
    wxEVENT_HANDLER_CAST(wxFocusEventFunction, func)
4354
#define wxChildFocusEventHandler(func) \
4355
    wxEVENT_HANDLER_CAST(wxChildFocusEventFunction, func)
4356
#define wxActivateEventHandler(func) \
4357
    wxEVENT_HANDLER_CAST(wxActivateEventFunction, func)
4358
#define wxMenuEventHandler(func) \
4359
    wxEVENT_HANDLER_CAST(wxMenuEventFunction, func)
4360
#define wxJoystickEventHandler(func) \
4361
    wxEVENT_HANDLER_CAST(wxJoystickEventFunction, func)
4362
#define wxDropFilesEventHandler(func) \
4363
    wxEVENT_HANDLER_CAST(wxDropFilesEventFunction, func)
4364
#define wxInitDialogEventHandler(func) \
4365
    wxEVENT_HANDLER_CAST(wxInitDialogEventFunction, func)
4366
#define wxSysColourChangedEventHandler(func) \
4367
    wxEVENT_HANDLER_CAST(wxSysColourChangedEventFunction, func)
4368
#define wxSysMetricChangedEventHandler(func) \
4369
    wxEVENT_HANDLER_CAST(wxSysMetricChangedEventFunction, func)
4370
#define wxDisplayChangedEventHandler(func) \
4371
    wxEVENT_HANDLER_CAST(wxDisplayChangedEventFunction, func)
4372
#define wxDPIChangedEventHandler(func) \
4373
    wxEVENT_HANDLER_CAST(wxDPIChangedEventFunction, func)
4374
#define wxUpdateUIEventHandler(func) \
4375
    wxEVENT_HANDLER_CAST(wxUpdateUIEventFunction, func)
4376
#define wxCloseEventHandler(func) \
4377
    wxEVENT_HANDLER_CAST(wxCloseEventFunction, func)
4378
#define wxShowEventHandler(func) \
4379
    wxEVENT_HANDLER_CAST(wxShowEventFunction, func)
4380
#define wxIconizeEventHandler(func) \
4381
    wxEVENT_HANDLER_CAST(wxIconizeEventFunction, func)
4382
#define wxMaximizeEventHandler(func) \
4383
    wxEVENT_HANDLER_CAST(wxMaximizeEventFunction, func)
4384
#define wxNavigationKeyEventHandler(func) \
4385
    wxEVENT_HANDLER_CAST(wxNavigationKeyEventFunction, func)
4386
#define wxPaletteChangedEventHandler(func) \
4387
    wxEVENT_HANDLER_CAST(wxPaletteChangedEventFunction, func)
4388
#define wxQueryNewPaletteEventHandler(func) \
4389
    wxEVENT_HANDLER_CAST(wxQueryNewPaletteEventFunction, func)
4390
#define wxWindowCreateEventHandler(func) \
4391
    wxEVENT_HANDLER_CAST(wxWindowCreateEventFunction, func)
4392
#define wxWindowDestroyEventHandler(func) \
4393
    wxEVENT_HANDLER_CAST(wxWindowDestroyEventFunction, func)
4394
#define wxSetCursorEventHandler(func) \
4395
    wxEVENT_HANDLER_CAST(wxSetCursorEventFunction, func)
4396
#define wxNotifyEventHandler(func) \
4397
    wxEVENT_HANDLER_CAST(wxNotifyEventFunction, func)
4398
#define wxHelpEventHandler(func) \
4399
    wxEVENT_HANDLER_CAST(wxHelpEventFunction, func)
4400
#define wxContextMenuEventHandler(func) \
4401
    wxEVENT_HANDLER_CAST(wxContextMenuEventFunction, func)
4402
#define wxMouseCaptureChangedEventHandler(func) \
4403
    wxEVENT_HANDLER_CAST(wxMouseCaptureChangedEventFunction, func)
4404
#define wxMouseCaptureLostEventHandler(func) \
4405
    wxEVENT_HANDLER_CAST(wxMouseCaptureLostEventFunction, func)
4406
#define wxClipboardTextEventHandler(func) \
4407
    wxEVENT_HANDLER_CAST(wxClipboardTextEventFunction, func)
4408
#define wxMultiTouchEventHandler(func) \
4409
    wxEVENT_HANDLER_CAST(wxMultiTouchEventFunction, func)
4410
#define wxPanGestureEventHandler(func) \
4411
    wxEVENT_HANDLER_CAST(wxPanGestureEventFunction, func)
4412
#define wxZoomGestureEventHandler(func) \
4413
    wxEVENT_HANDLER_CAST(wxZoomGestureEventFunction, func)
4414
#define wxRotateGestureEventHandler(func) \
4415
    wxEVENT_HANDLER_CAST(wxRotateGestureEventFunction, func)
4416
#define wxTwoFingerTapEventHandler(func) \
4417
    wxEVENT_HANDLER_CAST(wxTwoFingerTapEventFunction, func)
4418
#define wxLongPressEventHandler(func) \
4419
    wxEVENT_HANDLER_CAST(wxLongPressEventFunction, func)
4420
#define wxPressAndTapEventHandler(func) \
4421
    wxEVENT_HANDLER_CAST(wxPressAndTapEventFunction, func)
4422
#define wxFullScreenEventHandler(func) \
4423
    wxEVENT_HANDLER_CAST(wxFullScreenEventFunction, func)
4424
4425
#endif // wxUSE_GUI
4426
4427
// N.B. In GNU-WIN32, you *have* to take the address of a member function
4428
// (use &) or the compiler crashes...
4429
4430
#define wxDECLARE_EVENT_TABLE()                                         \
4431
    private:                                                            \
4432
        static const wxEventTableEntry sm_eventTableEntries[];          \
4433
    protected:                                                          \
4434
        wxWARNING_SUPPRESS_MISSING_OVERRIDE()                           \
4435
        const wxEventTable* GetEventTable() const wxDUMMY_OVERRIDE;     \
4436
        wxEventHashTable& GetEventHashTable() const wxDUMMY_OVERRIDE;   \
4437
        wxWARNING_RESTORE_MISSING_OVERRIDE()                            \
4438
        static const wxEventTable        sm_eventTable;                 \
4439
        static wxEventHashTable          sm_eventHashTable
4440
4441
#define wxBEGIN_EVENT_TABLE(theClass, baseClass) \
4442
    const wxEventTable theClass::sm_eventTable = \
4443
        { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \
4444
    const wxEventTable *theClass::GetEventTable() const \
4445
        { return &theClass::sm_eventTable; } \
4446
    wxEventHashTable theClass::sm_eventHashTable(theClass::sm_eventTable); \
4447
    wxEventHashTable &theClass::GetEventHashTable() const \
4448
        { return theClass::sm_eventHashTable; } \
4449
    const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
4450
4451
#define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \
4452
    template<typename T1> \
4453
    const wxEventTable theClass<T1>::sm_eventTable = \
4454
        { &baseClass::sm_eventTable, &theClass<T1>::sm_eventTableEntries[0] }; \
4455
    template<typename T1> \
4456
    const wxEventTable *theClass<T1>::GetEventTable() const \
4457
        { return &theClass<T1>::sm_eventTable; } \
4458
    template<typename T1> \
4459
    wxEventHashTable theClass<T1>::sm_eventHashTable(theClass<T1>::sm_eventTable); \
4460
    template<typename T1> \
4461
    wxEventHashTable &theClass<T1>::GetEventHashTable() const \
4462
        { return theClass<T1>::sm_eventHashTable; } \
4463
    template<typename T1> \
4464
    const wxEventTableEntry theClass<T1>::sm_eventTableEntries[] = { \
4465
4466
#define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \
4467
    template<typename T1, typename T2> \
4468
    const wxEventTable theClass<T1, T2>::sm_eventTable = \
4469
        { &baseClass::sm_eventTable, &theClass<T1, T2>::sm_eventTableEntries[0] }; \
4470
    template<typename T1, typename T2> \
4471
    const wxEventTable *theClass<T1, T2>::GetEventTable() const \
4472
        { return &theClass<T1, T2>::sm_eventTable; } \
4473
    template<typename T1, typename T2> \
4474
    wxEventHashTable theClass<T1, T2>::sm_eventHashTable(theClass<T1, T2>::sm_eventTable); \
4475
    template<typename T1, typename T2> \
4476
    wxEventHashTable &theClass<T1, T2>::GetEventHashTable() const \
4477
        { return theClass<T1, T2>::sm_eventHashTable; } \
4478
    template<typename T1, typename T2> \
4479
    const wxEventTableEntry theClass<T1, T2>::sm_eventTableEntries[] = { \
4480
4481
#define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \
4482
    template<typename T1, typename T2, typename T3> \
4483
    const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \
4484
        { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \
4485
    template<typename T1, typename T2, typename T3> \
4486
    const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \
4487
        { return &theClass<T1, T2, T3>::sm_eventTable; } \
4488
    template<typename T1, typename T2, typename T3> \
4489
    wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \
4490
    template<typename T1, typename T2, typename T3> \
4491
    wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \
4492
        { return theClass<T1, T2, T3>::sm_eventHashTable; } \
4493
    template<typename T1, typename T2, typename T3> \
4494
    const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \
4495
4496
#define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \
4497
    template<typename T1, typename T2, typename T3, typename T4> \
4498
    const wxEventTable theClass<T1, T2, T3, T4>::sm_eventTable = \
4499
        { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4>::sm_eventTableEntries[0] }; \
4500
    template<typename T1, typename T2, typename T3, typename T4> \
4501
    const wxEventTable *theClass<T1, T2, T3, T4>::GetEventTable() const \
4502
        { return &theClass<T1, T2, T3, T4>::sm_eventTable; } \
4503
    template<typename T1, typename T2, typename T3, typename T4> \
4504
    wxEventHashTable theClass<T1, T2, T3, T4>::sm_eventHashTable(theClass<T1, T2, T3, T4>::sm_eventTable); \
4505
    template<typename T1, typename T2, typename T3, typename T4> \
4506
    wxEventHashTable &theClass<T1, T2, T3, T4>::GetEventHashTable() const \
4507
        { return theClass<T1, T2, T3, T4>::sm_eventHashTable; } \
4508
    template<typename T1, typename T2, typename T3, typename T4> \
4509
    const wxEventTableEntry theClass<T1, T2, T3, T4>::sm_eventTableEntries[] = { \
4510
4511
#define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \
4512
    template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4513
    const wxEventTable theClass<T1, T2, T3, T4, T5>::sm_eventTable = \
4514
        { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[0] }; \
4515
    template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4516
    const wxEventTable *theClass<T1, T2, T3, T4, T5>::GetEventTable() const \
4517
        { return &theClass<T1, T2, T3, T4, T5>::sm_eventTable; } \
4518
    template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4519
    wxEventHashTable theClass<T1, T2, T3, T4, T5>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5>::sm_eventTable); \
4520
    template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4521
    wxEventHashTable &theClass<T1, T2, T3, T4, T5>::GetEventHashTable() const \
4522
        { return theClass<T1, T2, T3, T4, T5>::sm_eventHashTable; } \
4523
    template<typename T1, typename T2, typename T3, typename T4, typename T5> \
4524
    const wxEventTableEntry theClass<T1, T2, T3, T4, T5>::sm_eventTableEntries[] = { \
4525
4526
#define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \
4527
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4528
    const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable = \
4529
        { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[0] }; \
4530
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4531
    const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventTable() const \
4532
        { return &theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable; } \
4533
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4534
    wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTable); \
4535
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4536
    wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7>::GetEventHashTable() const \
4537
        { return theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventHashTable; } \
4538
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> \
4539
    const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7>::sm_eventTableEntries[] = { \
4540
4541
#define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \
4542
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4543
    const wxEventTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable = \
4544
        { &baseClass::sm_eventTable, &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[0] }; \
4545
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4546
    const wxEventTable *theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventTable() const \
4547
        { return &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable; } \
4548
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4549
    wxEventHashTable theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable(theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTable); \
4550
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4551
    wxEventHashTable &theClass<T1, T2, T3, T4, T5, T6, T7, T8>::GetEventHashTable() const \
4552
        { return theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventHashTable; } \
4553
    template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> \
4554
    const wxEventTableEntry theClass<T1, T2, T3, T4, T5, T6, T7, T8>::sm_eventTableEntries[] = { \
4555
4556
#define wxEND_EVENT_TABLE() \
4557
    wxDECLARE_EVENT_TABLE_TERMINATOR() };
4558
4559
/*
4560
 * Event table macros
4561
 */
4562
4563
// helpers for writing shorter code below: declare an event macro taking 2, 1
4564
// or none ids (the missing ids default to wxID_ANY)
4565
//
4566
// macro arguments:
4567
//  - evt one of wxEVT_XXX constants
4568
//  - id1, id2 ids of the first/last id
4569
//  - fn the function (should be cast to the right type)
4570
#define wx__DECLARE_EVT2(evt, id1, id2, fn) \
4571
    wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, nullptr),
4572
#define wx__DECLARE_EVT1(evt, id, fn) \
4573
    wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
4574
#define wx__DECLARE_EVT0(evt, fn) \
4575
    wx__DECLARE_EVT1(evt, wxID_ANY, fn)
4576
4577
4578
// Generic events
4579
#define EVT_CUSTOM(event, winid, func) \
4580
    wx__DECLARE_EVT1(event, winid, wxEventHandler(func))
4581
#define EVT_CUSTOM_RANGE(event, id1, id2, func) \
4582
    wx__DECLARE_EVT2(event, id1, id2, wxEventHandler(func))
4583
4584
// EVT_COMMAND
4585
#define EVT_COMMAND(winid, event, func) \
4586
    wx__DECLARE_EVT1(event, winid, wxCommandEventHandler(func))
4587
4588
#define EVT_COMMAND_RANGE(id1, id2, event, func) \
4589
    wx__DECLARE_EVT2(event, id1, id2, wxCommandEventHandler(func))
4590
4591
#define EVT_NOTIFY(event, winid, func) \
4592
    wx__DECLARE_EVT1(event, winid, wxNotifyEventHandler(func))
4593
4594
#define EVT_NOTIFY_RANGE(event, id1, id2, func) \
4595
    wx__DECLARE_EVT2(event, id1, id2, wxNotifyEventHandler(func))
4596
4597
// Miscellaneous
4598
#define EVT_SIZE(func)  wx__DECLARE_EVT0(wxEVT_SIZE, wxSizeEventHandler(func))
4599
#define EVT_SIZING(func)  wx__DECLARE_EVT0(wxEVT_SIZING, wxSizeEventHandler(func))
4600
#define EVT_MOVE(func)  wx__DECLARE_EVT0(wxEVT_MOVE, wxMoveEventHandler(func))
4601
#define EVT_MOVING(func)  wx__DECLARE_EVT0(wxEVT_MOVING, wxMoveEventHandler(func))
4602
#define EVT_MOVE_START(func)  wx__DECLARE_EVT0(wxEVT_MOVE_START, wxMoveEventHandler(func))
4603
#define EVT_MOVE_END(func)  wx__DECLARE_EVT0(wxEVT_MOVE_END, wxMoveEventHandler(func))
4604
#define EVT_CLOSE(func)  wx__DECLARE_EVT0(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(func))
4605
#define EVT_END_SESSION(func)  wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4606
#define EVT_QUERY_END_SESSION(func)  wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4607
#define EVT_PAINT(func)  wx__DECLARE_EVT0(wxEVT_PAINT, wxPaintEventHandler(func))
4608
#define EVT_NC_PAINT(func)  wx__DECLARE_EVT0(wxEVT_NC_PAINT, wxNcPaintEventHandler(func))
4609
#define EVT_ERASE_BACKGROUND(func)  wx__DECLARE_EVT0(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(func))
4610
#define EVT_CHAR(func)  wx__DECLARE_EVT0(wxEVT_CHAR, wxCharEventHandler(func))
4611
#define EVT_KEY_DOWN(func)  wx__DECLARE_EVT0(wxEVT_KEY_DOWN, wxKeyEventHandler(func))
4612
#define EVT_KEY_UP(func)  wx__DECLARE_EVT0(wxEVT_KEY_UP, wxKeyEventHandler(func))
4613
#if wxUSE_HOTKEY
4614
#define EVT_HOTKEY(winid, func)  wx__DECLARE_EVT1(wxEVT_HOTKEY, winid, wxCharEventHandler(func))
4615
#endif
4616
#define EVT_CHAR_HOOK(func)  wx__DECLARE_EVT0(wxEVT_CHAR_HOOK, wxCharEventHandler(func))
4617
#define EVT_MENU_OPEN(func)  wx__DECLARE_EVT0(wxEVT_MENU_OPEN, wxMenuEventHandler(func))
4618
#define EVT_MENU_CLOSE(func)  wx__DECLARE_EVT0(wxEVT_MENU_CLOSE, wxMenuEventHandler(func))
4619
#define EVT_MENU_HIGHLIGHT(winid, func)  wx__DECLARE_EVT1(wxEVT_MENU_HIGHLIGHT, winid, wxMenuEventHandler(func))
4620
#define EVT_MENU_HIGHLIGHT_ALL(func)  wx__DECLARE_EVT0(wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler(func))
4621
#define EVT_SET_FOCUS(func)  wx__DECLARE_EVT0(wxEVT_SET_FOCUS, wxFocusEventHandler(func))
4622
#define EVT_KILL_FOCUS(func)  wx__DECLARE_EVT0(wxEVT_KILL_FOCUS, wxFocusEventHandler(func))
4623
#define EVT_CHILD_FOCUS(func)  wx__DECLARE_EVT0(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(func))
4624
#define EVT_ACTIVATE(func)  wx__DECLARE_EVT0(wxEVT_ACTIVATE, wxActivateEventHandler(func))
4625
#define EVT_ACTIVATE_APP(func)  wx__DECLARE_EVT0(wxEVT_ACTIVATE_APP, wxActivateEventHandler(func))
4626
#define EVT_HIBERNATE(func)  wx__DECLARE_EVT0(wxEVT_HIBERNATE, wxActivateEventHandler(func))
4627
#define EVT_END_SESSION(func)  wx__DECLARE_EVT0(wxEVT_END_SESSION, wxCloseEventHandler(func))
4628
#define EVT_QUERY_END_SESSION(func)  wx__DECLARE_EVT0(wxEVT_QUERY_END_SESSION, wxCloseEventHandler(func))
4629
#define EVT_DROP_FILES(func)  wx__DECLARE_EVT0(wxEVT_DROP_FILES, wxDropFilesEventHandler(func))
4630
#define EVT_INIT_DIALOG(func)  wx__DECLARE_EVT0(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(func))
4631
#define EVT_SYS_COLOUR_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_COLOUR_CHANGED, wxSysColourChangedEventHandler(func))
4632
#define EVT_SYS_METRIC_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SYS_METRIC_CHANGED, wxSysMetricChangedEventHandler(func))
4633
#define EVT_DISPLAY_CHANGED(func)  wx__DECLARE_EVT0(wxEVT_DISPLAY_CHANGED, wxDisplayChangedEventHandler(func))
4634
#define EVT_DPI_CHANGED(func)  wx__DECLARE_EVT0(wxEVT_DPI_CHANGED, wxDPIChangedEventHandler(func))
4635
#define EVT_SHOW(func) wx__DECLARE_EVT0(wxEVT_SHOW, wxShowEventHandler(func))
4636
#define EVT_MAXIMIZE(func) wx__DECLARE_EVT0(wxEVT_MAXIMIZE, wxMaximizeEventHandler(func))
4637
#define EVT_ICONIZE(func) wx__DECLARE_EVT0(wxEVT_ICONIZE, wxIconizeEventHandler(func))
4638
#define EVT_NAVIGATION_KEY(func) wx__DECLARE_EVT0(wxEVT_NAVIGATION_KEY, wxNavigationKeyEventHandler(func))
4639
#define EVT_PALETTE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_PALETTE_CHANGED, wxPaletteChangedEventHandler(func))
4640
#define EVT_QUERY_NEW_PALETTE(func) wx__DECLARE_EVT0(wxEVT_QUERY_NEW_PALETTE, wxQueryNewPaletteEventHandler(func))
4641
#define EVT_WINDOW_CREATE(func) wx__DECLARE_EVT0(wxEVT_CREATE, wxWindowCreateEventHandler(func))
4642
#define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func))
4643
#define EVT_SET_CURSOR(func) wx__DECLARE_EVT0(wxEVT_SET_CURSOR, wxSetCursorEventHandler(func))
4644
#define EVT_MOUSE_CAPTURE_CHANGED(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_CHANGED, wxMouseCaptureChangedEventHandler(func))
4645
#define EVT_MOUSE_CAPTURE_LOST(func) wx__DECLARE_EVT0(wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler(func))
4646
#define EVT_FULLSCREEN(func) wx__DECLARE_EVT0(wxEVT_FULLSCREEN, wxFullScreenEventHandler(func))
4647
4648
// Mouse events
4649
#define EVT_LEFT_DOWN(func) wx__DECLARE_EVT0(wxEVT_LEFT_DOWN, wxMouseEventHandler(func))
4650
#define EVT_LEFT_UP(func) wx__DECLARE_EVT0(wxEVT_LEFT_UP, wxMouseEventHandler(func))
4651
#define EVT_MIDDLE_DOWN(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(func))
4652
#define EVT_MIDDLE_UP(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_UP, wxMouseEventHandler(func))
4653
#define EVT_RIGHT_DOWN(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DOWN, wxMouseEventHandler(func))
4654
#define EVT_RIGHT_UP(func) wx__DECLARE_EVT0(wxEVT_RIGHT_UP, wxMouseEventHandler(func))
4655
#define EVT_MOTION(func) wx__DECLARE_EVT0(wxEVT_MOTION, wxMouseEventHandler(func))
4656
#define EVT_LEFT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_LEFT_DCLICK, wxMouseEventHandler(func))
4657
#define EVT_MIDDLE_DCLICK(func) wx__DECLARE_EVT0(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(func))
4658
#define EVT_RIGHT_DCLICK(func) wx__DECLARE_EVT0(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(func))
4659
#define EVT_LEAVE_WINDOW(func) wx__DECLARE_EVT0(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(func))
4660
#define EVT_ENTER_WINDOW(func) wx__DECLARE_EVT0(wxEVT_ENTER_WINDOW, wxMouseEventHandler(func))
4661
#define EVT_MOUSEWHEEL(func) wx__DECLARE_EVT0(wxEVT_MOUSEWHEEL, wxMouseEventHandler(func))
4662
#define EVT_MOUSE_AUX1_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX1_DOWN, wxMouseEventHandler(func))
4663
#define EVT_MOUSE_AUX1_UP(func) wx__DECLARE_EVT0(wxEVT_AUX1_UP, wxMouseEventHandler(func))
4664
#define EVT_MOUSE_AUX1_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX1_DCLICK, wxMouseEventHandler(func))
4665
#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
4666
#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
4667
#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
4668
#define EVT_MAGNIFY(func) wx__DECLARE_EVT0(wxEVT_MAGNIFY, wxMouseEventHandler(func))
4669
4670
// All mouse events
4671
#define EVT_MOUSE_EVENTS(func) \
4672
    EVT_LEFT_DOWN(func) \
4673
    EVT_LEFT_UP(func) \
4674
    EVT_LEFT_DCLICK(func) \
4675
    EVT_MIDDLE_DOWN(func) \
4676
    EVT_MIDDLE_UP(func) \
4677
    EVT_MIDDLE_DCLICK(func) \
4678
    EVT_RIGHT_DOWN(func) \
4679
    EVT_RIGHT_UP(func) \
4680
    EVT_RIGHT_DCLICK(func) \
4681
    EVT_MOUSE_AUX1_DOWN(func) \
4682
    EVT_MOUSE_AUX1_UP(func) \
4683
    EVT_MOUSE_AUX1_DCLICK(func) \
4684
    EVT_MOUSE_AUX2_DOWN(func) \
4685
    EVT_MOUSE_AUX2_UP(func) \
4686
    EVT_MOUSE_AUX2_DCLICK(func) \
4687
    EVT_MOTION(func) \
4688
    EVT_LEAVE_WINDOW(func) \
4689
    EVT_ENTER_WINDOW(func) \
4690
    EVT_MOUSEWHEEL(func) \
4691
    EVT_MAGNIFY(func)
4692
4693
// Scrolling from wxWindow (sent to wxScrolledWindow)
4694
#define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
4695
#define EVT_SCROLLWIN_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(func))
4696
#define EVT_SCROLLWIN_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(func))
4697
#define EVT_SCROLLWIN_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(func))
4698
#define EVT_SCROLLWIN_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(func))
4699
#define EVT_SCROLLWIN_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(func))
4700
#define EVT_SCROLLWIN_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(func))
4701
#define EVT_SCROLLWIN_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(func))
4702
4703
#define EVT_SCROLLWIN(func) \
4704
    EVT_SCROLLWIN_TOP(func) \
4705
    EVT_SCROLLWIN_BOTTOM(func) \
4706
    EVT_SCROLLWIN_LINEUP(func) \
4707
    EVT_SCROLLWIN_LINEDOWN(func) \
4708
    EVT_SCROLLWIN_PAGEUP(func) \
4709
    EVT_SCROLLWIN_PAGEDOWN(func) \
4710
    EVT_SCROLLWIN_THUMBTRACK(func) \
4711
    EVT_SCROLLWIN_THUMBRELEASE(func)
4712
4713
// Scrolling from wxSlider and wxScrollBar
4714
#define EVT_SCROLL_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_TOP, wxScrollEventHandler(func))
4715
#define EVT_SCROLL_BOTTOM(func) wx__DECLARE_EVT0(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(func))
4716
#define EVT_SCROLL_LINEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(func))
4717
#define EVT_SCROLL_LINEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(func))
4718
#define EVT_SCROLL_PAGEUP(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(func))
4719
#define EVT_SCROLL_PAGEDOWN(func) wx__DECLARE_EVT0(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(func))
4720
#define EVT_SCROLL_THUMBTRACK(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(func))
4721
#define EVT_SCROLL_THUMBRELEASE(func) wx__DECLARE_EVT0(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(func))
4722
#define EVT_SCROLL_CHANGED(func) wx__DECLARE_EVT0(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(func))
4723
4724
#define EVT_SCROLL(func) \
4725
    EVT_SCROLL_TOP(func) \
4726
    EVT_SCROLL_BOTTOM(func) \
4727
    EVT_SCROLL_LINEUP(func) \
4728
    EVT_SCROLL_LINEDOWN(func) \
4729
    EVT_SCROLL_PAGEUP(func) \
4730
    EVT_SCROLL_PAGEDOWN(func) \
4731
    EVT_SCROLL_THUMBTRACK(func) \
4732
    EVT_SCROLL_THUMBRELEASE(func) \
4733
    EVT_SCROLL_CHANGED(func)
4734
4735
// Scrolling from wxSlider and wxScrollBar, with an id
4736
#define EVT_COMMAND_SCROLL_TOP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_TOP, winid, wxScrollEventHandler(func))
4737
#define EVT_COMMAND_SCROLL_BOTTOM(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_BOTTOM, winid, wxScrollEventHandler(func))
4738
#define EVT_COMMAND_SCROLL_LINEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEUP, winid, wxScrollEventHandler(func))
4739
#define EVT_COMMAND_SCROLL_LINEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_LINEDOWN, winid, wxScrollEventHandler(func))
4740
#define EVT_COMMAND_SCROLL_PAGEUP(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEUP, winid, wxScrollEventHandler(func))
4741
#define EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_PAGEDOWN, winid, wxScrollEventHandler(func))
4742
#define EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBTRACK, winid, wxScrollEventHandler(func))
4743
#define EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_THUMBRELEASE, winid, wxScrollEventHandler(func))
4744
#define EVT_COMMAND_SCROLL_CHANGED(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLL_CHANGED, winid, wxScrollEventHandler(func))
4745
4746
#define EVT_COMMAND_SCROLL(winid, func) \
4747
    EVT_COMMAND_SCROLL_TOP(winid, func) \
4748
    EVT_COMMAND_SCROLL_BOTTOM(winid, func) \
4749
    EVT_COMMAND_SCROLL_LINEUP(winid, func) \
4750
    EVT_COMMAND_SCROLL_LINEDOWN(winid, func) \
4751
    EVT_COMMAND_SCROLL_PAGEUP(winid, func) \
4752
    EVT_COMMAND_SCROLL_PAGEDOWN(winid, func) \
4753
    EVT_COMMAND_SCROLL_THUMBTRACK(winid, func) \
4754
    EVT_COMMAND_SCROLL_THUMBRELEASE(winid, func) \
4755
    EVT_COMMAND_SCROLL_CHANGED(winid, func)
4756
4757
// Multi-Touch events
4758
#define EVT_TOUCH_BEGIN(func) wx__DECLARE_EVT0(wxEVT_TOUCH_BEGIN, wxMultiTouchEventHandler(func))
4759
#define EVT_TOUCH_MOVE(func) wx__DECLARE_EVT0(wxEVT_TOUCH_MOVE, wxMultiTouchEventHandler(func))
4760
#define EVT_TOUCH_END(func) wx__DECLARE_EVT0(wxEVT_TOUCH_END, wxMultiTouchEventHandler(func))
4761
#define EVT_TOUCH_CANCEL(func) wx__DECLARE_EVT0(wxEVT_TOUCH_CANCEL, wxMultiTouchEventHandler(func))
4762
4763
// All touch events
4764
#define EVT_TOUCH_EVENTS(func) \
4765
    EVT_TOUCH_BEGIN(func) \
4766
    EVT_TOUCH_MOVE(func) \
4767
    EVT_TOUCH_END(func) \
4768
    EVT_TOUCH_CANCEL(func)
4769
4770
// Gesture events
4771
#define EVT_GESTURE_PAN(winid, func) wx__DECLARE_EVT1(wxEVT_GESTURE_PAN, winid, wxPanGestureEventHandler(func))
4772
#define EVT_GESTURE_ZOOM(winid, func) wx__DECLARE_EVT1(wxEVT_GESTURE_ZOOM, winid, wxZoomGestureEventHandler(func))
4773
#define EVT_GESTURE_ROTATE(winid, func) wx__DECLARE_EVT1(wxEVT_GESTURE_ROTATE, winid, wxRotateGestureEventHandler(func))
4774
#define EVT_TWO_FINGER_TAP(winid, func) wx__DECLARE_EVT1(wxEVT_TWO_FINGER_TAP, winid, wxTwoFingerTapEventHandler(func))
4775
#define EVT_LONG_PRESS(winid, func) wx__DECLARE_EVT1(wxEVT_LONG_PRESS, winid, wxLongPressEventHandler(func))
4776
#define EVT_PRESS_AND_TAP(winid, func) wx__DECLARE_EVT1(wxEVT_PRESS_AND_TAP, winid, wxPressAndTapEventHandler(func))
4777
4778
// Convenience macros for commonly-used commands
4779
#define EVT_CHECKBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKBOX, winid, wxCommandEventHandler(func))
4780
#define EVT_CHOICE(winid, func) wx__DECLARE_EVT1(wxEVT_CHOICE, winid, wxCommandEventHandler(func))
4781
#define EVT_LISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX, winid, wxCommandEventHandler(func))
4782
#define EVT_LISTBOX_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_LISTBOX_DCLICK, winid, wxCommandEventHandler(func))
4783
#define EVT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_MENU, winid, wxCommandEventHandler(func))
4784
#define EVT_MENU_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_MENU, id1, id2, wxCommandEventHandler(func))
4785
#define EVT_BUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_BUTTON, winid, wxCommandEventHandler(func))
4786
#define EVT_SLIDER(winid, func) wx__DECLARE_EVT1(wxEVT_SLIDER, winid, wxCommandEventHandler(func))
4787
#define EVT_RADIOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBOX, winid, wxCommandEventHandler(func))
4788
#define EVT_RADIOBUTTON(winid, func) wx__DECLARE_EVT1(wxEVT_RADIOBUTTON, winid, wxCommandEventHandler(func))
4789
// EVT_SCROLLBAR is now obsolete since we use EVT_COMMAND_SCROLL... events
4790
#define EVT_SCROLLBAR(winid, func) wx__DECLARE_EVT1(wxEVT_SCROLLBAR, winid, wxCommandEventHandler(func))
4791
#define EVT_VLBOX(winid, func) wx__DECLARE_EVT1(wxEVT_VLBOX, winid, wxCommandEventHandler(func))
4792
#define EVT_COMBOBOX(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX, winid, wxCommandEventHandler(func))
4793
#define EVT_TOOL(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL, winid, wxCommandEventHandler(func))
4794
#define EVT_TOOL_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_DROPDOWN, winid, wxCommandEventHandler(func))
4795
#define EVT_TOOL_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL, id1, id2, wxCommandEventHandler(func))
4796
#define EVT_TOOL_RCLICKED(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_RCLICKED, winid, wxCommandEventHandler(func))
4797
#define EVT_TOOL_RCLICKED_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_TOOL_RCLICKED, id1, id2, wxCommandEventHandler(func))
4798
#define EVT_TOOL_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_TOOL_ENTER, winid, wxCommandEventHandler(func))
4799
#define EVT_CHECKLISTBOX(winid, func) wx__DECLARE_EVT1(wxEVT_CHECKLISTBOX, winid, wxCommandEventHandler(func))
4800
#define EVT_COMBOBOX_DROPDOWN(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_DROPDOWN, winid, wxCommandEventHandler(func))
4801
#define EVT_COMBOBOX_CLOSEUP(winid, func) wx__DECLARE_EVT1(wxEVT_COMBOBOX_CLOSEUP, winid, wxCommandEventHandler(func))
4802
4803
// Generic command events
4804
#define EVT_COMMAND_LEFT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_CLICK, winid, wxCommandEventHandler(func))
4805
#define EVT_COMMAND_LEFT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_LEFT_DCLICK, winid, wxCommandEventHandler(func))
4806
#define EVT_COMMAND_RIGHT_CLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_CLICK, winid, wxCommandEventHandler(func))
4807
#define EVT_COMMAND_RIGHT_DCLICK(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_RIGHT_DCLICK, winid, wxCommandEventHandler(func))
4808
#define EVT_COMMAND_SET_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_SET_FOCUS, winid, wxCommandEventHandler(func))
4809
#define EVT_COMMAND_KILL_FOCUS(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_KILL_FOCUS, winid, wxCommandEventHandler(func))
4810
#define EVT_COMMAND_ENTER(winid, func) wx__DECLARE_EVT1(wxEVT_COMMAND_ENTER, winid, wxCommandEventHandler(func))
4811
4812
// Joystick events
4813
4814
#define EVT_JOY_BUTTON_DOWN(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_DOWN, wxJoystickEventHandler(func))
4815
#define EVT_JOY_BUTTON_UP(func) wx__DECLARE_EVT0(wxEVT_JOY_BUTTON_UP, wxJoystickEventHandler(func))
4816
#define EVT_JOY_MOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_MOVE, wxJoystickEventHandler(func))
4817
#define EVT_JOY_ZMOVE(func) wx__DECLARE_EVT0(wxEVT_JOY_ZMOVE, wxJoystickEventHandler(func))
4818
4819
// All joystick events
4820
#define EVT_JOYSTICK_EVENTS(func) \
4821
    EVT_JOY_BUTTON_DOWN(func) \
4822
    EVT_JOY_BUTTON_UP(func) \
4823
    EVT_JOY_MOVE(func) \
4824
    EVT_JOY_ZMOVE(func)
4825
4826
// Idle event
4827
#define EVT_IDLE(func) wx__DECLARE_EVT0(wxEVT_IDLE, wxIdleEventHandler(func))
4828
4829
// Update UI event
4830
#define EVT_UPDATE_UI(winid, func) wx__DECLARE_EVT1(wxEVT_UPDATE_UI, winid, wxUpdateUIEventHandler(func))
4831
#define EVT_UPDATE_UI_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_UPDATE_UI, id1, id2, wxUpdateUIEventHandler(func))
4832
4833
// Help events
4834
#define EVT_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_HELP, winid, wxHelpEventHandler(func))
4835
#define EVT_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_HELP, id1, id2, wxHelpEventHandler(func))
4836
#define EVT_DETAILED_HELP(winid, func) wx__DECLARE_EVT1(wxEVT_DETAILED_HELP, winid, wxHelpEventHandler(func))
4837
#define EVT_DETAILED_HELP_RANGE(id1, id2, func) wx__DECLARE_EVT2(wxEVT_DETAILED_HELP, id1, id2, wxHelpEventHandler(func))
4838
4839
// Context Menu Events
4840
#define EVT_CONTEXT_MENU(func) wx__DECLARE_EVT0(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(func))
4841
#define EVT_COMMAND_CONTEXT_MENU(winid, func) wx__DECLARE_EVT1(wxEVT_CONTEXT_MENU, winid, wxContextMenuEventHandler(func))
4842
4843
// Clipboard text Events
4844
#define EVT_TEXT_CUT(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_CUT, winid, wxClipboardTextEventHandler(func))
4845
#define EVT_TEXT_COPY(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_COPY, winid, wxClipboardTextEventHandler(func))
4846
#define EVT_TEXT_PASTE(winid, func) wx__DECLARE_EVT1(wxEVT_TEXT_PASTE, winid, wxClipboardTextEventHandler(func))
4847
4848
// Thread events
4849
#define EVT_THREAD(id, func)  wx__DECLARE_EVT1(wxEVT_THREAD, id, wxThreadEventHandler(func))
4850
4851
// ----------------------------------------------------------------------------
4852
// Helper functions
4853
// ----------------------------------------------------------------------------
4854
4855
#if wxUSE_GUI
4856
4857
// Find a window with the focus, that is also a descendant of the given window.
4858
// This is used to determine the window to initially send commands to.
4859
WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor);
4860
4861
#endif // wxUSE_GUI
4862
4863
4864
// ----------------------------------------------------------------------------
4865
// Compatibility macro aliases
4866
// ----------------------------------------------------------------------------
4867
4868
// deprecated variants _not_ requiring a semicolon after them and without wx prefix
4869
// (note that also some wx-prefixed macro do _not_ require a semicolon because
4870
// it's not always possible to force the compiler to require it)
4871
4872
#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \
4873
    wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj)
4874
#define DECLARE_EVENT_TABLE_TERMINATOR()               wxDECLARE_EVENT_TABLE_TERMINATOR()
4875
#define DECLARE_EVENT_TABLE()                          wxDECLARE_EVENT_TABLE();
4876
#define BEGIN_EVENT_TABLE(a,b)                         wxBEGIN_EVENT_TABLE(a,b)
4877
#define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c)             wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c)
4878
#define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d)           wxBEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d)
4879
#define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e)         wxBEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e)
4880
#define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f)       wxBEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f)
4881
#define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g)     wxBEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g)
4882
#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)
4883
#define END_EVENT_TABLE()                              wxEND_EVENT_TABLE()
4884
4885
// other obsolete event declaration/definition macros; we don't need them any longer
4886
// but we keep them for compatibility as it doesn't cost us anything anyhow
4887
#define BEGIN_DECLARE_EVENT_TYPES()
4888
#define END_DECLARE_EVENT_TYPES()
4889
#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \
4890
    extern expdecl const wxEventType name;
4891
#define DECLARE_EVENT_TYPE(name, value) \
4892
    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value)
4893
#define DECLARE_LOCAL_EVENT_TYPE(name, value) \
4894
    DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value)
4895
#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType();
4896
#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name)
4897
4898
// alias for backward compatibility with 2.9.0:
4899
#define wxEVT_COMMAND_THREAD                  wxEVT_THREAD
4900
// other old wxEVT_COMMAND_* constants
4901
#define wxEVT_COMMAND_BUTTON_CLICKED          wxEVT_BUTTON
4902
#define wxEVT_COMMAND_CHECKBOX_CLICKED        wxEVT_CHECKBOX
4903
#define wxEVT_COMMAND_CHOICE_SELECTED         wxEVT_CHOICE
4904
#define wxEVT_COMMAND_LISTBOX_SELECTED        wxEVT_LISTBOX
4905
#define wxEVT_COMMAND_LISTBOX_DOUBLECLICKED   wxEVT_LISTBOX_DCLICK
4906
#define wxEVT_COMMAND_CHECKLISTBOX_TOGGLED    wxEVT_CHECKLISTBOX
4907
#define wxEVT_COMMAND_MENU_SELECTED           wxEVT_MENU
4908
#define wxEVT_COMMAND_TOOL_CLICKED            wxEVT_TOOL
4909
#define wxEVT_COMMAND_SLIDER_UPDATED          wxEVT_SLIDER
4910
#define wxEVT_COMMAND_RADIOBOX_SELECTED       wxEVT_RADIOBOX
4911
#define wxEVT_COMMAND_RADIOBUTTON_SELECTED    wxEVT_RADIOBUTTON
4912
#define wxEVT_COMMAND_SCROLLBAR_UPDATED       wxEVT_SCROLLBAR
4913
#define wxEVT_COMMAND_VLBOX_SELECTED          wxEVT_VLBOX
4914
#define wxEVT_COMMAND_COMBOBOX_SELECTED       wxEVT_COMBOBOX
4915
#define wxEVT_COMMAND_TOOL_RCLICKED           wxEVT_TOOL_RCLICKED
4916
#define wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED   wxEVT_TOOL_DROPDOWN
4917
#define wxEVT_COMMAND_TOOL_ENTER              wxEVT_TOOL_ENTER
4918
#define wxEVT_COMMAND_COMBOBOX_DROPDOWN       wxEVT_COMBOBOX_DROPDOWN
4919
#define wxEVT_COMMAND_COMBOBOX_CLOSEUP        wxEVT_COMBOBOX_CLOSEUP
4920
#define wxEVT_COMMAND_TEXT_COPY               wxEVT_TEXT_COPY
4921
#define wxEVT_COMMAND_TEXT_CUT                wxEVT_TEXT_CUT
4922
#define wxEVT_COMMAND_TEXT_PASTE              wxEVT_TEXT_PASTE
4923
#define wxEVT_COMMAND_TEXT_UPDATED            wxEVT_TEXT
4924
4925
#endif // _WX_EVENT_H_