View | Details | Raw Unified | Return to bug 79268 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT PI/carbon/library/os.c (+37 lines)
Lines 5285-5290 Link Here
5285
}
5285
}
5286
#endif
5286
#endif
5287
5287
5288
5289
#ifndef NO_GetIconRefFromTypeInfo
5290
JNIEXPORT jint JNICALL OS_NATIVE(GetIconRefFromTypeInfo)
5291
	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5)
5292
{
5293
	jint *lparg5=NULL;
5294
	jint rc = 0;
5295
	OS_NATIVE_ENTER(env, that, GetIconRefFromTypeInfo_FUNC);
5296
	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
5297
	rc = (jint)GetIconRefFromTypeInfo((OSType)arg0, (OSType)arg1, (CFStringRef)arg2, (CFStringRef)arg3, arg4, (IconRef *)lparg5);
5298
fail:
5299
	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
5300
	OS_NATIVE_EXIT(env, that, GetIconRefFromTypeInfo_FUNC);
5301
	return rc;
5302
}
5303
#endif
5304
5288
#ifndef NO_GetIndMenuItemWithCommandID
5305
#ifndef NO_GetIndMenuItemWithCommandID
5289
JNIEXPORT jint JNICALL OS_NATIVE(GetIndMenuItemWithCommandID)
5306
JNIEXPORT jint JNICALL OS_NATIVE(GetIndMenuItemWithCommandID)
5290
	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jshortArray arg4)
5307
	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jshortArray arg4)
Lines 8276-8281 Link Here
8276
}
8293
}
8277
#endif
8294
#endif
8278
8295
8296
#ifndef NO_PlotIconRefInContext
8297
JNIEXPORT jint JNICALL OS_NATIVE(PlotIconRefInContext)
8298
	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jint arg6)
8299
{
8300
	jint rc = 0;
8301
	CGRect _arg1, *lparg1 = NULL;
8302
	RGBColor _arg4, *lparg4 = NULL;
8303
	OS_NATIVE_ENTER(env, that, PlotIconRefInContext_FUNC);
8304
	if (arg1) if ((lparg1 = getCGRectFields(env, arg1, &_arg1)) == NULL) goto failCGRect;
8305
	if (arg4) if ((lparg4 = getRGBColorFields(env, arg4, &_arg4)) == NULL) goto failRGBColor;
8306
	rc = (jint)PlotIconRefInContext((CGContextRef)arg0, (const CGRect *)lparg1, arg2, arg3, (const RGBColor *)lparg4, arg5, (IconRef)arg6);
8307
failRGBColor:
8308
	if (arg4 && lparg4) setRGBColorFields(env, arg4, lparg4);
8309
failCGRect:
8310
	if (arg1 && lparg1) setCGRectFields(env, arg1, lparg1);
8311
	OS_NATIVE_EXIT(env, that, PlotIconRefInContext_FUNC);
8312
	return rc;
8313
}
8314
#endif
8315
8279
#ifndef NO_PopUpMenuSelect
8316
#ifndef NO_PopUpMenuSelect
8280
JNIEXPORT jint JNICALL OS_NATIVE(PopUpMenuSelect)
8317
JNIEXPORT jint JNICALL OS_NATIVE(PopUpMenuSelect)
8281
	(JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jshort arg3)
8318
	(JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jshort arg3)
(-)Eclipse SWT PI/carbon/library/os_stats.h (+2 lines)
Lines 396-401 Link Here
396
	GetHandleSize_FUNC,
396
	GetHandleSize_FUNC,
397
	GetIconFamilyData_FUNC,
397
	GetIconFamilyData_FUNC,
398
	GetIconRef_FUNC,
398
	GetIconRef_FUNC,
399
	GetIconRefFromTypeInfo_FUNC,
399
	GetIndMenuItemWithCommandID_FUNC,
400
	GetIndMenuItemWithCommandID_FUNC,
400
	GetIndexedSubControl_FUNC,
401
	GetIndexedSubControl_FUNC,
401
	GetItemMark_FUNC,
402
	GetItemMark_FUNC,
Lines 609-614 Link Here
609
	PaintRoundRect_FUNC,
610
	PaintRoundRect_FUNC,
610
	PenSize_FUNC,
611
	PenSize_FUNC,
611
	PickColor_FUNC,
612
	PickColor_FUNC,
613
	PlotIconRefInContext_FUNC,
612
	PopUpMenuSelect_FUNC,
614
	PopUpMenuSelect_FUNC,
613
	PostEvent_FUNC,
615
	PostEvent_FUNC,
614
	PostEventToQueue_FUNC,
616
	PostEventToQueue_FUNC,
(-)Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java (+7 lines)
Lines 56-61 Link Here
56
	public static final int kAlertStdAlertOKButton        = 1;
56
	public static final int kAlertStdAlertOKButton        = 1;
57
	public static final int kAlertStdAlertCancelButton    = 2;
57
	public static final int kAlertStdAlertCancelButton    = 2;
58
	public static final int kAlertStdAlertOtherButton     = 3;
58
	public static final int kAlertStdAlertOtherButton     = 3;
59
	public static final int kAlignNone = 0;
59
	public static final int kAtSpecifiedOrigin = 0;
60
	public static final int kAtSpecifiedOrigin = 0;
60
	public static final int kATSDeletedGlyphcode = 0xFFFF;
61
	public static final int kATSDeletedGlyphcode = 0xFFFF;
61
	public static final int kATSUDirectDataBaselineDeltaFixedArray = 1;
62
	public static final int kATSUDirectDataBaselineDeltaFixedArray = 1;
Lines 380-385 Link Here
380
	public static final int kFontNoLanguageCode = -1;
381
	public static final int kFontNoLanguageCode = -1;
381
	public static final int kFontSelectionQDStyleVersionZero = 0;
382
	public static final int kFontSelectionQDStyleVersionZero = 0;
382
	public static final int kFontSelectionQDType = ('q'<<24) + ('s'<<16) + ('t'<<8) + 'l';
383
	public static final int kFontSelectionQDType = ('q'<<24) + ('s'<<16) + ('t'<<8) + 'l';
384
	public static final int kGenericDocumentIcon = ('d'<<24) + ('o'<<16) + ('c'<<8) + 'u';
385
	public static final int kGenericFolderIcon = ('f'<<24) + ('l'<<16) + ('d'<<8) + 'r';
383
	public static final int kHIComboBoxAutoCompletionAttribute = (1 << 0);	
386
	public static final int kHIComboBoxAutoCompletionAttribute = (1 << 0);	
384
	public static final int kHIComboBoxAutoSizeListAttribute = (1 << 3);
387
	public static final int kHIComboBoxAutoSizeListAttribute = (1 << 3);
385
	public static final int kHIComboBoxEditTextPart = 5;
388
	public static final int kHIComboBoxEditTextPart = 5;
Lines 496-501 Link Here
496
	public static final int kNavUserActionSaveAs = 3;
499
	public static final int kNavUserActionSaveAs = 3;
497
	public static final short kOnSystemDisk = -32768;
500
	public static final short kOnSystemDisk = -32768;
498
	public static final int kOverlayWindowClass = 14;
501
	public static final int kOverlayWindowClass = 14;
502
	public static final int kPlotIconRefNormalFlags = 0;
499
	public static final int kPMCancel = 0x0080;
503
	public static final int kPMCancel = 0x0080;
500
	public static final int kPMDestinationFax = 3;
504
	public static final int kPMDestinationFax = 3;
501
	public static final int kPMDestinationFile = 2;
505
	public static final int kPMDestinationFile = 2;
Lines 515-520 Link Here
515
	public static final int kSystemIconsCreator = ('m'<<24) + ('a'<<16) + ('c'<<8) + 's';
519
	public static final int kSystemIconsCreator = ('m'<<24) + ('a'<<16) + ('c'<<8) + 's';
516
	public static final int kSymbolLigaturesOffSelector = 17;
520
	public static final int kSymbolLigaturesOffSelector = 17;
517
	public static final int kControlSliderDoesNotPoint = 2;
521
	public static final int kControlSliderDoesNotPoint = 2;
522
	public static final int kTransformNone = 0;
518
	public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11;
523
	public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11;
519
	public static final int kTXNBackgroundTypeRGB = 1;
524
	public static final int kTXNBackgroundTypeRGB = 1;
520
	public static final int kTXNDefaultFontSize = 0x000C0000;
525
	public static final int kTXNDefaultFontSize = 0x000C0000;
Lines 1079-1084 Link Here
1079
public static final native int GetHandleSize(int handle);
1084
public static final native int GetHandleSize(int handle);
1080
public static final native int GetIconFamilyData(int iconFamily, int iconType, int h);
1085
public static final native int GetIconFamilyData(int iconFamily, int iconType, int h);
1081
public static final native int GetIconRef(short vRefNum, int creator, int iconType, int[] theIconRef);
1086
public static final native int GetIconRef(short vRefNum, int creator, int iconType, int[] theIconRef);
1087
public static final native int GetIconRefFromTypeInfo(int inCreator, int inType, int inExtension, int inMIMEType, int inUsageFlags, int[] outIconRef);
1082
public static final native int GetIndMenuItemWithCommandID(int mHandle, int commandId, int index, int[] outMenu, short[] outIndex);
1088
public static final native int GetIndMenuItemWithCommandID(int mHandle, int commandId, int index, int[] outMenu, short[] outIndex);
1083
public static final native int GetIndexedSubControl(int cHandle, short index, int[] outHandle);
1089
public static final native int GetIndexedSubControl(int cHandle, short index, int[] outHandle);
1084
public static final native void GetItemMark (int theMenu, short item, short[] markChar);
1090
public static final native void GetItemMark (int theMenu, short item, short[] markChar);
Lines 1250-1255 Link Here
1250
public static final native void PaintRoundRect(Rect bounds, short ovalWidth, short ovalHeight);
1256
public static final native void PaintRoundRect(Rect bounds, short ovalWidth, short ovalHeight);
1251
public static final native void PenSize(short h, short v);
1257
public static final native void PenSize(short h, short v);
1252
public static final native int PickColor(ColorPickerInfo theColorInfo);
1258
public static final native int PickColor(ColorPickerInfo theColorInfo);
1259
public static final native int PlotIconRefInContext(int inContext, CGRect inRect, int inAlign, int inTransform, RGBColor inLabelColor, int inFlags, int inIconRef);
1253
public static final native int PopUpMenuSelect(int mHandle, short top, short left, short popUpItem);
1260
public static final native int PopUpMenuSelect(int mHandle, short top, short left, short popUpItem);
1254
public static final native int PostEvent(short eventNum, int eventMsg);
1261
public static final native int PostEvent(short eventNum, int eventMsg);
1255
public static final native int PostEventToQueue(int inQueue, int inEvent, short inPriority);
1262
public static final native int PostEventToQueue(int inQueue, int inEvent, short inPriority);
(-)Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java (-1 / +119 lines)
Lines 12-17 Link Here
12
12
13
 
13
 
14
import org.eclipse.swt.internal.*;
14
import org.eclipse.swt.internal.*;
15
import org.eclipse.swt.internal.carbon.CGRect;
16
import org.eclipse.swt.internal.carbon.OS;
15
import org.eclipse.swt.*;
17
import org.eclipse.swt.*;
16
import org.eclipse.swt.graphics.*;
18
import org.eclipse.swt.graphics.*;
17
19
Lines 24-30 Link Here
24
 * system.
26
 * system.
25
 */
27
 */
26
public final class Program {
28
public final class Program {
27
	String name;
29
    
30
    private static final int BYTES_PER_PIXEL = 4;
31
    private static final int MAXIMUM_IMAGE_DIMENSION_LENGTH = 128;
32
33
    String name;
28
	String command;
34
	String command;
29
	String iconName;
35
	String iconName;
30
36
Lines 276-281 Link Here
276
	return data;
282
	return data;
277
}
283
}
278
284
285
public static ImageData getImageData ( String extension, int iconSize ) {
286
    int iconRef = getIconRefForExtension ( extension );
287
    if ( iconRef == 0 ) {
288
        iconRef = getIconRefForConstant ( OS.kGenericDocumentIcon );
289
    }
290
    
291
    return getImageDataForIconRef ( iconRef, iconSize );
292
}
293
294
public static ImageData getSystemFolderImageData ( int iconSize ) {
295
    int iconRef = getIconRefForConstant ( OS.kGenericFolderIcon );
296
    return getImageDataForIconRef ( iconRef, iconSize );
297
}
298
299
private static ImageData getImageDataForIconRef ( int iconRef, int iconSize ) {
300
    if ( iconRef != 0 ) {
301
        ImageData imageData = loadImageDataForIconRef ( iconRef, iconSize );
302
        OS.ReleaseIconRef ( iconRef );
303
        return imageData;
304
    }
305
306
    return null;
307
}
308
309
private static int getIconRefForConstant ( int iconConstant ) {
310
    int status;
311
    int[] iconRef = new int[1];
312
313
    status = OS.GetIconRef ( OS.kOnSystemDisk,
314
            OS.kSystemIconsCreator,
315
            iconConstant,
316
            iconRef
317
            );
318
319
    return status == 0 ? iconRef[0] : 0;
320
}
321
322
private static int getIconRefForExtension ( String extension ) {
323
    int status = -1; // Start off with an error condition
324
    int[] iconRef = new int[1];
325
326
    // Convert the java.lang.String into a CFString
327
    
328
    int length = extension.length();
329
    char[] buffer = new char[ length ];
330
    extension.getChars ( 0, length, buffer, 0 );
331
    int extensionAsACFString = OS.CFStringCreateWithCharacters ( 0, buffer, length );
332
    if ( extensionAsACFString != 0 ) {
333
        
334
        // Get the icon reference for this extension
335
    
336
        status = OS.GetIconRefFromTypeInfo ( 0, // OSType inCreator
337
									  0, // OSType inType
338
									  extensionAsACFString,
339
									  0, // CFStringRef inMIMEType
340
									  0, // IconServicesUsageFlags inUsageFlags
341
									  iconRef
342
									  );
343
        
344
        OS.CFRelease ( extensionAsACFString );
345
    }
346
347
    return status == 0 ? iconRef[0] : 0;
348
}
349
350
private static ImageData loadImageDataForIconRef ( final int iconRef, final int iconSize ) {
351
    int size = Math.max ( 1, Math.min ( MAXIMUM_IMAGE_DIMENSION_LENGTH, iconSize ) );
352
    
353
    Image image = new Image ( null, size, size );
354
355
    int colorSpace = OS.CGColorSpaceCreateDeviceRGB();
356
    if ( colorSpace != 0 ) {
357
        int bpc = OS.CGImageGetBitsPerComponent ( image.handle );
358
        int context = OS.CGBitmapContextCreate ( image.data,
359
                size,
360
                size,
361
                bpc,
362
                size * BYTES_PER_PIXEL, // bytesPerRow
363
                colorSpace,
364
                OS.kCGImageAlphaNoneSkipFirst
365
                );
366
367
		CGRect rect = new CGRect();
368
		rect.x = rect.y = 0;
369
		rect.height = rect.width = size;
370
		
371
		int status = OS.PlotIconRefInContext ( context,
372
				rect,
373
				OS.kAlignNone,
374
				OS.kTransformNone,
375
				null, // inlabelColor
376
				OS.kPlotIconRefNormalFlags,
377
				iconRef
378
				);
379
		if ( status != 0) {
380
		    image.dispose();
381
		    image = null;
382
		}
383
		
384
		OS.CGContextRelease ( context );
385
    }
386
387
    // We intend to return a copy of the image data
388
    ImageData ret = ( ImageData ) image.getImageData().clone();
389
    
390
    // Release resources
391
    image.dispose();
392
    OS.CGColorSpaceRelease ( colorSpace );
393
394
    return ret;
395
}
396
279
/**
397
/**
280
 * Returns the receiver's name.  This is as short and
398
 * Returns the receiver's name.  This is as short and
281
 * descriptive a name as possible for the program.  If
399
 * descriptive a name as possible for the program.  If

Return to bug 79268