comparison dwt/widgets/List.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents e831403a80a9
children cfa563df4fdd
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2000, 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 *
13 import dwt.dwthelper.utils; 13 import dwt.dwthelper.utils;
14 14
15 15
16 import dwt.DWT; 16 import dwt.DWT;
17 import dwt.DWTException; 17 import dwt.DWTException;
18 import dwt.accessibility.ACC;
18 import dwt.events.SelectionEvent; 19 import dwt.events.SelectionEvent;
19 import dwt.events.SelectionListener; 20 import dwt.events.SelectionListener;
20 import dwt.graphics.Color; 21 import dwt.graphics.Color;
21 import dwt.graphics.GC; 22 import dwt.graphics.GC;
22 import dwt.graphics.Point; 23 import dwt.graphics.Point;
23 import dwt.graphics.Rectangle; 24 import dwt.graphics.Rectangle;
24 import dwt.internal.cocoa.NSAttributedString; 25 import dwt.internal.cocoa.NSAttributedString;
25 import dwt.internal.cocoa.NSColor; 26 import dwt.internal.cocoa.NSColor;
27 import dwt.internal.cocoa.NSEvent;
28 import dwt.internal.cocoa.NSFont;
26 import dwt.internal.cocoa.NSIndexSet; 29 import dwt.internal.cocoa.NSIndexSet;
27 import dwt.internal.cocoa.NSMutableDictionary; 30 import dwt.internal.cocoa.NSMutableDictionary;
28 import dwt.internal.cocoa.NSMutableIndexSet; 31 import dwt.internal.cocoa.NSMutableIndexSet;
29 import dwt.internal.cocoa.NSPoint; 32 import dwt.internal.cocoa.NSPoint;
30 import dwt.internal.cocoa.NSRange; 33 import dwt.internal.cocoa.NSRange;
31 import dwt.internal.cocoa.NSRect; 34 import dwt.internal.cocoa.NSRect;
35 import dwt.internal.cocoa.NSScrollView;
32 import dwt.internal.cocoa.NSString; 36 import dwt.internal.cocoa.NSString;
33 import dwt.internal.cocoa.NSTableColumn; 37 import dwt.internal.cocoa.NSTableColumn;
34 import dwt.internal.cocoa.NSTableView; 38 import dwt.internal.cocoa.NSTableView;
35 import dwt.internal.cocoa.OS; 39 import dwt.internal.cocoa.OS;
36 import dwt.internal.cocoa.SWTScrollView; 40 import dwt.internal.cocoa.SWTScrollView;
37 import dwt.internal.cocoa.SWTTableView; 41 import dwt.internal.cocoa.SWTTableView;
42 import dwt.internal.cocoa.id;
38 43
39 /** 44 /**
40 * Instances of this class represent a selectable user interface 45 * Instances of this class represent a selectable user interface
41 * object that displays a list of strings and issues notification 46 * object that displays a list of strings and issues notification
42 * when a string is selected. A list may be single or multi select. 47 * when a string is selected. A list may be single or multi select.
50 * <p> 55 * <p>
51 * Note: Only one of SINGLE and MULTI may be specified. 56 * Note: Only one of SINGLE and MULTI may be specified.
52 * </p><p> 57 * </p><p>
53 * IMPORTANT: This class is <em>not</em> intended to be subclassed. 58 * IMPORTANT: This class is <em>not</em> intended to be subclassed.
54 * </p> 59 * </p>
60 *
61 * @see <a href="http://www.eclipse.org/swt/snippets/#list">List snippets</a>
62 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a>
63 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
55 */ 64 */
56 public class List : Scrollable { 65 public class List : Scrollable {
57 NSTableColumn column; 66 NSTableColumn column;
58 String [] items; 67 String [] items;
59 int itemCount; 68 int itemCount;
88 * @see Widget#checkSubclass 97 * @see Widget#checkSubclass
89 * @see Widget#getStyle 98 * @see Widget#getStyle
90 */ 99 */
91 public this (Composite parent, int style) { 100 public this (Composite parent, int style) {
92 super (parent, checkStyle (style)); 101 super (parent, checkStyle (style));
102 }
103
104 int accessibilityAttributeValue (int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
105
106 if (accessible !is null) {
107 NSString attribute = new NSString(arg0);
108 id returnValue = accessible.internal_accessibilityAttributeValue(attribute, ACC.CHILDID_SELF);
109 if (returnValue !is null) return returnValue.id;
110 }
111
112 NSString attributeName = new NSString(arg0);
113
114 // Accessibility Verifier queries for a title or description. NSOutlineView doesn't
115 // seem to return either, so we return a default description value here.
116 if (attributeName.isEqualToString (OS.NSAccessibilityDescriptionAttribute)) {
117 return NSString.stringWith("").id;
118 }
119
120 // if (attributeName.isEqualToString(OS.NSAccessibilityHeaderAttribute)) {
121 // /*
122 // * Bug in the Macintosh. Even when the header is not visible,
123 // * VoiceOver still reports each column header's role for every row.
124 // * This is confusing and overly verbose. The fix is to return
125 // * "no header" when the screen reader asks for the header, by
126 // * returning noErr without setting the event parameter.
127 // */
128 // return 0;
129 // }
130
131 return super.accessibilityAttributeValue(id, sel, arg0);
93 } 132 }
94 133
95 /** 134 /**
96 * Adds the argument to the end of the receiver's list. 135 * Adds the argument to the end of the receiver's list.
97 * 136 *
219 Rectangle rect = computeTrim (0, 0, width, height); 258 Rectangle rect = computeTrim (0, 0, width, height);
220 return new Point (rect.width, rect.height); 259 return new Point (rect.width, rect.height);
221 } 260 }
222 261
223 void createHandle () { 262 void createHandle () {
224 SWTScrollView scrollWidget = cast(SWTScrollView)new SWTScrollView().alloc(); 263 NSScrollView scrollWidget = cast(NSScrollView)new SWTScrollView().alloc();
225 scrollWidget.initWithFrame(new NSRect ()); 264 scrollWidget.initWithFrame(new NSRect ());
226 if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true); 265 if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true);
227 if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true); 266 if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true);
228 scrollWidget.setAutohidesScrollers(true); 267 scrollWidget.setAutohidesScrollers(true);
229 scrollWidget.setBorderType((style & DWT.BORDER) !is 0 ? OS.NSBezelBorder : OS.NSNoBorder); 268 scrollWidget.setBorderType((style & DWT.BORDER) !is 0 ? OS.NSBezelBorder : OS.NSNoBorder);
230 scrollWidget.setTag(jniRef);
231 269
232 NSTableView widget = cast(NSTableView)new SWTTableView().alloc(); 270 NSTableView widget = cast(NSTableView)new SWTTableView().alloc();
233 widget.initWithFrame(new NSRect()); 271 widget.initWithFrame(new NSRect());
234 widget.setAllowsMultipleSelection((style & DWT.MULTI) !is 0); 272 widget.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
235 widget.setDataSource(widget); 273 widget.setDataSource(widget);
236 widget.setHeaderView(null); 274 widget.setHeaderView(null);
237 widget.setDelegate(widget); 275 widget.setDelegate(widget);
238 widget.setDoubleAction(OS.sel_sendDoubleSelection); 276 widget.setDoubleAction(OS.sel_sendDoubleSelection);
239 if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone); 277 if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone);
240 widget.setTag(jniRef);
241 278
242 column = cast(NSTableColumn)new NSTableColumn().alloc(); 279 column = cast(NSTableColumn)new NSTableColumn().alloc();
243 column.initWithIdentifier(NSString.stringWith("")); 280 column.initWithIdentifier(NSString.stringWith(""));
244 widget.addTableColumn (column); 281 widget.addTableColumn (column);
245 282
246 scrollView = scrollWidget; 283 scrollView = scrollWidget;
247 view = widget; 284 view = widget;
248 scrollView.setDocumentView(widget);
249 parent.contentView().addSubview_(scrollView);
250 } 285 }
251 286
252 void createWidget () { 287 void createWidget () {
253 super.createWidget (); 288 super.createWidget ();
254 items = new String [4]; 289 items = new String [4];
303 checkWidget(); 338 checkWidget();
304 if (start > end) return; 339 if (start > end) return;
305 if (end < 0 || start >= itemCount) return; 340 if (end < 0 || start >= itemCount) return;
306 start = Math.max (0, start); 341 start = Math.max (0, start);
307 end = Math.min (itemCount - 1, end); 342 end = Math.min (itemCount - 1, end);
308 int length = end - start + 1;
309 if (length <= 0) return;
310 if (start is 0 && end is itemCount - 1) { 343 if (start is 0 && end is itemCount - 1) {
311 deselectAll (); 344 deselectAll ();
312 } else { 345 } else {
313 NSTableView widget = cast(NSTableView)view; 346 NSTableView widget = cast(NSTableView)view;
314 ignoreSelect = true; 347 ignoreSelect = true;
315 for (int i=0; i<length; i++) { 348 for (int i=start; i<=end; i++) {
316 widget.deselectRow (i); 349 widget.deselectRow (i);
317 } 350 }
318 ignoreSelect = false; 351 ignoreSelect = false;
319 } 352 }
320 } 353 }
394 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 427 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
395 * </ul> 428 * </ul>
396 */ 429 */
397 public int getFocusIndex () { 430 public int getFocusIndex () {
398 checkWidget(); 431 checkWidget();
399 // int [] first = new int [1], last = new int [1]; 432 return (int)/*64*/((NSTableView)view).selectedRow();
400 // if (OS.GetDataBrowserSelectionAnchor (handle, first, last) !is OS.noErr) return -1;
401 // return first [0] - 1;
402 return -1;
403 } 433 }
404 434
405 /** 435 /**
406 * Returns the item at the given, zero-relative index in the 436 * Returns the item at the given, zero-relative index in the
407 * receiver. Throws an exception if the index is out of range. 437 * receiver. Throws an exception if the index is out of range.
498 NSTableView widget = cast(NSTableView)view; 528 NSTableView widget = cast(NSTableView)view;
499 if (widget.numberOfSelectedRows() is 0) { 529 if (widget.numberOfSelectedRows() is 0) {
500 return new String [0]; 530 return new String [0];
501 } 531 }
502 NSIndexSet selection = widget.selectedRowIndexes(); 532 NSIndexSet selection = widget.selectedRowIndexes();
503 int count = selection.count(); 533 int count = (int)/*64*/selection.count();
504 int [] indexBuffer = new int [count]; 534 int /*long*/ [] indexBuffer = new int /*long*/ [count];
505 selection.getIndexes(indexBuffer, count, 0); 535 selection.getIndexes(indexBuffer, count, 0);
506 String [] result = new String [count]; 536 String [] result = new String [count];
507 for (int i=0; i<count; i++) { 537 for (int i=0; i<count; i++) {
508 result [i] = items [indexBuffer [i]]; 538 result [i] = items [(int)/*64*/indexBuffer [i]];
509 } 539 }
510 return result; 540 return result;
511 } 541 }
512 542
513 /** 543 /**
520 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 550 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
521 * </ul> 551 * </ul>
522 */ 552 */
523 public int getSelectionCount () { 553 public int getSelectionCount () {
524 checkWidget (); 554 checkWidget ();
525 return (cast(NSTableView)view).numberOfSelectedRows(); 555 return cast(int)/*64*/(cast(NSTableView)view).numberOfSelectedRows();
526 } 556 }
527 557
528 /** 558 /**
529 * Returns the zero-relative index of the item which is currently 559 * Returns the zero-relative index of the item which is currently
530 * selected in the receiver, or -1 if no item is selected. 560 * selected in the receiver, or -1 if no item is selected.
536 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 566 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
537 * </ul> 567 * </ul>
538 */ 568 */
539 public int getSelectionIndex () { 569 public int getSelectionIndex () {
540 checkWidget(); 570 checkWidget();
541 //TODO - check empty selection case 571 NSTableView widget = (NSTableView)view;
542 return (cast(NSTableView)view).selectedRow(); 572 if (widget.numberOfSelectedRows() is 0) {
573 return -1;
574 }
575 NSIndexSet selection = widget.selectedRowIndexes();
576 int count = (int)/*64*/selection.count();
577 int /*long*/ [] result = new int /*long*/ [count];
578 selection.getIndexes(result, count, 0);
579 return (int)/*64*/result [0];
543 } 580 }
544 581
545 /** 582 /**
546 * Returns the zero-relative indices of the items which are currently 583 * Returns the zero-relative indices of the items which are currently
547 * selected in the receiver. The order of the indices is unspecified. 584 * selected in the receiver. The order of the indices is unspecified.
563 NSTableView widget = cast(NSTableView)view; 600 NSTableView widget = cast(NSTableView)view;
564 if (widget.numberOfSelectedRows() is 0) { 601 if (widget.numberOfSelectedRows() is 0) {
565 return new int [0]; 602 return new int [0];
566 } 603 }
567 NSIndexSet selection = widget.selectedRowIndexes(); 604 NSIndexSet selection = widget.selectedRowIndexes();
568 int count = selection.count(); 605 int count = (int)/*64*/selection.count();
606 int /*long*/ [] indices = new int /*long*/ [count];
607 selection.getIndexes(indices, count, 0);
569 int [] result = new int [count]; 608 int [] result = new int [count];
570 selection.getIndexes(result, count, 0); 609 for (int i = 0; i < result.length; i++) {
610 result [i] = (int)/*64*/indices [i];
611 }
571 return result; 612 return result;
572 } 613 }
573 614
574 /** 615 /**
575 * Returns the zero-relative index of the item which is currently 616 * Returns the zero-relative index of the item which is currently
588 //TODO - partial item at the top 629 //TODO - partial item at the top
589 NSRect rect = scrollView.documentVisibleRect(); 630 NSRect rect = scrollView.documentVisibleRect();
590 NSPoint point = new NSPoint(); 631 NSPoint point = new NSPoint();
591 point.x = rect.x; 632 point.x = rect.x;
592 point.y = rect.y; 633 point.y = rect.y;
593 return (cast(NSTableView)view).rowAtPoint(point); 634 int result = (int)/*64*/(cast(NSTableView)view).rowAtPoint(point);
635 if (result is -1) result = 0;
636 return result;
594 } 637 }
595 638
596 /** 639 /**
597 * Gets the index of an item. 640 * Gets the index of an item.
598 * <p> 641 * <p>
662 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 705 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
663 * </ul> 706 * </ul>
664 */ 707 */
665 public bool isSelected (int index) { 708 public bool isSelected (int index) {
666 checkWidget(); 709 checkWidget();
667 //TODO - range check 710 if (!(0 <= index && index < itemCount)) return false;
668 return (cast(NSTableView)view).isRowSelected(index); 711 return (cast(NSTableView)view).isRowSelected(index);
669 } 712 }
670 713
671 int numberOfRowsInTableView(int aTableView) { 714 int /*long*/ numberOfRowsInTableView(int /*long*/ id, int /*long*/ sel, int /*long*/ aTableView) {
672 return itemCount; 715 return itemCount;
673 } 716 }
674 717
675 void releaseHandle () { 718 void releaseHandle () {
676 super.releaseHandle (); 719 super.releaseHandle ();
850 if (0 <= index && index < itemCount) { 893 if (0 <= index && index < itemCount) {
851 NSIndexSet indexes = cast(NSIndexSet)new NSIndexSet().alloc(); 894 NSIndexSet indexes = cast(NSIndexSet)new NSIndexSet().alloc();
852 indexes.initWithIndex(index); 895 indexes.initWithIndex(index);
853 NSTableView widget = cast(NSTableView)view; 896 NSTableView widget = cast(NSTableView)view;
854 ignoreSelect = true; 897 ignoreSelect = true;
855 (cast(NSTableView)view).selectRowIndexes(indexes, true); 898 widget.selectRowIndexes(indexes, (style & DWT.MULTI) !is 0);
856 ignoreSelect = false; 899 ignoreSelect = false;
857 } 900 }
858 } 901 }
859 902
860 /** 903 /**
894 range.location = start; 937 range.location = start;
895 range.length = length; 938 range.length = length;
896 indexes.initWithIndexesInRange(range); 939 indexes.initWithIndexesInRange(range);
897 NSTableView widget = cast(NSTableView)view; 940 NSTableView widget = cast(NSTableView)view;
898 ignoreSelect = true; 941 ignoreSelect = true;
899 widget.selectRowIndexes(indexes, true); 942 widget.selectRowIndexes(indexes, (style & DWT.MULTI) !is 0);
900 ignoreSelect = false; 943 ignoreSelect = false;
901 } 944 }
902 } 945 }
903 946
904 /** 947 /**
929 int length = indices.length; 972 int length = indices.length;
930 if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return; 973 if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
931 int count = 0; 974 int count = 0;
932 NSMutableIndexSet indexes = cast(NSMutableIndexSet)new NSMutableIndexSet().alloc().init(); 975 NSMutableIndexSet indexes = cast(NSMutableIndexSet)new NSMutableIndexSet().alloc().init();
933 for (int i=0; i<length; i++) { 976 for (int i=0; i<length; i++) {
934 int index = indices [length - i - 1]; 977 int index = indices [i];
935 if (index >= 0 && index < itemCount) { 978 if (index >= 0 && index < itemCount) {
936 indexes.addIndex (indices [i]); 979 indexes.addIndex (indices [i]);
937 count++; 980 count++;
938 } 981 }
939 } 982 }
940 if (count > 0) { 983 if (count > 0) {
941 NSTableView widget = cast(NSTableView)view; 984 NSTableView widget = cast(NSTableView)view;
942 ignoreSelect = true; 985 ignoreSelect = true;
943 widget.selectRowIndexes(indexes, true); 986 widget.selectRowIndexes(indexes, (style & DWT.MULTI) !is 0);
944 ignoreSelect = false; 987 ignoreSelect = false;
945 } 988 }
946 } 989 }
947 990
948 void select (int [] ids, int count, bool clear) { 991 void select (int [] ids, int count, bool clear) {
973 ignoreSelect = false; 1016 ignoreSelect = false;
974 } 1017 }
975 1018
976 void sendDoubleSelection() { 1019 void sendDoubleSelection() {
977 postEvent (DWT.DefaultSelection); 1020 postEvent (DWT.DefaultSelection);
1021 }
1022
1023 bool sendKeyEvent (NSEvent nsEvent, int type) {
1024 bool result = super.sendKeyEvent (nsEvent, type);
1025 if (!result) return result;
1026 if (type !is DWT.KeyDown) return result;
1027 short keyCode = nsEvent.keyCode ();
1028 switch (keyCode) {
1029 case 76: /* KP Enter */
1030 case 36: { /* Return */
1031 postEvent (DWT.DefaultSelection);
1032 break;
1033 }
1034 }
1035 return result;
1036 }
1037
1038 void setBackground (float [] color) {
1039 super.setBackground (color);
1040 NSColor nsColor;
1041 if (color is null) {
1042 nsColor = null;
1043 } else {
1044 nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
1045 }
1046 ((NSTableView) view).setBackgroundColor (nsColor);
1047 }
1048
1049 void setFont (NSFont font) {
1050 super.setFont (font);
1051 float ascent = font.ascender ();
1052 float descent = -font.descender () + font.leading ();
1053 ((NSTableView)view).setRowHeight ((int)Math.ceil (ascent + descent) + 1);
978 } 1054 }
979 1055
980 /** 1056 /**
981 * Sets the text of the item in the receiver's list at the given 1057 * Sets the text of the item in the receiver's list at the given
982 * zero-relative index to the string argument. 1058 * zero-relative index to the string argument.
1229 checkWidget(); 1305 checkWidget();
1230 int index = getSelectionIndex (); 1306 int index = getSelectionIndex ();
1231 if (index >= 0) showIndex (index); 1307 if (index >= 0) showIndex (index);
1232 } 1308 }
1233 1309
1234 void tableViewSelectionDidChange (int aNotification) { 1310 void tableViewSelectionDidChange (int /*long*/ id, int /*long*/ sel, int /*long*/ aNotification) {
1235 if (ignoreSelect) return; 1311 if (ignoreSelect) return;
1236 postEvent (DWT.Selection); 1312 postEvent (DWT.Selection);
1237 } 1313 }
1238 1314
1239 bool tableView_shouldEditTableColumn_row(int aTableView, int aTableColumn, int rowIndex) { 1315 bool tableView_shouldEditTableColumn_row(int /*long*/ id, int /*long*/ sel, int /*long*/ aTableView, int /*long*/ aTableColumn, int /*long*/ rowIndex) {
1240 return false; 1316 return false;
1241 } 1317 }
1242 1318
1243 int tableView_objectValueForTableColumn_row(int aTableView, int aTableColumn, int rowIndex) { 1319 int /*long*/ tableView_objectValueForTableColumn_row(int /*long*/ id, int /*long*/ sel, int /*long*/ aTableView, int /*long*/ aTableColumn, int /*long*/ rowIndex) {
1244 NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4); 1320 NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
1245 if (foreground !is null) { 1321 if (foreground !is null) {
1246 NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1); 1322 NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
1247 dict.setObject(color, OS.NSForegroundColorAttributeName()); 1323 dict.setObject(color, OS.NSForegroundColorAttributeName);
1248 } 1324 }
1249 if (font !is null) { 1325 if (font !is null) {
1250 dict.setObject(font.handle, OS.NSFontAttributeName()); 1326 dict.setObject(font.handle, OS.NSFontAttributeName);
1251 } 1327 }
1252 if (background !is null) { 1328 String text = items[(int)/*64*/rowIndex];
1253 NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
1254 dict.setObject(color, OS.NSBackgroundColorAttributeName());
1255 }
1256 String text = items[rowIndex];
1257 int length = text.length(); 1329 int length = text.length();
1258 char[] chars = new char[length]; 1330 char[] chars = new char[length];
1259 text.getChars(0, length, chars, 0); 1331 text.getChars(0, length, chars, 0);
1260 NSString str = NSString.stringWithCharacters(chars, length); 1332 NSString str = NSString.stringWithCharacters(chars, length);
1261 NSAttributedString attribStr = (cast(NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); 1333 NSAttributedString attribStr = (cast(NSAttributedString)new NSAttributedString().alloc()).initWithString_(str, dict);
1262 attribStr.autorelease();
1263 return attribStr.id; 1334 return attribStr.id;
1264 } 1335 }
1265 1336
1266 } 1337 }