Moved client data stuff directly into wxEvtHandler, #if'd out
wxClientDataContainer for now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11945 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,7 +50,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
// This class is a mixin that provides storage and management of "client
|
// 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
|
// 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
|
// object in which case it is managed by the container (i.e. it will delete
|
||||||
@@ -73,7 +73,7 @@ protected:
|
|||||||
// The user data: either an object which will be deleted by the container
|
// 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
|
// 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
|
// 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)
|
// versa)
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ protected:
|
|||||||
wxClientDataType m_clientDataType;
|
wxClientDataType m_clientDataType;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -1653,7 +1653,7 @@ struct WXDLLEXPORT wxEventTable
|
|||||||
// wxEvtHandler: the base class for all objects handling wxWindows events
|
// wxEvtHandler: the base class for all objects handling wxWindows events
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxEvtHandler : public wxObject, public wxClientDataContainer
|
class WXDLLEXPORT wxEvtHandler : public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxEvtHandler();
|
wxEvtHandler();
|
||||||
@@ -1703,6 +1703,15 @@ public:
|
|||||||
wxObject *userData = (wxObject *) NULL )
|
wxObject *userData = (wxObject *) NULL )
|
||||||
{ return Disconnect(id, -1, eventType, func, userData); }
|
{ 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
|
// implementation from now on
|
||||||
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
|
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
|
||||||
bool SearchDynamicEventTable( wxEvent& event );
|
bool SearchDynamicEventTable( wxEvent& event );
|
||||||
@@ -1763,6 +1772,29 @@ protected:
|
|||||||
// Is event handler enabled?
|
// Is event handler enabled?
|
||||||
bool m_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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxEvtHandler)
|
DECLARE_DYNAMIC_CLASS(wxEvtHandler)
|
||||||
};
|
};
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
#if 0
|
||||||
|
|
||||||
wxClientDataContainer::wxClientDataContainer()
|
wxClientDataContainer::wxClientDataContainer()
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ void *wxClientDataContainer::DoGetClientData() const
|
|||||||
return m_clientData;
|
return m_clientData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@@ -761,6 +761,9 @@ wxEvtHandler::wxEvtHandler()
|
|||||||
m_eventsLocker = new wxCriticalSection;
|
m_eventsLocker = new wxCriticalSection;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
// no client data (yet)
|
||||||
|
m_clientData = NULL;
|
||||||
|
m_clientDataType = wxClientData_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEvtHandler::~wxEvtHandler()
|
wxEvtHandler::~wxEvtHandler()
|
||||||
@@ -798,6 +801,10 @@ wxEvtHandler::~wxEvtHandler()
|
|||||||
delete m_eventsLocker;
|
delete m_eventsLocker;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// we only delete object data, not untyped
|
||||||
|
if ( m_clientDataType == wxClientData_Object )
|
||||||
|
delete m_clientObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
@@ -1171,6 +1178,48 @@ bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
|
|||||||
return FALSE;
|
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
|
#if WXWIN_COMPATIBILITY
|
||||||
bool wxEvtHandler::OnClose()
|
bool wxEvtHandler::OnClose()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user