]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/clipbrd.tex
mask corrections
[wxWidgets.git] / docs / latex / wx / clipbrd.tex
CommitLineData
a660d684
KB
1\section{\class{wxClipboard}}\label{wxclipboard}
2
dface61c
JS
3A class for manipulating the clipboard. Note that this is not compatible with the
4clipboard class from wxWindows 1.xx, which has the same name but a different implementation.
5
4ce81a75
JS
6To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
7
8Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you
fc9c7c09
RR
9now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
10on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
dface61c
JS
11retrieve data from the clipboard. Call \helpref{wxClipboard::Close}{wxclipboardclose} to close
12the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
13
14For example:
15
16\begin{verbatim}
dface61c 17 // Write some text to the clipboard
4ce81a75 18 if (wxTheClipboard->Open())
dface61c 19 {
75ce0581
RR
20 // This data objects are held by the clipboard,
21 // so do not delete them in the app.
330d6fd0 22 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
4ce81a75 23 wxTheClipboard->Close();
dface61c
JS
24 }
25
26 // Read some text
75ce0581 27 if (wxTheClipboard->Open())
dface61c 28 {
fc9c7c09 29 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
75ce0581 30 {
b453e1b2 31 wxTextDataObject data;
fc9c7c09 32 wxTheClipboard->GetData( data );
b453e1b2 33 wxMessageBox( data.GetText() );
75ce0581 34 }
4ce81a75 35 wxTheClipboard->Close();
dface61c
JS
36 }
37\end{verbatim}
a660d684
KB
38
39\wxheading{Derived from}
40
41\helpref{wxObject}{wxobject}
42
954b8ae6
JS
43\wxheading{Include files}
44
45<wx/clipbrd.h>
46
a660d684
KB
47\wxheading{See also}
48
dface61c 49\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}
a660d684
KB
50
51\latexignore{\rtfignore{\wxheading{Members}}}
52
dface61c 53\membersection{wxClipboard::wxClipboard}
a660d684 54
dface61c 55\func{}{wxClipboard}{\void}
a660d684 56
dface61c 57Constructor.
a660d684 58
dface61c 59\membersection{wxClipboard::\destruct{wxClipboard}}
a660d684 60
dface61c 61\func{}{\destruct{wxClipboard}}{\void}
a660d684 62
dface61c 63Destructor.
a660d684 64
dface61c 65\membersection{wxClipboard::Clear}\label{wxclipboardclear}
a660d684 66
dface61c 67\func{void}{Clear}{\void}
a660d684 68
dface61c 69Clears the global clipboard object and the system's clipboard if possible.
a660d684 70
dface61c 71\membersection{wxClipboard::Close}\label{wxclipboardclose}
a660d684 72
dface61c 73\func{bool}{Close}{\void}
a660d684 74
75ce0581 75Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
a660d684 76
dface61c 77\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
a660d684 78
fc9c7c09 79\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
a660d684 80
dface61c 81Call this function to fill {\it data} with data on the clipboard, if available in the required
75ce0581 82format. Returns TRUE on success.
a660d684 83
75ce0581 84\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
a660d684 85
fc9c7c09 86\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
a660d684 87
75ce0581 88Returns TRUE if the format of the given data object is available on the clipboard.
a660d684 89
dface61c 90\membersection{wxClipboard::Open}\label{wxclipboardopen}
a660d684 91
dface61c 92\func{bool}{Open}{\void}
a660d684 93
dface61c
JS
94Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
95and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
a660d684 96
dface61c
JS
97Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
98should keep the clipboard open for only a very short time.
a660d684 99
75ce0581
RR
100Returns TRUE on success. This should be tested (as in the sample shown above).
101
f9b1708c 102\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
a660d684 103
dface61c 104\func{bool}{SetData}{\param{wxDataObject*}{ data}}
a660d684 105
75ce0581
RR
106Call this function to set the data object to the clipboard. This function will
107clear all previous contents in the clipboard, so calling it several times
108does not make any sense.
a660d684 109
7ff14117 110\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
b453e1b2 111
7ff14117 112\func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}}
b453e1b2
RR
113
114On platforms supporting it (currently only GTK), selects the so called
115PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
7ff14117 116if {\it primary} is TRUE.
b453e1b2
RR
117
118