]>
Commit | Line | Data |
---|---|---|
864753e9 VZ |
1 | \section{\class{wxCustomDataObject}}\label{wxcustomdataobject} |
2 | ||
b1462dfa | 3 | wxCustomDataObject is a specialization of |
864753e9 VZ |
4 | \helpref{wxDataObjectSimple}{wxdataobjectsimple} for some |
5 | application-specific data in arbitrary (either custom or one of the standard | |
6 | ones). The only restriction is that it is supposed that this data can be | |
7 | copied bitwise (i.e. with {\tt memcpy()}), so it would be a bad idea to make | |
8 | it contain a C++ object (though C struct is fine). | |
9 | ||
11c7d5b6 | 10 | By default, wxCustomDataObject stores the data inside in a buffer. To put the |
b1462dfa RD |
11 | data into the buffer you may use either |
12 | \helpref{SetData}{wxcustomdataobjectsetdata} or | |
11c7d5b6 VZ |
13 | \helpref{TakeData}{wxcustomdataobjecttakedata} depending on whether you want |
14 | the object to make a copy of data or not. | |
15 | ||
16 | If you already store the data in another place, it may be more convenient and | |
17 | efficient to provide the data on-demand which is possible too if you override | |
18 | the virtual functions mentioned below. | |
19 | ||
20 | \wxheading{Virtual functions to override} | |
21 | ||
22 | This class may be used as is, but if you don't want store the data inside the | |
b1462dfa | 23 | object but provide it on demand instead, you should override |
11c7d5b6 | 24 | \helpref{GetSize}{wxcustomdataobjectgetsize}, |
b1462dfa | 25 | \helpref{GetData}{wxcustomdataobjectgetdata} and |
11c7d5b6 VZ |
26 | \helpref{SetData}{wxcustomdataobjectsetdata} (or may be only the first two or |
27 | only the last one if you only allow reading/writing the data) | |
28 | ||
864753e9 VZ |
29 | \wxheading{Derived from} |
30 | ||
0a2017e0 | 31 | \helpref{wxDataObjectSimple}{wxdataobjectsimple}\\ |
864753e9 VZ |
32 | \helpref{wxDataObject}{wxdataobject} |
33 | ||
34 | \wxheading{Include files} | |
35 | ||
36 | <wx/dataobj.h> | |
37 | ||
38 | \wxheading{See also} | |
39 | ||
40 | \helpref{wxDataObject}{wxdataobject} | |
41 | ||
42 | \latexignore{\rtfignore{\wxheading{Members}}} | |
43 | ||
44 | \membersection{wxCustomDataObject::wxCustomDataObject}\label{wxcustomdataobjectwxcustomdataobject} | |
45 | ||
46 | \func{}{wxCustomDataObject}{\param{const wxDataFormat\& }{format = wxFormatInvalid}} | |
47 | ||
48 | The constructor accepts a {\it format} argument which specifies the (single) | |
b1462dfa | 49 | format supported by this object. If it isn't set here, |
864753e9 VZ |
50 | \helpref{SetFormat}{wxdataobjectsimplesetformat} should be used. |
51 | ||
52 | \membersection{wxCustomDataObject::\destruct{wxCustomDataObject}}\label{wxcustomdataobjectdtor} | |
53 | ||
54 | \func{}{\destruct{wxCustomDataObject}}{\void} | |
55 | ||
56 | The destructor will free the data hold by the object. Notice that although it | |
57 | calls a virtual \helpref{Free()}{wxcustomdataobjectfree} function, the base | |
58 | class version will always be called (C++ doesn't allow calling virtual | |
59 | functions from constructors or destructors), so if you override {\tt Free()}, you | |
60 | should override the destructor in your class as well (which would probably | |
61 | just call the derived class' version of {\tt Free()}). | |
62 | ||
11c7d5b6 | 63 | \membersection{wxCustomDataObject::Alloc}\label{wxcustomdataobjectalloc} |
864753e9 | 64 | |
11c7d5b6 | 65 | \func{virtual void *}{Alloc}{\param{size\_t }{size}} |
864753e9 | 66 | |
11c7d5b6 VZ |
67 | This function is called to allocate {\it size} bytes of memory from SetData(). |
68 | The default version just uses the operator new. | |
864753e9 | 69 | |
11c7d5b6 VZ |
70 | \membersection{wxCustomDataObject::Free}\label{wxcustomdataobjectfree} |
71 | ||
b1462dfa RD |
72 | \pythonnote{This method expects a string in wxPython. You can pass |
73 | nearly any object by pickling it first.} | |
74 | ||
11c7d5b6 VZ |
75 | \func{virtual void}{Free}{\void} |
76 | ||
77 | This function is called when the data is freed, you may override it to anything | |
78 | you want (or may be nothing at all). The default version calls operator | |
0a2017e0 | 79 | delete$[]$ on the data. |
864753e9 VZ |
80 | |
81 | \membersection{wxCustomDataObject::GetSize}\label{wxcustomdataobjectgetsize} | |
82 | ||
11c7d5b6 | 83 | \constfunc{virtual size\_t}{GetSize}{\void} |
864753e9 | 84 | |
11c7d5b6 | 85 | Returns the data size in bytes. |
864753e9 VZ |
86 | |
87 | \membersection{wxCustomDataObject::GetData}\label{wxcustomdataobjectgetdata} | |
88 | ||
11c7d5b6 | 89 | \constfunc{virtual void *}{GetData}{\void} |
864753e9 VZ |
90 | |
91 | Returns a pointer to the data. | |
92 | ||
11c7d5b6 VZ |
93 | \membersection{wxCustomDataObject::SetData}\label{wxcustomdataobjectsetdata} |
94 | ||
95 | \func{virtual void}{SetData}{ | |
0a2017e0 | 96 | \param{size\_t }{size}, \param{const void }{*data}} |
11c7d5b6 VZ |
97 | |
98 | Set the data. The data object will make an internal copy. | |
99 | ||
100 | \membersection{wxCustomDataObject::TakeData}\label{wxcustomdataobjecttakedata} | |
101 | ||
102 | \func{virtual void}{TakeData}{ | |
0a2017e0 | 103 | \param{size\_t }{size}, \param{const void }{*data}} |
11c7d5b6 VZ |
104 | |
105 | Like \helpref{SetData}{wxcustomdataobjectsetdata}, but doesn't copy the data - | |
106 | instead the object takes ownership of the pointer. | |
0a2017e0 | 107 |