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/dataobj.h"
28 #include "wx/module.h"
30 bool WXDLLEXPORT
wxOpenClipboard();
31 bool WXDLLEXPORT
wxClipboardOpen();
32 bool WXDLLEXPORT
wxCloseClipboard();
33 bool WXDLLEXPORT
wxEmptyClipboard();
34 bool WXDLLEXPORT
wxIsClipboardFormatAvailable(wxDataFormat dataFormat
);
35 bool WXDLLEXPORT
wxSetClipboardData(wxDataFormat dataFormat
, wxObject
*obj
, int width
= 0, int height
= 0);
36 wxObject
* WXDLLEXPORT
wxGetClipboardData(wxDataFormat dataFormat
, long *len
= NULL
);
37 wxDataFormat WXDLLEXPORT
wxEnumClipboardFormats(wxDataFormat dataFormat
);
38 wxDataFormat WXDLLEXPORT
wxRegisterClipboardFormat(char *formatName
);
39 bool WXDLLEXPORT
wxGetClipboardFormatName(wxDataFormat dataFormat
, char *formatName
, int maxCount
);
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 class WXDLLEXPORT wxDataObject
;
46 class WXDLLEXPORT wxClipboard
: public wxObject
48 DECLARE_DYNAMIC_CLASS(wxClipboard
)
55 // open the clipboard before SetData() and GetData()
58 // close the clipboard after SetData() and GetData()
61 // can be called several times
62 virtual bool SetData( wxDataObject
*data
);
64 // format available on the clipboard ?
65 // supply ID if private format, the same as wxPrivateDataObject::SetId()
66 virtual bool IsSupported( wxDataFormat format
);
68 // fill data with data on the clipboard (if available)
69 virtual bool GetData( wxDataObject
*data
);
71 // clears wxTheClipboard and the system's clipboard if possible
74 /// If primary == TRUE, use primary selection in all further ops,
75 /// primary=FALSE resets it.
76 inline void UsePrimarySelection(bool primary
= TRUE
) { m_usePrimary
= primary
; }
86 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
88 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
92 class wxClipboardModule
: public wxModule
94 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
97 wxClipboardModule() {}
102 // This is the old, 1.68 implementation
105 /* A clipboard client holds data belonging to the clipboard.
106 For plain text, a client is not necessary. */
107 class WXDLLEXPORT wxClipboardClient
: public wxObject
109 DECLARE_ABSTRACT_CLASS(wxClipboardClient
)
112 /* This list should be filled in with strings indicating the formats
113 this client can provide. Almost all clients will provide "TEXT".
114 Format names should be 4 characters long, so things will work
115 out on the Macintosh */
116 wxStringList formats
;
118 /* This method is called when the client is losing the selection. */
119 virtual void BeingReplaced() = 0;
121 /* This method is called when someone wants the data this client is
122 supplying to the clipboard. "format" is a string indicating the
123 format of the data - one of the strings from the "formats"
124 list. "*size" should be filled with the size of the resulting
125 data. In the case of text, "*size" does not count the
127 virtual char *GetData(char *format
, long *size
) = 0;
130 /* ONE instance of this class: */
131 class WXDLLEXPORT wxClipboard
: public wxObject
133 DECLARE_DYNAMIC_CLASS(wxClipboard
)
136 wxClipboardClient
*clipOwner
;
137 char *cbString
, *sentString
, *receivedString
;
138 void *receivedTargets
;
144 /* Set the clipboard data owner. "time" comes from the event record. */
145 void SetClipboardClient(wxClipboardClient
*, long time
);
147 /* Set the clipboard string; does not require a client. */
148 void SetClipboardString(char *, long time
);
150 /* Get data from the clipboard in the format "TEXT". */
151 char *GetClipboardString(long time
);
153 /* Get data from the clipboard */
154 char *GetClipboardData(char *format
, long *length
, long time
);
156 /* Get the clipboard client directly. Will be NULL if clipboard data
157 is a string, or if some other application owns the clipboard.
158 This can be useful for shortcutting data translation, if the
159 clipboard user can check for a specific client. (This is used
160 by the wxMediaEdit class.) */
161 wxClipboardClient
*GetClipboardClient();
164 /* Initialize wxTheClipboard. Can be called repeatedly */
165 void WXDLLEXPORT
wxInitClipboard();
168 WXDLLEXPORT_DATA(extern wxClipboard
*) wxTheClipboard
;
171 // Old clipboard class
173 #endif // wxUSE_CLIPBOARD