]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/clipbrd.tex
cvs debugging
[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
75ce0581 9now own the clipboard. Call \helpref{wxClipboard::AddData}{wxclipboardadddata} to put data
dface61c
JS
10on the clipboard (one or more times), or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
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.
22 wxTheClipboard->AddData( new wxTextDataObject("Some text") );
4ce81a75 23 wxTheClipboard->Close();
dface61c
JS
24 }
25
26 // Read some text
75ce0581 27 if (wxTheClipboard->Open())
dface61c 28 {
b453e1b2 29 if (wxTheClipboard->IsSupported( "STRING" ))
75ce0581 30 {
b453e1b2
RR
31 wxTextDataObject data;
32 wxTheClipboard->GetData( &data );
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
75ce0581
RR
65\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
66
67\func{bool}{AddData}{\param{wxDataObject*}{ data}}
68
69Call this function to add a data object to the clipboard. This function can be called several times
70to put different formats on the clipboard.
71
dface61c 72\membersection{wxClipboard::Clear}\label{wxclipboardclear}
a660d684 73
dface61c 74\func{void}{Clear}{\void}
a660d684 75
dface61c 76Clears the global clipboard object and the system's clipboard if possible.
a660d684 77
dface61c 78\membersection{wxClipboard::Close}\label{wxclipboardclose}
a660d684 79
dface61c 80\func{bool}{Close}{\void}
a660d684 81
75ce0581 82Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
a660d684 83
dface61c 84\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
a660d684 85
b453e1b2 86\func{bool}{GetData}{\param{wxDataObject*}{ data}}
a660d684 87
dface61c 88Call this function to fill {\it data} with data on the clipboard, if available in the required
75ce0581 89format. Returns TRUE on success.
a660d684 90
75ce0581 91\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
a660d684 92
b453e1b2 93\func{bool}{IsSupported}{\param{wxDataFormat}{ format}}
a660d684 94
75ce0581 95Returns TRUE if the format of the given data object is available on the clipboard.
a660d684 96
dface61c 97\membersection{wxClipboard::Open}\label{wxclipboardopen}
a660d684 98
dface61c 99\func{bool}{Open}{\void}
a660d684 100
dface61c
JS
101Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
102and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
a660d684 103
dface61c
JS
104Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
105should keep the clipboard open for only a very short time.
a660d684 106
75ce0581
RR
107Returns TRUE on success. This should be tested (as in the sample shown above).
108
f9b1708c 109\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
a660d684 110
dface61c 111\func{bool}{SetData}{\param{wxDataObject*}{ data}}
a660d684 112
75ce0581
RR
113Call this function to set the data object to the clipboard. This function will
114clear all previous contents in the clipboard, so calling it several times
115does not make any sense.
a660d684 116
7ff14117 117\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
b453e1b2 118
7ff14117 119\func{void}{UsePrimarySelection}{\param{bool}{ primary = TRUE}}
b453e1b2
RR
120
121On platforms supporting it (currently only GTK), selects the so called
122PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
7ff14117 123if {\it primary} is TRUE.
b453e1b2
RR
124
125