]>
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) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/clntdata.h"
22 // ----------------------------------------------------------------------------
25 wxClientDataContainer::wxClientDataContainer()
27 // no client data (yet)
29 m_clientDataType
= wxClientData_None
;
32 wxClientDataContainer::~wxClientDataContainer()
34 // we only delete object data, not untyped
35 if ( m_clientDataType
== wxClientData_Object
)
36 delete m_clientObject
;
39 void wxClientDataContainer::DoSetClientObject( wxClientData
*data
)
41 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
42 wxT("can't have both object and void client data") );
45 delete m_clientObject
;
47 m_clientObject
= data
;
48 m_clientDataType
= wxClientData_Object
;
51 wxClientData
*wxClientDataContainer::DoGetClientObject() const
53 // it's not an error to call GetClientObject() on a window which doesn't
54 // have client data at all - NULL will be returned
55 wxASSERT_MSG( m_clientDataType
!= wxClientData_Void
,
56 wxT("this window doesn't have object client data") );
58 return m_clientObject
;
61 void wxClientDataContainer::DoSetClientData( void *data
)
63 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
64 wxT("can't have both object and void client data") );
67 m_clientDataType
= wxClientData_Void
;
70 void *wxClientDataContainer::DoGetClientData() const
72 // it's not an error to call GetClientData() on a window which doesn't have
73 // client data at all - NULL will be returned
74 wxASSERT_MSG( m_clientDataType
!= wxClientData_Object
,
75 wxT("this window doesn't have void client data") );
81 // ----------------------------------------------------------------------------