]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/clipbrd.tex
Native wxCheckListBox implementation for wxWinCE.
[wxWidgets.git] / docs / latex / wx / clipbrd.tex
CommitLineData
a660d684
KB
1\section{\class{wxClipboard}}\label{wxclipboard}
2
dface61c 3A class for manipulating the clipboard. Note that this is not compatible with the
fc2171bd 4clipboard class from wxWidgets 1.xx, which has the same name but a different implementation.
dface61c 5
4ce81a75
JS
6To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
7
23efdd02
RR
8See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information.
9
cc81d32f 10Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns true, you
fc9c7c09
RR
11now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
12on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
dface61c
JS
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}
dface61c 19 // Write some text to the clipboard
4ce81a75 20 if (wxTheClipboard->Open())
dface61c 21 {
75ce0581
RR
22 // This data objects are held by the clipboard,
23 // so do not delete them in the app.
330d6fd0 24 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
4ce81a75 25 wxTheClipboard->Close();
dface61c
JS
26 }
27
28 // Read some text
75ce0581 29 if (wxTheClipboard->Open())
dface61c 30 {
fc9c7c09 31 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
75ce0581 32 {
b453e1b2 33 wxTextDataObject data;
fc9c7c09 34 wxTheClipboard->GetData( data );
b453e1b2 35 wxMessageBox( data.GetText() );
75ce0581 36 }
4ce81a75 37 wxTheClipboard->Close();
dface61c
JS
38 }
39\end{verbatim}
a660d684
KB
40
41\wxheading{Derived from}
42
43\helpref{wxObject}{wxobject}
44
954b8ae6
JS
45\wxheading{Include files}
46
47<wx/clipbrd.h>
48
a660d684
KB
49\wxheading{See also}
50
dface61c 51\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDataObject}{wxdataobject}
a660d684
KB
52
53\latexignore{\rtfignore{\wxheading{Members}}}
54
f510b7b2 55\membersection{wxClipboard::wxClipboard}\label{wxclipboardctor}
a660d684 56
dface61c 57\func{}{wxClipboard}{\void}
a660d684 58
dface61c 59Constructor.
a660d684 60
f510b7b2 61\membersection{wxClipboard::\destruct{wxClipboard}}\label{wxclipboarddtor}
a660d684 62
dface61c 63\func{}{\destruct{wxClipboard}}{\void}
a660d684 64
dface61c 65Destructor.
a660d684 66
40219523
JS
67\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
68
69\func{bool}{AddData}{\param{wxDataObject*}{ data}}
70
71Call this function to add the data object to the clipboard. You may call
72this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}.
73
74After this function has been called, the clipboard owns the data, so do not delete
75the data explicitly.
76
77\wxheading{See also}
78
79\helpref{wxClipboard::SetData}{wxclipboardsetdata}
80
dface61c 81\membersection{wxClipboard::Clear}\label{wxclipboardclear}
a660d684 82
dface61c 83\func{void}{Clear}{\void}
a660d684 84
dface61c 85Clears the global clipboard object and the system's clipboard if possible.
a660d684 86
dface61c 87\membersection{wxClipboard::Close}\label{wxclipboardclose}
a660d684 88
2f930c85 89\func{void}{Close}{\void}
a660d684 90
75ce0581 91Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
a660d684 92
741ed114
MB
93\membersection{wxClipboard::Flush}\label{wxclipboardflush}
94
95\func{bool}{Flush}{\void}
96
97Flushes the clipboard: this means that the data which is currently on
98clipboard will stay available even after the application exits (possibly
99eating memory), otherwise the clipboard will be emptied on exit.
dbd94b75 100Returns false if the operation is unsuccessful for any reason.
741ed114 101
dface61c 102\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
a660d684 103
fc9c7c09 104\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
a660d684 105
dface61c 106Call this function to fill {\it data} with data on the clipboard, if available in the required
cc81d32f 107format. Returns true on success.
a660d684 108
40219523
JS
109\membersection{wxClipboard::IsOpened}\label{wxclipboardisopened}
110
111\constfunc{bool}{IsOpened}{\void}
112
cc81d32f 113Returns true if the clipboard has been opened.
40219523 114
75ce0581 115\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
a660d684 116
fc9c7c09 117\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
a660d684 118
3980000c 119Returns 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.
a660d684 120
dface61c 121\membersection{wxClipboard::Open}\label{wxclipboardopen}
a660d684 122
dface61c 123\func{bool}{Open}{\void}
a660d684 124
dface61c
JS
125Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
126and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
a660d684 127
dface61c
JS
128Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
129should keep the clipboard open for only a very short time.
a660d684 130
cc81d32f 131Returns true on success. This should be tested (as in the sample shown above).
75ce0581 132
f9b1708c 133\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
a660d684 134
dface61c 135\func{bool}{SetData}{\param{wxDataObject*}{ data}}
a660d684 136
75ce0581
RR
137Call this function to set the data object to the clipboard. This function will
138clear all previous contents in the clipboard, so calling it several times
139does not make any sense.
a660d684 140
40219523
JS
141After this function has been called, the clipboard owns the data, so do not delete
142the data explicitly.
143
144\wxheading{See also}
145
146\helpref{wxClipboard::AddData}{wxclipboardadddata}
147
7ff14117 148\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
b453e1b2 149
cc81d32f 150\func{void}{UsePrimarySelection}{\param{bool}{ primary = true}}
b453e1b2
RR
151
152On platforms supporting it (currently only GTK), selects the so called
153PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
cc81d32f 154if {\it primary} is true.
b453e1b2
RR
155
156