]> git.saurik.com Git - wxWidgets.git/blob - src/common/clntdata.cpp
Add wxDataViewCtrl::GTKPathToItem() function and use it.
[wxWidgets.git] / src / common / clntdata.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 // RCS-ID: $Id$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #include "wx/clntdata.h"
20
21
22 // ----------------------------------------------------------------------------
23
24
25 wxClientDataContainer::wxClientDataContainer()
26 {
27 // no client data (yet)
28 m_clientData = NULL;
29 m_clientDataType = wxClientData_None;
30 }
31
32 wxClientDataContainer::~wxClientDataContainer()
33 {
34 // we only delete object data, not untyped
35 if ( m_clientDataType == wxClientData_Object )
36 delete m_clientObject;
37 }
38
39 void wxClientDataContainer::DoSetClientObject( wxClientData *data )
40 {
41 wxASSERT_MSG( m_clientDataType != wxClientData_Void,
42 wxT("can't have both object and void client data") );
43
44 if ( m_clientObject )
45 delete m_clientObject;
46
47 m_clientObject = data;
48 m_clientDataType = wxClientData_Object;
49 }
50
51 wxClientData *wxClientDataContainer::DoGetClientObject() const
52 {
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") );
57
58 return m_clientObject;
59 }
60
61 void wxClientDataContainer::DoSetClientData( void *data )
62 {
63 wxASSERT_MSG( m_clientDataType != wxClientData_Object,
64 wxT("can't have both object and void client data") );
65
66 m_clientData = data;
67 m_clientDataType = wxClientData_Void;
68 }
69
70 void *wxClientDataContainer::DoGetClientData() const
71 {
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") );
76
77 return m_clientData;
78 }
79
80
81 // ----------------------------------------------------------------------------
82
83