1 \section{\class{wxDataObject
}}\label{wxdataobject
}
3 A wxDataObject represents data that can be copied to or from the clipboard, or
4 dragged and dropped. There are two classes directly derived from wxDataObject:
5 wxDataObjectSimple and wxDataObjectComposite. As you will guess, wxDataObjectSimple
6 holds data for a single format (such as HTML or text) and wxDataObjectComposite
7 can hold any number of wxDataObjectSimple classes. Please note that this is an
8 easy way to use Drag'n'Drop and the clipboard with multiple formats, but not the
9 most efficient one as each wxDataObjectSimple would contain the whole data in its
10 respective formars. Now imagine that you want to paste
200 pages of text in your
11 proprietary format, as well as Word, RTF, HTML, Unicode and plain text to the
12 clipboard and even today's computers are in trouble. For this case, you will have
13 to derive from wxDataObject directly and make it enumerate its formats and provide
14 the data in the requested format on demand.
16 Note that neither the GTK data transfer mechanisms for the clipboard and Drag'n'Drop
17 nor the OLE data transfer copies any data until another application actually
18 requests the data. This is in contrast to the "feel" offered to the user of a
19 program who would normally think that the data resides in the clipboard after
20 having pressed "Copy" - in reality it is only declared to be available.
22 There are several predefined data object classes derived from wxDataObjectSimple:
23 \helpref{wxFileDataObject
}{wxfiledataobject
},
\helpref{wxTextDataObject
}{wxtextdataobject
}
24 and
\helpref{wxBitmapDataObject
}{wxbitmapdataobject
} which can be used without change.
26 You may also derive your own data object classes from
\helpref{wxCustomDataObject
}{wxprivatedataobject
}
27 for user-defined types. The format of user-defined data is given as mime-type string literal,
28 such as "application/word" or "image/png". These strings are used as they are under Unix (so
29 far only GTK) to identify a format and are translated into their Windows equivalent under
30 Win32 (using the OLE IDataObject for data exchange to and from the clipboard and for Drag'n'Drop).
31 Note that the format string translation under Windows is not yet finnished.
33 \wxheading{Derived from
}
35 \helpref{wxObject
}{wxobject
}
37 \wxheading{Include files
}
43 \helpref{wxFileDataObject
}{wxfiledataobject
},
44 \helpref{wxTextDataObject
}{wxtextdataobject
},
45 \helpref{wxBitmapDataObject
}{wxbitmapdataobject
},
46 \helpref{wxPrivateDataObject
}{wxprivatedataobject
},
47 \helpref{Drag and drop overview
}{wxdndoverview
},
\helpref{wxDropTarget
}{wxdroptarget
},
48 \helpref{wxDropSource
}{wxdropsource
},
49 \helpref{wxTextDropTarget
}{wxtextdroptarget
},
\helpref{wxFileDropTarget
}{wxfiledroptarget
}
51 \latexignore{\rtfignore{\wxheading{Members
}}}
53 \membersection{wxDataObject::wxDataObject
}\label{wxdataobjectwxdataobject
}
55 \func{}{wxDataObject
}{\void}
59 \membersection{wxDataObject::
\destruct{wxDataObject
}}\label{wxdataobjectdtor
}
61 \func{}{\destruct{wxDataObject
}}{\void}
65 \membersection{wxDataObject::GetFormatCount
}\label{wxdataobjectgetformatcount
}
67 \constfunc{virtual size_t
}{GetFormatCount
}{\void}
69 Return the number of available formats.
71 \membersection{wxDataObject::GetDataHere
}\label{wxdataobjectgetdatahere
}
73 \constfunc{virtual bool
}{GetDataHere
}{\param{const wxDataFormat\&
}{ format
},
\param{void
}{*buf
} }
75 The method will write the data of the format
{\it format
} in the buffer
{\it buf
}.
77 \membersection{wxDataObject::GetDataSize
}\label{wxdataobjectgetdatasize
}
79 \constfunc{virtual size
\_t}{GetDataSize
}{\param{const wxDataFormat\&
}{ format
} }
81 Returns the data size of the given format
{\it format
}.
83 \membersection{wxDataObject::GetPreferredFormat
}\label{wxdataobjectgetpreferredformat
}
85 \constfunc{virtual wxDataFormat
}{GetPreferredFormat
}{\void}
87 Returns the preferred format. Usually the first format in the list of available formats.
89 \membersection{wxDataObject::SetData
}\label{wxdataobjectsetdata
}
91 \func{virtual bool
}{SetData
}{\param{const wxDataFormat\&
}{ format
},
\param{size_t
}{ len
},
\param{const void
}{*buf
} }
93 Set the data of the format
{\it format
} and the size
{\it len
} provided in the buffer
{\it buf
}.