1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Clipboard functionality.
4 // Note: this functionality is under review, and
5 // is derived from wxWindows 1.xx code. Please contact
6 // the wxWindows developers for further information.
7 // Author: Julian Smart
11 // Copyright: (c) Julian Smart
12 // Licence: wxWindows licence
13 /////////////////////////////////////////////////////////////////////////////
15 #ifndef _WX_CLIPBRD_H_
16 #define _WX_CLIPBRD_H_
19 #pragma interface "clipbrd.h"
26 #include "wx/module.h"
28 bool WXDLLEXPORT
wxOpenClipboard();
29 bool WXDLLEXPORT
wxClipboardOpen();
30 bool WXDLLEXPORT
wxCloseClipboard();
31 bool WXDLLEXPORT
wxEmptyClipboard();
32 bool WXDLLEXPORT
wxIsClipboardFormatAvailable(wxDataFormat dataFormat
);
33 bool WXDLLEXPORT
wxSetClipboardData(wxDataFormat dataFormat
, wxObject
*obj
, int width
= 0, int height
= 0);
34 wxObject
* WXDLLEXPORT
wxGetClipboardData(wxDataFormat dataFormat
, long *len
= NULL
);
35 wxDataFormat WXDLLEXPORT
wxEnumClipboardFormats(wxDataFormat dataFormat
);
36 wxDataFormat WXDLLEXPORT
wxRegisterClipboardFormat(char *formatName
);
37 bool WXDLLEXPORT
wxGetClipboardFormatName(wxDataFormat dataFormat
, char *formatName
, int maxCount
);
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 class WXDLLEXPORT wxDataObject
;
44 class WXDLLEXPORT wxClipboard
: public wxObject
46 DECLARE_DYNAMIC_CLASS(wxClipboard
)
53 // open the clipboard before SetData() and GetData()
56 // close the clipboard after SetData() and GetData()
59 // can be called several times
60 virtual bool SetData( wxDataObject
*data
);
62 // format available on the clipboard ?
63 // supply ID if private format, the same as wxPrivateDataObject::SetId()
64 virtual bool IsSupportedFormat( wxDataFormat format
, const wxString
&id
= wxEmptyString
);
66 // fill data with data on the clipboard (if available)
67 virtual bool GetData( wxDataObject
*data
);
69 // clears wxTheClipboard and the system's clipboard if possible
79 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
81 //-----------------------------------------------------------------------------
83 //-----------------------------------------------------------------------------
85 class wxClipboardModule
: public wxModule
87 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
90 wxClipboardModule() {}
95 // This is the old, 1.68 implementation
98 /* A clipboard client holds data belonging to the clipboard.
99 For plain text, a client is not necessary. */
100 class WXDLLEXPORT wxClipboardClient
: public wxObject
102 DECLARE_ABSTRACT_CLASS(wxClipboardClient
)
105 /* This list should be filled in with strings indicating the formats
106 this client can provide. Almost all clients will provide "TEXT".
107 Format names should be 4 characters long, so things will work
108 out on the Macintosh */
109 wxStringList formats
;
111 /* This method is called when the client is losing the selection. */
112 virtual void BeingReplaced() = 0;
114 /* This method is called when someone wants the data this client is
115 supplying to the clipboard. "format" is a string indicating the
116 format of the data - one of the strings from the "formats"
117 list. "*size" should be filled with the size of the resulting
118 data. In the case of text, "*size" does not count the
120 virtual char *GetData(char *format
, long *size
) = 0;
123 /* ONE instance of this class: */
124 class WXDLLEXPORT wxClipboard
: public wxObject
126 DECLARE_DYNAMIC_CLASS(wxClipboard
)
129 wxClipboardClient
*clipOwner
;
130 char *cbString
, *sentString
, *receivedString
;
131 void *receivedTargets
;
137 /* Set the clipboard data owner. "time" comes from the event record. */
138 void SetClipboardClient(wxClipboardClient
*, long time
);
140 /* Set the clipboard string; does not require a client. */
141 void SetClipboardString(char *, long time
);
143 /* Get data from the clipboard in the format "TEXT". */
144 char *GetClipboardString(long time
);
146 /* Get data from the clipboard */
147 char *GetClipboardData(char *format
, long *length
, long time
);
149 /* Get the clipboard client directly. Will be NULL if clipboard data
150 is a string, or if some other application owns the clipboard.
151 This can be useful for shortcutting data translation, if the
152 clipboard user can check for a specific client. (This is used
153 by the wxMediaEdit class.) */
154 wxClipboardClient
*GetClipboardClient();
157 /* Initialize wxTheClipboard. Can be called repeatedly */
158 void WXDLLEXPORT
wxInitClipboard();
161 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
164 // Old clipboard class