Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinClipboard.h
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-2024 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
33#include <Inventor/Win/SoWinBeginStrict.h>
34
35
36class SbDict;
37class SoByteStream;
38class SoNode;
39class SoPath;
40class SoPathList;
41class SoSelection;
42
43
44// callback function prototypes
50typedef void SoWinClipboardPasteCB(void *userData, SoPathList *pathList);
51
52
53// The CLIPBOARD selection atom is not a predefined atom in X11 R4.
54// However, it is widely recognized. We define it to 0 here for
55// convenience. Internally, when SoWinClipboard sees _XA_CLIPBOARD_,
56// it will use XInternAtom(d, "CLIPBOARD", False).
57
58#define _XA_CLIPBOARD_ ((Atom) 0)
59
60#define XA_STRING ((Atom) 1)
61
62
64//
65// Class: SoWinClipboard
66//
67//
69
91 public:
92 // Constructor.
93 // The selection atom determines which X selection atom data transfers
94 // should happen through. Default is _XA_CLIPBOARD_. (wsh uses XA_PRIMARY).
95
102 SoWinClipboard(SoWidget w, Atom selectionAtom = _XA_CLIPBOARD_);
103
108
109 //
110 // These methods transfer inventor scene graphs as the data.
111 //
112 // Data types supported for export (so another process can paste):
113 // INVENTOR, XA_STRING
114 // (and someday: POSTSCRIPT, IMAGE)
115 //
116 // Data types supported for import (so this process can paste):
117 // INVENTOR, XA_STRING (pasted as an SoText2 node)
118 //
119
120 // Copy - these routines copy the passed data into a byte stream,
121 // and make the data available to any X client which requests it.
122 // The eventTime should be the time stamp from the event which
123 // triggered the copy request.
124
159 void copy(SoNode *node, Time eventTime);
160
165 void copy(SoPath *path, Time eventTime);
166
171 void copy(SoPathList *pathList, Time eventTime);
172
173 // Paste - make a request to the X server so we can import data for paste.
174 // A paste is asynchronous - when this routine is called, it simply
175 // makes a request to the X server for data to paste, then returns.
176 // Once the data is delivered, the pasteDoneFunc will be called and passed
177 // the user data along with a list of paths that were pasted. The app
178 // should delete this path list when it is done with it.
179 // The eventTime should be the time stamp from the event which
180 // triggered the paste request.
181
189 void paste(Time eventTime,
190 SoWinClipboardPasteCB *pasteDoneFunc,
191 void *userData = NULL);
192
193 private:
194 static void exitClass();
195
196 private:
197 SoWidget widget; // the widget to associated data with
198 Atom selAtom; // which selection: XA_PRIMARY, XA_SECONDARY, etc.
199 Time eventTime; // time of the event which caused the copy/paste
200
201 // Paste callback info
202 SoWinClipboardPasteCB *callbackFunc;
203 void *userData;
204
205 // Atoms supported for copy and paste targets:
206 static Atom TARGETSatom; // XInternAtom(d, "TARGETS", False);
207 static Atom INVENTORatom; // XInternAtom(d, "INVENTOR", False);
208 // XA_STRING
209
210 static Atom *supportedTargets;
211
212 // There can only be one owner of each X selection at any one time.
213 // We use the selection atom as the key, and 'this' as the data.
214 // We set the owner for each selection in this list for exportSelection.
215 static SbDict *selOwnerList;
216
217 // Return the clipboard data in binary or ascii form.
218 SoByteStream *getBinaryBuffer();
219 SoByteStream *getAsciiBuffer();
220
221 // All the overloaded copy functions call this one.
222 void copy(SoByteStream *byteStream, Time t);
223
224 private:
225 SoByteStream *binaryBuffer; // copy/paste storage buffer
226 SoByteStream *asciiBuffer; // ascii version of storage buffer
227
228 // Copy and paste callback functions - these are called by the X server.
229 // importSelection is called when we import data to paste.
230 // exportSelection is called when we send data for someone else to paste.
231 // loseSelection is called when we no longer own the selection.
232 static void importSelection(
233 SoWidget w,
234 SoWinClipboard *clipboard,
235 Atom *selAtom,
236 Atom *type,
237 char *value,
238 size_t *length,
239 int *format);
240
241 static Boolean exportSelection(
242 SoWidget w,
243 Atom *xselection,
244 Atom *target,
245 Atom *type,
246 char **value,
247 size_t *length,
248 int *format);
249
250 static void loseSelection(
251 SoWidget w,
252 Atom *xselection);
253
254 static void importSelectionTargets(
255 SoWidget w,
256 SoWinClipboard *clipboard,
257 Atom *selAtom,
258 Atom *type,
259 char *value,
260 unsigned long *length,
261 int *format);
262
263};
264
265#include <Inventor/Win/SoWinEndStrict.h>
266
267#endif /* _SO_WIN_CLIPBOARD_ */
268
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...
void SoWinClipboardPasteCB(void *userData, SoPathList *pathList)
char Boolean
Definition SoQtDef.h:124