X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0f02dab276d6e0db31b060c070c71b6d7543d96..53cdd2c11d11b6286936b93158b157610b169edd:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 21936ccaa1..4aa6e97a94 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -26,6 +26,8 @@ #include "wx/dynarray.h" #include "wx/thread.h" #include "wx/tracker.h" +#include "wx/typeinfo.h" +#include "wx/any.h" #ifdef wxHAS_EVENT_BIND #include "wx/meta/convertible.h" @@ -77,25 +79,12 @@ typedef int wxEventType; // the wxEVENT_HANDLER_CAST-macro. #define wxStaticCastEvent(type, val) static_cast(val) -#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ +#define wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj) -#define DECLARE_EVENT_TABLE_TERMINATOR() \ +#define wxDECLARE_EVENT_TABLE_TERMINATOR() \ wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) -// obsolete event declaration/definition macros, we don't need them any longer -// but we keep them for compatibility as it doesn't cost us anything anyhow -#define BEGIN_DECLARE_EVENT_TYPES() -#define END_DECLARE_EVENT_TYPES() -#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ - extern expdecl const wxEventType name; -#define DECLARE_EVENT_TYPE(name, value) \ - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) -#define DECLARE_LOCAL_EVENT_TYPE(name, value) \ - DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) -#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); -#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) - // generate a new unique event type extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); @@ -189,16 +178,6 @@ typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&); // compiler we can restore its old definition for it. typedef wxEventFunction wxObjectEventFunction; - -// wxEventFunctorClassInfo is used as a unique identifier for wxEventFunctor- -// derived classes; it is more light weight than wxClassInfo and can be used in -// template classes -typedef void (*wxEventFunctorClassInfo)(); - -// this macro must be used in wxEventFunctor-derived classes -#define wxDEFINE_EVENT_FUNCTOR_CLASS_INFO( classInfoName ) \ - static void classInfoName() {} - // The event functor which is stored in the static and dynamic event tables: class WXDLLIMPEXP_BASE wxEventFunctor { @@ -212,11 +191,6 @@ public: // finding it in an event table in Unbind(), by the given functor: virtual bool IsMatching(const wxEventFunctor& functor) const = 0; - // Test whether the given class info is the same as from this functor. This - // allows us in IsMatching to safely downcast the given wxEventFunctor without - // the usage of dynamic_cast<>(). - virtual bool IsSameClass(wxEventFunctorClassInfo classInfo) const = 0; - // If the functor holds an wxEvtHandler, then get access to it and track // its lifetime with wxEventConnectionRef: virtual wxEvtHandler *GetEvtHandler() const @@ -228,6 +202,9 @@ public: // wxEventFunction: virtual wxEventFunction GetEvtMethod() const { return NULL; } + +private: + WX_DECLARE_ABSTRACT_TYPEINFO(wxEventFunctor) }; // A plain method functor for the untyped legacy event types: @@ -238,16 +215,11 @@ public: : m_handler( handler ), m_method( method ) { } - virtual void operator()(wxEvtHandler *handler, wxEvent& event) - { - wxEvtHandler * const realHandler = m_handler ? m_handler : handler; - - (realHandler->*m_method)(event); - } + virtual void operator()(wxEvtHandler *handler, wxEvent& event); virtual bool IsMatching(const wxEventFunctor& functor) const { - if ( functor.IsSameClass( sm_classInfo )) + if ( wxTypeId(functor) == wxTypeId(*this) ) { const wxObjectEventFunctor &other = static_cast< const wxObjectEventFunctor & >( functor ); @@ -262,9 +234,6 @@ public: return false; } - virtual bool IsSameClass( wxEventFunctorClassInfo otherClassInfo ) const - { return sm_classInfo == otherClassInfo; } - virtual wxEvtHandler *GetEvtHandler() const { return m_handler; } @@ -275,7 +244,10 @@ private: wxEvtHandler *m_handler; wxEventFunction m_method; - wxDEFINE_EVENT_FUNCTOR_CLASS_INFO( sm_classInfo ); + // Provide a dummy default ctor for type info purposes + wxObjectEventFunctor() { } + + WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor) }; // Create a functor for the legacy events: used by Connect() @@ -287,7 +259,7 @@ wxNewEventFunctor(const wxEventType& WXUNUSED(evtType), return new wxObjectEventFunctor(method, handler); } -// This version is used by DECLARE_EVENT_TABLE_ENTRY() +// This version is used by wxDECLARE_EVENT_TABLE_ENTRY() inline wxObjectEventFunctor * wxNewEventTableFunctor(const wxEventType& WXUNUSED(evtType), wxObjectEventFunction method) @@ -424,22 +396,19 @@ public: virtual bool IsMatching(const wxEventFunctor& functor) const { - if ( !functor.IsSameClass(sm_classInfo) ) + if ( wxTypeId(functor) != wxTypeId(*this) ) return false; typedef wxEventFunctorMethod ThisFunctor; - // the cast is valid because IsSameClass() returned true above + // the cast is valid because wxTypeId()s matched above const ThisFunctor& other = static_cast(functor); return (m_method == other.m_method || other.m_method == NULL) && (m_handler == other.m_handler || other.m_handler == NULL); } - virtual bool IsSameClass( wxEventFunctorClassInfo otherClassInfo ) const - { return sm_classInfo == otherClassInfo; } - virtual wxEvtHandler *GetEvtHandler() const { return this->ConvertToEvtHandler(m_handler); } @@ -450,7 +419,12 @@ private: EventHandler *m_handler; void (Class::*m_method)(EventArg&); - wxDEFINE_EVENT_FUNCTOR_CLASS_INFO( sm_classInfo ); + // Provide a dummy default ctor for type info purposes + wxEventFunctorMethod() { } + + typedef wxEventFunctorMethod thisClass; + WX_DECLARE_TYPEINFO_INLINE(thisClass) }; @@ -488,7 +462,7 @@ public: virtual bool IsMatching(const wxEventFunctor &functor) const { - if ( !functor.IsSameClass(sm_classInfo) ) + if ( wxTypeId(functor) != wxTypeId(*this) ) return false; typedef wxEventFunctorFunction ThisFunctor; @@ -498,13 +472,14 @@ public: return m_handler == other.m_handler; } - virtual bool IsSameClass( wxEventFunctorClassInfo otherClassInfo ) const - { return sm_classInfo == otherClassInfo; } - private: void (*m_handler)(EventArg&); - wxDEFINE_EVENT_FUNCTOR_CLASS_INFO( sm_classInfo ); + // Provide a dummy default ctor for type info purposes + wxEventFunctorFunction() { } + + typedef wxEventFunctorFunction thisClass; + WX_DECLARE_TYPEINFO_INLINE(thisClass) }; @@ -532,7 +507,7 @@ public: virtual bool IsMatching(const wxEventFunctor &functor) const { - if ( !functor.IsSameClass(sm_classInfo) ) + if ( wxTypeId(functor) != wxTypeId(*this) ) return false; typedef wxEventFunctorFunctor FunctorThis; @@ -544,9 +519,6 @@ public: return m_handlerAddr == other.m_handlerAddr; } - virtual bool IsSameClass( wxEventFunctorClassInfo otherClassInfo ) const - { return sm_classInfo == otherClassInfo; } - private: // Store a copy of the functor to prevent using/calling an already // destroyed instance: @@ -555,7 +527,11 @@ private: // Use the address of the original functor for comparison in IsMatching: const void *m_handlerAddr; - wxDEFINE_EVENT_FUNCTOR_CLASS_INFO( sm_classInfo ); + // Provide a dummy default ctor for type info purposes + wxEventFunctorFunctor() { } + + typedef wxEventFunctorFunctor thisClass; + WX_DECLARE_TYPEINFO_INLINE(thisClass) }; // Create functors for the templatized events, either allocated on the heap for @@ -617,7 +593,7 @@ wxMakeEventFunctor(const EventTag&, method, handler); } -// Create an event functor for the event table via DECLARE_EVENT_TABLE_ENTRY: +// Create an event functor for the event table via wxDECLARE_EVENT_TABLE_ENTRY: // in this case we don't have the handler (as it's always the same as the // object which generated the event) so we must use Class as its type template @@ -1002,6 +978,25 @@ public: return false; } + // This is also used only internally by ProcessEvent() to check if it + // should process the event normally or only restrict the search for the + // event handler to this object itself. + bool ShouldProcessOnlyIn(wxEvtHandler *h) const + { + return h == m_handlerToProcessOnlyIn; + } + + // Called to indicate that the result of ShouldProcessOnlyIn() wasn't taken + // into account. The existence of this function may seem counterintuitive + // but unfortunately it's needed by wxScrollHelperEvtHandler, see comments + // there. Don't even think of using this in your own code, this is a gross + // hack and is only needed because of wx complicated history and should + // never be used anywhere else. + void DidntHonourProcessOnlyIn() + { + m_handlerToProcessOnlyIn = NULL; + } + protected: wxObject* m_eventObject; wxEventType m_eventType; @@ -1012,6 +1007,10 @@ public: // m_callbackUserData is for internal usage only wxObject* m_callbackUserData; +private: + // If this handler + wxEvtHandler *m_handlerToProcessOnlyIn; + protected: // the propagation level: while it is positive, we propagate the event to // the parent window (if any) @@ -1034,6 +1033,10 @@ private: // it needs to access our m_propagationLevel friend class WXDLLIMPEXP_FWD_BASE wxPropagateOnce; + // and this one needs to access our m_handlerToProcessOnlyIn + friend class WXDLLIMPEXP_FWD_BASE wxEventProcessInHandlerOnly; + + DECLARE_ABSTRACT_CLASS(wxEvent) }; @@ -1085,6 +1088,29 @@ private: wxDECLARE_NO_COPY_CLASS(wxPropagateOnce); }; +// A helper object used to temporarily make wxEvent::ShouldProcessOnlyIn() +// return true for the handler passed to its ctor. +class wxEventProcessInHandlerOnly +{ +public: + wxEventProcessInHandlerOnly(wxEvent& event, wxEvtHandler *handler) + : m_event(event), + m_handlerToProcessOnlyInOld(event.m_handlerToProcessOnlyIn) + { + m_event.m_handlerToProcessOnlyIn = handler; + } + + ~wxEventProcessInHandlerOnly() + { + m_event.m_handlerToProcessOnlyIn = m_handlerToProcessOnlyInOld; + } + +private: + wxEvent& m_event; + wxEvtHandler * const m_handlerToProcessOnlyInOld; + + wxDECLARE_NO_COPY_CLASS(wxEventProcessInHandlerOnly); +}; #if wxUSE_GUI @@ -1210,16 +1236,15 @@ public: // make sure our string member (which uses COW, aka refcounting) is not // shared by other wxString instances: SetString(GetString().c_str()); + +#if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) + m_payload = event.m_payload; +#endif } virtual wxEvent *Clone() const { - wxThreadEvent* ev = new wxThreadEvent(*this); - - // make sure our string member (which uses COW, aka refcounting) is not - // shared by other wxString instances: - ev->SetString(GetString().c_str()); - return ev; + return new wxThreadEvent(*this); } // this is important to avoid that calling wxEventLoopBase::YieldFor thread events @@ -1227,6 +1252,23 @@ public: virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_THREAD; } +#if wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) + template + void SetPayload(const T& payload) + { + m_payload = payload; + } + + template + T GetPayload() const + { + return m_payload.As(); + } + +protected: + wxAny m_payload; +#endif // wxUSE_ANY && (!defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)) + private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThreadEvent) }; @@ -1504,6 +1546,33 @@ private: wxEVT_HOTKEY */ +// key categories: the bit flags for IsKeyInCategory() function +// +// the enum values used may change in future version of wx +// use the named constants only, or bitwise combinations thereof +enum wxKeyCategoryFlags +{ + // arrow keys, on and off numeric keypads + WXK_CATEGORY_ARROW = 1, + + // page up and page down keys, on and off numeric keypads + WXK_CATEGORY_PAGING = 2, + + // home and end keys, on and off numeric keypads + WXK_CATEGORY_JUMP = 4, + + // tab key, on and off numeric keypads + WXK_CATEGORY_TAB = 8, + + // backspace and delete keys, on and off numeric keypads + WXK_CATEGORY_CUT = 16, + + // all keys usually used for navigation + WXK_CATEGORY_NAVIGATION = WXK_CATEGORY_ARROW | + WXK_CATEGORY_PAGING | + WXK_CATEGORY_JUMP +}; + class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent, public wxKeyboardState { @@ -1514,6 +1583,9 @@ public: // get the key code: an ASCII7 char or an element of wxKeyCode enum int GetKeyCode() const { return (int)m_keyCode; } + // returns true iff this event's key code is of a certain type + bool IsKeyInCategory(int category) const; + #if wxUSE_UNICODE // get the Unicode character corresponding to this key wxChar GetUnicodeKey() const { return m_uniChar; } @@ -2730,7 +2802,10 @@ struct WXDLLIMPEXP_BASE wxEventTableEntryBase m_lastId(idLast), m_fn(fn), m_callbackUserData(data) - { } + { + wxASSERT_MSG( idLast == wxID_ANY || winid <= idLast, + "invalid IDs range: lower bound > upper bound" ); + } wxEventTableEntryBase( const wxEventTableEntryBase &entry ) : m_id( entry.m_id ), @@ -2923,6 +2998,20 @@ public: bool SafelyProcessEvent(wxEvent& event); // NOTE: uses ProcessEvent() + // This method tries to process the event in this event handler, including + // any preprocessing done by TryBefore() and all the handlers chained to + // it, but excluding the post-processing done in TryAfter(). + // + // It is meant to be called from ProcessEvent() only and is not virtual, + // additional event handlers can be hooked into the normal event processing + // logic using TryBefore() and TryAfter() hooks. + // + // You can also call it yourself to forward an event to another handler but + // without propagating it upwards if it's unhandled (this is usually + // unwanted when forwarding as the original handler would already do it if + // needed normally). + bool ProcessEventLocally(wxEvent& event); + // Schedule the given event to be processed later. It takes ownership of // the event pointer, i.e. it will be deleted later. This is safe to call // from multiple threads although you still need to ensure that wxString @@ -3135,14 +3224,6 @@ public: void OnSinkDestroyed( wxEvtHandler *sink ); - // The method tries to process the event in this event handler. - // - // It is meant to be called from ProcessEvent() only and is not virtual, - // additional event handlers can be hooked into the normal event processing - // logic using TryBefore() and TryAfter() hooks. - bool ProcessEventHere(wxEvent& event); - - private: void DoBind(int winid, int lastId, @@ -3167,6 +3248,20 @@ protected: // validators. virtual bool TryBefore(wxEvent& event); + // This one is not a hook but just a helper which looks up the handler in + // this object itself. + // + // It is called from ProcessEventLocally() and normally shouldn't be called + // directly as doing it would ignore any chained event handlers + bool TryHereOnly(wxEvent& event); + + // Another helper which simply calls pre-processing hook and then tries to + // handle the event at this handler level. + bool TryBeforeAndHere(wxEvent& event) + { + return TryBefore(event) || TryHereOnly(event); + } + // this one is called after failing to find the event handle in our own // table to give a chance to the other windows to process it // @@ -3231,11 +3326,25 @@ private: // pass the event to wxTheApp instance, called from TryAfter() bool DoTryApp(wxEvent& event); + // try to process events in all handlers chained to this one + bool DoTryChain(wxEvent& event); + DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler) }; WX_DEFINE_ARRAY_WITH_DECL_PTR(wxEvtHandler *, wxEvtHandlerArray, class WXDLLIMPEXP_BASE); + +// Define an inline method of wxObjectEventFunctor which couldn't be defined +// before wxEvtHandler declaration: at least Sun CC refuses to compile function +// calls through pointer to member for forward-declared classes (see #12452). +inline void wxObjectEventFunctor::operator()(wxEvtHandler *handler, wxEvent& event) +{ + wxEvtHandler * const realHandler = m_handler ? m_handler : handler; + + (realHandler->*m_method)(event); +} + // ---------------------------------------------------------------------------- // wxEventConnectionRef represents all connections between two event handlers // and enables automatic disconnect when an event handler sink goes out of @@ -3460,20 +3569,20 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& // N.B. In GNU-WIN32, you *have* to take the address of a member function // (use &) or the compiler crashes... -#define DECLARE_EVENT_TABLE() \ - private: \ - static const wxEventTableEntry sm_eventTableEntries[]; \ - protected: \ - static const wxEventTable sm_eventTable; \ - virtual const wxEventTable* GetEventTable() const; \ - static wxEventHashTable sm_eventHashTable; \ - virtual wxEventHashTable& GetEventHashTable() const; +#define wxDECLARE_EVENT_TABLE() \ + private: \ + static const wxEventTableEntry sm_eventTableEntries[]; \ + protected: \ + static const wxEventTable sm_eventTable; \ + virtual const wxEventTable* GetEventTable() const; \ + static wxEventHashTable sm_eventHashTable; \ + virtual wxEventHashTable& GetEventHashTable() const // N.B.: when building DLL with Borland C++ 5.5 compiler, you must initialize // sm_eventTable before using it in GetEventTable() or the compiler gives // E2233 (see http://groups.google.com/groups?selm=397dcc8a%241_2%40dnews) -#define BEGIN_EVENT_TABLE(theClass, baseClass) \ +#define wxBEGIN_EVENT_TABLE(theClass, baseClass) \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ const wxEventTable *theClass::GetEventTable() const \ @@ -3483,7 +3592,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& { return theClass::sm_eventHashTable; } \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE1(theClass, baseClass, T1) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3498,7 +3607,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE2(theClass, baseClass, T1, T2) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3513,7 +3622,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3528,7 +3637,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE4(theClass, baseClass, T1, T2, T3, T4) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3543,7 +3652,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE5(theClass, baseClass, T1, T2, T3, T4, T5) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3558,7 +3667,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE7(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3573,7 +3682,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define BEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ +#define wxBEGIN_EVENT_TABLE_TEMPLATE8(theClass, baseClass, T1, T2, T3, T4, T5, T6, T7, T8) \ template \ const wxEventTable theClass::sm_eventTable = \ { &baseClass::sm_eventTable, &theClass::sm_eventTableEntries[0] }; \ @@ -3588,7 +3697,8 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& template \ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ -#define END_EVENT_TABLE() DECLARE_EVENT_TABLE_TERMINATOR() }; +#define wxEND_EVENT_TABLE() \ + wxDECLARE_EVENT_TABLE_TERMINATOR() }; /* * Event table macros @@ -3602,7 +3712,7 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& // - id1, id2 ids of the first/last id // - fn the function (should be cast to the right type) #define wx__DECLARE_EVT2(evt, id1, id2, fn) \ - DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), + wxDECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL), #define wx__DECLARE_EVT1(evt, id, fn) \ wx__DECLARE_EVT2(evt, id, wxID_ANY, fn) #define wx__DECLARE_EVT0(evt, fn) \ @@ -3897,12 +4007,12 @@ typedef void (wxEvtHandler::*wxClipboardTextEventFunction)(wxClipboardTextEvent& #ifdef wxHAS_EVENT_BIND #define wxBIND_OR_CONNECT_HACK_BASE_CLASS #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS - #define wxBIND_OR_CONNECT_HACK(w, evt, handler, func, obj) \ + #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ win->Bind(evt, &func, obj) #else // wxHAS_EVENT_BIND #define wxBIND_OR_CONNECT_HACK_BASE_CLASS public wxEvtHandler, #define wxBIND_OR_CONNECT_HACK_ONLY_BASE_CLASS : public wxEvtHandler - #define wxBIND_OR_CONNECT_HACK(w, evt, handler, func, obj) \ + #define wxBIND_OR_CONNECT_HACK(win, evt, handler, func, obj) \ win->Connect(evt, handler(func), NULL, obj) #endif // wxHAS_EVENT_BIND @@ -3914,4 +4024,39 @@ WXDLLIMPEXP_CORE wxWindow* wxFindFocusDescendant(wxWindow* ancestor); #endif // wxUSE_GUI + +// ---------------------------------------------------------------------------- +// Compatibility macro aliases +// ---------------------------------------------------------------------------- + +// deprecated variants _not_ requiring a semicolon after them and without wx prefix +// (note that also some wx-prefixed macro do _not_ require a semicolon because +// it's not always possible to force the compire to require it) + +#define DECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) \ + wxDECLARE_EVENT_TABLE_ENTRY(type, winid, idLast, fn, obj) +#define DECLARE_EVENT_TABLE_TERMINATOR() wxDECLARE_EVENT_TABLE_TERMINATOR() +#define DECLARE_EVENT_TABLE() wxDECLARE_EVENT_TABLE(); +#define BEGIN_EVENT_TABLE(a,b) wxBEGIN_EVENT_TABLE(a,b) +#define BEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c) +#define BEGIN_EVENT_TABLE_TEMPLATE2(a,b,c,d) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c,d) +#define BEGIN_EVENT_TABLE_TEMPLATE3(a,b,c,d,e) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c,d,e) +#define BEGIN_EVENT_TABLE_TEMPLATE4(a,b,c,d,e,f) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c,d,e,f) +#define BEGIN_EVENT_TABLE_TEMPLATE5(a,b,c,d,e,f,g) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c,d,e,f,g) +#define BEGIN_EVENT_TABLE_TEMPLATE6(a,b,c,d,e,f,g,h) wxBEGIN_EVENT_TABLE_TEMPLATE1(a,b,c,d,e,f,g,h) +#define END_EVENT_TABLE() wxEND_EVENT_TABLE() + +// other obsolete event declaration/definition macros; we don't need them any longer +// but we keep them for compatibility as it doesn't cost us anything anyhow +#define BEGIN_DECLARE_EVENT_TYPES() +#define END_DECLARE_EVENT_TYPES() +#define DECLARE_EXPORTED_EVENT_TYPE(expdecl, name, value) \ + extern expdecl const wxEventType name; +#define DECLARE_EVENT_TYPE(name, value) \ + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, name, value) +#define DECLARE_LOCAL_EVENT_TYPE(name, value) \ + DECLARE_EXPORTED_EVENT_TYPE(wxEMPTY_PARAMETER_VALUE, name, value) +#define DEFINE_EVENT_TYPE(name) const wxEventType name = wxNewEventType(); +#define DEFINE_LOCAL_EVENT_TYPE(name) DEFINE_EVENT_TYPE(name) + #endif // _WX_EVENT_H_