Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSEvent.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 source
/******************************************************************************* * 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.NSEvent; import dwt.internal.cocoa.id; import dwt.internal.cocoa.CGEventTypes; import dwt.internal.cocoa.CGFloat; import dwt.internal.cocoa.NSDate : NSTimeInterval; import dwt.internal.cocoa.NSGraphicsContext; import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSPoint; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSTrackingArea; import dwt.internal.cocoa.NSWindow; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; enum NSEventType { 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 NSPointingDeviceType { NSUnknownPointingDevice = NX_TABLET_POINTER_UNKNOWN, NSPenPointingDevice = NX_TABLET_POINTER_PEN, NSCursorPointingDevice = NX_TABLET_POINTER_CURSOR, NSEraserPointingDevice = NX_TABLET_POINTER_ERASER } public class NSEvent : NSObject { public this () { super(); } public this (objc.id id) { super(id); } public CGEventRef CGEvent () { return OS.objc_msgSend(this.id, OS.sel_CGEvent); } public NSInteger absoluteX () { return OS.objc_msgSend(this.id, OS.sel_absoluteX); } public NSInteger absoluteY () { return OS.objc_msgSend(this.id, OS.sel_absoluteY); } public NSInteger absoluteZ () { return OS.objc_msgSend(this.id, OS.sel_absoluteZ); } public NSUInteger buttonMask () { return OS.objc_msgSend(this.id, OS.sel_buttonMask); } public NSInteger buttonNumber () { return OS.objc_msgSend(this.id, OS.sel_buttonNumber); } public NSUInteger capabilityMask () { return OS.objc_msgSend(this.id, OS.sel_capabilityMask); } public NSString characters () { objc.id result = OS.objc_msgSend(this.id, OS.sel_characters); return result !is null ? new NSString(result) : null; } public NSString charactersIgnoringModifiers () { objc.id result = OS.objc_msgSend(this.id, OS.sel_charactersIgnoringModifiers); return result !is null ? new NSString(result) : null; } public NSInteger clickCount () { return OS.objc_msgSend(this.id, OS.sel_clickCount); } public NSGraphicsContext context () { objc.id result = OS.objc_msgSend(this.id, OS.sel_context); return result !is null ? new NSGraphicsContext(result) : null; } public NSInteger data1 () { return OS.objc_msgSend(this.id, OS.sel_data1); } public NSInteger data2 () { return OS.objc_msgSend(this.id, OS.sel_data2); } public CGFloat deltaX () { return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaX); } public CGFloat deltaY () { return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaY); } public CGFloat deltaZ () { return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaZ); } public NSUInteger deviceID () { return OS.objc_msgSend(this.id, OS.sel_deviceID); } public static NSEvent enterExitEventWithType (objc.id type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger tNum, void* data) { objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_enterExitEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1trackingNumber_1userData_1, type, location, flags, time, wNum, context !is null ? context.id : null, eNum, tNum, data); return result !is null ? new NSEvent(result) : null; } public NSInteger eventNumber () { return OS.objc_msgSend(this.id, OS.sel_eventNumber); } public /*const*/void* eventRef () { return OS.objc_msgSend(this.id, OS.sel_eventRef); } public static NSEvent eventWithCGEvent (CGEvent cgEvent) { objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithCGEvent_1, cgEvent); return result !is null ? new NSEvent(result) : null; } public static NSEvent eventWithEventRef (/*const*/void* eventRef) { objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithEventRef_1, eventRef); return result !is null ? new NSEvent(result) : null; } public bool isARepeat () { return OS.objc_msgSend(this.id, OS.sel_isARepeat) !is null; } public bool isEnteringProximity () { return OS.objc_msgSend(this.id, OS.sel_isEnteringProximity) !is null; } public static bool isMouseCoalescingEnabled () { return OS.objc_msgSend(OS.class_NSEvent, OS.sel_isMouseCoalescingEnabled) !is null; } public short keyCode () { return cast(short) OS.objc_msgSend(this.id, OS.sel_keyCode); } public static NSEvent keyEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context, NSString keys, NSString ukeys, bool flag, short code) { objc.id result = OS.objc_msgSend( OS.class_NSEvent, OS.sel_keyEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1characters_1charactersIgnoringModifiers_1isARepeat_1keyCode_1, type, location, flags, time, wNum, context !is null ? context.id : null, keys !is null ? keys.id : null, ukeys !is null ? ukeys.id : null, flag, code); return result !is null ? new NSEvent(result) : null; } public NSPoint locationInWindow () { NSPoint result; OS.objc_msgSend_struct(result, this.id, OS.sel_locationInWindow); return result; } public NSUInteger modifierFlags () { return OS.objc_msgSend(this.id, OS.sel_modifierFlags); } public static NSEvent mouseEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context, NSInteger eNum, NSInteger cNum, float pressure) { objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_mouseEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1clickCount_1pressure_1, type, location, flags, time, wNum, context !is null ? context.id : null, eNum, cNum, pressure); return result !is null ? new NSEvent(result) : null; } public static NSPoint mouseLocation () { NSPoint result; OS.objc_msgSend_struct(result, OS.class_NSEvent, OS.sel_mouseLocation); return result; } public static NSEvent otherEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context, short subtype, NSInteger d1, NSInteger d2) { objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_otherEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1subtype_1data1_1data2_1, type, location, flags, time, wNum, context !is null ? context.id : null, subtype, d1, d2); return result !is null ? new NSEvent(result) : null; } public NSUInteger pointingDeviceID () { return OS.objc_msgSend(this.id, OS.sel_pointingDeviceID); } public NSUInteger pointingDeviceSerialNumber () { return OS.objc_msgSend(this.id, OS.sel_pointingDeviceSerialNumber); } public NSPointingDeviceType pointingDeviceType () { return OS.objc_msgSend(this.id, OS.sel_pointingDeviceType); } public float pressure () { return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_pressure); } public float rotation () { return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_rotation); } public static void setMouseCoalescingEnabled (bool flag) { OS.objc_msgSend(OS.class_NSEvent, OS.sel_setMouseCoalescingEnabled_1, flag); } public static void startPeriodicEventsAfterDelay (double delay, double period) { OS.objc_msgSend(OS.class_NSEvent, OS.sel_startPeriodicEventsAfterDelay_1withPeriod_1, delay, period); } public static void stopPeriodicEvents () { OS.objc_msgSend(OS.class_NSEvent, OS.sel_stopPeriodicEvents); } public short subtype () { return cast(short) OS.objc_msgSend(this.id, OS.sel_subtype); } public NSUInteger systemTabletID () { return OS.objc_msgSend(this.id, OS.sel_systemTabletID); } public NSUInteger tabletID () { return OS.objc_msgSend(this.id, OS.sel_tabletID); } public float tangentialPressure () { return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_tangentialPressure); } public NSPoint tilt () { NSPoint result; OS.objc_msgSend_stret(result, this.id, OS.sel_tilt); return result; } public NSTimeInterval timestamp () { return OS.objc_msgSend_fpret(this.id, OS.sel_timestamp); } public NSTrackingArea trackingArea () { objc.id result = OS.objc_msgSend(this.id, OS.sel_trackingArea); return result !is null ? new NSTrackingArea(result) : null; } public NSInteger trackingNumber () { return OS.objc_msgSend(this.id, OS.sel_trackingNumber); } public NSEventType type () { return OS.objc_msgSend(this.id, OS.sel_type); } public long uniqueID () { return cast(long) OS.objc_msgSend(this.id, OS.sel_uniqueID); } public void* userData () { return OS.objc_msgSend(this.id, OS.sel_userData); } public id vendorDefined () { objc.id result = OS.objc_msgSend(this.id, OS.sel_vendorDefined); return result !is null ? new id(result) : null; } public NSUInteger vendorID () { return OS.objc_msgSend(this.id, OS.sel_vendorID); } public NSUInteger vendorPointingDeviceType () { return OS.objc_msgSend(this.id, OS.sel_vendorPointingDeviceType); } public NSWindow window () { objc.id result = OS.objc_msgSend(this.id, OS.sel_window); return result !is null ? new NSWindow(result) : null; } public NSInteger windowNumber () { return OS.objc_msgSend(this.id, OS.sel_windowNumber); } }