-
+#if 0
// This class is a mixin that provides storage and management of "client
// data." The client data stored can either be a pointer to a wxClientData
// object in which case it is managed by the container (i.e. it will delete
// 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 window with wxClientData or vice
+ // the void data and then associate the container with wxClientData or vice
// versa)
union
{
wxClientDataType m_clientDataType;
};
-
+#endif
// ----------------------------------------------------------------------------
#endif
// wxEvtHandler: the base class for all objects handling wxWindows events
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxEvtHandler : public wxObject, public wxClientDataContainer
+class WXDLLEXPORT wxEvtHandler : public wxObject
{
public:
wxEvtHandler();
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 );
// 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)
};
// ----------------------------------------------------------------------------
-
+#if 0
wxClientDataContainer::wxClientDataContainer()
{
return m_clientData;
}
-
+#endif
// ----------------------------------------------------------------------------
m_eventsLocker = new wxCriticalSection;
# endif
#endif
+ // no client data (yet)
+ m_clientData = NULL;
+ m_clientDataType = wxClientData_None;
}
wxEvtHandler::~wxEvtHandler()
delete m_eventsLocker;
# endif
#endif
+
+ // we only delete object data, not untyped
+ if ( m_clientDataType == wxClientData_Object )
+ delete m_clientObject;
}
#if wxUSE_THREADS
return FALSE;
};
+void wxEvtHandler::DoSetClientObject( wxClientData *data )
+{
+ wxASSERT_MSG( m_clientDataType != wxClientData_Void,
+ wxT("can't have both object and void client data") );
+
+ if ( m_clientObject )
+ delete m_clientObject;
+
+ m_clientObject = data;
+ m_clientDataType = wxClientData_Object;
+}
+
+wxClientData *wxEvtHandler::DoGetClientObject() const
+{
+ // it's not an error to call GetClientObject() on a window which doesn't
+ // have client data at all - NULL will be returned
+ wxASSERT_MSG( m_clientDataType != wxClientData_Void,
+ wxT("this window doesn't have object client data") );
+
+ return m_clientObject;
+}
+
+void wxEvtHandler::DoSetClientData( void *data )
+{
+ wxASSERT_MSG( m_clientDataType != wxClientData_Object,
+ wxT("can't have both object and void client data") );
+
+ m_clientData = data;
+ m_clientDataType = wxClientData_Void;
+}
+
+void *wxEvtHandler::DoGetClientData() const
+{
+ // it's not an error to call GetClientData() on a window which doesn't have
+ // client data at all - NULL will be returned
+ wxASSERT_MSG( m_clientDataType != wxClientData_Object,
+ wxT("this window doesn't have void client data") );
+
+ return m_clientData;
+}
+
+
#if WXWIN_COMPATIBILITY
bool wxEvtHandler::OnClose()
{