Mercurial > projects > dstep
view dstep/foundation/NSAttributedString.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSAttributedString; import dstep.foundation.NSDictionary; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc : id; class NSMutableAttributedString : NSAttributedString { mixin ObjcWrap; mixin TNSExtendedMutableAttributedString; void replaceCharactersInRange (NSRange range, NSString str) { return invokeObjcSelf!(void, "replaceCharactersInRange:withString:", NSRange, NSString)(range, str); } void setAttributes (NSDictionary attrs, NSRange range) { return invokeObjcSelf!(void, "setAttributes:range:", NSDictionary, NSRange)(attrs, range); } } class NSAttributedString : NSObject, INSCopying, INSMutableCopying, INSCoding { mixin ObjcWrap; mixin TNSExtendedAttributedString; NSString string () { return invokeObjcSelf!(NSString, "string"); } NSDictionary attributesAtIndex (NSUInteger location, NSRangePointer range) { return invokeObjcSelf!(NSDictionary, "attributesAtIndex:effectiveRange:", NSUInteger, NSRangePointer)(location, range); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } Object mutableCopyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "mutableCopyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); if (result) objcObject = ret; dObject = this; } } template TNSExtendedAttributedString () { NSUInteger length () { return invokeObjcSelf!(NSUInteger, "length"); } Object attribute (NSString attrName, NSUInteger location, NSRangePointer range) { return invokeObjcSelf!(Object, "attribute:atIndex:effectiveRange:", NSString, NSUInteger, NSRangePointer)(attrName, location, range); } NSAttributedString attributedSubstringFromRange (NSRange range) { return invokeObjcSelf!(NSAttributedString, "attributedSubstringFromRange:", NSRange)(range); } NSDictionary attributesAtIndex (NSUInteger location, NSRangePointer range, NSRange rangeLimit) { return invokeObjcSelf!(NSDictionary, "attributesAtIndex:longestEffectiveRange:inRange:", NSUInteger, NSRangePointer, NSRange)(location, range, rangeLimit); } Object attribute (NSString attrName, NSUInteger location, NSRangePointer range, NSRange rangeLimit) { return invokeObjcSelf!(Object, "attribute:atIndex:longestEffectiveRange:inRange:", NSString, NSUInteger, NSRangePointer, NSRange)(attrName, location, range, rangeLimit); } bool isEqualToAttributedString (NSAttributedString other) { return invokeObjcSelf!(bool, "isEqualToAttributedString:", NSAttributedString)(other); } Object initWithString (NSString str) { return invokeObjcSelf!(Object, "initWithString:", NSString)(str); } this (NSString str) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, str); if (result) objcObject = ret; dObject = this; } Object initWithString (NSString str, NSDictionary attrs) { return invokeObjcSelf!(Object, "initWithString:attributes:", NSString, NSDictionary)(str, attrs); } this (NSString str, NSDictionary attrs) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithString:attributes:", NSString, NSDictionary)(objcObject, str, attrs); if (result) objcObject = ret; dObject = this; } Object initWithAttributedString (NSAttributedString attrStr) { return invokeObjcSelf!(Object, "initWithAttributedString:", NSAttributedString)(attrStr); } this (NSAttributedString attrStr) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithAttributedString:", NSAttributedString)(objcObject, attrStr); if (result) objcObject = ret; dObject = this; } } template TNSExtendedMutableAttributedString () { NSMutableString mutableString () { return invokeObjcSelf!(NSMutableString, "mutableString"); } void addAttribute (NSString name, Object value, NSRange range) { return invokeObjcSelf!(void, "addAttribute:value:range:", NSString, Object, NSRange)(name, value, range); } void addAttributes (NSDictionary attrs, NSRange range) { return invokeObjcSelf!(void, "addAttributes:range:", NSDictionary, NSRange)(attrs, range); } void removeAttribute (NSString name, NSRange range) { return invokeObjcSelf!(void, "removeAttribute:range:", NSString, NSRange)(name, range); } void replaceCharactersInRange (NSRange range, NSAttributedString attrString) { return invokeObjcSelf!(void, "replaceCharactersInRange:withAttributedString:", NSRange, NSAttributedString)(range, attrString); } void insertAttributedString (NSAttributedString attrString, NSUInteger loc) { return invokeObjcSelf!(void, "insertAttributedString:atIndex:", NSAttributedString, NSUInteger)(attrString, loc); } void appendAttributedString (NSAttributedString attrString) { return invokeObjcSelf!(void, "appendAttributedString:", NSAttributedString)(attrString); } void deleteCharactersInRange (NSRange range) { return invokeObjcSelf!(void, "deleteCharactersInRange:", NSRange)(range); } void setAttributedString (NSAttributedString attrString) { return invokeObjcSelf!(void, "setAttributedString:", NSAttributedString)(attrString); } void beginEditing () { return invokeObjcSelf!(void, "beginEditing"); } void endEditing () { return invokeObjcSelf!(void, "endEditing"); } }