Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSAttributedString.d @ 1:8b48be5454ce
The internal cocoa classes compile now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 19 Aug 2008 17:35:17 +0200 |
parents | 380af2bdd8e5 |
children | f565d3a95c0a |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2007 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 * * Port to the D Programming language: * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.internal.cocoa.NSAttributedString; import 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.NSSize; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; public class NSAttributedString : NSObject { public this () { super(); } public this (objc.id id) { super(id); } 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 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 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_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 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 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 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 bool isEqualToAttributedString (NSAttributedString other) { return OS.objc_msgSend(this.id_, OS.sel_isEqualToAttributedString_1, other !is null ? other.id_ : null) !is null; } 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; OS.objc_msgSend_struct(&result, this.id_, OS.sel_size); return result; } 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 void drawInRect (NSRect rect, objc.id options) { OS.objc_msgSend(id_, OS.sel_drawInRect_1, rect, options); } public NSUInteger nextWordFromIndex (NSUInteger index, bool forward) { return cast(NSUInteger) OS.objc_msgSend(id_, OS.sel_nextWordFromIndex_1forward_1, index, forward); } public NSRange doubleClickAtIndex (NSUInteger index) { NSRange result; OS.objc_msgSend_struct(&result, id_, OS.sel_doubleClickAtIndex_1, index); return result; } }