1998-05-20 10:25:30 -04:00
\section { \class { wxClipboard} } \label { wxclipboard}
1999-01-13 09:23:31 -05:00
A class for manipulating the clipboard. Note that this is not compatible with the
2004-05-04 04:27:20 -04:00
clipboard class from wxWidgets 1.xx, which has the same name but a different implementation.
1999-01-13 09:23:31 -05:00
1999-01-14 06:23:37 -05:00
To use the clipboard, you call member functions of the global { \bf wxTheClipboard} object.
1999-12-29 06:52:51 -05:00
See also the \helpref { wxDataObject overview} { wxdataobjectoverview} for further information.
2003-01-17 19:16:34 -05:00
Call \helpref { wxClipboard::Open} { wxclipboardopen} to get ownership of the clipboard. If this operation returns true, you
1999-11-01 13:20:39 -05:00
now own the clipboard. Call \helpref { wxClipboard::SetData} { wxclipboardsetdata} to put data
on the clipboard, or \helpref { wxClipboard::GetData} { wxclipboardgetdata} to
1999-01-13 09:23:31 -05:00
retrieve data from the clipboard. Call \helpref { wxClipboard::Close} { wxclipboardclose} to close
the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
For example:
\begin { verbatim}
// Write some text to the clipboard
1999-01-14 06:23:37 -05:00
if (wxTheClipboard->Open())
1999-01-13 09:23:31 -05:00
{
1999-01-28 13:25:36 -05:00
// This data objects are held by the clipboard,
// so do not delete them in the app.
1999-11-04 12:49:21 -05:00
wxTheClipboard->SetData( new wxTextDataObject("Some text") );
1999-01-14 06:23:37 -05:00
wxTheClipboard->Close();
1999-01-13 09:23:31 -05:00
}
// Read some text
1999-01-28 13:25:36 -05:00
if (wxTheClipboard->Open())
1999-01-13 09:23:31 -05:00
{
1999-11-01 13:20:39 -05:00
if (wxTheClipboard->IsSupported( wxDF_ TEXT ))
1999-01-28 13:25:36 -05:00
{
1999-07-30 08:02:28 -04:00
wxTextDataObject data;
1999-11-01 13:20:39 -05:00
wxTheClipboard->GetData( data );
1999-07-30 08:02:28 -04:00
wxMessageBox( data.GetText() );
1999-01-28 13:25:36 -05:00
}
1999-01-14 06:23:37 -05:00
wxTheClipboard->Close();
1999-01-13 09:23:31 -05:00
}
\end { verbatim}
1998-05-20 10:25:30 -04:00
\wxheading { Derived from}
\helpref { wxObject} { wxobject}
1999-02-15 15:41:29 -05:00
\wxheading { Include files}
<wx/clipbrd.h>
1998-05-20 10:25:30 -04:00
\wxheading { See also}
1999-01-13 09:23:31 -05:00
\helpref { Drag and drop overview} { wxdndoverview} , \helpref { wxDataObject} { wxdataobject}
1998-05-20 10:25:30 -04:00
\latexignore { \rtfignore { \wxheading { Members} } }
2004-10-04 11:13:52 -04:00
\membersection { wxClipboard::wxClipboard} \label { wxclipboardctor}
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\func { } { wxClipboard} { \void }
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Constructor.
1998-05-20 10:25:30 -04:00
2004-10-04 11:13:52 -04:00
\membersection { wxClipboard::\destruct { wxClipboard} } \label { wxclipboarddtor}
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\func { } { \destruct { wxClipboard} } { \void }
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Destructor.
1998-05-20 10:25:30 -04:00
2000-01-06 10:09:35 -05:00
\membersection { wxClipboard::AddData} \label { wxclipboardadddata}
\func { bool} { AddData} { \param { wxDataObject*} { data} }
Call this function to add the data object to the clipboard. You may call
this function repeatedly after having cleared the clipboard using \helpref { wxClipboard::Clear} { wxclipboardclear} .
After this function has been called, the clipboard owns the data, so do not delete
the data explicitly.
\wxheading { See also}
\helpref { wxClipboard::SetData} { wxclipboardsetdata}
1999-01-13 09:23:31 -05:00
\membersection { wxClipboard::Clear} \label { wxclipboardclear}
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\func { void} { Clear} { \void }
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Clears the global clipboard object and the system's clipboard if possible.
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\membersection { wxClipboard::Close} \label { wxclipboardclose}
1998-05-20 10:25:30 -04:00
2003-04-28 06:37:08 -04:00
\func { void} { Close} { \void }
1998-05-20 10:25:30 -04:00
1999-01-28 13:25:36 -05:00
Call this function to close the clipboard, having opened it with \helpref { wxClipboard::Open} { wxclipboardopen} .
1998-05-20 10:25:30 -04:00
2002-05-05 15:27:07 -04:00
\membersection { wxClipboard::Flush} \label { wxclipboardflush}
\func { bool} { Flush} { \void }
Flushes the clipboard: this means that the data which is currently on
clipboard will stay available even after the application exits (possibly
eating memory), otherwise the clipboard will be emptied on exit.
2004-10-22 15:15:35 -04:00
Returns false if the operation is unsuccessful for any reason.
2002-05-05 15:27:07 -04:00
1999-01-13 09:23:31 -05:00
\membersection { wxClipboard::GetData} \label { wxclipboardgetdata}
1998-05-20 10:25:30 -04:00
1999-11-01 13:20:39 -05:00
\func { bool} { GetData} { \param { wxDataObject\& } { data} }
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Call this function to fill { \it data} with data on the clipboard, if available in the required
2003-01-17 19:16:34 -05:00
format. Returns true on success.
1998-05-20 10:25:30 -04:00
2000-01-06 10:09:35 -05:00
\membersection { wxClipboard::IsOpened} \label { wxclipboardisopened}
\constfunc { bool} { IsOpened} { \void }
2003-01-17 19:16:34 -05:00
Returns true if the clipboard has been opened.
2000-01-06 10:09:35 -05:00
1999-01-28 13:25:36 -05:00
\membersection { wxClipboard::IsSupported} \label { wxclipboardissupported}
1998-05-20 10:25:30 -04:00
1999-11-01 13:20:39 -05:00
\func { bool} { IsSupported} { \param { const wxDataFormat\& } { format} }
1998-05-20 10:25:30 -04:00
2004-12-11 16:33:17 -05:00
Returns 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.
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\membersection { wxClipboard::Open} \label { wxclipboardopen}
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\func { bool} { Open} { \void }
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Call this function to open the clipboard before calling \helpref { wxClipboard::SetData} { wxclipboardsetdata}
and \helpref { wxClipboard::GetData} { wxclipboardgetdata} .
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
Call \helpref { wxClipboard::Close} { wxclipboardclose} when you have finished with the clipboard. You
should keep the clipboard open for only a very short time.
1998-05-20 10:25:30 -04:00
2003-01-17 19:16:34 -05:00
Returns true on success. This should be tested (as in the sample shown above).
1999-01-28 13:25:36 -05:00
1999-01-30 16:37:17 -05:00
\membersection { wxClipboard::SetData} \label { wxclipboardsetdata}
1998-05-20 10:25:30 -04:00
1999-01-13 09:23:31 -05:00
\func { bool} { SetData} { \param { wxDataObject*} { data} }
1998-05-20 10:25:30 -04:00
1999-01-28 13:25:36 -05:00
Call this function to set the data object to the clipboard. This function will
clear all previous contents in the clipboard, so calling it several times
does not make any sense.
1998-05-20 10:25:30 -04:00
2000-01-06 10:09:35 -05:00
After this function has been called, the clipboard owns the data, so do not delete
the data explicitly.
\wxheading { See also}
\helpref { wxClipboard::AddData} { wxclipboardadddata}
1999-07-30 09:16:45 -04:00
\membersection { wxClipboard::UsePrimarySelection} \label { wxclipboarduseprimary}
1999-07-30 08:02:28 -04:00
2003-01-17 19:16:34 -05:00
\func { void} { UsePrimarySelection} { \param { bool} { primary = true} }
1999-07-30 08:02:28 -04:00
On platforms supporting it (currently only GTK), selects the so called
PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
2003-01-17 19:16:34 -05:00
if { \it primary} is true.
1999-07-30 08:02:28 -04:00