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