diff dwt/internal/cocoa/NSGraphicsContext.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/NSGraphicsContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * 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.NSGraphicsContext;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImage : NSCompositingOperation;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSColorRenderingIntent;
+
+enum
+{
+    NSColorRenderingIntentDefault,
+    NSColorRenderingIntentAbsoluteColorimetric,
+    NSColorRenderingIntentRelativeColorimetric,
+    NSColorRenderingIntentPerceptual,
+    NSColorRenderingIntentSaturation
+}
+
+enum NSImageInterpolation
+{
+    NSImageInterpolationDefault,
+    NSImageInterpolationNone,
+    NSImageInterpolationLow,
+    NSImageInterpolationHigh
+}
+
+public class NSGraphicsContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    //public CIContext CIContext() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_CIContext);
+    //  return result !is null ? new CIContext(result) : null;
+    //}
+
+    public NSDictionary attributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSColorRenderingIntent colorRenderingIntent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_colorRenderingIntent);
+    }
+
+    public NSCompositingOperation compositingOperation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compositingOperation);
+    }
+
+    public static NSGraphicsContext currentContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContext);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static bool currentContextDrawingToScreen ()
+    {
+        return OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContextDrawingToScreen) !is null;
+    }
+
+    public void flushGraphics ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushGraphics);
+    }
+
+    public id focusStack ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_focusStack);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithAttributes_1,
+                attributes !is null ? attributes.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithBitmapImageRep (NSBitmapImageRep bitmapRep)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithBitmapImageRep_1,
+                bitmapRep !is null ? bitmapRep.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithGraphicsPort (void* graphicsPort, bool initialFlippedState)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithGraphicsPort_1flipped_1, graphicsPort,
+                initialFlippedState);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithWindow (NSWindow window)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithWindow_1, window !is null ? window.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public void* graphicsPort ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_graphicsPort);
+    }
+
+    public NSImageInterpolation imageInterpolation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageInterpolation);
+    }
+
+    public bool isDrawingToScreen ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDrawingToScreen) !is null;
+    }
+
+    public bool isFlipped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
+    }
+
+    public NSPoint patternPhase ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_patternPhase);
+        return result;
+    }
+
+    public void restoreGraphicsState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_restoreGraphicsState);
+    }
+
+    public static void static_restoreGraphicsState ()
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_restoreGraphicsState);
+    }
+
+    public void saveGraphicsState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveGraphicsState);
+    }
+
+    public static void static_saveGraphicsState ()
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_saveGraphicsState);
+    }
+
+    public void setColorRenderingIntent (NSColorRenderingIntent renderingIntent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColorRenderingIntent_1, renderingIntent);
+    }
+
+    public void setCompositingOperation (NSCompositingOperation operation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompositingOperation_1, operation);
+    }
+
+    public static void setCurrentContext (NSGraphicsContext context)
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setCurrentContext_1, context !is null ? context.id : null);
+    }
+
+    public void setFocusStack (id stack)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFocusStack_1, stack !is null ? stack.id : null);
+    }
+
+    public static void setGraphicsState (NSInteger gState)
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setGraphicsState_1, gState);
+    }
+
+    public void setImageInterpolation (NSImageInterpolation interpolation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageInterpolation_1, interpolation);
+    }
+
+    public void setPatternPhase (NSPoint phase)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPatternPhase_1, phase);
+    }
+
+    public void setShouldAntialias (bool antialias)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldAntialias_1, antialias);
+    }
+
+    public bool shouldAntialias ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldAntialias) !is null;
+    }
+
+}