Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSFormatter.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSFormatter; | 14 module dwt.internal.cocoa.NSFormatter; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSAttributedString; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSDictionary; | |
19 import dwt.internal.cocoa.NSObject; | 18 import dwt.internal.cocoa.NSObject; |
20 import dwt.internal.cocoa.NSRange; | |
21 import dwt.internal.cocoa.NSString; | 19 import dwt.internal.cocoa.NSString; |
22 import dwt.internal.cocoa.OS; | 20 import dwt.internal.cocoa.OS; |
23 import objc = dwt.internal.objc.runtime; | 21 import objc = dwt.internal.objc.runtime; |
24 | 22 |
25 public class NSFormatter : NSObject | 23 public class NSFormatter : NSObject { |
26 { | |
27 | 24 |
28 public this () | 25 public this() { |
29 { | 26 super(); |
30 super(); | 27 } |
31 } | |
32 | 28 |
33 public this (objc.id id) | 29 public this(objc.id id) { |
34 { | 30 super(id); |
35 super(id); | 31 } |
36 } | |
37 | 32 |
38 public NSAttributedString attributedStringForObjectValue (id obj, NSDictionary attrs) | 33 public this(cocoa.id id) { |
39 { | 34 super(id); |
40 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedStringForObjectValue_1withDefaultAttributes_1, obj !is null ? obj.id_ : null, | 35 } |
41 attrs !is null ? attrs.id_ : null); | |
42 return result !is null ? new NSAttributedString(result) : null; | |
43 } | |
44 | 36 |
45 public NSString editingStringForObjectValue (id obj) | 37 public NSString stringForObjectValue(cocoa.id obj) { |
46 { | 38 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForObjectValue_, obj !is null ? obj.id : null); |
47 objc.id result = OS.objc_msgSend(this.id_, OS.sel_editingStringForObjectValue_1, obj !is null ? obj.id_ : null); | 39 return result !is null ? new NSString(result) : null; |
48 return result !is null ? new NSString(result) : null; | 40 } |
49 } | |
50 | |
51 public bool getObjectValue (objc.id* obj, NSString str, objc.id** error) | |
52 { | |
53 return OS.objc_msgSend(this.id_, OS.sel_getObjectValue_1forString_1errorDescription_1, obj, str !is null ? str.id_ : null, error) !is null; | |
54 } | |
55 | |
56 public bool isPartialStringValid_newEditingString_errorDescription_ (NSString partialString, objc.id** newString, objc.id** error) | |
57 { | |
58 return OS.objc_msgSend(this.id_, OS.sel_isPartialStringValid_1newEditingString_1errorDescription_1, | |
59 partialString !is null ? partialString.id_ : null, newString, error) !is null; | |
60 } | |
61 | |
62 public bool isPartialStringValid_proposedSelectedRange_originalString_originalSelectedRange_errorDescription_ (objc.id** partialStringPtr, | |
63 NSRangePointer proposedSelRangePtr, NSString origString, NSRange origSelRange, objc.id** error) | |
64 { | |
65 return OS.objc_msgSend(this.id_, | |
66 OS.sel_isPartialStringValid_1proposedSelectedRange_1originalString_1originalSelectedRange_1errorDescription_1, partialStringPtr, | |
67 proposedSelRangePtr, origString !is null ? origString.id_ : null, origSelRange, error) !is null; | |
68 } | |
69 | |
70 public NSString stringForObjectValue (id obj) | |
71 { | |
72 objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringForObjectValue_1, obj !is null ? obj.id_ : null); | |
73 return result !is null ? new NSString(result) : null; | |
74 } | |
75 | 41 |
76 } | 42 } |