]> git.saurik.com Git - wxWidgets.git/blame - src/common/clntdata.cpp
added possibility to throw different objects and crash directly from the main frame...
[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
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
88a9f974
RD
13 #pragma implementation "clntdata.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
23#include "wx/clntdata.h"
24
25
26// ----------------------------------------------------------------------------
2aab8f16 27
88a9f974
RD
28
29wxClientDataContainer::wxClientDataContainer()
30{
31 // no client data (yet)
32 m_clientData = NULL;
33 m_clientDataType = wxClientData_None;
34}
35
36wxClientDataContainer::~wxClientDataContainer()
37{
38 // we only delete object data, not untyped
39 if ( m_clientDataType == wxClientData_Object )
40 delete m_clientObject;
41}
42
43void wxClientDataContainer::DoSetClientObject( wxClientData *data )
44{
45 wxASSERT_MSG( m_clientDataType != wxClientData_Void,
46 wxT("can't have both object and void client data") );
47
48 if ( m_clientObject )
49 delete m_clientObject;
50
51 m_clientObject = data;
52 m_clientDataType = wxClientData_Object;
53}
54
55wxClientData *wxClientDataContainer::DoGetClientObject() const
56{
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") );
61
62 return m_clientObject;
63}
64
65void wxClientDataContainer::DoSetClientData( void *data )
66{
67 wxASSERT_MSG( m_clientDataType != wxClientData_Object,
68 wxT("can't have both object and void client data") );
69
70 m_clientData = data;
71 m_clientDataType = wxClientData_Void;
72}
73
74void *wxClientDataContainer::DoGetClientData() const
75{
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") );
80
81 return m_clientData;
82}
83
2aab8f16 84
88a9f974
RD
85// ----------------------------------------------------------------------------
86
87