Mercurial > projects > dstep
view dstep/foundation/NSAttributedString.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
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.appkit.NSFileWrapper; import dstep.appkit.NSStringDrawing; import dstep.appkit.NSTextAttachment; import dstep.appkit.NSTextList; import dstep.appkit.NSTextTable;*/ import dstep.foundation.NSArray; import dstep.foundation.NSCoder; import dstep.foundation.NSData; import dstep.foundation.NSError; import dstep.foundation.NSDictionary; import dstep.foundation.NSGeometry; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSRange; import dstep.foundation.NSString; import dstep.foundation.NSURL; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; const 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) { typeof(this).alloc.initWithString(str); } Object initWithString (NSString str, NSDictionary attrs) { return invokeObjcSelf!(Object, "initWithString:attributes:", NSString, NSDictionary)(str, attrs); } this (NSString str, NSDictionary attrs) { typeof(this).alloc.initWithString(str, attrs); } Object initWithAttributedString (NSAttributedString attrStr) { return invokeObjcSelf!(Object, "initWithAttributedString:", NSAttributedString)(attrStr); } this (NSAttributedString attrStr) { typeof(this).alloc.initWithAttributedString(attrStr); } `; const 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"); } `; class NSMutableAttributedString : NSAttributedString { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } 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); } // NSExtendedMutableAttributedString /*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"); }*/ // NSMutableAttributedStringKitAdditions bool readFromURL (NSURL url, NSDictionary opts, ref NSDictionary dict, ref NSError error) { id __arg2; id __arg3; if (dict) __arg2 = dict.objcObject; if (error) __arg3 = error.objcObject; bool result = invokeObjcSelf!(bool, "readFromURL:options:documentAttributes:error:", NSURL, NSDictionary, id*, id*)(url, opts, &__arg2, &__arg3); if (__arg2) dict = new NSDictionary(__arg2); if (__arg3) error = new NSError(__arg3); return result; } bool readFromData (NSData data, NSDictionary opts, ref NSDictionary dict, ref NSError error) { id __arg2; id __arg3; if (dict) __arg2 = dict.objcObject; if (error) __arg3 = error.objcObject; bool result = invokeObjcSelf!(bool, "readFromData:options:documentAttributes:error:", NSData, NSDictionary, id*, id*)(data, opts, &__arg2, &__arg3); if (__arg2) dict = new NSDictionary(__arg2); if (__arg3) error = new NSError(__arg3); return result; } bool readFromURL (NSURL url, NSDictionary options, ref NSDictionary dict) { id __arg2; if (dict) __arg2 = dict.objcObject; bool result = invokeObjcSelf!(bool, "readFromURL:options:documentAttributes:", NSURL, NSDictionary, id*)(url, options, &__arg2); if (__arg2) dict = new NSDictionary(__arg2); return result; } bool readFromData (NSData data, NSDictionary options, ref NSDictionary dict) { id __arg2; if (dict) __arg2 = dict.objcObject; bool result = invokeObjcSelf!(bool, "readFromData:options:documentAttributes:", NSData, NSDictionary, id*)(data, options, &__arg2); if (__arg2) dict = new NSDictionary(__arg2); return result; } void superscriptRange (NSRange range) { return invokeObjcSelf!(void, "superscriptRange:", NSRange)(range); } void subscriptRange (NSRange range) { return invokeObjcSelf!(void, "subscriptRange:", NSRange)(range); } void unscriptRange (NSRange range) { return invokeObjcSelf!(void, "unscriptRange:", NSRange)(range); } void applyFontTraits (uint traitMask, NSRange range) { return invokeObjcSelf!(void, "applyFontTraits:range:", uint, NSRange)(traitMask, range); } void setAlignment (uint alignment, NSRange range) { return invokeObjcSelf!(void, "setAlignment:range:", uint, NSRange)(alignment, range); } void setBaseWritingDirection (int writingDirection, NSRange range) { return invokeObjcSelf!(void, "setBaseWritingDirection:range:", int, NSRange)(writingDirection, range); } void fixAttributesInRange (NSRange range) { return invokeObjcSelf!(void, "fixAttributesInRange:", NSRange)(range); } void fixFontAttributeInRange (NSRange range) { return invokeObjcSelf!(void, "fixFontAttributeInRange:", NSRange)(range); } void fixParagraphStyleAttributeInRange (NSRange range) { return invokeObjcSelf!(void, "fixParagraphStyleAttributeInRange:", NSRange)(range); } void fixAttachmentAttributeInRange (NSRange range) { return invokeObjcSelf!(void, "fixAttachmentAttributeInRange:", NSRange)(range); } // NSMutableAttributedStringAttachmentConveniences void updateAttachmentsFromPath (NSString path) { return invokeObjcSelf!(void, "updateAttachmentsFromPath:", NSString)(path); } } class NSAttributedString : NSObject, INSCopying, INSMutableCopying, INSCoding { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } 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) { typeof(this).alloc.initWithCoder(aDecoder); } mixin (TNSExtendedAttributedString); //mixin (TNSAttributedStringAttachmentConveniences); //mixin (dstep.appkit.NSAttributedString.TNSExtendedAttributedString); //mixin (dstep.appkit.NSAttributedString.TNSDeprecatedKitAdditions); //mixin (TNSStringDrawing); //mixin (dstep.appkit.NSAttributedString.TNSAttributedStringKitAdditions); }