[Mono-osx] MonoMac NSAttributedString.h
Duane Wandless
duane at wandless.net
Wed Apr 21 14:26:39 EDT 2010
Here is the modified NSAttributeString definition that includes Foundation
and AppKit. I added this to maccore/src/foundation.cs.
Some of the AppKit selectors are commented out because the referenced class
has not been bound yet.
If there are generic changes to the parser I can make those... like this:
//- (id)initWithData:(NSData *)data options:(NSDictionary *)options
documentAttributes:(NSDictionary **)dict error:(NSError **)error;
[Export ("initWithData:options:documentAttributes:error:")]
NSAttributedString InitWithData (NSData data, NSDictionary options,
NSDictionary dict, NSError error);
I think should really be:
IntPtr Constructor (NSData data, NSDictionary options, NSDictionary dict,
NSError error)
Though I worry about the **... I did not notice that until just now. Should
that be a ref or out?
Duane
[Since (3,2)]
[BaseType (typeof (NSObject))]
public interface NSAttributedString {
// new editions
[Field("NSFontAttributeName")] string NSFontAttributeName { get; }
[Field("NSParagraphStyleAttributeName")] string
NSParagraphStyleAttributeName { get; }
[Field("NSForegroundColorAttributeName")] string
NSForegroundColorAttributeName { get; }
[Field("NSUnderlineStyleAttributeName")] string
NSUnderlineStyleAttributeName { get; }
[Field("NSSuperscriptAttributeName")] string
NSSuperscriptAttributeName { get; }
[Field("NSBackgroundColorAttributeName")] string
NSBackgroundColorAttributeName { get; }
[Field("NSAttachmentAttributeName")] string
NSAttachmentAttributeName { get; }
[Field("NSLigatureAttributeName")] string NSLigatureAttributeName {
get; }
[Field("NSBaselineOffsetAttributeName")] string
NSBaselineOffsetAttributeName { get; }
[Field("NSKernAttributeName")] string NSKernAttributeName { get; }
[Field("NSLinkAttributeName")] string NSLinkAttributeName { get; }
[Field("NSStrokeWidthAttributeName")] string
NSStrokeWidthAttributeName { get; }
[Field("NSStrokeColorAttributeName")] string
NSStrokeColorAttributeName { get; }
[Field("NSUnderlineColorAttributeName")] string
NSUnderlineColorAttributeName { get; }
[Field("NSStrikethroughStyleAttributeName")] string
NSStrikethroughStyleAttributeName { get; }
[Field("NSStrikethroughColorAttributeName")] string
NSStrikethroughColorAttributeName { get; }
[Field("NSShadowAttributeName")] string NSShadowAttributeName { get;
}
[Field("NSObliquenessAttributeName")] string
NSObliquenessAttributeName { get; }
[Field("NSExpansionAttributeName")] string NSExpansionAttributeName
{ get; }
[Field("NSCursorAttributeName")] string NSCursorAttributeName { get;
}
[Field("NSToolTipAttributeName")] string NSToolTipAttributeName {
get; }
[Field("NSCharacterShapeAttributeName")] string
NSCharacterShapeAttributeName { get; }
[Field("NSGlyphInfoAttributeName")] string NSGlyphInfoAttributeName
{ get; }
[Field("NSMarkedClauseSegmentAttributeName")] string
NSMarkedClauseSegmentAttributeName { get; }
[Field("NSUnderlineByWordMask")] string NSUnderlineByWordMask { get;
}
[Field("NSSpellingStateAttributeName")] string
NSSpellingStateAttributeName { get; }
[Field("NSPlainTextDocumentType")] string NSPlainTextDocumentType {
get; }
[Field("NSRTFTextDocumentType")] string NSRTFTextDocumentType { get;
}
[Field("NSRTFDTextDocumentType")] string NSRTFDTextDocumentType {
get; }
[Field("NSMacSimpleTextDocumentType")] string
NSMacSimpleTextDocumentType { get; }
[Field("NSHTMLTextDocumentType")] string NSHTMLTextDocumentType {
get; }
[Field("NSDocFormatTextDocumentType")] string
NSDocFormatTextDocumentType { get; }
[Field("NSWordMLTextDocumentType")] string NSWordMLTextDocumentType
{ get; }
[Field("NSWebArchiveTextDocumentType")] string
NSWebArchiveTextDocumentType { get; }
[Field("NSOfficeOpenXMLTextDocumentType")] string
NSOfficeOpenXMLTextDocumentType { get; }
[Field("NSOpenDocumentTextDocumentType")] string
NSOpenDocumentTextDocumentType { get; }
[Field("NSPaperSizeDocumentAttribute")] string
NSPaperSizeDocumentAttribute { get; }
[Field("NSLeftMarginDocumentAttribute")] string
NSLeftMarginDocumentAttribute { get; }
[Field("NSRightMarginDocumentAttribute")] string
NSRightMarginDocumentAttribute { get; }
[Field("NSTopMarginDocumentAttribute")] string
NSTopMarginDocumentAttribute { get; }
[Field("NSBottomMarginDocumentAttribute")] string
NSBottomMarginDocumentAttribute { get; }
[Field("NSViewSizeDocumentAttribute")] string
NSViewSizeDocumentAttribute { get; }
[Field("NSViewZoomDocumentAttribute")] string
NSViewZoomDocumentAttribute { get; }
[Field("NSViewModeDocumentAttribute")] string
NSViewModeDocumentAttribute { get; }
[Field("NSDocumentTypeDocumentAttribute")] string
NSDocumentTypeDocumentAttribute { get; }
[Field("NSReadOnlyDocumentAttribute")] string
NSReadOnlyDocumentAttribute { get; }
[Field("NSConvertedDocumentAttribute")] string
NSConvertedDocumentAttribute { get; }
[Field("NSCocoaVersionDocumentAttribute")] string
NSCocoaVersionDocumentAttribute { get; }
[Field("NSBackgroundColorDocumentAttribute")] string
NSBackgroundColorDocumentAttribute { get; }
[Field("NSHyphenationFactorDocumentAttribute")] string
NSHyphenationFactorDocumentAttribute { get; }
[Field("NSDefaultTabIntervalDocumentAttribute")] string
NSDefaultTabIntervalDocumentAttribute { get; }
[Field("NSCharacterEncodingDocumentAttribute")] string
NSCharacterEncodingDocumentAttribute { get; }
[Field("NSTitleDocumentAttribute")] string NSTitleDocumentAttribute
{ get; }
[Field("NSCompanyDocumentAttribute")] string
NSCompanyDocumentAttribute { get; }
[Field("NSCopyrightDocumentAttribute")] string
NSCopyrightDocumentAttribute { get; }
[Field("NSSubjectDocumentAttribute")] string
NSSubjectDocumentAttribute { get; }
[Field("NSAuthorDocumentAttribute")] string
NSAuthorDocumentAttribute { get; }
[Field("NSKeywordsDocumentAttribute")] string
NSKeywordsDocumentAttribute { get; }
[Field("NSCommentDocumentAttribute")] string
NSCommentDocumentAttribute { get; }
[Field("NSEditorDocumentAttribute")] string
NSEditorDocumentAttribute { get; }
[Field("NSCreationTimeDocumentAttribute")] string
NSCreationTimeDocumentAttribute { get; }
[Field("NSModificationTimeDocumentAttribute")] string
NSModificationTimeDocumentAttribute { get; }
[Field("NSExcludedElementsDocumentAttribute")] string
NSExcludedElementsDocumentAttribute { get; }
[Field("NSTextEncodingNameDocumentAttribute")] string
NSTextEncodingNameDocumentAttribute { get; }
[Field("NSPrefixSpacesDocumentAttribute")] string
NSPrefixSpacesDocumentAttribute { get; }
[Field("NSDocumentTypeDocumentOption")] string
NSDocumentTypeDocumentOption { get; }
[Field("NSDefaultAttributesDocumentOption")] string
NSDefaultAttributesDocumentOption { get; }
[Field("NSCharacterEncodingDocumentOption")] string
NSCharacterEncodingDocumentOption { get; }
[Field("NSTextEncodingNameDocumentOption")] string
NSTextEncodingNameDocumentOption { get; }
[Field("NSBaseURLDocumentOption")] string NSBaseURLDocumentOption {
get; }
[Field("NSTimeoutDocumentOption")] string NSTimeoutDocumentOption {
get; }
[Field("NSWebPreferencesDocumentOption")] string
NSWebPreferencesDocumentOption { get; }
[Field("NSWebResourceLoadDelegateDocumentOption")] string
NSWebResourceLoadDelegateDocumentOption { get; }
[Field("NSTextSizeMultiplierDocumentOption")] string
NSTextSizeMultiplierDocumentOption { get; }
[Field("NSUnderlineStrikethroughMask")] string
NSUnderlineStrikethroughMask { get; }
//- (NSDictionary *)fontAttributesInRange:(NSRange)range;
[Export ("fontAttributesInRange:")]
NSDictionary FontAttributesInRange (NSRange range);
//- (NSDictionary *)rulerAttributesInRange:(NSRange)range;
[Export ("rulerAttributesInRange:")]
NSDictionary RulerAttributesInRange (NSRange range);
//- (BOOL)containsAttachments;
[Export ("containsAttachments")]
bool ContainsAttachments { get; }
//- (NSUInteger)lineBreakBeforeIndex:(NSUInteger)location
withinRange:(NSRange)aRange;
[Export ("lineBreakBeforeIndex:withinRange:")]
uint LineBreakBeforeIndex (uint location, NSRange aRange);
//#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3-
(NSUInteger)lineBreakByHyphenatingBeforeIndex:(NSUInteger)location
withinRange:(NSRange)aRange;
[Export ("lineBreakByHyphenatingBeforeIndex:withinRange:")]
uint LineBreakByHyphenatingBeforeIndex (uint location, NSRange
aRange);
//#endif - (NSRange)doubleClickAtIndex:(NSUInteger)location;
[Export ("doubleClickAtIndex:")]
NSRange DoubleClickAtIndex (uint location);
//- (NSUInteger)nextWordFromIndex:(NSUInteger)location
forward:(BOOL)isForward;
[Export ("nextWordFromIndex:forward:")]
uint NextWordFromIndex (uint location, bool isForward);
////#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5-
(NSURL *)URLAtIndex:(NSUInteger)location
effectiveRange:(NSRangePointer)effectiveRange;
//[Export ("URLAtIndex:effectiveRange:")]
//NSUrl URLAtIndex (uint location, NSRangePointer effectiveRange);
//#endif #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5+
(NSArray *)textTypes;
[Export ("textTypes")]
NSArray TextTypes { get; }
//+ (NSArray *)textUnfilteredTypes;
[Static, Export ("textUnfilteredTypes")]
NSArray TextUnfilteredTypes { get; }
////#endif #if MAC_OS_X_VERSION_MAX_ALLOWED >=
MAC_OS_X_VERSION_10_4- (NSRange)rangeOfTextBlock:(NSTextBlock *)block
atIndex:(NSUInteger)location;
//[Export ("rangeOfTextBlock:atIndex:")]
//NSRange RangeOfTextBlock (NSTextBlock block, uint location);
////- (NSRange)rangeOfTextTable:(NSTextTable *)table
atIndex:(NSUInteger)location;
//[Export ("rangeOfTextTable:atIndex:")]
//NSRange RangeOfTextTable (NSTextTable table, uint location);
////- (NSRange)rangeOfTextList:(NSTextList *)list
atIndex:(NSUInteger)location;
//[Export ("rangeOfTextList:atIndex:")]
//NSRange RangeOfTextList (NSTextList list, uint location);
////- (NSInteger)itemNumberInTextList:(NSTextList *)list
atIndex:(NSUInteger)location;
//[Export ("itemNumberInTextList:atIndex:")]
//int ItemNumberInTextList (NSTextList list, uint location);
//#endif #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4-
(id)initWithURL:(NSURL *)url options:(NSDictionary *)options
documentAttributes:(NSDictionary **)dict error:(NSError **)error;
[Export ("initWithURL:options:documentAttributes:error:")]
NSAttributedString InitWithURL (NSUrl url, NSDictionary options,
NSDictionary dict, NSError error);
//- (id)initWithData:(NSData *)data options:(NSDictionary *)options
documentAttributes:(NSDictionary **)dict error:(NSError **)error;
[Export ("initWithData:options:documentAttributes:error:")]
NSAttributedString InitWithData (NSData data, NSDictionary options,
NSDictionary dict, NSError error);
//#endif - (id)initWithPath:(NSString *)path
documentAttributes:(NSDictionary **)dict;
[Export ("initWithPath:documentAttributes:")]
NSAttributedString InitWithPath (NSString path, NSDictionary dict);
//- (id)initWithURL:(NSURL *)url documentAttributes:(NSDictionary
**)dict;
[Export ("initWithURL:documentAttributes:")]
NSAttributedString InitWithURL (NSUrl url, NSDictionary dict);
//- (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary
**)dict;
[Export ("initWithRTF:documentAttributes:")]
NSAttributedString InitWithRTF (NSData data, NSDictionary dict);
//- (id)initWithRTFD:(NSData *)data documentAttributes:(NSDictionary
**)dict;
[Export ("initWithRTFD:documentAttributes:")]
NSAttributedString InitWithRTFD (NSData data, NSDictionary dict);
//- (id)initWithHTML:(NSData *)data documentAttributes:(NSDictionary
**)dict;
[Export ("initWithHTML:documentAttributes:")]
NSAttributedString InitWithHTML (NSData data, NSDictionary dict);
//- (id)initWithHTML:(NSData *)data baseURL:(NSURL *)base
documentAttributes:(NSDictionary **)dict;
[Export ("initWithHTML:baseURL:documentAttributes:")]
NSAttributedString InitWithHTML (NSData data, NSUrl baseUrl,
NSDictionary dict);
//#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3-
(id)initWithDocFormat:(NSData *)data documentAttributes:(NSDictionary
**)dict;
[Export ("initWithDocFormat:documentAttributes:")]
NSAttributedString InitWithDocFormat (NSData data, NSDictionary
dict);
//- (id)initWithHTML:(NSData *)data options:(NSDictionary *)options
documentAttributes:(NSDictionary **)dict;
[Export ("initWithHTML:options:documentAttributes:")]
NSAttributedString InitWithHTML (NSData data, NSDictionary options,
NSDictionary dict);
////#endif - (id)initWithRTFDFileWrapper:(NSFileWrapper *)wrapper
documentAttributes:(NSDictionary **)dict;
//[Export ("initWithRTFDFileWrapper:documentAttributes:")]
//NSAttributedString InitWithRTFDFileWrapper (NSFileWrapper wrapper,
NSDictionary dict);
//#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4- (NSData
*)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict
error:(NSError **)error;
[Export ("dataFromRange:documentAttributes:error:")]
NSData DataFromRange (NSRange range, NSDictionary dict, NSError
error);
////- (NSFileWrapper *)fileWrapperFromRange:(NSRange)range
documentAttributes:(NSDictionary *)dict error:(NSError **)error;
//[Export ("fileWrapperFromRange:documentAttributes:error:")]
//NSFileWrapper FileWrapperFromRange (NSRange range, NSDictionary
dict, NSError error);
//#endif - (NSData *)RTFFromRange:(NSRange)range
documentAttributes:(NSDictionary *)dict;
[Export ("RTFFromRange:documentAttributes:")]
NSData RTFFromRange (NSRange range, NSDictionary dict);
//- (NSData *)RTFDFromRange:(NSRange)range
documentAttributes:(NSDictionary *)dict;
[Export ("RTFDFromRange:documentAttributes:")]
NSData RTFDFromRange (NSRange range, NSDictionary dict);
////- (NSFileWrapper *)RTFDFileWrapperFromRange:(NSRange)range
documentAttributes:(NSDictionary *)dict;
//[Export ("RTFDFileWrapperFromRange:documentAttributes:")]
//NSFileWrapper RTFDFileWrapperFromRange (NSRange range,
NSDictionary dict);
//#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3- (NSData
*)docFormatFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
[Export ("docFormatFromRange:documentAttributes:")]
NSData DocFormatFromRange (NSRange range, NSDictionary dict);
//+ (NSArray *)textFileTypes;
[Static, Export ("textFileTypes")]
NSArray TextFileTypes { get; }
//+ (NSArray *)textPasteboardTypes;
[Static, Export ("textPasteboardTypes")]
NSArray TextPasteboardTypes { get; }
//+ (NSArray *)textUnfilteredFileTypes;
[Static, Export ("textUnfilteredFileTypes")]
NSArray TextUnfilteredFileTypes { get; }
//+ (NSArray *)textUnfilteredPasteboardTypes;
[Static, Export ("textUnfilteredPasteboardTypes")]
NSArray TextUnfilteredPasteboardTypes { get; }
// end of new additions
[Export ("string")]
string Value { get; }
[Export ("attributesAtIndex:effectiveRange:")]
NSDictionary GetAttributes (int location, out NSRange
effectiveRange);
[Export ("length")]
int Length { get; }
// TODO: figure out the type, this deserves to be strongly typed if
possble
[Export ("attribute:atIndex:effectiveRange:")]
NSObject GetAttribute (string attribute, int location, out NSRange
effectiveRange);
[Export ("attributedSubstringFromRange:"), Internal]
NSAttributedString Substring (NSRange range);
[Export ("attributesAtIndex:longestEffectiveRange:inRange:")]
NSDictionary GetAttributes (int location, out NSRange
longestEffectiveRange, NSRange rangeLimit);
[Export ("attribute:atIndex:longestEffectiveRange:inRange:")]
NSObject GetAttribute (string attribute, int location, out NSRange
longestEffectiveRange, NSRange rangeLimit);
[Export ("isEqualToAttributedString:")]
bool IsEqual (NSAttributedString other);
[Export ("initWithString:")]
IntPtr Constructor (string str);
[Export ("initWithString:attributes:")]
IntPtr Constructor (string str, NSDictionary attributes);
[Export ("initWithAttributedString:")]
IntPtr Constructor (NSAttributedString other);
}
On Wed, Apr 21, 2010 at 12:15 PM, Miguel de Icaza <miguel at novell.com> wrote:
> Hello Duane,
>
> I could not find in the bindings for these:
>>
>> APPKIT_EXTERN NSString *NSFontAttributeName; // NSFont,
>> default Helvetica 12
>> APPKIT_EXTERN NSString *NSParagraphStyleAttributeName; //
>> NSParagraphStyle, default defaultParagraphStyle
>> APPKIT_EXTERN NSString *NSForegroundColorAttributeName; // NSColor,
>> default blackColor
>> etc....
>>
>> How should these be exposed in the bindings? My guess is it needs to
>> follow the same pattern as in CTStringAttributeKey.cs with the call to
>> Dlfcn.GetStringConstant. Is that correct?
>>
>
> This is correct. I struggle with this because I feel that we should add
> support to the generator for this instead of writing this by hand every
> time.
>
> My concern is the following: for a class that has say 200 of those
> APPKIT_EXTERN declarations, we have multiple options:
>
> (a) initialize them all in the static constructor, slows down a class
> startup for no reason.
> (b) initialize them on demand doing an open/find/close per symbol every
> time (expensive if you need all keys)
>
> And it just occurred to me that what we could do is open the handle on the
> static constructor for the library (to avoid the GetSlowStringConstant
> slowness) and load the data on demand.
>
> The remaining issue is: how do we teach the generator about these
> constants?
>
> Perhaps a [Field] attribute applied to properties?
>
> Miguel.
>
>>
>> Duane
>>
>> _______________________________________________
>> Mono-osx mailing list
>> Mono-osx at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-osx
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100421/9423bf4e/attachment-0001.html
More information about the Mono-osx
mailing list