Coverage Report

Created: 2026-04-01 06:14

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