1 /*******************************************************************************
2 * Copyright (c) 2000, 2019 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.internal.cocoa;
15
16 public class NSAttributedString extends NSObject {
17
NSAttributedString()18 public NSAttributedString() {
19 super();
20 }
21
NSAttributedString(long id)22 public NSAttributedString(long id) {
23 super(id);
24 }
25
NSAttributedString(id id)26 public NSAttributedString(id id) {
27 super(id);
28 }
29
boundingRectWithSize(NSSize size, long options)30 public NSRect boundingRectWithSize(NSSize size, long options) {
31 NSRect result = new NSRect();
32 OS.objc_msgSend_stret(result, this.id, OS.sel_boundingRectWithSize_options_, size, options);
33 return result;
34 }
35
drawInRect(NSRect rect)36 public void drawInRect(NSRect rect) {
37 OS.objc_msgSend(this.id, OS.sel_drawInRect_, rect);
38 }
39
nextWordFromIndex(long location, boolean isForward)40 public long nextWordFromIndex(long location, boolean isForward) {
41 return OS.objc_msgSend(this.id, OS.sel_nextWordFromIndex_forward_, location, isForward);
42 }
43
size()44 public NSSize size() {
45 NSSize result = new NSSize();
46 OS.objc_msgSend_stret(result, this.id, OS.sel_size);
47 return result;
48 }
49
attribute(NSString attrName, long location, long range)50 public id attribute(NSString attrName, long location, long range) {
51 long result = OS.objc_msgSend(this.id, OS.sel_attribute_atIndex_effectiveRange_, attrName != null ? attrName.id : 0, location, range);
52 return result != 0 ? new id(result) : null;
53 }
54
attributedSubstringFromRange(NSRange range)55 public NSAttributedString attributedSubstringFromRange(NSRange range) {
56 long result = OS.objc_msgSend(this.id, OS.sel_attributedSubstringFromRange_, range);
57 return result == this.id ? this : (result != 0 ? new NSAttributedString(result) : null);
58 }
59
attributesAtIndex(long location, long range, NSRange rangeLimit)60 public NSDictionary attributesAtIndex(long location, long range, NSRange rangeLimit) {
61 long result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_longestEffectiveRange_inRange_, location, range, rangeLimit);
62 return result != 0 ? new NSDictionary(result) : null;
63 }
64
initWithString(NSString str)65 public NSAttributedString initWithString(NSString str) {
66 long result = OS.objc_msgSend(this.id, OS.sel_initWithString_, str != null ? str.id : 0);
67 return result == this.id ? this : (result != 0 ? new NSAttributedString(result) : null);
68 }
69
initWithString(NSString str, NSDictionary attrs)70 public NSAttributedString initWithString(NSString str, NSDictionary attrs) {
71 long result = OS.objc_msgSend(this.id, OS.sel_initWithString_attributes_, str != null ? str.id : 0, attrs != null ? attrs.id : 0);
72 return result == this.id ? this : (result != 0 ? new NSAttributedString(result) : null);
73 }
74
length()75 public long length() {
76 return OS.objc_msgSend(this.id, OS.sel_length);
77 }
78
string()79 public NSString string() {
80 long result = OS.objc_msgSend(this.id, OS.sel_string);
81 return result != 0 ? new NSString(result) : null;
82 }
83
84 }
85