Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSMutableAttributedString.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.NSMutableAttributedString; | 14 module dwt.internal.cocoa.NSMutableAttributedString; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import cocoa = dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSAttributedString; | 18 import dwt.internal.cocoa.NSAttributedString; |
18 import dwt.internal.cocoa.NSDictionary; | |
19 import dwt.internal.cocoa.NSInteger; | |
20 import dwt.internal.cocoa.NSMutableString; | 19 import dwt.internal.cocoa.NSMutableString; |
21 import dwt.internal.cocoa.NSRange; | 20 import dwt.internal.cocoa.NSRange; |
22 import dwt.internal.cocoa.NSString; | 21 import dwt.internal.cocoa.NSString; |
23 import dwt.internal.cocoa.OS; | 22 import dwt.internal.cocoa.OS; |
24 import objc = dwt.internal.objc.runtime; | 23 import objc = dwt.internal.objc.runtime; |
25 | 24 |
26 public class NSMutableAttributedString : NSAttributedString | 25 public class NSMutableAttributedString : NSAttributedString { |
27 { | |
28 | 26 |
29 public this () | 27 public this() { |
30 { | 28 super(); |
31 super(); | 29 } |
32 } | |
33 | 30 |
34 public this (objc.id id) | 31 public this(objc.id id) { |
35 { | 32 super(id); |
36 super(id); | 33 } |
37 } | |
38 | 34 |
39 public void addAttribute (/*java int*/ /*objc NSString* */ NSString name, id value, NSRange range) | 35 public this(cocoa.id id) { |
40 { | 36 super(id); |
41 OS.objc_msgSend(this.id_, OS.sel_addAttribute_1value_1range_1, name !is null ? name.id_ : null, value !is null ? value.id_ : null, range); | 37 } |
42 } | |
43 | 38 |
44 public void addAttributes (NSDictionary attrs, NSRange range) | 39 public NSMutableString mutableString() { |
45 { | 40 objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableString); |
46 OS.objc_msgSend(this.id_, OS.sel_addAttributes_1range_1, attrs !is null ? attrs.id_ : null, range); | 41 return result !is null ? new NSMutableString(result) : null; |
47 } | 42 } |
48 | 43 |
49 public void appendAttributedString (NSAttributedString attrString) | 44 public void replaceCharactersInRange(NSRange range, NSString str) { |
50 { | 45 OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_withString_, range, str !is null ? str.id : null); |
51 OS.objc_msgSend(this.id_, OS.sel_appendAttributedString_1, attrString !is null ? attrString.id_ : null); | 46 } |
52 } | |
53 | 47 |
54 public void beginEditing () | 48 public void addAttribute(NSString name, cocoa.id value, NSRange range) { |
55 { | 49 OS.objc_msgSend(this.id, OS.sel_addAttribute_value_range_, name !is null ? name.id : null, value !is null ? value.id : null, range); |
56 OS.objc_msgSend(this.id_, OS.sel_beginEditing); | 50 } |
57 } | |
58 | 51 |
59 public void deleteCharactersInRange (NSRange range) | 52 public void beginEditing() { |
60 { | 53 OS.objc_msgSend(this.id, OS.sel_beginEditing); |
61 OS.objc_msgSend(this.id_, OS.sel_deleteCharactersInRange_1, range); | 54 } |
62 } | |
63 | 55 |
64 public void endEditing () | 56 public void endEditing() { |
65 { | 57 OS.objc_msgSend(this.id, OS.sel_endEditing); |
66 OS.objc_msgSend(this.id_, OS.sel_endEditing); | 58 } |
67 } | |
68 | |
69 public void insertAttributedString (NSAttributedString attrString, NSUInteger loc) | |
70 { | |
71 OS.objc_msgSend(this.id_, OS.sel_insertAttributedString_1atIndex_1, attrString !is null ? attrString.id_ : null, loc); | |
72 } | |
73 | |
74 public NSMutableString mutableString () | |
75 { | |
76 objc.id result = OS.objc_msgSend(this.id_, OS.sel_mutableString); | |
77 return result !is null ? new NSMutableString(result) : null; | |
78 } | |
79 | |
80 public void removeAttribute (NSString name, NSRange range) | |
81 { | |
82 OS.objc_msgSend(this.id_, OS.sel_removeAttribute_1range_1, name !is null ? name.id_ : null, range); | |
83 } | |
84 | |
85 public void replaceCharactersInRange_withAttributedString_ (NSRange range, NSAttributedString attrString) | |
86 { | |
87 OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withAttributedString_1, range, attrString !is null ? attrString.id_ : null); | |
88 } | |
89 | |
90 public void replaceCharactersInRange_withString_ (NSRange range, NSString str) | |
91 { | |
92 OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withString_1, range, str !is null ? str.id_ : null); | |
93 } | |
94 | |
95 public void setAttributedString (NSAttributedString attrString) | |
96 { | |
97 OS.objc_msgSend(this.id_, OS.sel_setAttributedString_1, attrString !is null ? attrString.id_ : null); | |
98 } | |
99 | |
100 public void setAttributes (NSDictionary attrs, NSRange range) | |
101 { | |
102 OS.objc_msgSend(this.id_, OS.sel_setAttributes_1range_1, attrs !is null ? attrs.id_ : null, range); | |
103 } | |
104 | 59 |
105 } | 60 } |