comparison dwt/internal/cocoa/NSAttributedString.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 62202ce0039f
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.NSAttributedString; 14 module dwt.internal.cocoa.NSAttributedString;
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.NSDictionary; 18 import dwt.internal.cocoa.NSDictionary;
18 import dwt.internal.cocoa.NSInteger;
19 import dwt.internal.cocoa.NSObject; 19 import dwt.internal.cocoa.NSObject;
20 import dwt.internal.cocoa.NSPoint; 20 import dwt.internal.cocoa.NSPoint;
21 import dwt.internal.cocoa.NSRange; 21 import dwt.internal.cocoa.NSRange;
22 import dwt.internal.cocoa.NSRect; 22 import dwt.internal.cocoa.NSRect;
23 import dwt.internal.cocoa.NSString;
23 import dwt.internal.cocoa.NSSize; 24 import dwt.internal.cocoa.NSSize;
24 import dwt.internal.cocoa.NSString;
25 import dwt.internal.cocoa.OS; 25 import dwt.internal.cocoa.OS;
26 import dwt.internal.objc.cocoa.Cocoa;
26 import objc = dwt.internal.objc.runtime; 27 import objc = dwt.internal.objc.runtime;
27 28
28 public class NSAttributedString : NSObject 29 public class NSAttributedString : NSObject {
29 {
30 public this ()
31 {
32 super();
33 }
34 30
35 public this (objc.id id) 31 public this() {
36 { 32 super();
37 super(id); 33 }
38 }
39 34
40 public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range) 35 public this(objc.id id) {
41 { 36 super(id);
42 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id_ : null, location, 37 }
43 range);
44 return result !is null ? new id(result) : null;
45 }
46 38
47 public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit) 39 public this(cocoa.id id) {
48 { 40 super(id);
49 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1, 41 }
50 attrName !is null ? attrName.id_ : null, location, range, rangeLimit);
51 return result !is null ? new id(result) : null;
52 }
53 42
54 public NSAttributedString attributedSubStringFromRange (NSRange range) 43 public NSDictionary attributesAtIndex(NSUInteger location, NSRangePointer range, NSRange rangeLimit) {
55 { 44 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_longestEffectiveRange_inRange_, location, range, rangeLimit);
56 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedSubStringFromRange_1, range); 45 return result !is null ? new NSDictionary(result) : null;
57 return result is this.id_ ? this : (result !is null ? new NSAttributedString(result) : null); 46 }
58 }
59 47
60 public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range) 48 public NSRange doubleClickAtIndex(int /*long*/ location) {
61 { 49 NSRange result = NSRange();
62 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1effectiveRange_1, location, range); 50 OS.objc_msgSend_stret(result, this.id, OS.sel_doubleClickAtIndex_, location);
63 return result !is null ? new NSDictionary(result) : null; 51 return result;
64 } 52 }
65 53
66 public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit) 54 public void drawAtPoint(NSPoint point) {
67 { 55 OS.objc_msgSend(this.id, OS.sel_drawAtPoint_, point);
68 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit); 56 }
69 return result !is null ? new NSDictionary(result) : null;
70 }
71 57
72 public NSAttributedString initWithAttributedString (NSAttributedString attrStr) 58 public void drawInRect(NSRect rect) {
73 { 59 OS.objc_msgSend(this.id, OS.sel_drawInRect_, rect);
74 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id_ : null); 60 }
75 return result !is null ? this : null;
76 }
77 61
78 public NSAttributedString initWithString_ (NSString str) 62 public NSAttributedString initWithString(NSString str, NSDictionary attrs) {
79 { 63 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_attributes_, str !is null ? str.id : null, attrs !is null ? attrs.id : null);
80 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, str !is null ? str.id_ : null); 64 return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
81 return result !is null ? this : null; 65 }
82 }
83 66
84 public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs) 67 public int /*long*/ nextWordFromIndex(int /*long*/ location, bool isForward) {
85 { 68 return OS.objc_msgSend(this.id, OS.sel_nextWordFromIndex_forward_, location, isForward);
86 objc.id 69 }
87 result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1attributes_1, str !is null ? str.id_ : null, attrs !is null ? attrs.id_ : null);
88 return result !is null ? this : null;
89 }
90 70
91 public bool isEqualToAttributedString (NSAttributedString other) 71 public NSSize size() {
92 { 72 NSSize result = NSSize();
93 return OS.objc_msgSend(this.id_, OS.sel_isEqualToAttributedString_1, other !is null ? other.id_ : null) !is null; 73 OS.objc_msgSend_stret(result, this.id, OS.sel_size);
94 } 74 return result;
75 }
95 76
96 public NSUInteger length () 77 public NSAttributedString attributedSubstringFromRange(NSRange range) {
97 { 78 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubstringFromRange_, range);
98 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length); 79 return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
99 } 80 }
100 81
101 public NSString String () 82 public NSAttributedString initWithString(NSString str) {
102 { 83 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_, str !is null ? str.id : null);
103 objc.id result = OS.objc_msgSend(this.id_, OS.sel_string); 84 return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
104 return result !is null ? new NSString(result) : null; 85 }
105 }
106 86
107 public NSSize size () 87 public NSUInteger length() {
108 { 88 return OS.objc_msgSend(this.id, OS.sel_length);
109 NSSize result; 89 }
110 OS.objc_msgSend_struct(&result, this.id_, OS.sel_size);
111 return result;
112 }
113 90
114 public void drawAtPoint (NSPoint pt) 91 public NSString string() {
115 { 92 objc.id result = OS.objc_msgSend(this.id, OS.sel_string);
116 OS.objc_msgSend(id_, OS.sel_drawAtPoint_, pt); 93 return result !is null ? new NSString(result) : null;
117 } 94 }
118 95
119 public void drawInRect (NSRect rect)
120 {
121 OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect);
122 }
123
124 public void drawInRect (NSRect rect, objc.id options)
125 {
126 OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect, options);
127 }
128
129 public NSUInteger nextWordFromIndex (NSUInteger index, bool forward)
130 {
131 return cast(NSUInteger) OS.objc_msgSend(id_, OS.sel_nextWordFromIndex_1forward_1, index, forward);
132 }
133
134 public NSRange doubleClickAtIndex (NSUInteger index)
135 {
136 NSRange result;
137 OS.objc_msgSend_struct(&result, id_, OS.sel_doubleClickAtIndex_1, index);
138 return result;
139 }
140 } 96 }