60 { 61 cursor = [NSCursor arrowCursor]; 62 } 63 return cursor; 64 } 65 66 @end 67 68 #pragma mark --- com_sun_glass_ui_mac_MacCursor 69 70 /* 71 * Class: com_sun_glass_ui_mac_MacCursor 72 * Method: _initIDs 73 * Signature: ()V 74 */ 75 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacCursor__1initIDs 76 (JNIEnv *env, jclass jCursorClass) 77 { 78 LOG("Java_com_sun_glass_ui_mac_MacCursor__1initIDs"); 79 80 NSString *base = @"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors"; 81 NSString *nwse = @"resizenorthwestsoutheast"; 82 NSString *nesw = @"resizenortheastsouthwest"; 83 NSString *nwsePath = [base stringByAppendingPathComponent:nwse]; 84 NSString *neswPath = [base stringByAppendingPathComponent:nesw]; 85 NSString *nwseFile = [nwsePath stringByAppendingPathComponent:@"cursor.pdf"]; 86 NSString *neswFile = [neswPath stringByAppendingPathComponent:@"cursor.pdf"]; 87 NSString *nwseInfo = [nwsePath stringByAppendingPathComponent:@"info.plist"]; 88 NSString *neswInfo = [neswPath stringByAppendingPathComponent:@"info.plist"]; 89 NSImage *nwseImage = [[NSImage alloc] initByReferencingFile:nwseFile]; 90 NSImage *neswImage = [[NSImage alloc] initByReferencingFile:neswFile]; 91 NSDictionary *nwseDict = [NSDictionary dictionaryWithContentsOfFile:nwseInfo]; 92 NSDictionary *neswDict = [NSDictionary dictionaryWithContentsOfFile:neswInfo]; 93 NSPoint nwsePoint = NSMakePoint([[nwseDict valueForKey:@"hotx"] doubleValue], 94 [[nwseDict valueForKey:@"hoty"] doubleValue]); 95 NSPoint neswPoint = NSMakePoint([[neswDict valueForKey:@"hotx"] doubleValue], 96 [[neswDict valueForKey:@"hoty"] doubleValue]); 97 98 if (jSizeInit == NULL) 99 { 100 jSizeInit = (*env)->GetMethodID(env, [GlassHelper ClassForName:"com.sun.glass.ui.Size" withEnv:env], 101 "<init>", "(II)V"); 102 } 103 cursorCache = [NSArray arrayWithObjects: 104 /* CURSOR_CUSTOM */ [NSCursor arrowCursor], // not handed out in set 105 /* CURSOR_DEFAULT */ [NSCursor arrowCursor], 106 /* CURSOR_TEXT */ [NSCursor IBeamCursor], 107 /* CURSOR_CROSSHAIR */ [NSCursor crosshairCursor], 108 /* CURSOR_CLOSED_HAND */ [NSCursor closedHandCursor], 109 /* CURSOR_OPEN_HAND */ [NSCursor openHandCursor], 110 /* CURSOR_POINTING_HAND */ [NSCursor pointingHandCursor], 111 /* CURSOR_RESIZE_LEFT: */ [NSCursor resizeLeftCursor], 112 /* CURSOR_RESIZE_RIGHT */ [NSCursor resizeRightCursor], 113 /* CURSOR_RESIZE_UP */ [NSCursor resizeUpCursor], 114 /* CURSOR_RESIZE_DOWN */ [NSCursor resizeDownCursor], 115 /* CURSOR_RESIZE_LEFTRIGHT */ [NSCursor resizeLeftRightCursor], 116 /* CURSOR_RESIZE_UPDOWN */ [NSCursor resizeUpDownCursor], 117 /* CURSOR_DISAPPEAR */ [NSCursor disappearingItemCursor], 118 /* CURSOR_WAIT */ [NSCursor performJavaSelector:@selector(javaBusyButClickableCursor)], 119 /* CURSOR_RESIZE_SOUTHWEST */ [[NSCursor alloc] initWithImage:neswImage hotSpot:neswPoint], 120 /* CURSOR_RESIZE_SOUTHEAST */ [[NSCursor alloc] initWithImage:nwseImage hotSpot:nwsePoint], 121 /* CURSOR_RESIZE_NORTHWEST */ [[NSCursor alloc] initWithImage:nwseImage hotSpot:nwsePoint], 122 /* CURSOR_RESIZE_NORTHEAST */ [[NSCursor alloc] initWithImage:neswImage hotSpot:neswPoint], 253 } 254 else 255 { 256 widthBest = CURSOR_BEST_SIZE; 257 } 258 } 259 260 if (heightBest <= 0) 261 { 262 if (image != nil) 263 { 264 heightBest = (jint)[image size].height; 265 } 266 else 267 { 268 heightBest = CURSOR_BEST_SIZE; 269 } 270 } 271 272 [image release]; 273 274 jsize = (*env)->NewObject(env, [GlassHelper ClassForName:"com.sun.glass.ui.Size" withEnv:env], jSizeInit, widthBest, heightBest); 275 } 276 GLASS_POOL_EXIT; 277 GLASS_CHECK_EXCEPTION(env); 278 279 return jsize; 280 } | 60 { 61 cursor = [NSCursor arrowCursor]; 62 } 63 return cursor; 64 } 65 66 @end 67 68 #pragma mark --- com_sun_glass_ui_mac_MacCursor 69 70 /* 71 * Class: com_sun_glass_ui_mac_MacCursor 72 * Method: _initIDs 73 * Signature: ()V 74 */ 75 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacCursor__1initIDs 76 (JNIEnv *env, jclass jCursorClass) 77 { 78 LOG("Java_com_sun_glass_ui_mac_MacCursor__1initIDs"); 79 80 if (jSizeInit == NULL) 81 { 82 jclass cls = [GlassHelper ClassForName:"com.sun.glass.ui.Size" withEnv:env]; 83 if (!cls) { 84 return; 85 } 86 jSizeInit = (*env)->GetMethodID(env, cls, "<init>", "(II)V"); 87 } 88 89 NSString *base = @"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors"; 90 NSString *nwse = @"resizenorthwestsoutheast"; 91 NSString *nesw = @"resizenortheastsouthwest"; 92 NSString *nwsePath = [base stringByAppendingPathComponent:nwse]; 93 NSString *neswPath = [base stringByAppendingPathComponent:nesw]; 94 NSString *nwseFile = [nwsePath stringByAppendingPathComponent:@"cursor.pdf"]; 95 NSString *neswFile = [neswPath stringByAppendingPathComponent:@"cursor.pdf"]; 96 NSString *nwseInfo = [nwsePath stringByAppendingPathComponent:@"info.plist"]; 97 NSString *neswInfo = [neswPath stringByAppendingPathComponent:@"info.plist"]; 98 NSImage *nwseImage = [[NSImage alloc] initByReferencingFile:nwseFile]; 99 NSImage *neswImage = [[NSImage alloc] initByReferencingFile:neswFile]; 100 NSDictionary *nwseDict = [NSDictionary dictionaryWithContentsOfFile:nwseInfo]; 101 NSDictionary *neswDict = [NSDictionary dictionaryWithContentsOfFile:neswInfo]; 102 NSPoint nwsePoint = NSMakePoint([[nwseDict valueForKey:@"hotx"] doubleValue], 103 [[nwseDict valueForKey:@"hoty"] doubleValue]); 104 NSPoint neswPoint = NSMakePoint([[neswDict valueForKey:@"hotx"] doubleValue], 105 [[neswDict valueForKey:@"hoty"] doubleValue]); 106 107 108 cursorCache = [NSArray arrayWithObjects: 109 /* CURSOR_CUSTOM */ [NSCursor arrowCursor], // not handed out in set 110 /* CURSOR_DEFAULT */ [NSCursor arrowCursor], 111 /* CURSOR_TEXT */ [NSCursor IBeamCursor], 112 /* CURSOR_CROSSHAIR */ [NSCursor crosshairCursor], 113 /* CURSOR_CLOSED_HAND */ [NSCursor closedHandCursor], 114 /* CURSOR_OPEN_HAND */ [NSCursor openHandCursor], 115 /* CURSOR_POINTING_HAND */ [NSCursor pointingHandCursor], 116 /* CURSOR_RESIZE_LEFT: */ [NSCursor resizeLeftCursor], 117 /* CURSOR_RESIZE_RIGHT */ [NSCursor resizeRightCursor], 118 /* CURSOR_RESIZE_UP */ [NSCursor resizeUpCursor], 119 /* CURSOR_RESIZE_DOWN */ [NSCursor resizeDownCursor], 120 /* CURSOR_RESIZE_LEFTRIGHT */ [NSCursor resizeLeftRightCursor], 121 /* CURSOR_RESIZE_UPDOWN */ [NSCursor resizeUpDownCursor], 122 /* CURSOR_DISAPPEAR */ [NSCursor disappearingItemCursor], 123 /* CURSOR_WAIT */ [NSCursor performJavaSelector:@selector(javaBusyButClickableCursor)], 124 /* CURSOR_RESIZE_SOUTHWEST */ [[NSCursor alloc] initWithImage:neswImage hotSpot:neswPoint], 125 /* CURSOR_RESIZE_SOUTHEAST */ [[NSCursor alloc] initWithImage:nwseImage hotSpot:nwsePoint], 126 /* CURSOR_RESIZE_NORTHWEST */ [[NSCursor alloc] initWithImage:nwseImage hotSpot:nwsePoint], 127 /* CURSOR_RESIZE_NORTHEAST */ [[NSCursor alloc] initWithImage:neswImage hotSpot:neswPoint], 258 } 259 else 260 { 261 widthBest = CURSOR_BEST_SIZE; 262 } 263 } 264 265 if (heightBest <= 0) 266 { 267 if (image != nil) 268 { 269 heightBest = (jint)[image size].height; 270 } 271 else 272 { 273 heightBest = CURSOR_BEST_SIZE; 274 } 275 } 276 277 [image release]; 278 jclass sizeClass = [GlassHelper ClassForName:"com.sun.glass.ui.Size" withEnv:env]; 279 if (sizeClass) { 280 return NULL; 281 } 282 jsize = (*env)->NewObject(env, sizeClass, jSizeInit, widthBest, heightBest); 283 } 284 GLASS_POOL_EXIT; 285 GLASS_CHECK_EXCEPTION(env); 286 287 return jsize; 288 } |