Mercurial > projects > dstep
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSKeyValueObserving; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSIndexSet; | |
11 import dstep.foundation.NSSet; | |
12 import dstep.foundation.NSString; | |
13 import dstep.objc.bridge.Bridge; | |
14 import dstep.objc.objc : id; | |
15 | |
16 import bindings = dstep.foundation.NSKeyValueObserving_bindings; | |
17 | |
18 alias NSUInteger NSKeyValueObservingOptions; | |
19 alias NSUInteger NSKeyValueChange; | |
20 alias NSUInteger NSKeyValueSetMutationKind; | |
21 | |
22 const NSString NSKeyValueChangeKindKey; | |
23 const NSString NSKeyValueChangeNewKey; | |
24 const NSString NSKeyValueChangeOldKey; | |
25 const NSString NSKeyValueChangeIndexesKey; | |
26 const NSString NSKeyValueChangeNotificationIsPriorKey; | |
27 | |
28 enum | |
29 { | |
30 NSKeyValueObservingOptionNew = 0x01, | |
31 NSKeyValueObservingOptionOld = 0x02, | |
32 NSKeyValueObservingOptionInitial = 0x04, | |
33 NSKeyValueObservingOptionPrior = 0x08 | |
34 } | |
35 | |
36 enum | |
37 { | |
38 NSKeyValueChangeSetting = 1, | |
39 NSKeyValueChangeInsertion = 2, | |
40 NSKeyValueChangeRemoval = 3, | |
41 NSKeyValueChangeReplacement = 4 | |
42 } | |
43 | |
44 enum | |
45 { | |
46 NSKeyValueUnionSetMutation = 1, | |
47 NSKeyValueMinusSetMutation = 2, | |
48 NSKeyValueIntersectSetMutation = 3, | |
49 NSKeyValueSetSetMutation = 4 | |
50 } | |
51 | |
52 static this () | |
53 { | |
54 NSKeyValueChangeKindKey = new NSString(bindings.NSKeyValueChangeKindKey); | |
55 NSKeyValueChangeNewKey = new NSString(bindings.NSKeyValueChangeNewKey); | |
56 NSKeyValueChangeOldKey = new NSString(bindings.NSKeyValueChangeOldKey); | |
57 NSKeyValueChangeIndexesKey = new NSString(bindings.NSKeyValueChangeIndexesKey); | |
58 NSKeyValueChangeNotificationIsPriorKey = new NSString(bindings.NSKeyValueChangeNotificationIsPriorKey); | |
59 } | |
60 | |
61 template TNSKeyValueObserverNotification () | |
62 { | |
63 void willChangeValueForKey (NSString key); | |
64 void didChangeValueForKey (NSString key); | |
65 void willChange (uint changeKind, NSIndexSet indexes, NSString key); | |
66 void didChange (uint changeKind, NSIndexSet indexes, NSString key); | |
67 void willChangeValueForKey (NSString key, uint mutationKind, NSSet objects); | |
68 void didChangeValueForKey (NSString key, uint mutationKind, NSSet objects); | |
69 } | |
70 | |
71 template TNSKeyValueObservingCustomization () | |
72 { | |
73 static NSSet keyPathsForValuesAffectingValueForKey (NSString key); | |
74 static bool automaticallyNotifiesObserversForKey (NSString key); | |
75 void setObservationInfo (void* observationInfo); | |
76 void* observationInfo (); | |
77 } | |
78 | |
79 template TNSKeyValueObserverRegistration () | |
80 { | |
81 void addObserver (NSObject observer, NSString keyPath, uint options, void* context) | |
82 { | |
83 return invokeObjcSelf!(void, "addObserver:forKeyPath:options:context:", NSObject, NSString, uint, void*)(observer, keyPath, options, context); | |
84 } | |
85 | |
86 void removeObserver (NSObject observer, NSString keyPath) | |
87 { | |
88 return invokeObjcSelf!(void, "removeObserver:forKeyPath:", NSObject, NSString)(observer, keyPath); | |
89 } | |
90 } | |
91 | |
92 template TNSDeprecatedKeyValueObservingCustomization () | |
93 { | |
94 static void setKeys (NSArray keys, NSString dependentKey); | |
95 } | |
96 | |
97 template TNSKeyValueObserving () | |
98 { | |
99 void observeValueForKeyPath (NSString keyPath, Object object, NSDictionary change, void* context); | |
100 } | |
101 |