Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSImage.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSImage.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,440 @@ +/******************************************************************************* + * 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.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 +{ + 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 +} + +enum NSImageCacheMode +{ + NSImageCacheDefault, + NSImageCacheAlways, + NSImageCacheBySize, + 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 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; + } + +}