diff dstep/foundation/NSKeyValueObserving.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSKeyValueObserving.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,101 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSKeyValueObserving;
+
+import dstep.foundation.NSArray;
+import dstep.foundation.NSIndexSet;
+import dstep.foundation.NSSet;
+import dstep.foundation.NSString;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+import bindings = dstep.foundation.NSKeyValueObserving_bindings;
+
+alias NSUInteger NSKeyValueObservingOptions;
+alias NSUInteger NSKeyValueChange;
+alias NSUInteger NSKeyValueSetMutationKind;
+
+const NSString NSKeyValueChangeKindKey;
+const NSString NSKeyValueChangeNewKey;
+const NSString NSKeyValueChangeOldKey;
+const NSString NSKeyValueChangeIndexesKey;
+const NSString NSKeyValueChangeNotificationIsPriorKey;
+
+enum
+{
+	NSKeyValueObservingOptionNew = 0x01,
+	NSKeyValueObservingOptionOld = 0x02,
+	NSKeyValueObservingOptionInitial = 0x04,
+	NSKeyValueObservingOptionPrior = 0x08
+}
+
+enum
+{
+	NSKeyValueChangeSetting = 1,
+	NSKeyValueChangeInsertion = 2,
+	NSKeyValueChangeRemoval = 3,
+	NSKeyValueChangeReplacement = 4
+}
+
+enum
+{
+	NSKeyValueUnionSetMutation = 1,
+	NSKeyValueMinusSetMutation = 2,
+	NSKeyValueIntersectSetMutation = 3,
+	NSKeyValueSetSetMutation = 4
+}
+
+static this ()
+{
+	NSKeyValueChangeKindKey = new NSString(bindings.NSKeyValueChangeKindKey);
+	NSKeyValueChangeNewKey = new NSString(bindings.NSKeyValueChangeNewKey);
+	NSKeyValueChangeOldKey = new NSString(bindings.NSKeyValueChangeOldKey);
+	NSKeyValueChangeIndexesKey = new NSString(bindings.NSKeyValueChangeIndexesKey);
+	NSKeyValueChangeNotificationIsPriorKey = new NSString(bindings.NSKeyValueChangeNotificationIsPriorKey);
+}
+
+template TNSKeyValueObserverNotification ()
+{
+	void willChangeValueForKey (NSString key);
+	void didChangeValueForKey (NSString key);
+	void willChange (uint changeKind, NSIndexSet indexes, NSString key);
+	void didChange (uint changeKind, NSIndexSet indexes, NSString key);
+	void willChangeValueForKey (NSString key, uint mutationKind, NSSet objects);
+	void didChangeValueForKey (NSString key, uint mutationKind, NSSet objects);
+}
+
+template TNSKeyValueObservingCustomization ()
+{
+	static NSSet keyPathsForValuesAffectingValueForKey (NSString key);
+	static bool automaticallyNotifiesObserversForKey (NSString key);
+	void setObservationInfo (void* observationInfo);
+	void* observationInfo ();
+}
+
+template TNSKeyValueObserverRegistration ()
+{
+	void addObserver (NSObject observer, NSString keyPath, uint options, void* context)
+	{
+		return invokeObjcSelf!(void, "addObserver:forKeyPath:options:context:", NSObject, NSString, uint, void*)(observer, keyPath, options, context);
+	}
+
+	void removeObserver (NSObject observer, NSString keyPath)
+	{
+		return invokeObjcSelf!(void, "removeObserver:forKeyPath:", NSObject, NSString)(observer, keyPath);
+	}
+}
+
+template TNSDeprecatedKeyValueObservingCustomization ()
+{
+	static void setKeys (NSArray keys, NSString dependentKey);
+}
+
+template TNSKeyValueObserving ()
+{
+	void observeValueForKeyPath (NSString keyPath, Object object, NSDictionary change, void* context);
+}
+