]>
Commit | Line | Data |
---|---|---|
dface61c JS |
1 | \section{\class{wxTextDataObject}}\label{wxtextdataobject} |
2 | ||
ab272c0b | 3 | wxTextDataObject is a specialization of wxDataObject for text data. It can be |
b2cf617c | 4 | used without change to paste data into the \helpref{wxClipboard}{wxclipboard} |
717a57c2 VZ |
5 | or a \helpref{wxDropSource}{wxdropsource}. A user may wish to derive a new |
6 | class from this class for providing text on-demand in order to minimize memory | |
7 | consumption when offering data in several formats, such as plain text and RTF | |
8 | because by default the text is stored in a string in this class, but it might | |
b2cf617c JS |
9 | as well be generated when requested. For this, |
10 | \helpref{GetTextLength}{wxtextdataobjectgettextlength} and | |
717a57c2 | 11 | \helpref{GetText}{wxtextdataobjectgettext} will have to be overridden. |
ab272c0b | 12 | |
717a57c2 VZ |
13 | Note that if you already have the text inside a string, you will not achieve |
14 | any efficiency gain by overriding these functions because copying wxStrings is | |
b1462dfa | 15 | already a very efficient operation (data is not actually copied because |
717a57c2 VZ |
16 | wxStrings are reference counted). |
17 | ||
b1462dfa RD |
18 | \pythonnote{If you wish to create a derived wxTextDataObject class in |
19 | wxPython you should derive the class from wxPyTextDataObject | |
20 | in order to get Python-aware capabilities for the various virtual | |
21 | methods.} | |
22 | ||
717a57c2 VZ |
23 | \wxheading{Virtual functions to override} |
24 | ||
b2cf617c | 25 | This class may be used as is, but all of the data transfer functions may be |
717a57c2 | 26 | overridden to increase efficiency. |
dface61c JS |
27 | |
28 | \wxheading{Derived from} | |
29 | ||
407f3681 | 30 | \helpref{wxDataObjectSimple}{wxdataobjectsimple}\\ |
dface61c JS |
31 | \helpref{wxDataObject}{wxdataobject} |
32 | ||
954b8ae6 JS |
33 | \wxheading{Include files} |
34 | ||
35 | <wx/dataobj.h> | |
36 | ||
a7af285d VZ |
37 | \wxheading{Library} |
38 | ||
39 | \helpref{wxCore}{librarieslist} | |
40 | ||
dface61c JS |
41 | \wxheading{See also} |
42 | ||
b2cf617c JS |
43 | \helpref{Clipboard and drag and drop overview}{wxdndoverview}, |
44 | \helpref{wxDataObject}{wxdataobject}, | |
45 | \helpref{wxDataObjectSimple}{wxdataobjectsimple}, | |
46 | \helpref{wxFileDataObject}{wxfiledataobject}, | |
717a57c2 | 47 | \helpref{wxBitmapDataObject}{wxbitmapdataobject} |
dface61c JS |
48 | |
49 | \latexignore{\rtfignore{\wxheading{Members}}} | |
50 | ||
51 | \membersection{wxTextDataObject::wxTextDataObject}\label{wxtextdataobjectwxtextdataobject} | |
52 | ||
717a57c2 | 53 | \func{}{wxTextDataObject}{\param{const wxString\& }{text = wxEmptyString}} |
dface61c | 54 | |
b2cf617c | 55 | Constructor, may be used to initialise the text (otherwise |
407f3681 | 56 | \helpref{SetText}{wxtextdataobjectsettext} should be used later). |
dface61c | 57 | |
717a57c2 | 58 | \membersection{wxTextDataObject::GetTextLength}\label{wxtextdataobjectgettextlength} |
dface61c | 59 | |
717a57c2 | 60 | \constfunc{virtual size\_t}{GetTextLength}{\void} |
ab272c0b RR |
61 | |
62 | Returns the data size. By default, returns the size of the text data | |
63 | set in the constructor or using \helpref{SetText}{wxtextdataobjectsettext}. | |
64 | This can be overridden to provide text size data on-demand. It is recommended | |
65 | to return the text length plus 1 for a trailing zero, but this is not | |
66 | strictly required. | |
dface61c | 67 | |
ab272c0b RR |
68 | \membersection{wxTextDataObject::GetText}\label{wxtextdataobjectgettext} |
69 | ||
70 | \constfunc{virtual wxString}{GetText}{\void} | |
dface61c | 71 | |
ab272c0b RR |
72 | Returns the text associated with the data object. You may wish to override |
73 | this method when offering data on-demand, but this is not required by | |
fc2171bd | 74 | wxWidgets' internals. Use this method to get data in text form from |
ab272c0b | 75 | the \helpref{wxClipboard}{wxclipboard}. |
dface61c JS |
76 | |
77 | \membersection{wxTextDataObject::SetText}\label{wxtextdataobjectsettext} | |
78 | ||
79 | \func{virtual void}{SetText}{\param{const wxString\& }{strText}} | |
80 | ||
ab272c0b | 81 | Sets the text associated with the data object. This method is called |
717a57c2 VZ |
82 | when the data object receives the data and, by default, copies the text into |
83 | the member variable. If you want to process the text on the fly you may wish to | |
84 | override this function. | |
dface61c | 85 |