]> git.saurik.com Git - wxWidgets.git/blame - include/wx/clntdata.h
corrections for Mac OS X
[wxWidgets.git] / include / wx / clntdata.h
CommitLineData
88a9f974
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/clntdata.h
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) wxWindows team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CLNTDATAH__
13#define _WX_CLNTDATAH__
14
15#ifdef __GNUG__
16d38102 16 #pragma interface "clntdata.h"
88a9f974
RD
17#endif
18
19#include "wx/defs.h"
16d38102 20#include "wx/string.h"
88a9f974
RD
21
22// ----------------------------------------------------------------------------
23
24// what kind of client data do we have?
25enum wxClientDataType
26{
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
30};
31
32class WXDLLEXPORT wxClientData
33{
34public:
35 wxClientData() { }
36 virtual ~wxClientData() { }
37};
38
39class WXDLLEXPORT wxStringClientData : public wxClientData
40{
41public:
42 wxStringClientData() { }
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; }
46
47private:
48 wxString m_data;
49};
50
51
16d38102 52
b88c44e7 53#if 0
16d38102
RD
54// This class is a mixin that provides storage and management of "client
55// data." The client data stored can either be a pointer to a wxClientData
56// object in which case it is managed by the container (i.e. it will delete
57// the data when it's destroyed) or an untyped pointer which won't be deleted
58// by the window - but not both of them
59
88a9f974
RD
60class WXDLLEXPORT wxClientDataContainer
61{
62public:
63 wxClientDataContainer();
16d38102 64 virtual ~wxClientDataContainer();
88a9f974 65
88a9f974
RD
66 void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
67 wxClientData *GetClientObject() const { return DoGetClientObject(); }
68
69 void SetClientData( void *data ) { DoSetClientData(data); }
70 void *GetClientData() const { return DoGetClientData(); }
71
72protected:
16d38102
RD
73 // The user data: either an object which will be deleted by the container
74 // when it's deleted or some raw pointer which we do nothing with - only
75 // one type of data can be used with the given window (i.e. you cannot set
b88c44e7 76 // the void data and then associate the container with wxClientData or vice
16d38102 77 // versa)
88a9f974
RD
78 union
79 {
80 wxClientData *m_clientObject;
81 void *m_clientData;
82 };
83
84 // client data accessors
85 virtual void DoSetClientObject( wxClientData *data );
86 virtual wxClientData *DoGetClientObject() const;
87
88 virtual void DoSetClientData( void *data );
89 virtual void *DoGetClientData() const;
90
91 // what kind of data do we have?
92 wxClientDataType m_clientDataType;
93
94};
b88c44e7 95#endif
88a9f974
RD
96// ----------------------------------------------------------------------------
97#endif
98