src/macosx/native/sun/awt/CDragSource.m

Print this page




  80 @interface CDragSource ()
  81 // Updates from the destination to the source
  82 - (void) postDragEnter;
  83 - (void) postDragExit;
  84 // Utility
  85 - (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
  86 @end
  87 
  88 @implementation CDragSource
  89 
  90 - (id)        init:(jobject)jDragSourceContextPeer
  91          component:(jobject)jComponent
  92            control:(id)control
  93       transferable:(jobject)jTransferable
  94       triggerEvent:(jobject)jTrigger
  95           dragPosX:(jint)dragPosX
  96           dragPosY:(jint)dragPosY
  97          modifiers:(jint)extModifiers
  98         clickCount:(jint)clickCount
  99          timeStamp:(jlong)timeStamp
 100          dragImage:(jobject)jDragImage
 101   dragImageOffsetX:(jint)jDragImageOffsetX
 102   dragImageOffsetY:(jint)jDragImageOffsetY
 103      sourceActions:(jint)jSourceActions
 104            formats:(jlongArray)jFormats
 105          formatMap:(jobject)jFormatMap
 106 {
 107     self = [super init];
 108     DLog2(@"[CDragSource init]: %@\n", self);
 109 
 110     fView = nil;
 111     fComponent = nil;
 112 
 113     // Construct the object if we have a valid model for it:
 114     if (control != nil) {
 115         JNIEnv *env = [ThreadUtilities getJNIEnv];
 116         fComponent = JNFNewGlobalRef(env, jComponent);
 117         fDragSourceContextPeer = JNFNewGlobalRef(env, jDragSourceContextPeer);
 118 
 119         fTransferable = JNFNewGlobalRef(env, jTransferable);
 120         fTriggerEvent = JNFNewGlobalRef(env, jTrigger);
 121 
 122         if (jDragImage) {
 123             JNF_MEMBER_CACHE(nsImagePtr, CImageClass, "ptr", "J");
 124             jlong imgPtr = JNFGetLongField(env, jDragImage, nsImagePtr);
 125             fDragImage = (NSImage*) jlong_to_ptr(imgPtr); // Double-casting prevents compiler 'd$|//
 126 


 127             [fDragImage retain];
 128         }
 129 
 130         fDragImageOffset = NSMakePoint(jDragImageOffsetX, jDragImageOffsetY);
 131 
 132         fSourceActions = jSourceActions;
 133         fFormats = JNFNewGlobalRef(env, jFormats);
 134         fFormatMap = JNFNewGlobalRef(env, jFormatMap);
 135 
 136         fTriggerEventTimeStamp = timeStamp;
 137         fDragPos = NSMakePoint(dragPosX, dragPosY);
 138         fClickCount = clickCount;
 139         fModifiers = extModifiers;
 140 
 141         // Set this object as a dragging source:
 142 
 143         fView = [(AWTView *) control retain];
 144         [fView setDragSource:self];
 145 
 146         // Let AWTEvent know Java drag is getting underway:
 147         [NSEvent javaDraggingBegin];
 148     }
 149 
 150     else {
 151         [self release];
 152         self = nil;
 153     }
 154 




  80 @interface CDragSource ()
  81 // Updates from the destination to the source
  82 - (void) postDragEnter;
  83 - (void) postDragExit;
  84 // Utility
  85 - (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
  86 @end
  87 
  88 @implementation CDragSource
  89 
  90 - (id)        init:(jobject)jDragSourceContextPeer
  91          component:(jobject)jComponent
  92            control:(id)control
  93       transferable:(jobject)jTransferable
  94       triggerEvent:(jobject)jTrigger
  95           dragPosX:(jint)dragPosX
  96           dragPosY:(jint)dragPosY
  97          modifiers:(jint)extModifiers
  98         clickCount:(jint)clickCount
  99          timeStamp:(jlong)timeStamp
 100          dragImage:(jlong)nsDragImagePtr
 101   dragImageOffsetX:(jint)jDragImageOffsetX
 102   dragImageOffsetY:(jint)jDragImageOffsetY
 103      sourceActions:(jint)jSourceActions
 104            formats:(jlongArray)jFormats
 105          formatMap:(jobject)jFormatMap
 106 {
 107     self = [super init];
 108     DLog2(@"[CDragSource init]: %@\n", self);
 109 
 110     fView = nil;
 111     fComponent = nil;
 112 
 113     // Construct the object if we have a valid model for it:
 114     if (control != nil) {
 115         fComponent = jComponent;
 116         fDragSourceContextPeer = jDragSourceContextPeer;
 117         fTransferable = jTransferable;
 118         fTriggerEvent = jTrigger;







 119 
 120         if (nsDragImagePtr) {
 121             fDragImage = (NSImage*) jlong_to_ptr(nsDragImagePtr); // Double-casting prevents compiler 'd$|//
 122             [fDragImage retain];
 123         }
 124 
 125         fDragImageOffset = NSMakePoint(jDragImageOffsetX, jDragImageOffsetY);
 126 
 127         fSourceActions = jSourceActions;
 128         fFormats = jFormats;
 129         fFormatMap = jFormatMap;
 130 
 131         fTriggerEventTimeStamp = timeStamp;
 132         fDragPos = NSMakePoint(dragPosX, dragPosY);
 133         fClickCount = clickCount;
 134         fModifiers = extModifiers;
 135 
 136         // Set this object as a dragging source:
 137 
 138         fView = [(AWTView *) control retain];
 139         [fView setDragSource:self];
 140 
 141         // Let AWTEvent know Java drag is getting underway:
 142         [NSEvent javaDraggingBegin];
 143     }
 144 
 145     else {
 146         [self release];
 147         self = nil;
 148     }
 149