view dwt/internal/cocoa/NSPasteboard.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D Programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSPasteboard;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSFileWrapper;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSPasteboard : NSObject
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public NSInteger addTypes (NSArray newTypes, id newOwner)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_addTypes_1owner_1, newTypes !is null ? newTypes.id_ : null, newOwner !is null ? newOwner.id_ : null);
    }

    public NSString availableTypeFromArray (NSArray types)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableTypeFromArray_1, types !is null ? types.id_ : null);
        return result !is null ? new NSString(result) : null;
    }

    public NSInteger changeCount ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_changeCount);
    }

    public NSData dataForType (NSString dataType)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_dataForType_1, dataType !is null ? dataType.id_ : null);
        return result !is null ? new NSData(result) : null;
    }

    public NSInteger declareTypes (NSArray newTypes, id newOwner)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_declareTypes_1owner_1, newTypes !is null ? newTypes.id_ : null, newOwner !is null ? newOwner.id_ : null);
    }

    public static NSPasteboard generalPasteboard ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_generalPasteboard);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public NSString name ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_name);
        return result !is null ? new NSString(result) : null;
    }

    public static NSPasteboard pasteboardByFilteringData (NSData data, NSString type)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringData_1ofType_1, data !is null ? data.id_ : null,
                type !is null ? type.id_ : null);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public static NSPasteboard pasteboardByFilteringFile (NSString filename)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringFile_1, filename !is null ? filename.id_ : null);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public static NSPasteboard pasteboardByFilteringTypesInPasteboard (NSPasteboard pboard)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringTypesInPasteboard_1, pboard !is null ? pboard.id_ : null);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public static NSPasteboard pasteboardWithName (NSString name)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithName_1, name !is null ? name.id_ : null);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public static NSPasteboard pasteboardWithUniqueName ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithUniqueName);
        return result !is null ? new NSPasteboard(result) : null;
    }

    public id propertyListForType (NSString dataType)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_propertyListForType_1, dataType !is null ? dataType.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public NSString readFileContentsType (NSString type, NSString filename)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_readFileContentsType_1toFile_1, type !is null ? type.id_ : null,
                filename !is null ? filename.id_ : null);
        return result !is null ? new NSString(result) : null;
    }

    public NSFileWrapper readFileWrapper ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_readFileWrapper);
        return result !is null ? new NSFileWrapper(result) : null;
    }

    public void releaseGlobally ()
    {
        OS.objc_msgSend(this.id_, OS.sel_releaseGlobally);
    }

    public bool setData (NSData data, NSString dataType)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setData_1forType_1, data !is null ? data.id_ : null, dataType !is null ? dataType.id_ : null) !is null;
    }

    public bool setPropertyList (id plist, NSString dataType)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setPropertyList_1forType_1, plist !is null ? plist.id_ : null, dataType !is null ? dataType.id_ : null) !is null;
    }

    public bool setString (NSString string, NSString dataType)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setString_1forType_1, string !is null ? string.id_ : null, dataType !is null ? dataType.id_ : null) !is null;
    }

    public NSString stringForType (NSString dataType)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringForType_1, dataType !is null ? dataType.id_ : null);
        return result !is null ? new NSString(result) : null;
    }

    public NSArray types ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_types);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray typesFilterableTo (NSString type)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_typesFilterableTo_1, type !is null ? type.id_ : null);
        return result !is null ? new NSArray(result) : null;
    }

    public bool writeFileContents (NSString filename)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeFileContents_1, filename !is null ? filename.id_ : null) !is null;
    }

    public bool writeFileWrapper (NSFileWrapper wrapper)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeFileWrapper_1, wrapper !is null ? wrapper.id_ : null) !is null;
    }

}