summaryrefslogtreecommitdiff
path: root/lib/wx/doc/src/wxDataObject.xml
blob: 7e25ae3cabca421c68faf1bd93910924f700f046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<!-- THIS FILE IS GENERATED DO NOT EDIT -->


<erlref>
<header>
  <copyright>
    <year>2020</year>
    <holder>wxWidgets team.</holder></copyright>
  <legalnotice>Licensed under the wxWindows Free Documentation Licence, Version 3
  </legalnotice>
  <title>wxDataObject</title>
</header>
<module>wxDataObject</module>
<modulesummary>Functions for wxDataObject class</modulesummary>
<description><p>A <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> represents data that can be copied to or from the clipboard, or dragged and dropped. The important thing about <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> is that this is a 'smart' piece of data unlike 'dumb' data containers such as memory buffers or files. Being 'smart' here means that the data object itself should know what data formats it supports and how to render itself in each of its supported formats.
      </p><p>A supported format, incidentally, is exactly the format in which the data can be requested from a data object or from which the data object may be set. In the general case, an object may support different formats on 'input' and 'output', i.e. it may be able to render itself in a given format but not be created from data on this format or vice versa. <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> defines the <c>wxDataObject::Direction</c> (not implemented in wx) enumeration type which distinguishes between them.
      </p><p>See <c>wxDataFormat</c> (not implemented in wx) documentation for more about formats.
      </p><p>Not surprisingly, being 'smart' comes at a price of added complexity. This is reasonable for the situations when you really need to support multiple formats, but may be annoying if you only want to do something simple like cut and paste text.
      </p><p>To provide a solution for both cases, wxWidgets has two predefined classes which derive from <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl>: <c>wxDataObjectSimple</c> (not implemented in wx) and <c>wxDataObjectComposite</c> (not implemented in wx). <c>wxDataObjectSimple</c> (not implemented in wx) is the simplest <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> possible and only holds data in a single format (such as HTML or text) and <c>wxDataObjectComposite</c> (not implemented in wx) is the simplest way to implement a <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> that does support multiple formats because it achieves this by simply holding several <c>wxDataObjectSimple</c> (not implemented in wx) objects.
      </p><p>So, you have several solutions when you need a <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> class (and you need one as soon as you want to transfer data via the clipboard or drag and drop):
      </p><p>Please note that the easiest way to use drag and drop and the clipboard with multiple formats is by using <c>wxDataObjectComposite</c> (not implemented in wx), but it is not the most efficient one as each <c>wxDataObjectSimple</c> (not implemented in wx) would contain the whole data in its respective formats. Now imagine that you want to paste 200 pages of text in your proprietary format, as well as Word, RTF, HTML, Unicode and plain text to the clipboard and even today's computers are in trouble. For this case, you will have to derive from <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> directly and make it enumerate its formats and provide the data in the requested format on demand.
      </p><p>Note that neither the GTK+ data transfer mechanisms for clipboard and drag and drop, nor OLE data transfer, <c>copies</c> any data until another application actually requests the data. This is in contrast to the 'feel' offered to the user of a program who would normally think that the data resides in the clipboard after having pressed 'Copy' - in reality it is only declared to be <c>available</c>.
      </p><p>You may also derive your own data object classes from <c>wxCustomDataObject</c> (not implemented in wx) for user-defined types. The format of user-defined data is given as a mime-type string literal, such as "application/word" or "image/png". These strings are used as they are under Unix (so far only GTK+) to identify a format and are translated into their Windows equivalent under Win32 (using the OLE IDataObject for data exchange to and from the clipboard and for drag and drop). Note that the format string translation under Windows is not yet finished.
      </p><p>Each class derived directly from <seeerl marker="wxDataObject"><c>wxDataObject</c></seeerl> must override and implement all of its functions which are pure virtual in the base class. The data objects which only render their data or only set it (i.e. work in only one direction), should return 0 from <c>GetFormatCount()</c> (not implemented in wx).
      </p><p>See: <url href="https://docs.wxwidgets.org/3.1/overview_dnd.html#overview_dnd">Overview dnd</url>, <url href="https://docs.wxwidgets.org/3.1/page_samples.html#page_samples_dnd">Examples</url>, <seeerl marker="wxFileDataObject"><c>wxFileDataObject</c></seeerl>, <seeerl marker="wxTextDataObject"><c>wxTextDataObject</c></seeerl>, <seeerl marker="wxBitmapDataObject"><c>wxBitmapDataObject</c></seeerl>, <c>wxCustomDataObject</c> (not implemented in wx), <c>wxDropTarget</c> (not implemented in wx), <c>wxDropSource</c> (not implemented in wx), <c>wxTextDropTarget</c> (not implemented in wx), <c>wxFileDropTarget</c> (not implemented in wx)
      </p>
  <p>wxWidgets docs: <url href="https://docs.wxwidgets.org/3.1/classwx_data_object.html">wxDataObject</url></p>
  </description>
<datatypes><datatype><name name="wxDataObject"/></datatype></datatypes>

</erlref>