]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dataobj.tex
Several changes and updates
[wxWidgets.git] / docs / latex / wx / dataobj.tex
CommitLineData
dface61c
JS
1\section{\class{wxDataObject}}\label{wxdataobject}
2
3A wxDataObject represents data that can be copied to or from the clipboard, or
4dragged and dropped.
5
6There are several predefined data object classes, such as \helpref{wxFileDataObject}{wxfiledataobject},
f37615d7
RR
7\helpref{wxTextDataObject}{wxtextdataobject}, and \helpref{wxBitmapDataObject}{wxbitmapdataobject} which
8can be used without change or can be altered (by deriving a new class from them) in order to deliver
9data and data size on-demand. There is no need to ever use wxDataObject itself or derive directly from it.
10
11You may also derive your own data object classes from \helpref{wxPrivateDataObject}{wxprivatedataobject}
12for user-defined types. The format of user-defined data is given as mime-type string literal,
13such as "application/word" or "image/png". These strings are used as they are under Unix (so
14far only GTK) to identify a format and are translated into their Windows equivalent under
15Win32 (using the OLE IDataObject for data exchange to and from the clipboard and for Drag'n'Drop).
16Note that the format string translation under Windows is not yet finnished.
17
18As mentioned above, data may be placed into the \helpref{wxClipboard}{wxclipboard}
19or a \helpref{wxDropSource}{wxdropsource} instance either directly or on-demand.
20As long as only one format is offerred, putting data directly into the clipboard may
21be sufficient. But imagine that you paste a large piece of text to the clipboard and
22offer it in "text/plain", "text/rtf", "text/html", "application/word" and your own
23format for internal use - here offering data on-demand is required to minimize memory
24consumption. This would generally get implemented using a central object that
25contains clipboard information in the format with the maximum of information. Note
26that neither the GTK data transfer mechanisms for the clipboard and Drag'n'Drop
27nor the OLE data transfer copies any data until another application actually
28requests the data. This is in contrast to the "feel" offered to the user of a
29program who would normally think that the data resides in the clipboard after
30having pressed "Copy" - in reality it is only declared to be available.
31
32Let's assume that you have written an HTML editor and want it to paste contents
33in the formats "text/plain" and "text/html" to the clipboard. For offering
34data on-demand in "text/plain" you would derive your class from \helpref{wxTextDataObject}{wxtextdataobject}
35and for offering data on-demand in "text/html" you would derive your own class from
36\helpref{wxPrivateDataObject}{wxprivatedataobject} and set its ID string
37identifying the format to "text/html" using \helpref{wxPrivateDataObject::SetId}{wxprivatedataobjectsetid}.
38In your two derived classed you'd then have a pointer or reference to the central
39data container and you'd override the methods returning the size of the
40available data and the WriteData() methods in both classes.
dface61c
JS
41
42\wxheading{Derived from}
43
44\helpref{wxObject}{wxobject}
45
954b8ae6
JS
46\wxheading{Include files}
47
48<wx/dataobj.h>
49
dface61c
JS
50\wxheading{See also}
51
52\helpref{wxFileDataObject}{wxfiledataobject},
53\helpref{wxTextDataObject}{wxtextdataobject},
54\helpref{wxBitmapDataObject}{wxbitmapdataobject},
f37615d7 55\helpref{wxPrivateDataObject}{wxprivatedataobject},
dface61c
JS
56\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDropTarget}{wxdroptarget},
57\helpref{wxDropSource}{wxdropsource},
58\helpref{wxTextDropTarget}{wxtextdroptarget}, \helpref{wxFileDropTarget}{wxfiledroptarget}
59
60\latexignore{\rtfignore{\wxheading{Members}}}
61
62\membersection{wxDataObject::wxDataObject}\label{wxdataobjectwxdataobject}
63
64\func{}{wxDataObject}{\void}
65
66Constructor.
67
68\membersection{wxDataObject::\destruct{wxDataObject}}\label{wxdataobjectdtor}
69
70\func{}{\destruct{wxDataObject}}{\void}
71
72Destructor.
73
f37615d7
RR
74\membersection{wxDataObject::WriteData}\label{wxdataobjectwritedata}
75
76\constfunc{virtual void}{WriteData}{\param{void}{*dest} }
77
78Write the data owned by this class to {\it dest}. This method is a pure
79virtual function and must be overridden.
80
81\membersection{wxDataObject::GetSize}\label{wxdataobjectgetdatasize}
82
83\constfunc{virtual size\_t}{GetSize}{\void}
dface61c 84
f37615d7
RR
85Returns the data size. This method is a pure
86virtual function and must be overridden.
dface61c 87
dface61c 88