Java 类org.eclipse.swt.internal.cocoa.NSToolbar 实例源码

项目: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_ );
        }
    }
}
项目: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_ );
        }
    }
}