diff dwt/internal/cocoa/NSTrackingArea.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/NSTrackingArea.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.NSTrackingArea;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+/* Type of tracking area.  You must specify one or more type from this list in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingMouseEnteredAndExited = 0x01, // owner receives mouseEntered when mouse enters area, and mouseExited when mouse leaves area
+    NSTrackingMouseMoved = 0x02, // owner receives mouseMoved while mouse is within area.  Note that mouseMoved events do not contain userInfo 
+    NSTrackingCursorUpdate = 0x04, // owner receives cursorUpdate when mouse enters area.  Cursor is set appropriately when mouse exits area
+}
+
+/* When tracking area is active.  You must specify one of the following in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingActiveWhenFirstResponder = 0x10, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when view is first responder
+    NSTrackingActiveInKeyWindow = 0x20, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when view is in key window
+    NSTrackingActiveInActiveApp = 0x40, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when app is active
+    NSTrackingActiveAlways = 0x80, // owner receives mouseEntered/Exited or mouseMoved regardless of activation.  Not supported for NSTrackingCursorUpdate.
+}
+
+/* Behavior of tracking area.  These values are used in NSTrackingAreaOptions.  You may specify any number of the following in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingAssumeInside = 0x100, // If set, generate mouseExited event when mouse leaves area (same as assumeInside argument in deprecated addtrackingArea:owner:userData:assumeInside:)
+    NSTrackingInVisibleRect = 0x200, // If set, tracking occurs in visibleRect of view and rect is ignored
+    NSTrackingEnabledDuringMouseDrag = 0x400 // If set, mouseEntered events will be generated as mouse is dragged.  If not set, mouseEntered events will be generated as mouse is moved, and on mouseUp after a drag.  mouseExited events are paired with mouseEntered events so their delivery is affected indirectly.  That is, if a mouseEntered event is generated and the mouse subsequently moves out of the trackingArea, a mouseExited event will be generated whether the mouse is being moved or dragged, independent of this flag.
+}
+
+alias NSUInteger NSTrackingAreaOptions;
+
+public class NSTrackingArea : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTrackingArea initWithRect (NSRect rect, NSTrackingAreaOptions options, id owner, NSDictionary userInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRect_1options_1owner_1userInfo_1, rect, options, owner !is null ? owner.id : null,
+                userInfo !is null ? userInfo.id : null);
+        return result is this.id ? this : (result !is null ? new NSTrackingArea(result) : null);
+    }
+
+    public NSTrackingAreaOptions options ()
+    {
+        return cast(NSTrackingAreaOptions) OS.objc_msgSend(this.id, OS.sel_options);
+    }
+
+    public id owner ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_owner);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect rect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rect);
+        return result;
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}