diff dstep/appkit/NSEvent.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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/appkit/NSEvent.d	Sun Jan 03 22:06:11 2010 +0100
@@ -0,0 +1,533 @@
+/**
+ * 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.NSEvent;
+
+import dstep.appkit.NSGraphicsContext;
+import dstep.appkit.NSTrackingArea;
+import dstep.appkit.NSWindow;
+import dstep.applicationservices.ApplicationServices;
+import dstep.foundation.NSCoder;
+import dstep.foundation.NSDate;
+import dstep.foundation.NSGeometry;
+import dstep.foundation.NSObjCRuntime;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSString;
+import dstep.foundation.NSZone;
+//import dstep.iokit.hidsystem.IOLLEvent;
+import dstep.internal.Version;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc;
+
+typedef NSUInteger NSEventType;
+typedef NSUInteger NSPointingDeviceType;
+
+enum : NSUInteger
+{
+	NSLeftMouseDown = 1,
+	NSLeftMouseUp = 2,
+	NSRightMouseDown = 3,
+	NSRightMouseUp = 4,
+	NSMouseMoved = 5,
+	NSLeftMouseDragged = 6,
+	NSRightMouseDragged = 7,
+	NSMouseEntered = 8,
+	NSMouseExited = 9,
+	NSKeyDown = 10,
+	NSKeyUp = 11,
+	NSFlagsChanged = 12,
+	NSAppKitDefined = 13,
+	NSSystemDefined = 14,
+	NSApplicationDefined = 15,
+	NSPeriodic = 16,
+	NSCursorUpdate = 17,
+	NSScrollWheel = 22,
+	NSTabletPoint = 23,
+	NSTabletProximity = 24,
+	NSOtherMouseDown = 25,
+	NSOtherMouseUp = 26,
+	NSOtherMouseDragged = 27
+}
+
+enum : NSUInteger
+{
+	NSLeftMouseDownMask = 1 << NSLeftMouseDown,
+	NSLeftMouseUpMask = 1 << NSLeftMouseUp,
+	NSRightMouseDownMask = 1 << NSRightMouseDown,
+	NSRightMouseUpMask = 1 << NSRightMouseUp,
+	NSMouseMovedMask = 1 << NSMouseMoved,
+	NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
+	NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
+	NSMouseEnteredMask = 1 << NSMouseEntered,
+	NSMouseExitedMask = 1 << NSMouseExited,
+	NSKeyDownMask = 1 << NSKeyDown,
+	NSKeyUpMask = 1 << NSKeyUp,
+	NSFlagsChangedMask = 1 << NSFlagsChanged,
+	NSAppKitDefinedMask = 1 << NSAppKitDefined,
+	NSSystemDefinedMask = 1 << NSSystemDefined,
+	NSApplicationDefinedMask = 1 << NSApplicationDefined,
+	NSPeriodicMask = 1 << NSPeriodic,
+	NSCursorUpdateMask = 1 << NSCursorUpdate,
+	NSScrollWheelMask = 1 << NSScrollWheel,
+	NSTabletPointMask = 1 << NSTabletPoint,
+	NSTabletProximityMask = 1 << NSTabletProximity,
+	NSOtherMouseDownMask = 1 << NSOtherMouseDown,
+	NSOtherMouseUpMask = 1 << NSOtherMouseUp,
+	NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
+	NSAnyEventMask = (2147483647L * 2UL + 1UL)
+}
+
+version (D_LP64)
+{
+	enum : ulong
+	{
+		NSAlphaShiftKeyMask = 1 << 16,
+		NSShiftKeyMask = 1 << 17,
+		NSControlKeyMask = 1 << 18,
+		NSAlternateKeyMask = 1 << 19,
+		NSCommandKeyMask = 1 << 20,
+		NSNumericPadKeyMask = 1 << 21,
+		NSHelpKeyMask = 1 << 22,
+		NSFunctionKeyMask = 1 << 23,
+		NSDeviceIndependentModifierFlagsMask = 0xffff0000UL
+	}
+}
+
+else
+{
+	enum : uint
+	{
+		NSAlphaShiftKeyMask = 1 << 16,
+		NSShiftKeyMask = 1 << 17,
+		NSControlKeyMask = 1 << 18,
+		NSAlternateKeyMask = 1 << 19,
+		NSCommandKeyMask = 1 << 20,
+		NSNumericPadKeyMask = 1 << 21,
+		NSHelpKeyMask = 1 << 22,
+		NSFunctionKeyMask = 1 << 23,
+		NSDeviceIndependentModifierFlagsMask = 0xffff0000U
+	}
+}
+
+enum
+{
+	NSUnknownPointingDevice = 0,
+	NSPenPointingDevice = 1,
+	NSCursorPointingDevice = 2,
+	NSEraserPointingDevice = 3
+}
+
+enum
+{
+	NSPenTipMask = 0x0001,
+	NSPenLowerSideMask = 0x0002,
+	NSPenUpperSideMask = 0x0004
+}
+
+enum
+{
+	NSUpArrowFunctionKey = 0xF700,
+	NSDownArrowFunctionKey = 0xF701,
+	NSLeftArrowFunctionKey = 0xF702,
+	NSRightArrowFunctionKey = 0xF703,
+	NSF1FunctionKey = 0xF704,
+	NSF2FunctionKey = 0xF705,
+	NSF3FunctionKey = 0xF706,
+	NSF4FunctionKey = 0xF707,
+	NSF5FunctionKey = 0xF708,
+	NSF6FunctionKey = 0xF709,
+	NSF7FunctionKey = 0xF70A,
+	NSF8FunctionKey = 0xF70B,
+	NSF9FunctionKey = 0xF70C,
+	NSF10FunctionKey = 0xF70D,
+	NSF11FunctionKey = 0xF70E,
+	NSF12FunctionKey = 0xF70F,
+	NSF13FunctionKey = 0xF710,
+	NSF14FunctionKey = 0xF711,
+	NSF15FunctionKey = 0xF712,
+	NSF16FunctionKey = 0xF713,
+	NSF17FunctionKey = 0xF714,
+	NSF18FunctionKey = 0xF715,
+	NSF19FunctionKey = 0xF716,
+	NSF20FunctionKey = 0xF717,
+	NSF21FunctionKey = 0xF718,
+	NSF22FunctionKey = 0xF719,
+	NSF23FunctionKey = 0xF71A,
+	NSF24FunctionKey = 0xF71B,
+	NSF25FunctionKey = 0xF71C,
+	NSF26FunctionKey = 0xF71D,
+	NSF27FunctionKey = 0xF71E,
+	NSF28FunctionKey = 0xF71F,
+	NSF29FunctionKey = 0xF720,
+	NSF30FunctionKey = 0xF721,
+	NSF31FunctionKey = 0xF722,
+	NSF32FunctionKey = 0xF723,
+	NSF33FunctionKey = 0xF724,
+	NSF34FunctionKey = 0xF725,
+	NSF35FunctionKey = 0xF726,
+	NSInsertFunctionKey = 0xF727,
+	NSDeleteFunctionKey = 0xF728,
+	NSHomeFunctionKey = 0xF729,
+	NSBeginFunctionKey = 0xF72A,
+	NSEndFunctionKey = 0xF72B,
+	NSPageUpFunctionKey = 0xF72C,
+	NSPageDownFunctionKey = 0xF72D,
+	NSPrintScreenFunctionKey = 0xF72E,
+	NSScrollLockFunctionKey = 0xF72F,
+	NSPauseFunctionKey = 0xF730,
+	NSSysReqFunctionKey = 0xF731,
+	NSBreakFunctionKey = 0xF732,
+	NSResetFunctionKey = 0xF733,
+	NSStopFunctionKey = 0xF734,
+	NSMenuFunctionKey = 0xF735,
+	NSUserFunctionKey = 0xF736,
+	NSSystemFunctionKey = 0xF737,
+	NSPrintFunctionKey = 0xF738,
+	NSClearLineFunctionKey = 0xF739,
+	NSClearDisplayFunctionKey = 0xF73A,
+	NSInsertLineFunctionKey = 0xF73B,
+	NSDeleteLineFunctionKey = 0xF73C,
+	NSInsertCharFunctionKey = 0xF73D,
+	NSDeleteCharFunctionKey = 0xF73E,
+	NSPrevFunctionKey = 0xF73F,
+	NSNextFunctionKey = 0xF740,
+	NSSelectFunctionKey = 0xF741,
+	NSExecuteFunctionKey = 0xF742,
+	NSUndoFunctionKey = 0xF743,
+	NSRedoFunctionKey = 0xF744,
+	NSFindFunctionKey = 0xF745,
+	NSHelpFunctionKey = 0xF746,
+	NSModeSwitchFunctionKey = 0xF747
+}
+
+enum
+{
+	NSWindowExposedEventType = 0,
+	NSApplicationActivatedEventType = 1,
+	NSApplicationDeactivatedEventType = 2,
+	NSWindowMovedEventType = 4,
+	NSScreenChangedEventType = 8,
+	NSAWTEventType = 16
+}
+
+enum
+{
+	NSPowerOffEventType = 1
+}
+
+enum
+{
+	NSMouseEventSubtype = 0,
+	NSTabletPointEventSubtype = 1,
+	NSTabletProximityEventSubtype = 2
+}
+
+class NSEvent : NSObject, INSCopying, INSCoding
+{
+	mixin (ObjcWrap);
+	
+	this (NSCoder aDecoder)
+	{
+		super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
+	}
+	
+	void encodeWithCoder (NSCoder aCoder)
+	{
+		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
+	}
+	
+	typeof(this) initWithCoder (NSCoder aDecoder)
+	{
+		return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
+	}
+	
+	typeof(this) copyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
+	}
+
+	uint type ()
+	{
+		return invokeObjcSelf!(uint, "type");
+	}
+
+	NSUInteger modifierFlags ()
+	{
+		return invokeObjcSelf!(NSUInteger, "modifierFlags");
+	}
+
+	double timestamp ()
+	{
+		return invokeObjcSelf!(double, "timestamp");
+	}
+
+	NSWindow window ()
+	{
+		return invokeObjcSelf!(NSWindow, "window");
+	}
+
+	NSInteger windowNumber ()
+	{
+		return invokeObjcSelf!(NSInteger, "windowNumber");
+	}
+
+	NSGraphicsContext context ()
+	{
+		return invokeObjcSelf!(NSGraphicsContext, "context");
+	}
+
+	NSInteger clickCount ()
+	{
+		return invokeObjcSelf!(NSInteger, "clickCount");
+	}
+
+	NSInteger buttonNumber ()
+	{
+		return invokeObjcSelf!(NSInteger, "buttonNumber");
+	}
+
+	NSInteger eventNumber ()
+	{
+		return invokeObjcSelf!(NSInteger, "eventNumber");
+	}
+
+	float pressure ()
+	{
+		return invokeObjcSelf!(float, "pressure");
+	}
+
+	NSPoint locationInWindow ()
+	{
+		return invokeObjcSelf!(NSPoint, "locationInWindow");
+	}
+
+	CGFloat deltaX ()
+	{
+		return invokeObjcSelf!(CGFloat, "deltaX");
+	}
+
+	CGFloat deltaY ()
+	{
+		return invokeObjcSelf!(CGFloat, "deltaY");
+	}
+
+	CGFloat deltaZ ()
+	{
+		return invokeObjcSelf!(CGFloat, "deltaZ");
+	}
+
+	NSString characters ()
+	{
+		return invokeObjcSelf!(NSString, "characters");
+	}
+
+	NSString charactersIgnoringModifiers ()
+	{
+		return invokeObjcSelf!(NSString, "charactersIgnoringModifiers");
+	}
+
+	bool isARepeat ()
+	{
+		return invokeObjcSelf!(bool, "isARepeat");
+	}
+
+	ushort keyCode ()
+	{
+		return invokeObjcSelf!(ushort, "keyCode");
+	}
+
+	NSInteger trackingNumber ()
+	{
+		return invokeObjcSelf!(NSInteger, "trackingNumber");
+	}
+
+	void* userData ()
+	{
+		return invokeObjcSelf!(void*, "userData");
+	}
+
+	NSTrackingArea trackingArea ()
+	{
+		return invokeObjcSelf!(NSTrackingArea, "trackingArea");
+	}
+
+	short subtype ()
+	{
+		return invokeObjcSelf!(short, "subtype");
+	}
+
+	NSInteger data1 ()
+	{
+		return invokeObjcSelf!(NSInteger, "data1");
+	}
+
+	NSInteger data2 ()
+	{
+		return invokeObjcSelf!(NSInteger, "data2");
+	}
+
+	void* eventRef ()
+	{
+		return invokeObjcSelf!(void*, "eventRef");
+	}
+
+	static NSEvent eventWithEventRef (void* eventRef)
+	{
+		return invokeObjcSelfClass!(NSEvent, "eventWithEventRef:", void*)(eventRef);
+	}
+
+	CGEventRef CGEvent ()
+	{
+		return invokeObjcSelf!(CGEventRef, "CGEvent");
+	}
+
+	static NSEvent eventWithCGEvent (CGEventRef cgEvent)
+	{
+		return invokeObjcSelfClass!(NSEvent, "eventWithCGEvent:", CGEventRef)(cgEvent);
+	}
+
+	static void setMouseCoalescingEnabled (bool flag)
+	{
+		return invokeObjcSelfClass!(void, "setMouseCoalescingEnabled:", bool)(flag);
+	}
+
+	static bool isMouseCoalescingEnabled ()
+	{
+		return invokeObjcSelfClass!(bool, "isMouseCoalescingEnabled");
+	}
+
+	NSUInteger deviceID ()
+	{
+		return invokeObjcSelf!(NSUInteger, "deviceID");
+	}
+
+	NSInteger absoluteX ()
+	{
+		return invokeObjcSelf!(NSInteger, "absoluteX");
+	}
+
+	NSInteger absoluteY ()
+	{
+		return invokeObjcSelf!(NSInteger, "absoluteY");
+	}
+
+	NSInteger absoluteZ ()
+	{
+		return invokeObjcSelf!(NSInteger, "absoluteZ");
+	}
+
+	NSUInteger buttonMask ()
+	{
+		return invokeObjcSelf!(NSUInteger, "buttonMask");
+	}
+
+	NSPoint tilt ()
+	{
+		return invokeObjcSelf!(NSPoint, "tilt");
+	}
+
+	float rotation ()
+	{
+		return invokeObjcSelf!(float, "rotation");
+	}
+
+	float tangentialPressure ()
+	{
+		return invokeObjcSelf!(float, "tangentialPressure");
+	}
+
+	Object vendorDefined ()
+	{
+		return invokeObjcSelf!(Object, "vendorDefined");
+	}
+
+	NSUInteger vendorID ()
+	{
+		return invokeObjcSelf!(NSUInteger, "vendorID");
+	}
+
+	NSUInteger tabletID ()
+	{
+		return invokeObjcSelf!(NSUInteger, "tabletID");
+	}
+
+	NSUInteger pointingDeviceID ()
+	{
+		return invokeObjcSelf!(NSUInteger, "pointingDeviceID");
+	}
+
+	NSUInteger systemTabletID ()
+	{
+		return invokeObjcSelf!(NSUInteger, "systemTabletID");
+	}
+
+	NSUInteger vendorPointingDeviceType ()
+	{
+		return invokeObjcSelf!(NSUInteger, "vendorPointingDeviceType");
+	}
+
+	NSUInteger pointingDeviceSerialNumber ()
+	{
+		return invokeObjcSelf!(NSUInteger, "pointingDeviceSerialNumber");
+	}
+
+	ulong uniqueID ()
+	{
+		return invokeObjcSelf!(ulong, "uniqueID");
+	}
+
+	NSUInteger capabilityMask ()
+	{
+		return invokeObjcSelf!(NSUInteger, "capabilityMask");
+	}
+
+	uint pointingDeviceType ()
+	{
+		return invokeObjcSelf!(uint, "pointingDeviceType");
+	}
+
+	bool isEnteringProximity ()
+	{
+		return invokeObjcSelf!(bool, "isEnteringProximity");
+	}
+
+	static void startPeriodicEventsAfterDelay (double delay, double period)
+	{
+		return invokeObjcSelfClass!(void, "startPeriodicEventsAfterDelay:withPeriod:", double, double)(delay, period);
+	}
+
+	static void stopPeriodicEvents ()
+	{
+		return invokeObjcSelfClass!(void, "stopPeriodicEvents");
+	}
+
+	static NSEvent mouseEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger cNum, float pressure)
+	{
+		return invokeObjcSelfClass!(NSEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSInteger, NSInteger, float)(type, location, flags, time, wNum, context, eNum, cNum, pressure);
+	}
+
+	static NSEvent keyEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSString keys, NSString ukeys, bool flag, ushort code)
+	{
+		return invokeObjcSelfClass!(NSEvent, "keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSString, NSString, bool, ushort)(type, location, flags, time, wNum, context, keys, ukeys, flag, code);
+	}
+
+	static NSEvent enterExitEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger tNum, void* data)
+	{
+		return invokeObjcSelfClass!(NSEvent, "enterExitEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, NSInteger, NSInteger, void*)(type, location, flags, time, wNum, context, eNum, tNum, data);
+	}
+
+	static NSEvent otherEventWithType (uint type, NSPoint location, NSUInteger flags, double time, NSInteger wNum, NSGraphicsContext context, short subtype, NSInteger d1, NSInteger d2)
+	{
+		return invokeObjcSelfClass!(NSEvent, "otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:", uint, NSPoint, NSUInteger, double, NSInteger, NSGraphicsContext, short, NSInteger, NSInteger)(type, location, flags, time, wNum, context, subtype, d1, d2);
+	}
+
+	static NSPoint mouseLocation ()
+	{
+		return invokeObjcSelfClass!(NSPoint, "mouseLocation");
+	}
+
+}
+