]>
git.saurik.com Git - wxWidgets.git/blob - src/common/clntdata.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/clntdata.cpp
3 // Purpose: A mixin class for holding a wxClientData or void pointer
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #include "wx/clntdata.h"
21 // ----------------------------------------------------------------------------
24 wxClientDataContainer::wxClientDataContainer()
26 // no client data (yet)
28 m_clientDataType
= wxClientData_None
;
31 wxClientDataContainer::~wxClientDataContainer()
33 // we only delete object data, not untyped
34 if ( m_clientDataType
== wxClientData_Object
)
35 delete m_clientObject
;
38 void wxClientDataContainer::DoSetClientObject( wxClientData
*data
)
40 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
41 wxT("can't have both object and void client data") );
44 delete m_clientObject
;
46 m_clientObject
= data
;
47 m_clientDataType
= wxClientData_Object
;
50 wxClientData
*wxClientDataContainer::DoGetClientObject() const
52 // it's not an error to call GetClientObject() on a window which doesn't
53 // have client data at all - NULL will be returned
54 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
55 wxT("this window doesn't have object client data") );
57 return m_clientObject
;
60 void wxClientDataContainer::DoSetClientData( void *data
)
62 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
63 wxT("can't have both object and void client data") );
66 m_clientDataType
= wxClientData_Void
;
69 void *wxClientDataContainer::DoGetClientData() const
71 // it's not an error to call GetClientData() on a window which doesn't have
72 // client data at all - NULL will be returned
73 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
74 wxT("this window doesn't have void client data") );
80 // ----------------------------------------------------------------------------