home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkDataTransfer.h.z / VkDataTransfer.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  6.4 KB  |  196 lines

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // VkDataTransfer.h
  4. //
  5. // Copyright 1995, Silicon Graphics, Inc.
  6. // ALL RIGHTS RESERVED
  7. //
  8. // UNPUBLISHED -- Rights reserved under the copyright laws of the United
  9. // States.   Use of a copyright notice is precautionary only and does not
  10. // imply publication or disclosure.
  11. //
  12. // U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  13. // Use, duplication or disclosure by the Government is subject to restrictions
  14. // as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  15. // in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  16. // in similar or successor clauses in the FAR, or the DOD or NASA FAR
  17. // Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  18. // 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  19. //
  20. // THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  21. // INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  22. // DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  23. // PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  24. // GRAPHICS, INC.
  25. //
  26. ////////////////////////////////////////////////////////////////////////
  27.  
  28. #ifndef VK_DATA_TRANSFER_H_
  29. #define VK_DATA_TRANSFER_H_
  30.  
  31. #include <Vk/VkCutPaste.h>
  32.  
  33. class VkNameList;
  34.  
  35.  
  36. class VkDataTransfer : public VkCutPaste
  37. {
  38.   public:
  39.     
  40.     VkDataTransfer();
  41.     ~VkDataTransfer();
  42.     
  43.     static const char* const dropCallback;
  44.     static const char* const dragCallback;
  45.     static const char* const loseSelectionCallback;
  46.     static const char* const importCallback;
  47.     
  48.     Boolean exportClipboard(Time time = CurrentTime) {return export(clipboardAtom(), time); }
  49.     Boolean exportPrimary(Time time = CurrentTime) {return export(primaryAtom(), time); }
  50.  
  51.     void clearClipboard(Time time = CurrentTime) {clear(clipboardAtom(), time); }
  52.     void clearPrimary(Time time = CurrentTime) {clear(primaryAtom(), time); }
  53.  
  54.     Boolean remove(Atom selection, Atom target);
  55.     Boolean remove(Atom selection, const char *target);
  56.     
  57.     Boolean removeClipboard(const char *target) { return remove(clipboardAtom(), target); }
  58.     Boolean removePrimary(const char *target) { return remove(primaryAtom(), target); }
  59.  
  60.     //////////////////////////////////////////////////////////////////////
  61.     //////////////// Simple Cut/Paste Import API /////////////////////////
  62.     //////////////////////////////////////////////////////////////////////
  63.  
  64.     virtual XtPointer importImmediate(Atom selection, Atom *interestList, 
  65.                       int interestListLen, Atom *targetRet,
  66.                       unsigned long *numBytesRet, 
  67.                       Time theTime = CurrentTime);
  68.     
  69.     XtPointer importImmediate(Atom selection, 
  70.                   Atom *interestList, 
  71.                   int interestListLen,
  72.                   Time theTime = CurrentTime);
  73.     
  74.     XtPointer importImmediate(Atom selection, 
  75.                   const char *interestList, 
  76.                   Time theTime = CurrentTime);
  77.     
  78.     ////////
  79.     //
  80.     // import():
  81.     //
  82.     //   This call is exactly like "importImmediate()" above, but it uses a
  83.     //   callback to alert the program when the data has arrived.  This is 
  84.     //   useful if the client has a custom event loop and needs to do other 
  85.     //   tasks while waiting for the data to arrive.
  86.     //
  87.     ////////
  88.  
  89.  
  90.     virtual void import(Atom selection, Atom *interestList, int interestListLen,
  91.             ImportCallbackProc proc, void *clientData = NULL, 
  92.             Time theTime = CurrentTime);
  93.     
  94.     void import(Atom selection, 
  95.         Atom *interestList, 
  96.         int interestListLen,
  97.         Time theTime = CurrentTime);
  98.  
  99.     void import(Atom selection, const char *interestList,
  100.          Time theTime = CurrentTime);    
  101.     
  102.     
  103.     // ////////////////////////////////////////////////////////////////////
  104.     // ////////////// Simple Drag/Drop API ////////////////////////////////
  105.     // ////////////////////////////////////////////////////////////////////
  106.  
  107.    virtual Boolean registerDropSite(Widget w, Atom *interestList, 
  108.                      int interestListLen,
  109.                      DropSiteCallbackProc proc,
  110.                      void *clientData = NULL);
  111.  
  112.     Boolean registerDropSite(Widget w, const char * interestList);
  113.  
  114.     Boolean registerDropSite(Widget w, 
  115.                  const char *targets,
  116.                  VkCallbackObject *user, 
  117.                  VkCallbackMethod callback, 
  118.                  void *clientData);
  119.  
  120.  
  121.     void registerDragSite(Widget w);
  122.     void registerDragSite(Widget w, 
  123.               VkCallbackObject *user, 
  124.               VkCallbackMethod callback, 
  125.               void *clientData);
  126.     
  127.     Boolean unregisterDropSite(Widget);
  128.     void unregisterDragSite(Widget);
  129.  
  130.     // Methods for accessing imported or dropped data
  131.  
  132.     Boolean isTargetType(const char*); // Type of available data 
  133.     Atom  getTargetType();
  134.  
  135.     void *getData();                     // data dropped or pasted
  136.     int   getSize();                     // size of data dropped or pasted
  137.  
  138.     const char *getFile(int index = 0);  // If data is a file
  139.     int getNumFiles();                   // How many files
  140.  
  141.     void clearData();                 // clear dropped or pasted data
  142.  
  143.     Boolean getStatus();   // Whether import or drag succeeded
  144.  
  145.     void setData(const char *target, void *data, unsigned long numBytes);
  146.     void setData(void *data);
  147.     void setSize(unsigned long numBytes);
  148.     void setTarget(const char *target);
  149.  
  150.   private:
  151.  
  152.     Atom *strToAtomList(const char *, int&);
  153.     VkNameList    *_filelist;
  154.     void          *_data;
  155.     unsigned long  _size;
  156.     Atom           _targetType;
  157.     char *         _outgoingTarget;
  158.     Boolean        _status;
  159.  
  160.     static _VkCutPasteMgr *_theCutPasteMgr;
  161.     static int _refs;
  162.  
  163.     static void dropSiteCallback(Widget w, Atom target,
  164.                  XtPointer data, 
  165.                  unsigned long numBytes, 
  166.                  int x, int y, void *clientData);
  167.  
  168.     static void importCB(Widget w, Atom target, 
  169.                    XtPointer data, 
  170.                    unsigned long numBytes, 
  171.                    void *clientData);
  172.  
  173.     static void buttonPressCallback(Widget w, 
  174.                     XtPointer clientData, 
  175.                     XEvent *xev, 
  176.                     Boolean *);
  177.  
  178.     static void dragFinishCallback(Widget w, 
  179.                    Boolean result,
  180.                    XtPointer clientData);
  181.     
  182. };
  183.  
  184.  
  185. #define VkRegisterDragSite(w, dt, user, callback, client) \
  186.                             ((dt)->registerDragSite(w, user, (VkCallbackMethod) callback, client))
  187.  
  188. #define VkRegisterDropSite(w, targets, dt, user, callback, client)\
  189.                             ((dt)->registerDropSite(w, targets, user, (VkCallbackMethod) callback, client))
  190.  
  191.  
  192. extern VkDataTransfer *getTheDataTransferMgr();
  193. #define theDataTransferMgr  getTheDataTransferMgr()
  194.  
  195. #endif // VK_DATA_TRANSFER_H_
  196.