]> git.saurik.com Git - wxWidgets.git/blame - src/common/clntdata.cpp
use WX_ASSERT_STR/SIZET_EQUAL instead of CPPUNIT_ASSERT_EQUAL with casts
[wxWidgets.git] / src / common / clntdata.cpp
CommitLineData
88a9f974
RD
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$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
88a9f974
RD
10/////////////////////////////////////////////////////////////////////////////
11
88a9f974
RD
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// ----------------------------------------------------------------------------
2aab8f16 23
88a9f974
RD
24
25wxClientDataContainer::wxClientDataContainer()
26{
27 // no client data (yet)
28 m_clientData = NULL;
29 m_clientDataType = wxClientData_None;
30}
31
32wxClientDataContainer::~wxClientDataContainer()
33{
34 // we only delete object data, not untyped
35 if ( m_clientDataType == wxClientData_Object )
36 delete m_clientObject;
37}
38
39void 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
51wxClientData *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
61void 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
70void *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
2aab8f16 80
88a9f974
RD
81// ----------------------------------------------------------------------------
82
83