Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSAttributedString.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSAttributedString; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSDictionary; | |
18 import dwt.internal.cocoa.NSInteger; | |
19 import dwt.internal.cocoa.NSObject; | |
20 import dwt.internal.cocoa.NSPoint; | |
21 import dwt.internal.cocoa.NSRange; | |
22 import dwt.internal.cocoa.NSSize; | |
23 import dwt.internal.cocoa.NSString; | |
24 import dwt.internal.cocoa.OS; | |
25 import objc = dwt.internal.objc.runtime; | |
26 | |
27 public class NSAttributedString : NSObject | |
28 { | |
29 public this () | |
30 { | |
31 this(); | |
32 } | |
33 | |
34 public this (objc.id id) | |
35 { | |
36 this(id); | |
37 } | |
38 | |
39 public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range) | |
40 { | |
41 objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id : null, location, | |
42 range); | |
43 return result !is null ? new id(result) : null; | |
44 } | |
45 | |
46 public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit) | |
47 { | |
48 objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1, | |
49 attrName !is null ? attrName.id : null, location, range, rangeLimit); | |
50 return result !is null ? new id(result) : null; | |
51 } | |
52 | |
53 public NSAttributedString attributedSubStringFromRange (NSRange range) | |
54 { | |
55 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubStringFromRange_1, range); | |
56 return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null); | |
57 } | |
58 | |
59 public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range) | |
60 { | |
61 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1effectiveRange_1, location, range); | |
62 return result !is null ? new NSDictionary(result) : null; | |
63 } | |
64 | |
65 public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit) | |
66 { | |
67 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit); | |
68 return result !is null ? new NSDictionary(result) : null; | |
69 } | |
70 | |
71 public NSAttributedString initWithAttributedString (NSAttributedString attrStr) | |
72 { | |
73 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id : null); | |
74 return result !is null ? this : null; | |
75 } | |
76 | |
77 public NSAttributedString initWithString_ (NSString str) | |
78 { | |
79 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, str !is null ? str.id : null); | |
80 return result !is null ? this : null; | |
81 } | |
82 | |
83 public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs) | |
84 { | |
85 objc.id | |
86 result = OS.objc_msgSend(this.id, OS.sel_initWithString_1attributes_1, str !is null ? str.id : null, attrs !is null ? attrs.id : null); | |
87 return result !is null ? this : null; | |
88 } | |
89 | |
90 public bool isEqualToAttributedString (NSAttributedString other) | |
91 { | |
92 return OS.objc_msgSend(this.id, OS.sel_isEqualToAttributedString_1, other !is null ? other.id : null) !is null; | |
93 } | |
94 | |
95 public NSUInteger length () | |
96 { | |
97 return OS.objc_msgSend(this.id, OS.sel_length); | |
98 } | |
99 | |
100 public NSString String () | |
101 { | |
102 objc.id result = OS.objc_msgSend(this.id, OS.sel_String); | |
103 return result !is null ? new NSString(result) : null; | |
104 } | |
105 | |
106 public NSSize size () | |
107 { | |
108 NSSize result; | |
109 OS.objc_msgSend_struct(result, this.id, OS.sel_size); | |
110 return result; | |
111 } | |
112 | |
113 public void drawAtPoint (NSPoint pt) | |
114 { | |
115 OS.objc_msgSend(id, OS.sel_drawAtPoint_, pt); | |
116 } | |
117 | |
118 public void drawInRect (NSRect rect) | |
119 { | |
120 OS.objc_msgSend(id, OS.sel_drawInRect_1, rect); | |
121 } | |
122 | |
123 public void drawInRect (NSRect rect, objc.id options) | |
124 { | |
125 OS.objc_msgSend(id, OS.sel_drawInRect_1, rect, options); | |
126 } | |
127 | |
128 public NSUInteger nextWordFromIndex (NSUInteger index, bool forward) | |
129 { | |
130 return OS.objc_msgSend(id, OS.sel_nextWordFromIndex_1forward_1, index, forward); | |
131 } | |
132 | |
133 public NSRange doubleClickAtIndex (NSUInteger index) | |
134 { | |
135 NSRange result; | |
136 OS.objc_msgSend_struct(result, id, OS.sel_doubleClickAtIndex_1, index); | |
137 return result; | |
138 } | |
139 } |