]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/clipbrd.tex
fix typo
[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
9005f2ed 55
f510b7b2 56\membersection{wxClipboard::wxClipboard}\label{wxclipboardctor}
a660d684 57
dface61c 58\func{}{wxClipboard}{\void}
a660d684 59
dface61c 60Constructor.
a660d684 61
9005f2ed 62
f510b7b2 63\membersection{wxClipboard::\destruct{wxClipboard}}\label{wxclipboarddtor}
a660d684 64
dface61c 65\func{}{\destruct{wxClipboard}}{\void}
a660d684 66
dface61c 67Destructor.
a660d684 68
9005f2ed 69
40219523
JS
70\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
71
72\func{bool}{AddData}{\param{wxDataObject*}{ data}}
73
74Call this function to add the data object to the clipboard. You may call
75this function repeatedly after having cleared the clipboard using \helpref{wxClipboard::Clear}{wxclipboardclear}.
76
77After this function has been called, the clipboard owns the data, so do not delete
78the data explicitly.
79
80\wxheading{See also}
81
82\helpref{wxClipboard::SetData}{wxclipboardsetdata}
83
9005f2ed 84
dface61c 85\membersection{wxClipboard::Clear}\label{wxclipboardclear}
a660d684 86
dface61c 87\func{void}{Clear}{\void}
a660d684 88
dface61c 89Clears the global clipboard object and the system's clipboard if possible.
a660d684 90
9005f2ed 91
dface61c 92\membersection{wxClipboard::Close}\label{wxclipboardclose}
a660d684 93
2f930c85 94\func{void}{Close}{\void}
a660d684 95
75ce0581 96Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
a660d684 97
9005f2ed 98
741ed114
MB
99\membersection{wxClipboard::Flush}\label{wxclipboardflush}
100
101\func{bool}{Flush}{\void}
102
103Flushes the clipboard: this means that the data which is currently on
104clipboard will stay available even after the application exits (possibly
105eating memory), otherwise the clipboard will be emptied on exit.
dbd94b75 106Returns false if the operation is unsuccessful for any reason.
741ed114 107
9005f2ed 108
dface61c 109\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
a660d684 110
fc9c7c09 111\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
a660d684 112
dface61c 113Call this function to fill {\it data} with data on the clipboard, if available in the required
cc81d32f 114format. Returns true on success.
a660d684 115
9005f2ed 116
40219523
JS
117\membersection{wxClipboard::IsOpened}\label{wxclipboardisopened}
118
119\constfunc{bool}{IsOpened}{\void}
120
cc81d32f 121Returns true if the clipboard has been opened.
40219523 122
9005f2ed 123
75ce0581 124\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
a660d684 125
fc9c7c09 126\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
a660d684 127
3980000c 128Returns 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 129
9005f2ed
VZ
130
131\membersection{wxClipboard::IsUsingPrimarySelection}\label{wxclipboardisusingprimaryselection}
132
133\constfunc{bool}{IsUsingPrimarySelection}{\void}
134
135Returns \true if we are using the primary selection, \false if clipboard one.
136See \helpref{UsePrimarySelection}{wxclipboarduseprimary} for more information.
137
138
dface61c 139\membersection{wxClipboard::Open}\label{wxclipboardopen}
a660d684 140
dface61c 141\func{bool}{Open}{\void}
a660d684 142
dface61c
JS
143Call this function to open the clipboard before calling \helpref{wxClipboard::SetData}{wxclipboardsetdata}
144and \helpref{wxClipboard::GetData}{wxclipboardgetdata}.
a660d684 145
dface61c
JS
146Call \helpref{wxClipboard::Close}{wxclipboardclose} when you have finished with the clipboard. You
147should keep the clipboard open for only a very short time.
a660d684 148
cc81d32f 149Returns true on success. This should be tested (as in the sample shown above).
75ce0581 150
9005f2ed 151
f9b1708c 152\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
a660d684 153
dface61c 154\func{bool}{SetData}{\param{wxDataObject*}{ data}}
a660d684 155
75ce0581
RR
156Call this function to set the data object to the clipboard. This function will
157clear all previous contents in the clipboard, so calling it several times
158does not make any sense.
a660d684 159
40219523
JS
160After this function has been called, the clipboard owns the data, so do not delete
161the data explicitly.
162
163\wxheading{See also}
164
165\helpref{wxClipboard::AddData}{wxclipboardadddata}
166
9005f2ed 167
7ff14117 168\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
b453e1b2 169
cc81d32f 170\func{void}{UsePrimarySelection}{\param{bool}{ primary = true}}
b453e1b2 171
9005f2ed
VZ
172On platforms supporting it (all X11-based ports), wxClipboard uses the
173CLIPBOARD X11 selection by default. When this function is called with \true
174argument, all subsequent clipboard operations will use PRIMARY selection until
175this function is called again with \false.
176
177On the other platforms, there is no PRIMARY selection and so all clipboard
178operations will fail. This allows to implement the standard X11 handling of the
179clipboard which consists in copying data to the CLIPBOARD selection only when
180the user explicitly requests it (i.e. by selection \texttt{"Copy"} menu
181command) but putting the currently selected text into the PRIMARY selection
182automatically, without overwriting the normal clipboard contents with the
183currently selected text on the other platforms.
b453e1b2 184