]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/clipbrd.h
wxMemoryStream doc updated
[wxWidgets.git] / include / wx / motif / clipbrd.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: clipbrd.h
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
8 // Modified by:
9 // Created: 17/09/98
10 // RCS-ID: $Id$
11 // Copyright: (c) Julian Smart
12 // Licence: wxWindows licence
13 /////////////////////////////////////////////////////////////////////////////
14
15 #ifndef _WX_CLIPBRD_H_
16 #define _WX_CLIPBRD_H_
17
18 #ifdef __GNUG__
19 #pragma interface "clipbrd.h"
20 #endif
21
22 #include "wx/defs.h"
23
24 #if wxUSE_CLIPBOARD
25
26 #include "wx/dataobj.h"
27
28 #include "wx/module.h"
29
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);
40
41 //-----------------------------------------------------------------------------
42 // wxClipboard
43 //-----------------------------------------------------------------------------
44
45 class WXDLLEXPORT wxDataObject;
46 class WXDLLEXPORT wxClipboard: public wxObject
47 {
48 DECLARE_DYNAMIC_CLASS(wxClipboard)
49
50 public:
51
52 wxClipboard();
53 ~wxClipboard();
54
55 // open the clipboard before SetData() and GetData()
56 virtual bool Open();
57
58 // close the clipboard after SetData() and GetData()
59 virtual void Close();
60
61 // can be called several times
62 virtual bool SetData( wxDataObject *data );
63
64 // format available on the clipboard ?
65 // supply ID if private format, the same as wxPrivateDataObject::SetId()
66 virtual bool IsSupported( wxDataFormat format );
67
68 // fill data with data on the clipboard (if available)
69 virtual bool GetData( wxDataObject *data );
70
71 // clears wxTheClipboard and the system's clipboard if possible
72 virtual void Clear();
73
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; }
77
78 // implementation
79
80 bool m_open;
81 wxList m_data;
82 bool m_usePrimary;
83 };
84
85 /* The clipboard */
86 WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
87
88 //-----------------------------------------------------------------------------
89 // wxClipboardModule
90 //-----------------------------------------------------------------------------
91
92 class wxClipboardModule: public wxModule
93 {
94 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
95
96 public:
97 wxClipboardModule() {}
98 bool OnInit();
99 void OnExit();
100 };
101
102 // This is the old, 1.68 implementation
103 #if 0
104
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
108 {
109 DECLARE_ABSTRACT_CLASS(wxClipboardClient)
110
111 public:
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;
117
118 /* This method is called when the client is losing the selection. */
119 virtual void BeingReplaced() = 0;
120
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
126 NULL terminator. */
127 virtual char *GetData(char *format, long *size) = 0;
128 };
129
130 /* ONE instance of this class: */
131 class WXDLLEXPORT wxClipboard : public wxObject
132 {
133 DECLARE_DYNAMIC_CLASS(wxClipboard)
134
135 public:
136 wxClipboardClient *clipOwner;
137 char *cbString, *sentString, *receivedString;
138 void *receivedTargets;
139 long receivedLength;
140
141 wxClipboard();
142 ~wxClipboard();
143
144 /* Set the clipboard data owner. "time" comes from the event record. */
145 void SetClipboardClient(wxClipboardClient *, long time);
146
147 /* Set the clipboard string; does not require a client. */
148 void SetClipboardString(char *, long time);
149
150 /* Get data from the clipboard in the format "TEXT". */
151 char *GetClipboardString(long time);
152
153 /* Get data from the clipboard */
154 char *GetClipboardData(char *format, long *length, long time);
155
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();
162 };
163
164 /* Initialize wxTheClipboard. Can be called repeatedly */
165 void WXDLLEXPORT wxInitClipboard();
166
167 /* The clipboard */
168 WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
169
170 #endif
171 // Old clipboard class
172
173 #endif // wxUSE_CLIPBOARD
174
175 #endif
176 // _WX_CLIPBRD_H_