]>
git.saurik.com Git - wxWidgets.git/blob - interface/clipbrd.h
5ba025568d7585fde2d85e947250a0577940ffea
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxClipboard class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A class for manipulating the clipboard. Note that this is not compatible with
15 clipboard class from wxWidgets 1.xx, which has the same name but a different
18 To use the clipboard, you call member functions of the global @b wxTheClipboard
21 See also the @ref overview_wxdataobjectoverview for further information.
23 Call wxClipboard::Open to get ownership of the clipboard. If this operation
25 now own the clipboard. Call wxClipboard::SetData to put data
26 on the clipboard, or wxClipboard::GetData to
27 retrieve data from the clipboard. Call wxClipboard::Close to close
28 the clipboard and relinquish ownership. You should keep the clipboard open only
34 // Write some text to the clipboard
35 if (wxTheClipboard-Open())
37 // This data objects are held by the clipboard,
38 // so do not delete them in the app.
39 wxTheClipboard-SetData( new wxTextDataObject("Some text") );
40 wxTheClipboard-Close();
44 if (wxTheClipboard-Open())
46 if (wxTheClipboard-IsSupported( wxDF_TEXT ))
48 wxTextDataObject data;
49 wxTheClipboard-GetData( data );
50 wxMessageBox( data.GetText() );
52 wxTheClipboard-Close();
60 @ref overview_wxdndoverview, wxDataObject
62 class wxClipboard
: public wxObject
76 Call this function to add the data object to the clipboard. You may call
77 this function repeatedly after having cleared the clipboard using Clear().
78 After this function has been called, the clipboard owns the data, so do not
84 bool AddData(wxDataObject
* data
);
87 Clears the global clipboard object and the system's clipboard if possible.
92 Call this function to close the clipboard, having opened it with Open().
97 Flushes the clipboard: this means that the data which is currently on
98 clipboard will stay available even after the application exits (possibly
99 eating memory), otherwise the clipboard will be emptied on exit.
100 Returns @false if the operation is unsuccessful for any reason.
105 Call this function to fill @a data with data on the clipboard, if available in
107 format. Returns @true on success.
109 bool GetData(wxDataObject
& data
);
112 Returns @true if the clipboard has been opened.
117 Returns @true if there is data which matches the data format of the given data
118 object currently @b available (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard.
120 bool IsSupported(const wxDataFormat
& format
);
123 Returns @true if we are using the primary selection, @false if clipboard
125 See @ref useprimary() UsePrimarySelection for more information.
127 bool IsUsingPrimarySelection();
130 Call this function to open the clipboard before calling SetData()
132 Call Close() when you have finished with the clipboard. You
133 should keep the clipboard open for only a very short time.
134 Returns @true on success. This should be tested (as in the sample shown above).
139 Call this function to set the data object to the clipboard. This function will
140 clear all previous contents in the clipboard, so calling it several times
141 does not make any sense.
142 After this function has been called, the clipboard owns the data, so do not
148 bool SetData(wxDataObject
* data
);
151 On platforms supporting it (all X11-based ports), wxClipboard uses the
152 CLIPBOARD X11 selection by default. When this function is called with @true
153 argument, all subsequent clipboard operations will use PRIMARY selection until
154 this function is called again with @false.
155 On the other platforms, there is no PRIMARY selection and so all clipboard
156 operations will fail. This allows to implement the standard X11 handling of the
157 clipboard which consists in copying data to the CLIPBOARD selection only when
158 the user explicitly requests it (i.e. by selection @c "Copy" menu
159 command) but putting the currently selected text into the PRIMARY selection
160 automatically, without overwriting the normal clipboard contents with the
161 currently selected text on the other platforms.
163 void UsePrimarySelection(bool primary
= true);