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

Print this page




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "sun_lwawt_macosx_CDragSourceContextPeer.h"
  27 
  28 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  29 
  30 #import "CDragSource.h"
  31 #import "ThreadUtilities.h"
  32 
  33 
  34 /*
  35  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  36  * Method:    createNativeDragSource
  37  * Signature: (Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJLjava/awt/Cursor;IJIII[JLjava/util/Map;)J
  38  */
  39 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
  40   (JNIEnv *env, jobject jthis, jobject jcomponent, jobject jpeer, jlong jnativepeer, jobject jtransferable,
  41    jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
  42    jobject jcursor, jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
  43    jint jsourceactions, jlongArray jformats, jobject jformatmap)
  44 {
  45     id controlObj = (id) jlong_to_ptr(jnativepeer);
  46     __block CDragSource* dragSource = nil;
  47 
  48 JNF_COCOA_ENTER(env);
  49     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
  50         dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj
  51             transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
  52             dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
  53             cursor:jcursor dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx
  54             dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions
  55             formats:jformats formatMap:jformatmap];
  56     }];
  57 JNF_COCOA_EXIT(env);
  58 
  59     if (dragSource) {
  60         CFRetain(dragSource); // GC
  61         [dragSource release];
  62     }
  63     return ptr_to_jlong(dragSource);
  64 }
  65 
  66 /*
  67  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  68  * Method:    doDragging
  69  * Signature: (J)V
  70  */
  71 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_doDragging
  72   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal)
  73 {


  77 
  78 JNF_COCOA_ENTER(env);
  79     [dragSource drag];
  80 JNF_COCOA_EXIT(env);
  81 }
  82 
  83 /*
  84  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  85  * Method:    releaseNativeDragSource
  86  * Signature: (J)V
  87  */
  88 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_releaseNativeDragSource
  89   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal)
  90 {
  91       CDragSource* dragSource = (CDragSource*) jlong_to_ptr(nativeDragSourceVal);
  92 
  93 JNF_COCOA_ENTER(env);
  94     [dragSource removeFromView:env];
  95 JNF_COCOA_EXIT(env);
  96 }
  97 
  98 /*
  99  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
 100  * Method:    setNativeCursor
 101  * Signature: (JLjava/awt/Cursor;I)V
 102  */
 103 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor
 104   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype)
 105 {
 106    //AWT_ASSERT_NOT_APPKIT_THREAD;
 107 
 108 //JNF_COCOA_ENTER(env);
 109 //    jobject gCursor = JNFNewGlobalRef(env, jcursor);
 110 //    [EventFactory setJavaCursor:gCursor withEnv:env];
 111 //JNF_COCOA_EXIT(env);
 112 }


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "sun_lwawt_macosx_CDragSourceContextPeer.h"
  27 
  28 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  29 
  30 #import "CDragSource.h"
  31 #import "ThreadUtilities.h"
  32 
  33 
  34 /*
  35  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  36  * Method:    createNativeDragSource
  37  * Signature: (Ljava/awt/Component;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJIJIII[JLjava/util/Map;)J
  38  */
  39 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource
  40   (JNIEnv *env, jobject jthis, jobject jcomponent, jlong jnativepeer, jobject jtransferable,
  41    jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp,
  42    jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety,
  43    jint jsourceactions, jlongArray jformats, jobject jformatmap)
  44 {
  45     id controlObj = (id) jlong_to_ptr(jnativepeer);
  46     __block CDragSource* dragSource = nil;
  47 
  48 JNF_COCOA_ENTER(env);
  49     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
  50         dragSource = [[CDragSource alloc] init:jthis component:jcomponent control:controlObj
  51             transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
  52             dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
  53             dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx
  54             dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions
  55             formats:jformats formatMap:jformatmap];
  56     }];
  57 JNF_COCOA_EXIT(env);
  58 
  59     if (dragSource) {
  60         CFRetain(dragSource); // GC
  61         [dragSource release];
  62     }
  63     return ptr_to_jlong(dragSource);
  64 }
  65 
  66 /*
  67  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  68  * Method:    doDragging
  69  * Signature: (J)V
  70  */
  71 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_doDragging
  72   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal)
  73 {


  77 
  78 JNF_COCOA_ENTER(env);
  79     [dragSource drag];
  80 JNF_COCOA_EXIT(env);
  81 }
  82 
  83 /*
  84  * Class:     sun_lwawt_macosx_CDragSourceContextPeer
  85  * Method:    releaseNativeDragSource
  86  * Signature: (J)V
  87  */
  88 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_releaseNativeDragSource
  89   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal)
  90 {
  91       CDragSource* dragSource = (CDragSource*) jlong_to_ptr(nativeDragSourceVal);
  92 
  93 JNF_COCOA_ENTER(env);
  94     [dragSource removeFromView:env];
  95 JNF_COCOA_EXIT(env);
  96 }