]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: clntdata.h | |
d18d9f60 | 3 | // Purpose: interface of wxClientData[Container] and wxStringClientData |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxClientDataContainer | |
7c913512 | 11 | |
23324ae1 FM |
12 | This class is a mixin that provides storage and management of "client |
13 | data." This data can either be of type void - in which case the data | |
d18d9f60 BP |
14 | @e container does not take care of freeing the data again or it is of |
15 | type wxClientData or its derivatives. In that case the container will free | |
16 | the memory itself later. Note that you @e must not assign both void data | |
17 | and data derived from the wxClientData class to a container. | |
7c913512 | 18 | |
d18d9f60 BP |
19 | @note This functionality is currently duplicated in wxEvtHandler in order |
20 | to avoid having more than one vtable in that class hierarchy. | |
7c913512 | 21 | |
23324ae1 | 22 | @library{wxbase} |
d18d9f60 | 23 | @category{containers} |
7c913512 | 24 | |
e54c96f1 | 25 | @see wxEvtHandler, wxClientData |
23324ae1 | 26 | */ |
7c913512 | 27 | class wxClientDataContainer |
23324ae1 FM |
28 | { |
29 | public: | |
30 | /** | |
d18d9f60 | 31 | Default constructor. |
23324ae1 FM |
32 | */ |
33 | wxClientDataContainer(); | |
34 | ||
35 | /** | |
d18d9f60 | 36 | Destructor. |
23324ae1 FM |
37 | */ |
38 | ~wxClientDataContainer(); | |
39 | ||
40 | /** | |
41 | Get the untyped client data. | |
42 | */ | |
328f5751 | 43 | void* GetClientData() const; |
23324ae1 FM |
44 | |
45 | /** | |
46 | Get a pointer to the client data object. | |
47 | */ | |
328f5751 | 48 | wxClientData* GetClientObject() const; |
23324ae1 FM |
49 | |
50 | /** | |
51 | Set the untyped client data. | |
52 | */ | |
53 | void SetClientData(void* data); | |
54 | ||
55 | /** | |
56 | Set the client data object. Any previous object will be deleted. | |
57 | */ | |
58 | void SetClientObject(wxClientData* data); | |
59 | }; | |
60 | ||
61 | ||
e54c96f1 | 62 | |
23324ae1 FM |
63 | /** |
64 | @class wxClientData | |
7c913512 | 65 | |
d18d9f60 BP |
66 | All classes deriving from wxEvtHandler (such as all controls and wxApp) can |
67 | hold arbitrary data which is here referred to as "client data". This is | |
68 | useful e.g. for scripting languages which need to handle shadow objects for | |
69 | most of wxWidgets' classes and which store a handle to such a shadow class | |
70 | as client data in that class. This data can either be of type void - in | |
71 | which case the data @e container does not take care of freeing the data | |
72 | again or it is of type wxClientData or its derivatives. In that case the | |
73 | container (e.g. a control) will free the memory itself later. Note that you | |
74 | @e must not assign both void data and data derived from the wxClientData | |
75 | class to a container. | |
76 | ||
77 | Some controls can hold various items and these controls can additionally | |
78 | hold client data for each item. This is the case for wxChoice, wxComboBox | |
79 | and wxListBox. wxTreeCtrl has a specialized class wxTreeItemData for each | |
80 | item in the tree. | |
81 | ||
82 | If you want to add client data to your own classes, you may use the mix-in | |
83 | class wxClientDataContainer. | |
7c913512 | 84 | |
23324ae1 | 85 | @library{wxbase} |
d18d9f60 | 86 | @category{containers} |
7c913512 | 87 | |
d18d9f60 BP |
88 | @see wxEvtHandler, wxTreeItemData, wxStringClientData, |
89 | wxClientDataContainer | |
23324ae1 | 90 | */ |
7c913512 | 91 | class wxClientData |
23324ae1 FM |
92 | { |
93 | public: | |
94 | /** | |
95 | Constructor. | |
96 | */ | |
97 | wxClientData(); | |
98 | ||
99 | /** | |
100 | Virtual destructor. | |
101 | */ | |
102 | ~wxClientData(); | |
103 | }; | |
104 | ||
105 | ||
e54c96f1 | 106 | |
23324ae1 FM |
107 | /** |
108 | @class wxStringClientData | |
7c913512 | 109 | |
23324ae1 | 110 | Predefined client data class for holding a string. |
7c913512 | 111 | |
23324ae1 | 112 | @library{wxbase} |
d18d9f60 | 113 | @category{containers} |
23324ae1 FM |
114 | */ |
115 | class wxStringClientData : public wxClientData | |
116 | { | |
117 | public: | |
23324ae1 | 118 | /** |
d18d9f60 | 119 | Default constructor. |
23324ae1 FM |
120 | */ |
121 | wxStringClientData(); | |
d18d9f60 BP |
122 | |
123 | /** | |
124 | Create client data with string. | |
125 | */ | |
7c913512 | 126 | wxStringClientData(const wxString& data); |
23324ae1 FM |
127 | |
128 | /** | |
129 | Get string client data. | |
130 | */ | |
328f5751 | 131 | const wxString GetData() const; |
23324ae1 FM |
132 | |
133 | /** | |
134 | Set string client data. | |
135 | */ | |
136 | void SetData(const wxString& data); | |
137 | }; | |
e54c96f1 | 138 |