Mercurial > projects > dstep
view dstep/appkit/NSGraphicsContext.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Sep 24, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.appkit.NSGraphicsContext; import dstep.appkit.AppKitDefines; import dstep.appkit.NSBitmapImageRep; import dstep.appkit.NSGraphics; import dstep.appkit.NSWindow; import dstep.foundation.NSDictionary; import dstep.foundation.NSGeometry; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import dstep.quartzcore.CIContext; import bindings = dstep.appkit.NSGraphicsContext_bindings; typedef NSUInteger NSImageInterpolation; typedef NSInteger NSColorRenderingIntent; private { NSString NSGraphicsContextDestinationAttributeName_; NSString NSGraphicsContextRepresentationFormatAttributeName_; NSString NSGraphicsContextPSFormat_; NSString NSGraphicsContextPDFFormat_; } NSString NSGraphicsContextDestinationAttributeName () { if (NSGraphicsContextDestinationAttributeName_) return NSGraphicsContextDestinationAttributeName_; return NSGraphicsContextDestinationAttributeName_ = new NSString(bindings.NSGraphicsContextDestinationAttributeName); } NSString NSGraphicsContextRepresentationFormatAttributeName () { if (NSGraphicsContextRepresentationFormatAttributeName_) return NSGraphicsContextRepresentationFormatAttributeName_; return NSGraphicsContextRepresentationFormatAttributeName_ = new NSString(bindings.NSGraphicsContextRepresentationFormatAttributeName); } NSString NSGraphicsContextPSFormat () { if (NSGraphicsContextPSFormat_) return NSGraphicsContextPSFormat_; return NSGraphicsContextPSFormat_ = new NSString(bindings.NSGraphicsContextPSFormat); } NSString NSGraphicsContextPDFFormat () { if (NSGraphicsContextPDFFormat_) return NSGraphicsContextPDFFormat_; return NSGraphicsContextPDFFormat_ = new NSString(bindings.NSGraphicsContextPDFFormat); } enum { NSImageInterpolationDefault, NSImageInterpolationNone, NSImageInterpolationLow, NSImageInterpolationHigh } enum { NSColorRenderingIntentDefault, NSColorRenderingIntentAbsoluteColorimetric, NSColorRenderingIntentRelativeColorimetric, NSColorRenderingIntentPerceptual, NSColorRenderingIntentSaturation } const TNSQuartzCoreAdditions = ` CIContext CIContext_ () { return invokeObjcSelf!(CIContext, "CIContext"); } //mixin ObjcBindMethod!(CIContext_, "CIContext"); `; const TNSGraphicsContext_RenderingOptions = ` void setShouldAntialias (bool antialias) { return invokeObjcSelf!(void, "setShouldAntialias:", bool)(antialias); } bool shouldAntialias () { return invokeObjcSelf!(bool, "shouldAntialias"); } void setImageInterpolation (uint interpolation) { return invokeObjcSelf!(void, "setImageInterpolation:", uint)(interpolation); } uint imageInterpolation () { return invokeObjcSelf!(uint, "imageInterpolation"); } void setPatternPhase (NSPoint phase) { return invokeObjcSelf!(void, "setPatternPhase:", NSPoint)(phase); } NSPoint patternPhase () { return invokeObjcSelf!(NSPoint, "patternPhase"); } void setCompositingOperation (uint operation) { return invokeObjcSelf!(void, "setCompositingOperation:", uint)(operation); } uint compositingOperation () { return invokeObjcSelf!(uint, "compositingOperation"); } int colorRenderingIntent () { return invokeObjcSelf!(int, "colorRenderingIntent"); } void setColorRenderingIntent (int renderingIntent) { return invokeObjcSelf!(void, "setColorRenderingIntent:", int)(renderingIntent); } //mixin ObjcBindMethod!(setShouldAntialias, "setShouldAntialias:"); //mixin ObjcBindMethod!(shouldAntialias, "shouldAntialias"); //mixin ObjcBindMethod!(setImageInterpolation, "setImageInterpolation:"); //mixin ObjcBindMethod!(imageInterpolation, "imageInterpolation"); //mixin ObjcBindMethod!(setPatternPhase, "setPatternPhase:"); //mixin ObjcBindMethod!(patternPhase, "patternPhase"); //mixin ObjcBindMethod!(setCompositingOperation, "setCompositingOperation:"); //mixin ObjcBindMethod!(compositingOperation, "compositingOperation"); //mixin ObjcBindMethod!(colorRenderingIntent, "colorRenderingIntent"); //mixin ObjcBindMethod!(setColorRenderingIntent, "setColorRenderingIntent:"); `; class NSGraphicsContext : NSObject { mixin (ObjcWrap); static NSGraphicsContext graphicsContextWithAttributes (NSDictionary attributes) { return invokeObjcSelfClass!(NSGraphicsContext, "graphicsContextWithAttributes:", NSDictionary)(attributes); } static NSGraphicsContext graphicsContextWithWindow (NSWindow window) { return invokeObjcSelfClass!(NSGraphicsContext, "graphicsContextWithWindow:", NSWindow)(window); } static NSGraphicsContext graphicsContextWithBitmapImageRep (NSBitmapImageRep bitmapRep) { return invokeObjcSelfClass!(NSGraphicsContext, "graphicsContextWithBitmapImageRep:", NSBitmapImageRep)(bitmapRep); } static NSGraphicsContext graphicsContextWithGraphicsPort (void* graphicsPort, bool initialFlippedState) { return invokeObjcSelfClass!(NSGraphicsContext, "graphicsContextWithGraphicsPort:flipped:", void*, bool)(graphicsPort, initialFlippedState); } static NSGraphicsContext currentContext () { return invokeObjcSelfClass!(NSGraphicsContext, "currentContext"); } static void setCurrentContext (NSGraphicsContext context) { return invokeObjcSelfClass!(void, "setCurrentContext:", NSGraphicsContext)(context); } static bool currentContextDrawingToScreen () { return invokeObjcSelfClass!(bool, "currentContextDrawingToScreen"); } static void saveGraphicsState_static () { return invokeObjcSelfClass!(void, "saveGraphicsState"); } static void restoreGraphicsState_static () { return invokeObjcSelfClass!(void, "restoreGraphicsState"); } static void setGraphicsState (NSInteger gState) { return invokeObjcSelfClass!(void, "setGraphicsState:", NSInteger)(gState); } NSDictionary attributes () { return invokeObjcSelf!(NSDictionary, "attributes"); } bool isDrawingToScreen () { return invokeObjcSelf!(bool, "isDrawingToScreen"); } void saveGraphicsState () { return invokeObjcSelf!(void, "saveGraphicsState"); } void restoreGraphicsState () { return invokeObjcSelf!(void, "restoreGraphicsState"); } void flushGraphics () { return invokeObjcSelf!(void, "flushGraphics"); } Object focusStack () { return invokeObjcSelf!(Object, "focusStack"); } void setFocusStack (Object stack) { return invokeObjcSelf!(void, "setFocusStack:", Object)(stack); } void* graphicsPort () { return invokeObjcSelf!(void*, "graphicsPort"); } bool isFlipped () { return invokeObjcSelf!(bool, "isFlipped"); } // NSQuartzCoreAdditions CIContext CIContext_ () { return invokeObjcSelf!(CIContext, "CIContext"); } // NSGraphicsContext_RenderingOptions void setShouldAntialias (bool antialias) { return invokeObjcSelf!(void, "setShouldAntialias:", bool)(antialias); } bool shouldAntialias () { return invokeObjcSelf!(bool, "shouldAntialias"); } void setImageInterpolation (uint interpolation) { return invokeObjcSelf!(void, "setImageInterpolation:", uint)(interpolation); } uint imageInterpolation () { return invokeObjcSelf!(uint, "imageInterpolation"); } void setPatternPhase (NSPoint phase) { return invokeObjcSelf!(void, "setPatternPhase:", NSPoint)(phase); } NSPoint patternPhase () { return invokeObjcSelf!(NSPoint, "patternPhase"); } void setCompositingOperation (uint operation) { return invokeObjcSelf!(void, "setCompositingOperation:", uint)(operation); } uint compositingOperation () { return invokeObjcSelf!(uint, "compositingOperation"); } int colorRenderingIntent () { return invokeObjcSelf!(int, "colorRenderingIntent"); } void setColorRenderingIntent (int renderingIntent) { return invokeObjcSelf!(void, "setColorRenderingIntent:", int)(renderingIntent); } }