Mercurial > projects > dwt-mac
diff 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 |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSAttributedString.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSAttributedString.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,140 +1,96 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSAttributedString; -import dwt.internal.cocoa.id; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; import dwt.internal.cocoa.NSDictionary; -import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSPoint; import dwt.internal.cocoa.NSRange; import dwt.internal.cocoa.NSRect; +import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSSize; -import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; -public class NSAttributedString : NSObject -{ - public this () - { - super(); - } +public class NSAttributedString : NSObject { - public this (objc.id id) - { - super(id); - } +public this() { + super(); +} - public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id_ : null, location, - range); - return result !is null ? new id(result) : null; - } +public this(objc.id id) { + super(id); +} - public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1, - attrName !is null ? attrName.id_ : null, location, range, rangeLimit); - return result !is null ? new id(result) : null; - } +public this(cocoa.id id) { + super(id); +} - public NSAttributedString attributedSubStringFromRange (NSRange range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedSubStringFromRange_1, range); - return result is this.id_ ? this : (result !is null ? new NSAttributedString(result) : null); - } - - public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1effectiveRange_1, location, range); - return result !is null ? new NSDictionary(result) : null; - } +public NSDictionary attributesAtIndex(NSUInteger location, NSRangePointer range, NSRange rangeLimit) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_longestEffectiveRange_inRange_, location, range, rangeLimit); + return result !is null ? new NSDictionary(result) : null; +} - public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit); - return result !is null ? new NSDictionary(result) : null; - } +public NSRange doubleClickAtIndex(int /*long*/ location) { + NSRange result = NSRange(); + OS.objc_msgSend_stret(result, this.id, OS.sel_doubleClickAtIndex_, location); + return result; +} - public NSAttributedString initWithAttributedString (NSAttributedString attrStr) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id_ : null); - return result !is null ? this : null; - } +public void drawAtPoint(NSPoint point) { + OS.objc_msgSend(this.id, OS.sel_drawAtPoint_, point); +} - public NSAttributedString initWithString_ (NSString str) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1, str !is null ? str.id_ : null); - return result !is null ? this : null; - } +public void drawInRect(NSRect rect) { + OS.objc_msgSend(this.id, OS.sel_drawInRect_, rect); +} - public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs) - { - objc.id - result = OS.objc_msgSend(this.id_, OS.sel_initWithString_1attributes_1, str !is null ? str.id_ : null, attrs !is null ? attrs.id_ : null); - return result !is null ? this : null; - } +public NSAttributedString initWithString(NSString str, NSDictionary attrs) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_attributes_, str !is null ? str.id : null, attrs !is null ? attrs.id : null); + return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null); +} - public bool isEqualToAttributedString (NSAttributedString other) - { - return OS.objc_msgSend(this.id_, OS.sel_isEqualToAttributedString_1, other !is null ? other.id_ : null) !is null; - } +public int /*long*/ nextWordFromIndex(int /*long*/ location, bool isForward) { + return OS.objc_msgSend(this.id, OS.sel_nextWordFromIndex_forward_, location, isForward); +} - public NSUInteger length () - { - return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length); - } - - public NSString String () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_string); - return result !is null ? new NSString(result) : null; - } +public NSSize size() { + NSSize result = NSSize(); + OS.objc_msgSend_stret(result, this.id, OS.sel_size); + return result; +} - public NSSize size () - { - NSSize result; - OS.objc_msgSend_struct(&result, this.id_, OS.sel_size); - return result; - } +public NSAttributedString attributedSubstringFromRange(NSRange range) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubstringFromRange_, range); + return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null); +} - public void drawAtPoint (NSPoint pt) - { - OS.objc_msgSend(id_, OS.sel_drawAtPoint_, pt); - } - - public void drawInRect (NSRect rect) - { - OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect); - } +public NSAttributedString initWithString(NSString str) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_, str !is null ? str.id : null); + return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null); +} - public void drawInRect (NSRect rect, objc.id options) - { - OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect, options); - } +public NSUInteger length() { + return OS.objc_msgSend(this.id, OS.sel_length); +} - public NSUInteger nextWordFromIndex (NSUInteger index, bool forward) - { - return cast(NSUInteger) OS.objc_msgSend(id_, OS.sel_nextWordFromIndex_1forward_1, index, forward); - } +public NSString string() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_string); + return result !is null ? new NSString(result) : null; +} - public NSRange doubleClickAtIndex (NSUInteger index) - { - NSRange result; - OS.objc_msgSend_struct(&result, id_, OS.sel_doubleClickAtIndex_1, index); - return result; - } }