]> git.saurik.com Git - wxWidgets.git/blame - interface/clipbrd.h
make it callable from any path
[wxWidgets.git] / interface / clipbrd.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: clipbrd.h
3// Purpose: documentation for wxClipboard class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxClipboard
11 @wxheader{clipbrd.h}
12
13 A class for manipulating the clipboard. Note that this is not compatible with
14 the
15 clipboard class from wxWidgets 1.xx, which has the same name but a different
16 implementation.
17
18 To use the clipboard, you call member functions of the global @b wxTheClipboard
19 object.
20
21 See also the @ref overview_wxdataobjectoverview "wxDataObject overview" for
22 further information.
23
24 Call wxClipboard::Open to get ownership of the clipboard. If this operation
25 returns @true, you
26 now own the clipboard. Call wxClipboard::SetData to put data
27 on the clipboard, or wxClipboard::GetData to
28 retrieve data from the clipboard. Call wxClipboard::Close to close
29 the clipboard and relinquish ownership. You should keep the clipboard open only
30 momentarily.
31
32 For example:
33
34 @code
35 // Write some text to the clipboard
36 if (wxTheClipboard-Open())
37 {
38 // This data objects are held by the clipboard,
39 // so do not delete them in the app.
40 wxTheClipboard-SetData( new wxTextDataObject("Some text") );
41 wxTheClipboard-Close();
42 }
43
44 // Read some text
45 if (wxTheClipboard-Open())
46 {
47 if (wxTheClipboard-IsSupported( wxDF_TEXT ))
48 {
49 wxTextDataObject data;
50 wxTheClipboard-GetData( data );
51 wxMessageBox( data.GetText() );
52 }
53 wxTheClipboard-Close();
54 }
55 @endcode
56
57 @library{wxcore}
58 @category{dnd}
59
60 @seealso
61 @ref overview_wxdndoverview "Drag and drop overview", wxDataObject
62*/
63class wxClipboard : public wxObject
64{
65public:
66 /**
67 Constructor.
68 */
69 wxClipboard();
70
71 /**
72 Destructor.
73 */
74 ~wxClipboard();
75
76 /**
77 Call this function to add the data object to the clipboard. You may call
78 this function repeatedly after having cleared the clipboard using Clear().
79
80 After this function has been called, the clipboard owns the data, so do not
81 delete
82 the data explicitly.
83
84 @sa SetData()
85 */
86 bool AddData(wxDataObject* data);
87
88 /**
89 Clears the global clipboard object and the system's clipboard if possible.
90 */
91 void Clear();
92
93 /**
94 Call this function to close the clipboard, having opened it with Open().
95 */
96 void Close();
97
98 /**
99 Flushes the clipboard: this means that the data which is currently on
100 clipboard will stay available even after the application exits (possibly
101 eating memory), otherwise the clipboard will be emptied on exit.
102 Returns @false if the operation is unsuccessful for any reason.
103 */
104 bool Flush();
105
106 /**
107 Call this function to fill @e data with data on the clipboard, if available in
108 the required
109 format. Returns @true on success.
110 */
111 bool GetData(wxDataObject& data);
112
113 /**
114 Returns @true if the clipboard has been opened.
115 */
116 bool IsOpened();
117
118 /**
119 Returns @true if there is data which matches the data format of the given data
120 object currently @b available (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard.
121 */
122 bool IsSupported(const wxDataFormat& format);
123
124 /**
125 Returns @true if we are using the primary selection, @false if clipboard
126 one.
127 See @ref useprimary() UsePrimarySelection for more information.
128 */
129 bool IsUsingPrimarySelection();
130
131 /**
132 Call this function to open the clipboard before calling SetData()
133 and GetData().
134
135 Call Close() when you have finished with the clipboard. You
136 should keep the clipboard open for only a very short time.
137
138 Returns @true on success. This should be tested (as in the sample shown above).
139 */
140 bool Open();
141
142 /**
143 Call this function to set the data object to the clipboard. This function will
144 clear all previous contents in the clipboard, so calling it several times
145 does not make any sense.
146
147 After this function has been called, the clipboard owns the data, so do not
148 delete
149 the data explicitly.
150
151 @sa AddData()
152 */
153 bool SetData(wxDataObject* data);
154
155 /**
156 On platforms supporting it (all X11-based ports), wxClipboard uses the
157 CLIPBOARD X11 selection by default. When this function is called with @true
158 argument, all subsequent clipboard operations will use PRIMARY selection until
159 this function is called again with @false.
160
161 On the other platforms, there is no PRIMARY selection and so all clipboard
162 operations will fail. This allows to implement the standard X11 handling of the
163 clipboard which consists in copying data to the CLIPBOARD selection only when
164 the user explicitly requests it (i.e. by selection @c "Copy" menu
165 command) but putting the currently selected text into the PRIMARY selection
166 automatically, without overwriting the normal clipboard contents with the
167 currently selected text on the other platforms.
168 */
169 void UsePrimarySelection(bool primary = @true);
170};