Java 类org.eclipse.swt.internal.C 实例源码

项目:BiglyBT    文件:CocoaUIEnhancer.java   
private static Object wrapPointer(long value) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if (PTR_CLASS == long.class)
        return new Long(value);
    else
        return new Integer((int) value);
}
项目:BiglyBT    文件:CocoaUIEnhancer.java   
public boolean isRetinaDisplay() {
    try {
        //NSArray screens = NSScreen.screens();
        Object screens = invoke(nsscreenCls, "screens");
        //int count = (int) /*64*/screens.count();
        Object oCount = invoke(screens, "count");
        if (!(oCount instanceof Number)) {
            System.err.println("Can't determine Retina: count is " + oCount);
        }
        int count = ((Number) oCount).intValue();
        for (int i = 0; i < count; i++) {
            //NSScreen screen = new NSScreen(screens.objectAtIndex(i));
            Object screenID = invoke(screens, "objectAtIndex", new Class[] {
                C.PTR_SIZEOF == 8 ? long.class : int.class
            }, i);

            Object screen = nsscreenCls.getConstructor(screenID.getClass()).newInstance(screenID);
            //          if (screen.backingScaleFactor() == 2) {
            Object oBackingScaleFactor = invoke(screen, "backingScaleFactor");
            //System.err.println("Retina #" + i + " = " + oBackingScaleFactor);
            if ((oBackingScaleFactor instanceof Number)
                    && ((Number) oBackingScaleFactor).intValue() == 2) {
                return true;
            }
        }
    } catch (Throwable t) {
        Debug.out("Can't determine Retina", t);
    }
    return false;
}
项目:TuxGuitar-1.3.1-fork    文件:MacToolbar.java   
public void init( Shell shell ) throws Throwable{
    Callback callback = TGCocoa.newCallback( this , "callbackProc64", "callbackProc32", 3 );
    long callbackProc = TGCocoa.getCallbackAddress( callback );

    if( callbackProc != 0 ){
        String classname = ("MacToolbarDelegate");
        if( TGCocoa.objc_lookUpClass ( classname ) == 0 ) {
            long cls = TGCocoa.objc_allocateClassPair( classname , 0 ) ;
            TGCocoa.class_addIvar(cls, SWT_OBJECT, C.PTR_SIZEOF , (byte)(C.PTR_SIZEOF == 4 ? 2 : 3), new byte[]{'*','\0'} );
            TGCocoa.class_addMethod(cls, sel_toolbarButtonClicked_, callbackProc , "@:@");
            TGCocoa.objc_registerClassPair(cls);
        }

        this.delegate = TGCocoa.newMacToolbarDelegate();
        this.delegate.alloc().init();
        this.delegateRef = TGCocoa.NewGlobalRef( MacToolbar.this );

        TGCocoa.object_setInstanceVariable( MacToolbarDelegate.class.getField("id").get( delegate ) , SWT_OBJECT , this.delegateRef );

        NSToolbar dummyBar = new NSToolbar();
        dummyBar.alloc();
        dummyBar.initWithIdentifier(NSString.stringWith("SWTToolbar")); //$NON-NLS-1$
        dummyBar.setVisible(false);

        NSWindow nsWindow = shell.view.window();
        nsWindow.setToolbar(dummyBar);
        dummyBar.release();
        nsWindow.setShowsToolbarButton(true);

        NSButton toolbarButton = TGCocoa.getStandardWindowButton(nsWindow, NSWindowToolbarButton);
        if (toolbarButton != null) {
            toolbarButton.setTarget( delegate );
            TGCocoa.setControlAction( toolbarButton , sel_toolbarButtonClicked_ );
        }
    }
}
项目:ether    文件:CocoaUIEnhancer.java   
private static Object wrapPointer( long value ) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if ( PTR_CLASS == long.class )
        return new Long( value );
    else
        return new Integer( (int) value );
}
项目:ether    文件:CocoaUIEnhancer.java   
private static Object wrapPointer( long value ) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if ( PTR_CLASS == long.class )
        return new Long( value );
    else
        return new Integer( (int) value );
}
项目:raptor-chess-interface    文件:CocoaUIEnhancer.java   
private static Object wrapPointer( long value ) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if ( PTR_CLASS == long.class ) {
        return new Long( value );
    } else {
        return new Integer( (int) value );
    }
}
项目:JFaceUtils    文件:CocoaUIEnhancer.java   
private static Number wrapPointer(final long value) {
    final Class<?> ptrClass = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if (ptrClass == long.class) {
        return Long.valueOf(value);
    }
    else {
        return Integer.valueOf((int) value);
    }
}
项目:AcademicTorrents-Downloader    文件:CocoaUIEnhancer.java   
private static Object wrapPointer(long value) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if (PTR_CLASS == long.class)
        return new Long(value);
    else
        return new Integer((int) value);
}
项目:drinviewer    文件:CocoaUIEnhancer.java   
private static Object wrapPointer( long value ) {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
    if ( PTR_CLASS == long.class ) {
        return new Long( value );
    } else {
        return new Integer( (int) value );
    }
}
项目:totallicks-tuxguitar    文件:MacToolbar.java   
public void init( Shell shell ) throws Throwable{
    Callback callback = TGCocoa.newCallback( this , "callbackProc64", "callbackProc32", 3 );
    long callbackProc = TGCocoa.getCallbackAddress( callback );

    if( callbackProc != 0 ){
        String classname = ("MacToolbarDelegate");
        if( TGCocoa.objc_lookUpClass ( classname ) == 0 ) {
            long cls = TGCocoa.objc_allocateClassPair( classname , 0 ) ;
            TGCocoa.class_addIvar(cls, SWT_OBJECT, C.PTR_SIZEOF , (byte)(C.PTR_SIZEOF == 4 ? 2 : 3), new byte[]{'*','\0'} );
            TGCocoa.class_addMethod(cls, sel_toolbarButtonClicked_, callbackProc , "@:@");
            TGCocoa.objc_registerClassPair(cls);
        }

        this.delegate = TGCocoa.newMacToolbarDelegate();
        this.delegate.alloc().init();
        this.delegateRef = TGCocoa.NewGlobalRef( MacToolbar.this );

        TGCocoa.object_setInstanceVariable( MacToolbarDelegate.class.getField("id").get( delegate ) , SWT_OBJECT , this.delegateRef );

        NSToolbar dummyBar = new NSToolbar();
        dummyBar.alloc();
        dummyBar.initWithIdentifier(NSString.stringWith("SWTToolbar")); //$NON-NLS-1$
        dummyBar.setVisible(false);

        NSWindow nsWindow = shell.view.window();
        nsWindow.setToolbar(dummyBar);
        dummyBar.release();
        nsWindow.setShowsToolbarButton(true);

        NSButton toolbarButton = TGCocoa.getStandardWindowButton(nsWindow, NSWindowToolbarButton);
        if (toolbarButton != null) {
            toolbarButton.setTarget( delegate );
            TGCocoa.setControlAction( toolbarButton , sel_toolbarButtonClicked_ );
        }
    }
}
项目:TuxGuitar-1.3.1-fork    文件:TGCocoa.java   
public static final Callback newCallback(Object object, String method64, String method32, int argCount) throws Throwable {
    return new Callback( object, ( C.PTR_SIZEOF == 8 ? method64 : method32 ) , argCount );
}
项目:TuxGuitar-1.3.1-fork    文件:TGCocoa.java   
private static Object osType( long value ) {
    return ( C.PTR_SIZEOF == 8 ? ((Object)new Long(value)) : ((Object)new Integer((int)value)) );
}
项目:TuxGuitar-1.3.1-fork    文件:OpenDocListener.java   
public int openDocProc(int theAppleEvent, int reply, int handlerRefcon) {
    if(!this.isEnabled()){
        return OS.noErr;
    }
    AEDesc aeDesc = new AEDesc();
    EventRecord eventRecord = new EventRecord();
    OS.ConvertEventRefToEventRecord(theAppleEvent, eventRecord);
    try {
        int result = OpenDocJNI.AEGetParamDesc(theAppleEvent,OS.kEventParamDirectObject, typeAEList, aeDesc);
        if (result != OS.noErr) {
            System.err.println("OSX: Could call AEGetParamDesc. Error: " + result);
            return OS.noErr;
        }
    } catch (java.lang.UnsatisfiedLinkError e) {
        System.err.println("OSX: AEGetParamDesc not available.  Can't open sent file");
        return OS.noErr;
    }
    int[] count = new int[1];
    OS.AECountItems(aeDesc, count);

    if (count[0] > 0) {
        String[] fileNames = new String[count[0]];
        int maximumSize = 80; // size of FSRef
        int dataPtr = OS.NewPtr(maximumSize);
        int[] aeKeyword = new int[1];
        int[] typeCode = new int[1];
        int[] actualSize = new int[1];
        for (int i = 0; i < count[0]; i++) {
            if (OS.AEGetNthPtr(aeDesc, i + 1, OS.typeFSRef, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
                byte[] fsRef = new byte[actualSize[0]];
                C.memmove(fsRef, dataPtr, actualSize[0]);
                int dirUrl = OS.CFURLCreateFromFSRef(OS.kCFAllocatorDefault, fsRef);
                int dirString = OS.CFURLCopyFileSystemPath(dirUrl,OS.kCFURLPOSIXPathStyle);
                OS.CFRelease(dirUrl);
                int length = OS.CFStringGetLength(dirString);
                char[] buffer = new char[length];
                CFRange range = new CFRange();
                range.length = length;
                OS.CFStringGetCharacters(dirString, range, buffer);
                OS.CFRelease(dirString);
                fileNames[i] = new String(buffer);
            }

            if (OS.AEGetNthPtr(aeDesc, i + 1, typeText, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
                byte[] urlRef = new byte[actualSize[0]];
                C.memmove(urlRef, dataPtr, actualSize[0]);
                fileNames[i] = new String(urlRef);
            }
        }

        if( fileNames.length > 0 ){
            OpenDocAction.saveAndOpen( fileNames[0] );
        }
    }

    return OS.noErr;
}
项目:totallicks-tuxguitar    文件:TGCocoa.java   
public static final Callback newCallback(Object object, String method64, String method32, int argCount) throws Throwable {
    return new Callback( object, ( C.PTR_SIZEOF == 8 ? method64 : method32 ) , argCount );
}
项目:totallicks-tuxguitar    文件:TGCocoa.java   
private static Object osType( long value ) {
    return ( C.PTR_SIZEOF == 8 ? ((Object)new Long(value)) : ((Object)new Integer((int)value)) );
}
项目:totallicks-tuxguitar    文件:OpenDocListener.java   
public int openDocProc(int theAppleEvent, int reply, int handlerRefcon) {
    if(!this.isEnabled()){
        return OS.noErr;
    }
    AEDesc aeDesc = new AEDesc();
    EventRecord eventRecord = new EventRecord();
    OS.ConvertEventRefToEventRecord(theAppleEvent, eventRecord);
    try {
        int result = OpenDocJNI.AEGetParamDesc(theAppleEvent,OS.kEventParamDirectObject, typeAEList, aeDesc);
        if (result != OS.noErr) {
            System.err.println("OSX: Could call AEGetParamDesc. Error: " + result);
            return OS.noErr;
        }
    } catch (java.lang.UnsatisfiedLinkError e) {
        System.err.println("OSX: AEGetParamDesc not available.  Can't open sent file");
        return OS.noErr;
    }
    int[] count = new int[1];
    OS.AECountItems(aeDesc, count);

    if (count[0] > 0) {
        String[] fileNames = new String[count[0]];
        int maximumSize = 80; // size of FSRef
        int dataPtr = OS.NewPtr(maximumSize);
        int[] aeKeyword = new int[1];
        int[] typeCode = new int[1];
        int[] actualSize = new int[1];
        for (int i = 0; i < count[0]; i++) {
            if (OS.AEGetNthPtr(aeDesc, i + 1, OS.typeFSRef, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
                byte[] fsRef = new byte[actualSize[0]];
                C.memmove(fsRef, dataPtr, actualSize[0]);
                int dirUrl = OS.CFURLCreateFromFSRef(OS.kCFAllocatorDefault, fsRef);
                int dirString = OS.CFURLCopyFileSystemPath(dirUrl,OS.kCFURLPOSIXPathStyle);
                OS.CFRelease(dirUrl);
                int length = OS.CFStringGetLength(dirString);
                char[] buffer = new char[length];
                CFRange range = new CFRange();
                range.length = length;
                OS.CFStringGetCharacters(dirString, range, buffer);
                OS.CFRelease(dirString);
                fileNames[i] = new String(buffer);
            }

            if (OS.AEGetNthPtr(aeDesc, i + 1, typeText, aeKeyword,typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) {
                byte[] urlRef = new byte[actualSize[0]];
                C.memmove(urlRef, dataPtr, actualSize[0]);
                fileNames[i] = new String(urlRef);
            }
        }

        if( fileNames.length > 0 ){
            OpenDocAction.saveAndOpen( fileNames[0] );
        }
    }

    return OS.noErr;
}