view dwt/internal/cocoa/NSImageRep.d @ 13:f565d3a95c0a

Ported dwt.internal
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 22 Aug 2008 16:46:34 +0200
parents 8b48be5454ce
children d8635bb48c7c
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.NSImageRep;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPasteboard;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSImageRep : NSObject
{

    public this ()
    {
        super();
    }

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

    public NSInteger bitsPerSample ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_bitsPerSample);
    }

    public static bool canInitWithData (NSData data)
    {
        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithData_1, data !is null ? data.id_ : null) !is null;
    }

    public static bool canInitWithPasteboard (NSPasteboard pasteboard)
    {
        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null) !is null;
    }

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

    public bool draw ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_draw) !is null;
    }

    public bool drawAtPoint (NSPoint point)
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawAtPoint_1, point) !is null;
    }

    public bool drawInRect (NSRect rect)
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawInRect_1, rect) !is null;
    }

    public bool hasAlpha ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_hasAlpha) !is null;
    }

    public static NSArray imageFileTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageFileTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imagePasteboardTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imagePasteboardTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public static objc.Class imageRepClassForData (NSData data)
    {
        return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForData_1, data !is null ? data.id_ : null);
    }

    public static objc.Class imageRepClassForFileType (NSString type)
    {
        return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForFileType_1, type !is null ? type.id_ : null);
    }

    public static objc.Class imageRepClassForPasteboardType (NSString type)
    {
        return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForPasteboardType_1, type !is null ? type.id_ : null);
    }

    public static objc.Class imageRepClassForType (NSString type)
    {
        return cast(objc.Class) OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForType_1, type !is null ? type.id_ : null);
    }

    public static id imageRepWithContentsOfFile (NSString filename)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfFile_1, filename !is null ? filename.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id imageRepWithContentsOfURL (NSURL url)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfURL_1, url !is null ? url.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id imageRepWithPasteboard (NSPasteboard pasteboard)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static NSArray imageRepsWithContentsOfFile (NSString filename)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfFile_1, filename !is null ? filename.id_ : null);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageRepsWithContentsOfURL (NSURL url)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfURL_1, url !is null ? url.id_ : null);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageRepsWithPasteboard (NSPasteboard pasteboard)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageUnfilteredFileTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredFileTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageUnfilteredPasteboardTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredPasteboardTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public static NSArray imageUnfilteredTypes ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredTypes);
        return result !is null ? new NSArray(result) : null;
    }

    public bool isOpaque ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isOpaque) !is null;
    }

    public NSInteger pixelsHigh ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_pixelsHigh);
    }

    public NSInteger pixelsWide ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_pixelsWide);
    }

    public static void registerImageRepClass (objc.Class imageRepClass)
    {
        OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registerImageRepClass_1, imageRepClass);
    }

    public static NSArray registeredImageRepClasses ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registeredImageRepClasses);
        return result !is null ? new NSArray(result) : null;
    }

    public void setAlpha (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAlpha_1, flag);
    }

    public void setBitsPerSample (NSInteger anInt)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBitsPerSample_1, anInt);
    }

    public void setColorSpaceName (NSString string)
    {
        OS.objc_msgSend(this.id_, OS.sel_setColorSpaceName_1, string !is null ? string.id_ : null);
    }

    public void setOpaque (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setOpaque_1, flag);
    }

    public void setPixelsHigh (NSInteger anInt)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPixelsHigh_1, anInt);
    }

    public void setPixelsWide (NSInteger anInt)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPixelsWide_1, anInt);
    }

    public void setSize (NSSize aSize)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSize_1, aSize);
    }

    public NSSize size ()
    {
        NSSize result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_size);
        return result;
    }

    public static void unregisterImageRepClass (objc.Class imageRepClass)
    {
        OS.objc_msgSend(OS.class_NSImageRep, OS.sel_unregisterImageRepClass_1, imageRepClass);
    }

}