1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: A mixin class for holding a wxClientData or void pointer
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CLNTDATAH__
13 #define _WX_CLNTDATAH__
16 #pragma interface "clntdata.h"
20 #include "wx/string.h"
22 // ----------------------------------------------------------------------------
24 // what kind of client data do we have?
27 wxClientData_None
, // we don't know yet because we don't have it at all
28 wxClientData_Object
, // our client data is typed and we own it
29 wxClientData_Void
// client data is untyped and we don't own it
32 class WXDLLEXPORT wxClientData
36 virtual ~wxClientData() { }
39 class WXDLLEXPORT wxStringClientData
: public wxClientData
42 wxStringClientData() : m_data() { }
43 wxStringClientData( const wxString
&data
) : m_data(data
) { }
44 void SetData( const wxString
&data
) { m_data
= data
; }
45 const wxString
& GetData() const { return m_data
; }
53 // This class is a mixin that provides storage and management of "client
54 // data." The client data stored can either be a pointer to a wxClientData
55 // object in which case it is managed by the container (i.e. it will delete
56 // the data when it's destroyed) or an untyped pointer which won't be deleted
57 // by the container - but not both of them
59 // NOTE: This functionality is currently duplicated in wxEvtHandler in order
60 // to avoid having more than one vtable in that class heirachy.
62 class WXDLLEXPORT wxClientDataContainer
65 wxClientDataContainer();
66 virtual ~wxClientDataContainer();
68 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
69 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
71 void SetClientData( void *data
) { DoSetClientData(data
); }
72 void *GetClientData() const { return DoGetClientData(); }
75 // The user data: either an object which will be deleted by the container
76 // when it's deleted or some raw pointer which we do nothing with - only
77 // one type of data can be used with the given window (i.e. you cannot set
78 // the void data and then associate the container with wxClientData or vice
82 wxClientData
*m_clientObject
;
86 // client data accessors
87 virtual void DoSetClientObject( wxClientData
*data
);
88 virtual wxClientData
*DoGetClientObject() const;
90 virtual void DoSetClientData( void *data
);
91 virtual void *DoGetClientData() const;
93 // what kind of data do we have?
94 wxClientDataType m_clientDataType
;
98 // ----------------------------------------------------------------------------