Coverage Report

Created: 2023-02-22 06:06

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