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