]> git.saurik.com Git - wxWidgets.git/blob - src/common/clntdata.cpp
Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / src / common / clntdata.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/clntdata.cpp
3 // Purpose: A mixin class for holding a wxClientData or void pointer
4 // Author: Robin Dunn
5 // Modified by:
6 // Created: 9-Oct-2001
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/clntdata.h"
19
20
21 // ----------------------------------------------------------------------------
22
23
24 wxClientDataContainer::wxClientDataContainer()
25 {
26 // no client data (yet)
27 m_clientData = NULL;
28 m_clientDataType = wxClientData_None;
29 }
30
31 wxClientDataContainer::~wxClientDataContainer()
32 {
33 // we only delete object data, not untyped
34 if ( m_clientDataType == wxClientData_Object )
35 delete m_clientObject;
36 }
37
38 void wxClientDataContainer::DoSetClientObject( wxClientData *data )
39 {
40 wxASSERT_MSG( m_clientDataType != wxClientData_Void,
41 wxT("can't have both object and void client data") );
42
43 if ( m_clientObject )
44 delete m_clientObject;
45
46 m_clientObject = data;
47 m_clientDataType = wxClientData_Object;
48 }
49
50 wxClientData *wxClientDataContainer::DoGetClientObject() const
51 {
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") );
56
57 return m_clientObject;
58 }
59
60 void wxClientDataContainer::DoSetClientData( void *data )
61 {
62 wxASSERT_MSG( m_clientDataType != wxClientData_Object,
63 wxT("can't have both object and void client data") );
64
65 m_clientData = data;
66 m_clientDataType = wxClientData_Void;
67 }
68
69 void *wxClientDataContainer::DoGetClientData() const
70 {
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") );
75
76 return m_clientData;
77 }
78
79
80 // ----------------------------------------------------------------------------
81
82