view dstep/appkit/NSGraphics.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
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.NSGraphics;

import dstep.appkit.AppKitDefines;
import dstep.appkit.NSColor;
import dstep.appkit.NSView;
import dstep.applicationservices.coregraphics.CGBase;
import dstep.foundation.NSGeometry;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

import bindings = dstep.appkit.NSGraphics_bindings;

alias NSUInteger NSCompositingOperation;
alias NSUInteger NSBackingStoreType;
alias NSInteger NSWindowOrderingMode;
alias NSUInteger NSFocusRingPlacement;
alias NSUInteger NSFocusRingType;
alias int NSWindowDepth;
alias NSUInteger NSAnimationEffect;

extern (C)
{
	extern
	{
		const CGFloat NSWhite;
		const CGFloat NSLightGray;
		const CGFloat NSDarkGray;
		const CGFloat NSBlack;
	}
}

private
{
	NSString NSCalibratedWhiteColorSpace_;
	NSString NSCalibratedBlackColorSpace_;
	NSString NSCalibratedRGBColorSpace_;
	NSString NSDeviceWhiteColorSpace_;
	NSString NSDeviceBlackColorSpace_;
	NSString NSDeviceRGBColorSpace_;
	NSString NSDeviceCMYKColorSpace_;
	NSString NSNamedColorSpace_;
	NSString NSPatternColorSpace_;
	NSString NSCustomColorSpace_;
	NSString NSDeviceResolution_;
	NSString NSDeviceColorSpaceName_;
	NSString NSDeviceBitsPerSample_;
	NSString NSDeviceIsScreen_;
	NSString NSDeviceIsPrinter_;
	NSString NSDeviceSize_;
}

NSString NSCalibratedWhiteColorSpace ()
{
	if (NSCalibratedWhiteColorSpace_)
		return NSCalibratedWhiteColorSpace_;

	return NSCalibratedWhiteColorSpace_ = new NSString(bindings.NSCalibratedWhiteColorSpace);
}

NSString NSCalibratedBlackColorSpace ()
{
	if (NSCalibratedBlackColorSpace_)
		return NSCalibratedBlackColorSpace_;

	return NSCalibratedBlackColorSpace_ = new NSString(bindings.NSCalibratedBlackColorSpace);
}

NSString NSCalibratedRGBColorSpace ()
{
	if (NSCalibratedRGBColorSpace_)
		return NSCalibratedRGBColorSpace_;

	return NSCalibratedRGBColorSpace_ = new NSString(bindings.NSCalibratedRGBColorSpace);
}

NSString NSDeviceWhiteColorSpace ()
{
	if (NSDeviceWhiteColorSpace_)
		return NSDeviceWhiteColorSpace_;

	return NSDeviceWhiteColorSpace_ = new NSString(bindings.NSDeviceWhiteColorSpace);
}

NSString NSDeviceBlackColorSpace ()
{
	if (NSDeviceBlackColorSpace_)
		return NSDeviceBlackColorSpace_;

	return NSDeviceBlackColorSpace_ = new NSString(bindings.NSDeviceBlackColorSpace);
}

NSString NSDeviceRGBColorSpace ()
{
	if (NSDeviceRGBColorSpace_)
		return NSDeviceRGBColorSpace_;

	return NSDeviceRGBColorSpace_ = new NSString(bindings.NSDeviceRGBColorSpace);
}

NSString NSDeviceCMYKColorSpace ()
{
	if (NSDeviceCMYKColorSpace_)
		return NSDeviceCMYKColorSpace_;

	return NSDeviceCMYKColorSpace_ = new NSString(bindings.NSDeviceCMYKColorSpace);
}

NSString NSNamedColorSpace ()
{
	if (NSNamedColorSpace_)
		return NSNamedColorSpace_;

	return NSNamedColorSpace_ = new NSString(bindings.NSNamedColorSpace);
}

NSString NSPatternColorSpace ()
{
	if (NSPatternColorSpace_)
		return NSPatternColorSpace_;

	return NSPatternColorSpace_ = new NSString(bindings.NSPatternColorSpace);
}

NSString NSCustomColorSpace ()
{
	if (NSCustomColorSpace_)
		return NSCustomColorSpace_;

	return NSCustomColorSpace_ = new NSString(bindings.NSCustomColorSpace);
}

NSString NSDeviceResolution ()
{
	if (NSDeviceResolution_)
		return NSDeviceResolution_;

	return NSDeviceResolution_ = new NSString(bindings.NSDeviceResolution);
}

NSString NSDeviceColorSpaceName ()
{
	if (NSDeviceColorSpaceName_)
		return NSDeviceColorSpaceName_;

	return NSDeviceColorSpaceName_ = new NSString(bindings.NSDeviceColorSpaceName);
}

NSString NSDeviceBitsPerSample ()
{
	if (NSDeviceBitsPerSample_)
		return NSDeviceBitsPerSample_;

	return NSDeviceBitsPerSample_ = new NSString(bindings.NSDeviceBitsPerSample);
}

NSString NSDeviceIsScreen ()
{
	if (NSDeviceIsScreen_)
		return NSDeviceIsScreen_;

	return NSDeviceIsScreen_ = new NSString(bindings.NSDeviceIsScreen);
}

NSString NSDeviceIsPrinter ()
{
	if (NSDeviceIsPrinter_)
		return NSDeviceIsPrinter_;

	return NSDeviceIsPrinter_ = new NSString(bindings.NSDeviceIsPrinter);
}

NSString NSDeviceSize ()
{
	if (NSDeviceSize_)
		return NSDeviceSize_;

	return NSDeviceSize_ = new NSString(bindings.NSDeviceSize);
}

enum
{
	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
{
	NSBackingStoreRetained = 0,
	NSBackingStoreNonretained = 1,
	NSBackingStoreBuffered = 2
}

enum
{
	NSWindowAbove = 1,
	NSWindowBelow = -1,
	NSWindowOut = 0
}

enum
{
	NSFocusRingOnly = 0,
	NSFocusRingBelow = 1,
	NSFocusRingAbove = 2
}

enum
{
	NSFocusRingTypeDefault = 0,
	NSFocusRingTypeNone = 1,
	NSFocusRingTypeExterior = 2
}

enum
{
	NSAnimationEffectDisappearingItemDefault = 0,
	NSAnimationEffectPoof = 10
}
/*
int NSBestDepth (NSString colorSpace, NSInteger bps, NSInteger bpp, bool planar, bool* exactMatch)
{
	return Bridge.invokeObjcFunction!(int, bindings.NSBestDepth, NSString, NSInteger, NSInteger, bool, bool*)(colorSpace, bps, bpp, planar, exactMatch);
}

NSString NSColorSpaceFromDepth (int depth)
{
	return Bridge.invokeObjcFunction!(NSString, bindings.NSColorSpaceFromDepth, int)(depth);
}

NSInteger NSNumberOfColorComponents (NSString colorSpaceName)
{
	return Bridge.invokeObjcFunction!(NSInteger, bindings.NSNumberOfColorComponents, NSString)(colorSpaceName);
}

NSColor NSReadPixel (NSPoint passedPoint)
{
	return Bridge.invokeObjcFunction!(NSColor, bindings.NSReadPixel, NSPoint)(passedPoint);
}

void NSDrawBitmap (NSRect rect, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, NSInteger bpp, NSInteger bpr, bool isPlanar, bool hasAlpha, NSString colorSpaceName, char*[5] data)
{
	return Bridge.invokeObjcFunction!(void, bindings.NSDrawBitmap, NSRect, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, bool, bool, NSString, char*[5])(rect, width, height, bps, spp, bpp, bpr, isPlanar, hasAlpha, colorSpaceName, data);
}

void NSShowAnimationEffect (uint animationEffect, NSPoint centerLocation, NSSize size, Object animationDelegate, SEL didEndSelector, void* contextInfo)
{
	return Bridge.invokeObjcFunction!(void, bindings.NSShowAnimationEffect, uint, NSPoint, NSSize, Object, SEL, void*)(animationEffect, centerLocation, size, animationDelegate, didEndSelector, contextInfo);
}
*/
extern (C)
{
	bool NSPlanarFromDepth (int depth);
	NSInteger NSBitsPerSampleFromDepth (int depth);
	NSInteger NSBitsPerPixelFromDepth (int depth);
	NSWindowDepth* NSAvailableWindowDepths ();
	void NSRectFill (NSRect aRect);
	void NSRectFillList (NSRect* rects, NSInteger count);
	void NSRectFillListWithGrays (NSRect* rects, CGFloat* grays, NSInteger num);
	void NSRectFillListWithColors (NSRect* rects, NSColor** colors, NSInteger num);
	void NSRectFillUsingOperation (NSRect aRect, uint op);
	void NSRectFillListUsingOperation (NSRect* rects, NSInteger count, uint op);
	void NSRectFillListWithColorsUsingOperation (NSRect* rects, NSColor** colors, NSInteger num, uint op);
	void NSFrameRect (NSRect aRect);
	void NSFrameRectWithWidth (NSRect aRect, CGFloat frameWidth);
	void NSFrameRectWithWidthUsingOperation (NSRect aRect, CGFloat frameWidth, uint op);
	void NSRectClip (NSRect aRect);
	void NSRectClipList (NSRect* rects, NSInteger count);
	NSRect NSDrawTiledRects (NSRect boundsRect, NSRect clipRect, NSRectEdge* sides, CGFloat* grays, NSInteger count);
	void NSDrawGrayBezel (NSRect aRect, NSRect clipRect);
	void NSDrawGroove (NSRect aRect, NSRect clipRect);
	void NSDrawWhiteBezel (NSRect aRect, NSRect clipRect);
	void NSDrawButton (NSRect aRect, NSRect clipRect);
	void NSEraseRect (NSRect aRect);
	void NSCopyBits (NSInteger srcGState, NSRect srcRect, NSPoint destPoint);
	void NSHighlightRect (NSRect aRect);
	void NSBeep ();
	void NSCountWindows (NSInteger* count);
	void NSWindowList (NSInteger size, NSInteger* list);
	void NSCountWindowsForContext (NSInteger context, NSInteger* count);
	void NSWindowListForContext (NSInteger context, NSInteger size, NSInteger* list);
	NSInteger NSGetWindowServerMemory (NSInteger context, NSInteger* virtualMemory, NSInteger* windowBackingMemory, NSString** windowDumpString);
	NSRect NSDrawColorTiledRects (NSRect boundsRect, NSRect clipRect, NSRectEdge* sides, NSColor** colors, NSInteger count);
	void NSDrawDarkBezel (NSRect aRect, NSRect clipRect);
	void NSDrawLightBezel (NSRect aRect, NSRect clipRect);
	void NSDottedFrameRect (NSRect aRect);
	void NSDrawWindowBackground (NSRect aRect);
	void NSSetFocusRingStyle (uint placement);
	void NSDisableScreenUpdates ();
	void NSEnableScreenUpdates ();
}