X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a40c31edfde688eef2a8328286e859ce96f02f9..0122b7e3fcfd78f879470053c91a60e3c66537a3:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 9427bc81f9..760e675e55 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1653,7 +1653,7 @@ struct WXDLLEXPORT wxEventTable // wxEvtHandler: the base class for all objects handling wxWindows events // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxEvtHandler : public wxObject, public wxClientDataContainer +class WXDLLEXPORT wxEvtHandler : public wxObject { public: wxEvtHandler(); @@ -1703,6 +1703,15 @@ public: wxObject *userData = (wxObject *) NULL ) { return Disconnect(id, -1, eventType, func, userData); } + + // User data can be associated with each wxEvtHandler + void SetClientObject( wxClientData *data ) { DoSetClientObject(data); } + wxClientData *GetClientObject() const { return DoGetClientObject(); } + + void SetClientData( void *data ) { DoSetClientData(data); } + void *GetClientData() const { return DoGetClientData(); } + + // implementation from now on virtual bool SearchEventTable(wxEventTable& table, wxEvent& event); bool SearchDynamicEventTable( wxEvent& event ); @@ -1763,6 +1772,29 @@ protected: // Is event handler enabled? bool m_enabled; + + // The user data: either an object which will be deleted by the container + // when it's deleted or some raw pointer which we do nothing with - only + // one type of data can be used with the given window (i.e. you cannot set + // the void data and then associate the container with wxClientData or vice + // versa) + union + { + wxClientData *m_clientObject; + void *m_clientData; + }; + + // what kind of data do we have? + wxClientDataType m_clientDataType; + + // client data accessors + virtual void DoSetClientObject( wxClientData *data ); + virtual wxClientData *DoGetClientObject() const; + + virtual void DoSetClientData( void *data ); + virtual void *DoGetClientData() const; + + private: DECLARE_DYNAMIC_CLASS(wxEvtHandler) };