]>
git.saurik.com Git - wxWidgets.git/blob - src/common/clntdata.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/clntdata.cpp
3 // Purpose: A mixin class for holding a wxClientData or void pointer
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "clntdata.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
23 #include "wx/clntdata.h"
26 // ----------------------------------------------------------------------------
29 wxClientDataContainer::wxClientDataContainer()
31 // no client data (yet)
33 m_clientDataType
= wxClientData_None
;
36 wxClientDataContainer::~wxClientDataContainer()
38 // we only delete object data, not untyped
39 if ( m_clientDataType
== wxClientData_Object
)
40 delete m_clientObject
;
43 void wxClientDataContainer::DoSetClientObject( wxClientData
*data
)
45 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
46 wxT("can't have both object and void client data") );
49 delete m_clientObject
;
51 m_clientObject
= data
;
52 m_clientDataType
= wxClientData_Object
;
55 wxClientData
*wxClientDataContainer::DoGetClientObject() const
57 // it's not an error to call GetClientObject() on a window which doesn't
58 // have client data at all - NULL will be returned
59 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
60 wxT("this window doesn't have object client data") );
62 return m_clientObject
;
65 void wxClientDataContainer::DoSetClientData( void *data
)
67 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
68 wxT("can't have both object and void client data") );
71 m_clientDataType
= wxClientData_Void
;
74 void *wxClientDataContainer::DoGetClientData() const
76 // it's not an error to call GetClientData() on a window which doesn't have
77 // client data at all - NULL will be returned
78 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
79 wxT("this window doesn't have void client data") );
85 // ----------------------------------------------------------------------------