]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/clipbrd.tex
fixed TeX error introduced in rev 48093 (sorry)
[wxWidgets.git] / docs / latex / wx / clipbrd.tex
... / ...
CommitLineData
1\section{\class{wxClipboard}}\label{wxclipboard}
2
3A class for manipulating the clipboard. Note that this is not compatible with the
4clipboard class from wxWidgets 1.xx, which has the same name but a different implementation.
5
6To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
7
8See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information.
9
10Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns true, you
11now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
12on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
13retrieve data from the clipboard. Call \helpref{wxClipboard::Close}{wxclipboardclose} to close
14the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
15
16For example:
17
18\begin{verbatim}
19 // Write some text to the clipboard
20 if (wxTheClipboard->Open())
21 {
22 // This data objects are held by the clipboard,
23 // so do not delete them in the app.
24 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
25 wxTheClipboard->Close();
26 }
27
28 // Read some text
29 if (wxTheClipboard->Open())
30 {
31 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
32 {
33 wxTextDataObject data;
34 wxTheClipboard->GetData( data );
35 wxMessageBox( data.GetText() );
36 }
37 wxTheClipboard->Close();
38 }
39\end{verbatim}
40
41\wxheading{Derived from}
42
43\helpref{wxObject}{wxobject}
44
45\wxheading{Include files}
46
47<wx/clipbrd.h>
48
49\wxheading{Library}
50
51\helpref{wxCore}{librarieslist}
52
53\wxheading{See also}
54
55\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}
56
57\latexignore{\rtfignore{\wxheading{Members}}}
58
59
60\membersection{wxClipboard::wxClipboard}\label{wxclipboardctor}
61
62\func{}{wxClipboard}{\void}
63
64Constructor.
65
66
67\membersection{wxClipboard::\destruct{wxClipboard}}\label{wxclipboarddtor}
68
69\func{}{\destruct{wxClipboard}}{\void}
70
71Destructor.
72
73
74\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
75
76\func{bool}{AddData}{\param{wxDataObject*}{ data}}
77
78Call this function to add the data object to the clipboard. You may call
79this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}.
80
81After this function has been called, the clipboard owns the data, so do not delete
82the data explicitly.
83
84\wxheading{See also}
85
86\helpref{wxClipboard::SetData}{wxclipboardsetdata}
87
88
89\membersection{wxClipboard::Clear}\label{wxclipboardclear}
90
91\func{void}{Clear}{\void}
92
93Clears the global clipboard object and the system's clipboard if possible.
94
95
96\membersection{wxClipboard::Close}\label{wxclipboardclose}
97
98\func{void}{Close}{\void}
99
100Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
101
102
103\membersection{wxClipboard::Flush}\label{wxclipboardflush}
104
105\func{bool}{Flush}{\void}
106
107Flushes the clipboard: this means that the data which is currently on
108clipboard will stay available even after the application exits (possibly
109eating memory), otherwise the clipboard will be emptied on exit.
110Returns false if the operation is unsuccessful for any reason.
111
112
113\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
114
115\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
116
117Call this function to fill {\it data} with data on the clipboard, if available in the required
118format. Returns true on success.
119
120
121\membersection{wxClipboard::IsOpened}\label{wxclipboardisopened}
122
123\constfunc{bool}{IsOpened}{\void}
124
125Returns true if the clipboard has been opened.
126
127
128\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
129
130\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
131
132Returns true if there is data which matches the data format of the given data object currently {\bf available} (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard.
133
134
135\membersection{wxClipboard::IsUsingPrimarySelection}\label{wxclipboardisusingprimaryselection}
136
137\constfunc{bool}{IsUsingPrimarySelection}{\void}
138
139Returns \true if we are using the primary selection, \false if clipboard one.
140See \helpref{UsePrimarySelection}{wxclipboarduseprimary} for more information.
141
142
143\membersection{wxClipboard::Open}\label{wxclipboardopen}
144
145\func{bool}{Open}{\void}
146
147Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
148and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
149
150Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
151should keep the clipboard open for only a very short time.
152
153Returns true on success. This should be tested (as in the sample shown above).
154
155
156\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
157
158\func{bool}{SetData}{\param{wxDataObject*}{ data}}
159
160Call this function to set the data object to the clipboard. This function will
161clear all previous contents in the clipboard, so calling it several times
162does not make any sense.
163
164After this function has been called, the clipboard owns the data, so do not delete
165the data explicitly.
166
167\wxheading{See also}
168
169\helpref{wxClipboard::AddData}{wxclipboardadddata}
170
171
172\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
173
174\func{void}{UsePrimarySelection}{\param{bool}{ primary = true}}
175
176On platforms supporting it (all X11-based ports), wxClipboard uses the
177CLIPBOARD X11 selection by default. When this function is called with \true
178argument, all subsequent clipboard operations will use PRIMARY selection until
179this function is called again with \false.
180
181On the other platforms, there is no PRIMARY selection and so all clipboard
182operations will fail. This allows to implement the standard X11 handling of the
183clipboard which consists in copying data to the CLIPBOARD selection only when
184the user explicitly requests it (i.e. by selection \texttt{"Copy"} menu
185command) but putting the currently selected text into the PRIMARY selection
186automatically, without overwriting the normal clipboard contents with the
187currently selected text on the other platforms.
188