00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 00025 00026 #ifndef _SO_WIN_CLIPBOARD_ 00027 #define _SO_WIN_CLIPBOARD_ 00028 00029 #include <Inventor/sys/port.h> 00030 00031 #include <Inventor/Win/SoWin.h> 00032 00033 #include <Inventor/Win/SoWinBeginStrict.h> 00034 00035 00036 class SbDict; 00037 class SoByteStream; 00038 class SoNode; 00039 class SoPath; 00040 class SoPathList; 00041 class SoSelection; 00042 00043 00044 // callback function prototypes 00048 typedef void SoWinClipboardPasteCB(void *userData, SoPathList *pathList); 00049 00050 00051 // The CLIPBOARD selection atom is not a predefined atom in X11 R4. 00052 // However, it is widely recognized. We define it to 0 here for 00053 // convenience. Internally, when SoWinClipboard sees _XA_CLIPBOARD_, 00054 // it will use XInternAtom(d, "CLIPBOARD", False). 00055 00056 #define _XA_CLIPBOARD_ ((Atom) 0) 00057 00058 #define XA_STRING ((Atom) 1) 00059 00060 00062 // 00063 // Class: SoWinClipboard 00064 // 00065 // 00067 00088 class SoWinClipboard { 00089 public: 00090 // Constructor. 00091 // The selection atom determines which X selection atom data transfers 00092 // should happen through. Default is _XA_CLIPBOARD_. (wsh uses XA_PRIMARY). 00093 00100 SoWinClipboard(SoWidget w, Atom selectionAtom = _XA_CLIPBOARD_); 00101 00105 ~SoWinClipboard(); 00106 00107 // 00108 // These methods transfer inventor scene graphs as the data. 00109 // 00110 // Data types supported for export (so another process can paste): 00111 // INVENTOR, XA_STRING 00112 // (and someday: POSTSCRIPT, IMAGE) 00113 // 00114 // Data types supported for import (so this process can paste): 00115 // INVENTOR, XA_STRING (pasted as an SoText2 node) 00116 // 00117 00118 // Copy - these routines copy the passed data into a byte stream, 00119 // and make the data available to any X client which requests it. 00120 // The eventTime should be the time stamp from the event which 00121 // triggered the copy request. 00122 00157 void copy(SoNode *node, Time eventTime); 00158 00163 void copy(SoPath *path, Time eventTime); 00164 00169 void copy(SoPathList *pathList, Time eventTime); 00170 00171 // Paste - make a request to the X server so we can import data for paste. 00172 // A paste is asynchronous - when this routine is called, it simply 00173 // makes a request to the X server for data to paste, then returns. 00174 // Once the data is delivered, the pasteDoneFunc will be called and passed 00175 // the user data along with a list of paths that were pasted. The app 00176 // should delete this path list when it is done with it. 00177 // The eventTime should be the time stamp from the event which 00178 // triggered the paste request. 00179 00187 void paste(Time eventTime, 00188 SoWinClipboardPasteCB *pasteDoneFunc, 00189 void *userData = NULL); 00190 00191 private: 00192 static void exitClass(); 00193 00194 private: 00195 SoWidget widget; // the widget to associated data with 00196 Atom selAtom; // which selection: XA_PRIMARY, XA_SECONDARY, etc. 00197 Time eventTime; // time of the event which caused the copy/paste 00198 00199 // Paste callback info 00200 SoWinClipboardPasteCB *callbackFunc; 00201 void *userData; 00202 00203 // Atoms supported for copy and paste targets: 00204 static Atom TARGETSatom; // XInternAtom(d, "TARGETS", False); 00205 static Atom INVENTORatom; // XInternAtom(d, "INVENTOR", False); 00206 // XA_STRING 00207 00208 static Atom *supportedTargets; 00209 00210 // There can only be one owner of each X selection at any one time. 00211 // We use the selection atom as the key, and 'this' as the data. 00212 // We set the owner for each selection in this list for exportSelection. 00213 static SbDict *selOwnerList; 00214 00215 // Return the clipboard data in binary or ascii form. 00216 SoByteStream *getBinaryBuffer(); 00217 SoByteStream *getAsciiBuffer(); 00218 00219 // All the overloaded copy functions call this one. 00220 void copy(SoByteStream *byteStream, Time t); 00221 00222 private: 00223 SoByteStream *binaryBuffer; // copy/paste storage buffer 00224 SoByteStream *asciiBuffer; // ascii version of storage buffer 00225 00226 // Copy and paste callback functions - these are called by the X server. 00227 // importSelection is called when we import data to paste. 00228 // exportSelection is called when we send data for someone else to paste. 00229 // loseSelection is called when we no longer own the selection. 00230 static void importSelection( 00231 SoWidget w, 00232 SoWinClipboard *clipboard, 00233 Atom *selAtom, 00234 Atom *type, 00235 char *value, 00236 size_t *length, 00237 int *format); 00238 00239 static Boolean exportSelection( 00240 SoWidget w, 00241 Atom *xselection, 00242 Atom *target, 00243 Atom *type, 00244 char **value, 00245 size_t *length, 00246 int *format); 00247 00248 static void loseSelection( 00249 SoWidget w, 00250 Atom *xselection); 00251 00252 static void importSelectionTargets( 00253 SoWidget w, 00254 SoWinClipboard *clipboard, 00255 Atom *selAtom, 00256 Atom *type, 00257 char *value, 00258 unsigned long *length, 00259 int *format); 00260 00261 }; 00262 00263 #include <Inventor/Win/SoWinEndStrict.h> 00264 00265 #endif /* _SO_WIN_CLIPBOARD_ */ 00266 00267