Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoWinClipboard.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25
26#ifndef _SO_WIN_CLIPBOARD_
27#define _SO_WIN_CLIPBOARD_
28
29#include <Inventor/sys/port.h>
30
31#include <Inventor/Win/SoWin.h>
32
34
35
36class SbDict;
37class SoByteStream;
38class SoNode;
39class SoPath;
40class SoPathList;
41class SoSelection;
42
43
44// callback function prototypes
48typedef void SoWinClipboardPasteCB(void *userData, SoPathList *pathList);
49
50
51// The CLIPBOARD selection atom is not a predefined atom in X11 R4.
52// However, it is widely recognized. We define it to 0 here for
53// convenience. Internally, when SoWinClipboard sees _XA_CLIPBOARD_,
54// it will use XInternAtom(d, "CLIPBOARD", False).
55
56#define _XA_CLIPBOARD_ ((Atom) 0)
57
58#define XA_STRING ((Atom) 1)
59
60
62//
63// Class: SoWinClipboard
64//
65//
67
89 public:
90 // Constructor.
91 // The selection atom determines which X selection atom data transfers
92 // should happen through. Default is _XA_CLIPBOARD_. (wsh uses XA_PRIMARY).
93
101
106
107 //
108 // These methods transfer inventor scene graphs as the data.
109 //
110 // Data types supported for export (so another process can paste):
111 // INVENTOR, XA_STRING
112 // (and someday: POSTSCRIPT, IMAGE)
113 //
114 // Data types supported for import (so this process can paste):
115 // INVENTOR, XA_STRING (pasted as an SoText2 node)
116 //
117
118 // Copy - these routines copy the passed data into a byte stream,
119 // and make the data available to any X client which requests it.
120 // The eventTime should be the time stamp from the event which
121 // triggered the copy request.
122
157 void copy(SoNode *node, Time eventTime);
158
163 void copy(SoPath *path, Time eventTime);
164
169 void copy(SoPathList *pathList, Time eventTime);
170
171 // Paste - make a request to the X server so we can import data for paste.
172 // A paste is asynchronous - when this routine is called, it simply
173 // makes a request to the X server for data to paste, then returns.
174 // Once the data is delivered, the pasteDoneFunc will be called and passed
175 // the user data along with a list of paths that were pasted. The app
176 // should delete this path list when it is done with it.
177 // The eventTime should be the time stamp from the event which
178 // triggered the paste request.
179
187 void paste(Time eventTime,
188 SoWinClipboardPasteCB *pasteDoneFunc,
189 void *userData = NULL);
190
191 private:
192 static void exitClass();
193
194 private:
195 SoWidget widget; // the widget to associated data with
196 Atom selAtom; // which selection: XA_PRIMARY, XA_SECONDARY, etc.
197 Time eventTime; // time of the event which caused the copy/paste
198
199 // Paste callback info
200 SoWinClipboardPasteCB *callbackFunc;
201 void *userData;
202
203 // Atoms supported for copy and paste targets:
204 static Atom TARGETSatom; // XInternAtom(d, "TARGETS", False);
205 static Atom INVENTORatom; // XInternAtom(d, "INVENTOR", False);
206 // XA_STRING
207
208 static Atom *supportedTargets;
209
210 // There can only be one owner of each X selection at any one time.
211 // We use the selection atom as the key, and 'this' as the data.
212 // We set the owner for each selection in this list for exportSelection.
213 static SbDict *selOwnerList;
214
215 // Return the clipboard data in binary or ascii form.
216 SoByteStream *getBinaryBuffer();
217 SoByteStream *getAsciiBuffer();
218
219 // All the overloaded copy functions call this one.
220 void copy(SoByteStream *byteStream, Time t);
221
222 private:
223 SoByteStream *binaryBuffer; // copy/paste storage buffer
224 SoByteStream *asciiBuffer; // ascii version of storage buffer
225
226 // Copy and paste callback functions - these are called by the X server.
227 // importSelection is called when we import data to paste.
228 // exportSelection is called when we send data for someone else to paste.
229 // loseSelection is called when we no longer own the selection.
230 static void importSelection(
231 SoWidget w,
232 SoWinClipboard *clipboard,
233 Atom *selAtom,
234 Atom *type,
235 char *value,
236 size_t *length,
237 int *format);
238
239 static Boolean exportSelection(
240 SoWidget w,
241 Atom *xselection,
242 Atom *target,
243 Atom *type,
244 char **value,
245 size_t *length,
246 int *format);
247
248 static void loseSelection(
249 SoWidget w,
250 Atom *xselection);
251
252 static void importSelectionTargets(
253 SoWidget w,
254 SoWinClipboard *clipboard,
255 Atom *selAtom,
256 Atom *type,
257 char *value,
258 unsigned long *length,
259 int *format);
260
261};
262
264
265#endif /* _SO_WIN_CLIPBOARD_ */
266
char Boolean
Definition SoQtDef.h:119
#define SoWidget
Definition SoQtDef.h:40
#define _XA_CLIPBOARD_
void SoWinClipboardPasteCB(void *userData, SoPathList *pathList)
#define Atom
Definition SoWinDef.h:92
#define Time
Definition SoWinDef.h:93
Converts scene graph objects to character byte streams.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Manages a list of selected objects.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Supports copy/pa...
~SoWinClipboard()
Destructor.
void paste(Time eventTime, SoWinClipboardPasteCB *pasteDoneFunc, void *userData=NULL)
This requests data from the clipboard in the current clipboard format.
void copy(SoPath *path, Time eventTime)
Copies the passed path to the clipboard using the current clipboard format.
SoWinClipboard(SoWidget w, Atom selectionAtom=_XA_CLIPBOARD_)
Constructor.
void copy(SoPathList *pathList, Time eventTime)
Copies the passed pathlist to the clipboard using the current clipboard format.
void copy(SoNode *node, Time eventTime)
Copies the passed scene graph object (node, path, or pathlist) to the clipboard using the current cli...