]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/clipbrd.h
wxUsleep() introduced (and documented) to try to work around usleep() bug in
[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 #include "wx/setup.h"
24
25 #include "wx/list.h"
26 #include "wx/module.h"
27
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);
38
39 //-----------------------------------------------------------------------------
40 // wxClipboard
41 //-----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxDataObject;
44 class WXDLLEXPORT wxClipboard: public wxObject
45 {
46 DECLARE_DYNAMIC_CLASS(wxClipboard)
47
48 public:
49
50 wxClipboard();
51 ~wxClipboard();
52
53 // open the clipboard before SetData() and GetData()
54 virtual bool Open();
55
56 // close the clipboard after SetData() and GetData()
57 virtual void Close();
58
59 // can be called several times
60 virtual bool SetData( wxDataObject *data );
61
62 // format available on the clipboard ?
63 // supply ID if private format, the same as wxPrivateDataObject::SetId()
64 virtual bool IsSupported( wxDataFormat format );
65
66 // fill data with data on the clipboard (if available)
67 virtual bool GetData( wxDataObject *data );
68
69 // clears wxTheClipboard and the system's clipboard if possible
70 virtual void Clear();
71
72 // implementation
73
74 bool m_open;
75 wxList m_data;
76 };
77
78 /* The clipboard */
79 WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
80
81 //-----------------------------------------------------------------------------
82 // wxClipboardModule
83 //-----------------------------------------------------------------------------
84
85 class wxClipboardModule: public wxModule
86 {
87 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
88
89 public:
90 wxClipboardModule() {}
91 bool OnInit();
92 void OnExit();
93 };
94
95 // This is the old, 1.68 implementation
96 #if 0
97
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
101 {
102 DECLARE_ABSTRACT_CLASS(wxClipboardClient)
103
104 public:
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;
110
111 /* This method is called when the client is losing the selection. */
112 virtual void BeingReplaced() = 0;
113
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
119 NULL terminator. */
120 virtual char *GetData(char *format, long *size) = 0;
121 };
122
123 /* ONE instance of this class: */
124 class WXDLLEXPORT wxClipboard : public wxObject
125 {
126 DECLARE_DYNAMIC_CLASS(wxClipboard)
127
128 public:
129 wxClipboardClient *clipOwner;
130 char *cbString, *sentString, *receivedString;
131 void *receivedTargets;
132 long receivedLength;
133
134 wxClipboard();
135 ~wxClipboard();
136
137 /* Set the clipboard data owner. "time" comes from the event record. */
138 void SetClipboardClient(wxClipboardClient *, long time);
139
140 /* Set the clipboard string; does not require a client. */
141 void SetClipboardString(char *, long time);
142
143 /* Get data from the clipboard in the format "TEXT". */
144 char *GetClipboardString(long time);
145
146 /* Get data from the clipboard */
147 char *GetClipboardData(char *format, long *length, long time);
148
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();
155 };
156
157 /* Initialize wxTheClipboard. Can be called repeatedly */
158 void WXDLLEXPORT wxInitClipboard();
159
160 /* The clipboard */
161 WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
162
163 #endif
164 // Old clipboard class
165
166 #endif
167 // _WX_CLIPBRD_H_