Mercurial > projects > dstep
comparison dstep/foundation/NSFormatter.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.NSFormatter; | |
8 | |
9 import dstep.foundation.NSAttributedString; | |
10 import dstep.foundation.NSDictionary; | |
11 import dstep.foundation.NSObject; | |
12 import dstep.foundation.NSRange; | |
13 import dstep.foundation.NSString; | |
14 import dstep.objc.bridge.Bridge; | |
15 import dstep.objc.objc : id; | |
16 | |
17 class NSFormatter : NSObject, INSCopying, INSCoding | |
18 { | |
19 mixin ObjcWrap; | |
20 | |
21 NSString stringForObjectValue (Object obj) | |
22 { | |
23 return invokeObjcSelf!(NSString, "stringForObjectValue:", Object)(obj); | |
24 } | |
25 | |
26 NSAttributedString attributedStringForObjectValue (Object obj, NSDictionary attrs) | |
27 { | |
28 return invokeObjcSelf!(NSAttributedString, "attributedStringForObjectValue:withDefaultAttributes:", Object, NSDictionary)(obj, attrs); | |
29 } | |
30 | |
31 NSString editingStringForObjectValue (Object obj) | |
32 { | |
33 return invokeObjcSelf!(NSString, "editingStringForObjectValue:", Object)(obj); | |
34 } | |
35 | |
36 bool getObjectValue (id* obj, NSString string, NSString** error) | |
37 { | |
38 return invokeObjcSelf!(bool, "getObjectValue:forString:errorDescription:", id*, NSString, NSString**)(obj, string, error); | |
39 } | |
40 | |
41 bool isPartialStringValid (NSString partialString, NSString** newString, NSString** error) | |
42 { | |
43 return invokeObjcSelf!(bool, "isPartialStringValid:newEditingString:errorDescription:", NSString, NSString**, NSString**)(partialString, newString, error); | |
44 } | |
45 | |
46 bool isPartialStringValid (NSString** partialStringPtr, NSRangePointer proposedSelRangePtr, NSString origString, NSRange origSelRange, NSString** error) | |
47 { | |
48 return invokeObjcSelf!(bool, "isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:", NSString**, NSRangePointer, NSString, NSRange, NSString**)(partialStringPtr, proposedSelRangePtr, origString, origSelRange, error); | |
49 } | |
50 | |
51 Object copyWithZone (NSZone* zone) | |
52 { | |
53 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
54 } | |
55 | |
56 void encodeWithCoder (NSCoder aCoder) | |
57 { | |
58 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
59 } | |
60 | |
61 Object initWithCoder (NSCoder aDecoder) | |
62 { | |
63 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
64 } | |
65 | |
66 this (NSCoder aDecoder) | |
67 { | |
68 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
69 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
70 | |
71 if (result) | |
72 objcObject = ret; | |
73 | |
74 dObject = this; | |
75 } | |
76 } | |
77 |