Coverage Report

Created: 2024-03-18 06:28

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