view dwt/internal/cocoa/NSImage.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.NSImage;

import dwt.internal.cocoa.CGFloat;
import dwt.internal.cocoa.IconRef;
import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSBitmapImageRep : NSTIFFCompression;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSImageRep;
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;

enum NSCompositingOperation : NSUInteger
{
    NSCompositeClear = 0,
    NSCompositeCopy = 1,
    NSCompositeSourceOver = 2,
    NSCompositeSourceIn = 3,
    NSCompositeSourceOut = 4,
    NSCompositeSourceAtop = 5,
    NSCompositeDestinationOver = 6,
    NSCompositeDestinationIn = 7,
    NSCompositeDestinationOut = 8,
    NSCompositeDestinationAtop = 9,
    NSCompositeXOR = 10,
    NSCompositePlusDarker = 11,
    NSCompositeHighlight = 12,
    NSCompositePlusLighter = 13
}

alias NSCompositingOperation.NSCompositeClear NSCompositeClear;
alias NSCompositingOperation.NSCompositeCopy NSCompositeCopy;
alias NSCompositingOperation.NSCompositeSourceOver NSCompositeSourceOver;
alias NSCompositingOperation.NSCompositeSourceIn NSCompositeSourceIn;
alias NSCompositingOperation.NSCompositeSourceOut NSCompositeSourceOut;
alias NSCompositingOperation.NSCompositeSourceAtop NSCompositeSourceAtop;
alias NSCompositingOperation.NSCompositeDestinationOver NSCompositeDestinationOver;
alias NSCompositingOperation.NSCompositeDestinationIn NSCompositeDestinationIn;
alias NSCompositingOperation.NSCompositeDestinationOut NSCompositeDestinationOut;
alias NSCompositingOperation.NSCompositeDestinationAtop NSCompositeDestinationAtop;
alias NSCompositingOperation.NSCompositeXOR NSCompositeXOR;
alias NSCompositingOperation.NSCompositePlusDarker NSCompositePlusDarker;
alias NSCompositingOperation.NSCompositeHighlight NSCompositeHighlight;
alias NSCompositingOperation.NSCompositePlusLighter NSCompositePlusLighter;

enum NSImageCacheMode : NSUInteger
{
    NSImageCacheDefault,
    NSImageCacheAlways,
    NSImageCacheBySize,
    NSImageCacheNever
}

alias NSImageCacheMode.NSImageCacheDefault NSImageCacheDefault;
alias NSImageCacheMode.NSImageCacheAlways NSImageCacheAlways;
alias NSImageCacheMode.NSImageCacheBySize NSImageCacheBySize;
alias NSImageCacheMode.NSImageCacheNever NSImageCacheNever;

public class NSImage : NSObject
{

    public this ()
    {
        super();
    }

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

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

    public NSData TIFFRepresentationUsingCompression (NSTIFFCompression comp, float aFloat)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, aFloat);
        return result !is null ? new NSData(result) : null;
    }

    public void addRepresentation (NSImageRep imageRep)
    {
        OS.objc_msgSend(this.id_, OS.sel_addRepresentation_1, imageRep !is null ? imageRep.id_ : null);
    }

    public void addRepresentations (NSArray imageReps)
    {
        OS.objc_msgSend(this.id_, OS.sel_addRepresentations_1, imageReps !is null ? imageReps.id_ : null);
    }

    public NSRect alignmentRect ()
    {
        NSRect result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_alignmentRect);
        return result;
    }

    public NSColor backgroundColor ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
        return result !is null ? new NSColor(result) : null;
    }

    public NSImageRep bestRepresentationForDevice (NSDictionary deviceDescription)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_bestRepresentationForDevice_1, deviceDescription !is null ? deviceDescription.id_ : null);
        return result !is null ? new NSImageRep(result) : null;
    }

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

    public NSImageCacheMode cacheMode ()
    {
        return cast(NSImageCacheMode) OS.objc_msgSend(this.id_, OS.sel_cacheMode);
    }

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

    public void cancelIncrementalLoad ()
    {
        OS.objc_msgSend(this.id_, OS.sel_cancelIncrementalLoad);
    }

    public void compositeToPoint_fromRect_operation_ (NSPoint point, NSRect rect, NSCompositingOperation op)
    {
        OS.objc_msgSend(this.id_, OS.sel_compositeToPoint_1fromRect_1operation_1, point, rect, op);
    }

    public void compositeToPoint_fromRect_operation_fraction_ (NSPoint point, NSRect rect, NSCompositingOperation op, CGFloat delta)
    {
        OS.objc_msgSend(this.id_, OS.sel_compositeToPoint_1fromRect_1operation_1fraction_1, point, rect, op, delta);
    }

    public void compositeToPoint_operation_ (NSPoint point, NSCompositingOperation op)
    {
        OS.objc_msgSend(this.id_, OS.sel_compositeToPoint_1operation_1, point, op);
    }

    public void compositeToPoint_operation_fraction_ (NSPoint point, NSCompositingOperation op, CGFloat delta)
    {
        OS.objc_msgSend(this.id_, OS.sel_compositeToPoint_1operation_1fraction_1, point, op, delta);
    }

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

    public void dissolveToPoint_fraction_ (NSPoint point, CGFloat aFloat)
    {
        OS.objc_msgSend(this.id_, OS.sel_dissolveToPoint_1fraction_1, point, aFloat);
    }

    public void dissolveToPoint_fromRect_fraction_ (NSPoint point, NSRect rect, CGFloat aFloat)
    {
        OS.objc_msgSend(this.id_, OS.sel_dissolveToPoint_1fromRect_1fraction_1, point, rect, aFloat);
    }

    public void drawAtPoint (NSPoint point, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
    {
        OS.objc_msgSend(this.id_, OS.sel_drawAtPoint_1fromRect_1operation_1fraction_1, point, fromRect, op, delta);
    }

    public void drawInRect (NSRect rect, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
    {
        OS.objc_msgSend(this.id_, OS.sel_drawInRect_1fromRect_1operation_1fraction_1, rect, fromRect, op, delta);
    }

    public bool drawRepresentation (NSImageRep imageRep, NSRect rect)
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawRepresentation_1inRect_1, imageRep !is null ? imageRep.id_ : null, rect) !is null;
    }

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

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

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

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

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

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

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

    public NSImage initByReferencingFile (NSString fileName)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initByReferencingFile_1, fileName !is null ? fileName.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initByReferencingURL (NSURL url)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initByReferencingURL_1, url !is null ? url.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initWithContentsOfFile (NSString fileName)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, fileName !is null ? fileName.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initWithContentsOfURL (NSURL url)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initWithData (NSData data)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithData_1, data !is null ? data.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initWithIconRef (IconRef iconRef)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithIconRef_1, iconRef);
        return result !is null ? this : null;
    }

    public NSImage initWithPasteboard (NSPasteboard pasteboard)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithPasteboard_1, pasteboard !is null ? pasteboard.id_ : null);
        return result !is null ? this : null;
    }

    public NSImage initWithSize (NSSize aSize)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSize_1, aSize);
        return result !is null ? this : null;
    }

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

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

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

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

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

    public void lockFocus ()
    {
        OS.objc_msgSend(this.id_, OS.sel_lockFocus);
    }

    public void lockFocusOnRepresentation (NSImageRep imageRepresentation)
    {
        OS.objc_msgSend(this.id_, OS.sel_lockFocusOnRepresentation_1, imageRepresentation !is null ? imageRepresentation.id_ : null);
    }

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

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

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

    public void recache ()
    {
        OS.objc_msgSend(this.id_, OS.sel_recache);
    }

    public void removeRepresentation (NSImageRep imageRep)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeRepresentation_1, imageRep !is null ? imageRep.id_ : null);
    }

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

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

    public void setAlignmentRect (NSRect rect)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAlignmentRect_1, rect);
    }

    public void setBackgroundColor (NSColor aColor)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, aColor !is null ? aColor.id_ : null);
    }

    public void setCacheDepthMatchesImageDepth (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCacheDepthMatchesImageDepth_1, flag);
    }

    public void setCacheMode (NSImageCacheMode mode)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCacheMode_1, mode);
    }

    public void setCachedSeparately (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCachedSeparately_1, flag);
    }

    public void setDataRetained (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDataRetained_1, flag);
    }

    public void setDelegate (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
    }

    public void setFlipped (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setFlipped_1, flag);
    }

    public void setMatchesOnMultipleResolution (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setMatchesOnMultipleResolution_1, flag);
    }

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

    public void setPrefersColorMatch (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPrefersColorMatch_1, flag);
    }

    public void setScalesWhenResized (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setScalesWhenResized_1, flag);
    }

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

    public void setTemplate (bool isTemplate)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTemplate_1, isTemplate);
    }

    public void setUsesEPSOnResolutionMismatch (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setUsesEPSOnResolutionMismatch_1, flag);
    }

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

    public void unlockFocus ()
    {
        OS.objc_msgSend(this.id_, OS.sel_unlockFocus);
    }

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

}