]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/clipbrd.h
converted to 16 colors
[wxWidgets.git] / include / wx / motif / clipbrd.h
CommitLineData
9b6dbb09
JS
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
dfe1eee3 12// Licence: wxWindows licence
9b6dbb09
JS
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"
dfe1eee3
VZ
23
24#if wxUSE_CLIPBOARD
9b6dbb09 25
da175b2c
RR
26#include "wx/dataobj.h"
27
2d120f83 28#include "wx/module.h"
9b6dbb09
JS
29
30bool WXDLLEXPORT wxOpenClipboard();
31bool WXDLLEXPORT wxClipboardOpen();
32bool WXDLLEXPORT wxCloseClipboard();
33bool WXDLLEXPORT wxEmptyClipboard();
2d120f83
JS
34bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
35bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
36wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
37wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat);
38wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
39bool WXDLLEXPORT wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount);
40
41//-----------------------------------------------------------------------------
42// wxClipboard
43//-----------------------------------------------------------------------------
44
45class WXDLLEXPORT wxDataObject;
46class WXDLLEXPORT wxClipboard: public wxObject
47{
48 DECLARE_DYNAMIC_CLASS(wxClipboard)
49
50public:
dfe1eee3 51
2d120f83
JS
52 wxClipboard();
53 ~wxClipboard();
54
55 // open the clipboard before SetData() and GetData()
56 virtual bool Open();
dfe1eee3 57
2d120f83
JS
58 // close the clipboard after SetData() and GetData()
59 virtual void Close();
dfe1eee3 60
2d120f83
JS
61 // can be called several times
62 virtual bool SetData( wxDataObject *data );
63
dfe1eee3
VZ
64 // format available on the clipboard ?
65 // supply ID if private format, the same as wxPrivateDataObject::SetId()
5b6aa0ff 66 virtual bool IsSupported( wxDataFormat format );
dfe1eee3 67
2d120f83
JS
68 // fill data with data on the clipboard (if available)
69 virtual bool GetData( wxDataObject *data );
dfe1eee3 70
2d120f83
JS
71 // clears wxTheClipboard and the system's clipboard if possible
72 virtual void Clear();
73
da175b2c
RR
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; }
dfe1eee3
VZ
77
78 // implementation
79
2d120f83
JS
80 bool m_open;
81 wxList m_data;
da175b2c 82 bool m_usePrimary;
2d120f83
JS
83};
84
85/* The clipboard */
86WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
87
88//-----------------------------------------------------------------------------
89// wxClipboardModule
90//-----------------------------------------------------------------------------
91
92class wxClipboardModule: public wxModule
93{
94 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
dfe1eee3 95
2d120f83
JS
96public:
97 wxClipboardModule() {}
98 bool OnInit();
99 void OnExit();
100};
101
102// This is the old, 1.68 implementation
103#if 0
9b6dbb09
JS
104
105/* A clipboard client holds data belonging to the clipboard.
106 For plain text, a client is not necessary. */
107class 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: */
131class 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
dfe1eee3 157 is a string, or if some other application owns the clipboard.
9b6dbb09
JS
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 */
165void WXDLLEXPORT wxInitClipboard();
166
167/* The clipboard */
168WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
169
2d120f83
JS
170#endif
171 // Old clipboard class
172
dfe1eee3
VZ
173#endif // wxUSE_CLIPBOARD
174
9b6dbb09
JS
175#endif
176 // _WX_CLIPBRD_H_