home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / CALib & You… / Source / CALib / Implementation / ProxyPart / CAProxyPartDnD.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-07  |  7.9 KB  |  341 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CAProxyPartDnD.cpp
  3.  
  4.     Contains:    ODPart methods to support drag & drop
  5.  
  6.     Written by:    PartMaker 
  7.  
  8.     Change History (most recent first):
  9.  
  10.          <2>    11/18/95    RB        Major strip down, Removed many obsolete methods
  11.          <1>    6/15-6/30    RB        Major rewrite.  
  12.  
  13.         ------------------------------------------------------------------------------
  14.  
  15.         <16>     5/19/95    SJF        Fix bug that includes a NOPart on a native
  16.                                     content drag (not a final bug fix)
  17.         <15>     5/18/95    RB        Fixing a couple final geometry bugs
  18.         <14>     5/18/95    SJF        Fixes to local source drag handling
  19.         <10>     5/16/95    SJF        Change Drop to utilize new UTIL_Container... frame
  20.                                     negotiation callbacks
  21.          <8>     5/09/95    SJF        Drag hilite changes.
  22.          <6>     5/08/95    SJF        Cleanup Drag & Drop - What happend in revision 5????
  23.          <2>     4/30/95    SJF        Add changes from b1c19 TestDraw part...
  24.          <1>     3/15/95    SJF        first checked in
  25.          <0>      3/6/95    SJF        Moved methods from CAProxyPartStubs.cpp
  26.          
  27.     To Do:
  28. */
  29.  
  30.  
  31.  
  32. #ifndef _EXCEPT_
  33. #include <Except.h>
  34. #endif
  35.  
  36. #ifndef _CAPROXYPART_
  37. #include "CAProxyPart.h"
  38. #endif
  39.  
  40. #ifndef _CAPROXYPARTDEF_
  41. #include "CAProxyPartDef.h"
  42. #endif
  43.  
  44. #ifndef SOM_ODWindow_xh
  45. #include <Window.xh>
  46. #endif
  47.  
  48. #include <PlfmDef.h>
  49.  
  50. #ifndef __DRAG__
  51. #include <Drag.h>
  52. #endif
  53.  
  54. #ifndef SOM_ODDragAndDrop_xh
  55. #include <DragDrp.xh>
  56. #endif
  57.  
  58. #ifndef SOM_ODDragItemIterator_xh
  59. #include <DgItmIt.xh>
  60. #endif
  61.  
  62. #ifndef SOM_ODFrameFacetIterator_xh
  63. #include <FrFaItr.xh>
  64. #endif
  65.  
  66. #ifndef SOM_ODStorageUnit_xh
  67. #include <StorageU.xh>
  68. #endif
  69.  
  70. #ifndef _ORDCOLL_
  71. #include <OrdColl.h>
  72. #endif
  73.  
  74. #ifndef SOM_ODDraft_xh
  75. #include <Draft.xh>
  76. #endif
  77.  
  78. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  79. #include <StdTypes.xh>
  80. #endif
  81.  
  82. #ifndef SOM_Module_OpenDoc_StdProps_defined
  83. #include <StdProps.xh>
  84. #endif
  85.  
  86. #ifndef SOM_ODStorageUnitView_xh
  87. #include <SUView.xh>
  88. #endif
  89.  
  90. #ifndef SOM_ODFacet_xh
  91. #include <Facet.xh>
  92. #endif
  93.  
  94. #ifndef SOM_ODShape_xh
  95. #include <Shape.xh>
  96. #endif
  97.  
  98. #ifndef _STORUTIL_
  99. #include <StorUtil.h>
  100. #endif
  101.  
  102. #ifndef _ODUTILS_
  103. #include <ODUtils.h>
  104. #endif
  105.  
  106. #ifndef _ISOSTR_
  107. #include <ISOStr.h>
  108. #endif
  109.  
  110. #ifndef _BARRAY_
  111. #include <BArray.h>
  112. #endif
  113.  
  114. #ifndef _FOCUSLIB_
  115. #include <FocusLib.h>
  116. #endif 
  117.  
  118. #ifndef _ODUTILS_
  119. #include <ODUtils.h>
  120. #endif
  121.  
  122. #ifdef applec
  123. #pragma segment CAProxyPart
  124. #endif
  125.  
  126.  
  127. //====================================================================
  128. // CAProxyPart
  129. //
  130. // DragAndDrop protocol
  131. //====================================================================
  132.  
  133.  
  134. void CAProxyPart::DropCompleted(Environment* ev, ODPart* destPart, ODDropResult dropResult)
  135. {
  136. ODUnused(ev);
  137. ODUnused(destPart);
  138. ODUnused(dropResult);
  139. }
  140.  
  141.  
  142.  
  143. ODDragResult CAProxyPart::DragEnter(Environment* ev, ODDragItemIterator* dragInfo,
  144.                                                      ODFacet* facet, ODPoint* where)
  145. {
  146.     ODUnused (dragInfo);
  147.     ODUnused (where);
  148.  
  149.     ODStorageUnit*        dragSU = kODNULL;
  150.     ODDragResult        canHandleDrop = kODTrue;
  151.     ODWindow*            aWindow;
  152.     ODPlatformWindow     platformWindow;
  153.     DragReference        macDrag;
  154.     ODSession* session = fSelf->GetStorageUnit(ev)->GetSession(ev);
  155.  
  156.     // Check to see if the CA can handle the drop...
  157.     if (fCADnDTrackHnd)
  158.     {
  159.  
  160.         short    message;
  161.         
  162.         aWindow = facet->GetFrame(ev)->AcquireWindow(ev);
  163.         platformWindow = aWindow->GetPlatformWindow(ev);
  164.         aWindow->Release(ev);
  165.         
  166.         macDrag = session->GetDragAndDrop(ev)->GetDragReference(ev);
  167.  
  168.         message = dragTrackingEnterHandler;
  169.  
  170.         CallDragTrackingHandlerProc( fCADnDTrackHnd, message, platformWindow, fTrackRefCon, macDrag );
  171.         
  172.         message = dragTrackingEnterWindow;
  173.         
  174.         CallDragTrackingHandlerProc( fCADnDTrackHnd, message, platformWindow, fTrackRefCon, macDrag );
  175.     
  176.     }
  177.     
  178.     return canHandleDrop;
  179. }
  180.  
  181.  
  182.  
  183. ODDragResult CAProxyPart::DragWithin(Environment* ev, ODDragItemIterator* dragInfo,
  184.                                                       ODFacet* facet, ODPoint* where)
  185.  
  186. // Tracks the drag operation, and provides graphical feedback
  187. // regarding possible drop targets.
  188. //
  189. // This method highlights the appropriate content to provide
  190. // feedback about potential drop targets, based on type of dragged
  191. // data. It gets the type information out of the dragInfo. During
  192. // drag tracking (DragEnter, DragWithin) the part should never
  193. // attempt to read data from any of the storage units supplied by
  194. // the iterator. The part should only inspect the type of the
  195. // dragged data. Before calling tis method, you must ensure that
  196. // the part was previously activated via DragEnter().
  197. //
  198. // DragWithin() is called continuously when the mouse is still in
  199. // the facet. This allows the part to do any processing desired.
  200. // One good example is when the frame has several hot spots where
  201. // objects can be dropped. If the mouse is not over these hot spots,
  202. // the cursor may need to be changed to reflect that the no
  203. // dropping can be done there even though it is still in a
  204. // droppable frame. Again, a ODDragItemIterator is passed in so
  205. // that the part can examine the availabe data types of the dragged
  206. // objects.
  207. //
  208. // DragWithin() also provides a chance for the part to examine the
  209. // state of the machine. For example, some part may want to find
  210. // out whether the modifier keys are down or not.
  211.  
  212. {
  213.     ODUnused (dragInfo);
  214.     ODUnused (where);
  215.  
  216.     ODStorageUnit*        dragSU = kODNULL;
  217.     ODDragResult        canHandleDrop = kODTrue;
  218.     ODWindow*            aWindow;
  219.     ODPlatformWindow     platformWindow;
  220.     DragReference        macDrag;
  221.     ODSession* session = fSelf->GetStorageUnit(ev)->GetSession(ev);
  222.  
  223.     // Check to see if the CA needs notification
  224.     
  225.     if (fCADnDTrackHnd)
  226.     {
  227.         short    message;
  228.         
  229.         message = dragTrackingInWindow;
  230.         
  231.         aWindow = facet->GetFrame(ev)->AcquireWindow(ev);
  232.         platformWindow = aWindow->GetPlatformWindow(ev);
  233.         aWindow->Release(ev);
  234.         
  235.         macDrag = session->GetDragAndDrop(ev)->GetDragReference(ev);
  236.         CallDragTrackingHandlerProc( fCADnDTrackHnd, message, platformWindow, fTrackRefCon, macDrag );
  237.     }
  238.     
  239.     return canHandleDrop;
  240. }
  241.  
  242.  
  243.  
  244. void CAProxyPart::DragLeave(Environment* ev, ODFacet* facet, ODPoint* where)
  245. {
  246.     ODUnused (where);
  247.  
  248.     ODWindow*            aWindow;
  249.     ODPlatformWindow     platformWindow;
  250.     DragReference        macDrag;
  251.     ODSession* session = fSelf->GetStorageUnit(ev)->GetSession(ev);
  252.  
  253.     // Check to see if the CA needs notification
  254.     if (fCADnDTrackHnd)
  255.     {
  256.         short    message;
  257.         
  258.         message = dragTrackingLeaveWindow;
  259.         
  260.         aWindow = facet->GetFrame(ev)->AcquireWindow(ev);
  261.         platformWindow = aWindow->GetPlatformWindow(ev);
  262.         aWindow->Release(ev);
  263.         
  264.         macDrag = session->GetDragAndDrop(ev)->GetDragReference(ev);
  265.         CallDragTrackingHandlerProc( fCADnDTrackHnd, message, platformWindow, fTrackRefCon, macDrag );
  266.     }
  267.  
  268. }
  269.  
  270.  
  271. //-------------------------------------------------------------------------
  272. // CAProxyPart::Drop
  273. //-------------------------------------------------------------------------
  274.  
  275. ODDropResult CAProxyPart::Drop(Environment *ev,
  276.                                 ODDragItemIterator* dropInfo,
  277.                                 ODFacet* facet,
  278.                                 ODPoint* where)
  279. {
  280.     ODStorageUnit*        dragSU = kODNULL;
  281.     ODDragResult        canHandleDrop = kODTrue;
  282.     ODDropResult        dropResult = kODDropFail;
  283.     ODWindow*            aWindow;
  284.     ODPlatformWindow     platformWindow;
  285.     DragReference        macDrag;
  286.     OSErr                err;
  287.     ODULong                dragAttributes;
  288.     ODSession* session = fSelf->GetStorageUnit(ev)->GetSession(ev);
  289.  
  290.     dragAttributes = session->GetDragAndDrop(ev)->GetDragAttributes(ev);
  291.     
  292.     if (dragAttributes & kODDropIsMove)
  293.     {
  294.     
  295.         dropResult = kODDropMove;
  296.         
  297.         if (dragAttributes & kODDropIsInSourcePart)
  298.         {
  299.             dropResult = kODDropCopy;
  300.         }
  301.  
  302.     }
  303.     else if (dragAttributes & kODDropIsCopy)
  304.     {
  305.         dropResult = kODDropCopy;
  306.     }
  307.  
  308.     // Check to see if the CA needs notification
  309.     if (fCADnDReceiveHnd)
  310.     {
  311.         aWindow = facet->GetFrame(ev)->AcquireWindow(ev);
  312.         platformWindow = aWindow->GetPlatformWindow(ev);
  313.         aWindow->Release(ev);
  314.         
  315.         macDrag = session->GetDragAndDrop(ev)->GetDragReference(ev);
  316.         
  317.         err = (OSErr) CallDragReceiveHandlerProc(fCADnDReceiveHnd, platformWindow, fReceiveRefCon, macDrag);
  318.         
  319.     }
  320.     
  321.     if (err != noErr)
  322.         dropResult = kODDropFail;
  323.         
  324.     return (dropResult);
  325.  
  326. }
  327.  
  328. //-------------------------------------------------------------------------
  329. // CAProxyPart::FulfillPromise
  330. //-------------------------------------------------------------------------
  331.  
  332. void CAProxyPart::FulfillPromise(Environment *ev,
  333.         ODStorageUnitView* promiseSUView)
  334. {
  335.     ODUnused (ev);
  336.     ODUnused (promiseSUView);    
  337. }
  338.  
  339.  
  340.  
  341.