]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/doxygen/overviews/dataobject.h
Add missing XRC format docs for wxComboCtrl and wxEditableListBox.
[wxWidgets.git] / docs / doxygen / overviews / dataobject.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: dataobject.h
3// Purpose: topic overview
4// Author: wxWidgets team
5// Licence: wxWindows licence
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9
10@page overview_dataobject wxDataObject Overview
11
12@tableofcontents
13
14This overview discusses data transfer through clipboard or drag and drop. In
15wxWidgets, these two ways to transfer data (either between different
16applications or inside one and the same) are very similar which allows to
17implement both of them using almost the same code - or, in other words, if you
18implement drag and drop support for your application, you get clipboard support
19for free and vice versa.
20
21At the heart of both clipboard and drag and drop operations lies the
22wxDataObject class. The objects of this class (or, to be precise, classes
23derived from it) represent the data which is being carried by the mouse during
24drag and drop operation or copied to or pasted from the clipboard. wxDataObject
25is a "smart" piece of data because it knows which formats it supports (see
26GetFormatCount and GetAllFormats) and knows how to render itself in any of them
27(see GetDataHere). It can also receive its value from the outside in a format
28it supports if it implements the SetData method. Please see the documentation
29of this class for more details.
30
31Both clipboard and drag and drop operations have two sides: the source and
32target, the data provider and the data receiver. These which may be in the same
33application and even the same window when, for example, you drag some text from
34one position to another in a word processor. Let us describe what each of them
35should do.
36
37@see @ref overview_dnd, @ref group_class_dnd, @ref page_samples_dnd
38
39
40
41@section overview_dataobject_source The Data Provider (Source)
42
43The data provider is responsible for creating a wxDataObject containing the
44data to be transferred. Then it should either pass it to the clipboard using
45wxClipboard::SetData function or to wxDropSource and call
46wxDropSource::DoDragDrop function.
47
48The only (but important) difference is that the object for the clipboard
49transfer must always be created on the heap (i.e. using @c new) and it will be
50freed by the clipboard when it is no longer needed (indeed, it is not known in
51advance when, if ever, the data will be pasted from the clipboard). On the
52other hand, the object for drag and drop operation must only exist while
53wxDropSource::DoDragDrop executes and may be safely deleted afterwards and so
54can be created either on heap or on stack (i.e. as a local variable).
55
56Another small difference is that in the case of clipboard operation, the
57application usually knows in advance whether it copies or cuts (i.e. copies and
58deletes) data - in fact, this usually depends on which menu item the user
59chose. But for drag and drop it can only know it after wxDropSource::DoDragDrop
60returns (from its return value).
61
62
63
64@section overview_dataobject_target The Data Receiver (Target)
65
66To receive (paste in usual terminology) data from the clipboard, you should
67create a wxDataObject derived class which supports the data formats you need
68and pass it as argument to wxClipboard::GetData. If it returns @false,
69no data in (any of) the supported format(s) is available. If it returns @true,
70the data has been successfully transferred to wxDataObject.
71
72For drag and drop case, the wxDropTarget::OnData virtual function will be
73called when a data object is dropped, from which the data itself may be
74requested by calling wxDropTarget::GetData method which fills the data object.
75
76*/