1 \section{\class{wxClipboard
}}\label{wxclipboard
}
3 A class for manipulating the clipboard. Note that this is not compatible with the
4 clipboard class from wxWidgets
1.xx, which has the same name but a different implementation.
6 To use the clipboard, you call member functions of the global
{\bf wxTheClipboard
} object.
8 See also the
\helpref{wxDataObject overview
}{wxdataobjectoverview
} for further information.
10 Call
\helpref{wxClipboard::Open
}{wxclipboardopen
} to get ownership of the clipboard. If this operation returns true, you
11 now own the clipboard. Call
\helpref{wxClipboard::SetData
}{wxclipboardsetdata
} to put data
12 on the clipboard, or
\helpref{wxClipboard::GetData
}{wxclipboardgetdata
} to
13 retrieve data from the clipboard. Call
\helpref{wxClipboard::Close
}{wxclipboardclose
} to close
14 the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
19 // Write some text to the clipboard
20 if (wxTheClipboard->Open())
22 // This data objects are held by the clipboard,
23 // so do not delete them in the app.
24 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
25 wxTheClipboard->Close();
29 if (wxTheClipboard->Open())
31 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
33 wxTextDataObject data;
34 wxTheClipboard->GetData( data );
35 wxMessageBox( data.GetText() );
37 wxTheClipboard->Close();
41 \wxheading{Derived from
}
43 \helpref{wxObject
}{wxobject
}
45 \wxheading{Include files
}
51 \helpref{wxCore
}{librarieslist
}
55 \helpref{Drag and drop overview
}{wxdndoverview
},
\helpref{wxDataObject
}{wxdataobject
}
57 \latexignore{\rtfignore{\wxheading{Members
}}}
60 \membersection{wxClipboard::wxClipboard
}\label{wxclipboardctor
}
62 \func{}{wxClipboard
}{\void}
67 \membersection{wxClipboard::
\destruct{wxClipboard
}}\label{wxclipboarddtor
}
69 \func{}{\destruct{wxClipboard
}}{\void}
74 \membersection{wxClipboard::AddData
}\label{wxclipboardadddata
}
76 \func{bool
}{AddData
}{\param{wxDataObject*
}{ data
}}
78 Call this function to add the data object to the clipboard. You may call
79 this function repeatedly after having cleared the clipboard using
\helpref{wxClipboard::Clear
}{wxclipboardclear
}.
81 After this function has been called, the clipboard owns the data, so do not delete
86 \helpref{wxClipboard::SetData
}{wxclipboardsetdata
}
89 \membersection{wxClipboard::Clear
}\label{wxclipboardclear
}
91 \func{void
}{Clear
}{\void}
93 Clears the global clipboard object and the system's clipboard if possible.
96 \membersection{wxClipboard::Close
}\label{wxclipboardclose
}
98 \func{void
}{Close
}{\void}
100 Call this function to close the clipboard, having opened it with
\helpref{wxClipboard::Open
}{wxclipboardopen
}.
103 \membersection{wxClipboard::Flush
}\label{wxclipboardflush
}
105 \func{bool
}{Flush
}{\void}
107 Flushes the clipboard: this means that the data which is currently on
108 clipboard will stay available even after the application exits (possibly
109 eating memory), otherwise the clipboard will be emptied on exit.
110 Returns false if the operation is unsuccessful for any reason.
113 \membersection{wxClipboard::GetData
}\label{wxclipboardgetdata
}
115 \func{bool
}{GetData
}{\param{wxDataObject\&
}{ data
}}
117 Call this function to fill
{\it data
} with data on the clipboard, if available in the required
118 format. Returns true on success.
121 \membersection{wxClipboard::IsOpened
}\label{wxclipboardisopened
}
123 \constfunc{bool
}{IsOpened
}{\void}
125 Returns true if the clipboard has been opened.
128 \membersection{wxClipboard::IsSupported
}\label{wxclipboardissupported
}
130 \func{bool
}{IsSupported
}{\param{const wxDataFormat\&
}{ format
}}
132 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.
135 \membersection{wxClipboard::IsUsingPrimarySelection
}\label{wxclipboardisusingprimaryselection
}
137 \constfunc{bool
}{IsUsingPrimarySelection
}{\void}
139 Returns
\true if we are using the primary selection,
\false if clipboard one.
140 See
\helpref{UsePrimarySelection
}{wxclipboarduseprimary
} for more information.
143 \membersection{wxClipboard::Open
}\label{wxclipboardopen
}
145 \func{bool
}{Open
}{\void}
147 Call this function to open the clipboard before calling
\helpref{wxClipboard::SetData
}{wxclipboardsetdata
}
148 and
\helpref{wxClipboard::GetData
}{wxclipboardgetdata
}.
150 Call
\helpref{wxClipboard::Close
}{wxclipboardclose
} when you have finished with the clipboard. You
151 should keep the clipboard open for only a very short time.
153 Returns true on success. This should be tested (as in the sample shown above).
156 \membersection{wxClipboard::SetData
}\label{wxclipboardsetdata
}
158 \func{bool
}{SetData
}{\param{wxDataObject*
}{ data
}}
160 Call this function to set the data object to the clipboard. This function will
161 clear all previous contents in the clipboard, so calling it several times
162 does not make any sense.
164 After this function has been called, the clipboard owns the data, so do not delete
169 \helpref{wxClipboard::AddData
}{wxclipboardadddata
}
172 \membersection{wxClipboard::UsePrimarySelection
}\label{wxclipboarduseprimary
}
174 \func{void
}{UsePrimarySelection
}{\param{bool
}{ primary = true
}}
176 On platforms supporting it (all X11-based ports), wxClipboard uses the
177 CLIPBOARD X11 selection by default. When this function is called with
\true
178 argument, all subsequent clipboard operations will use PRIMARY selection until
179 this function is called again with
\false.
181 On the other platforms, there is no PRIMARY selection and so all clipboard
182 operations will fail. This allows to implement the standard X11 handling of the
183 clipboard which consists in copying data to the CLIPBOARD selection only when
184 the user explicitly requests it (i.e. by selection
\texttt{"Copy"
} menu
185 command) but putting the currently selected text into the PRIMARY selection
186 automatically, without overwriting the normal clipboard contents with the
187 currently selected text on the other platforms.