home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSAttributedString.h < prev    next >
Text File  |  1996-11-06  |  5KB  |  82 lines

  1. /*    
  2.     NSAttributedString.h
  3.     Copyright (c) 1994-1996, NeXT Software, Inc.
  4.     All rights reserved.
  5.  
  6.     This file defines Application Kit extensions to NSAttributedString and NSMutableAttributedString.
  7. */
  8.  
  9. #ifndef STRICT_OPENSTEP
  10.  
  11. #import <Foundation/Foundation.h>
  12. #import <AppKit/NSFontManager.h>
  13. #import <AppKit/NSText.h>
  14. #import <AppKit/AppKitDefines.h>
  15. @class NSFileWrapper;
  16.  
  17. /* Predefined character attributes for text. If the key is not in the dictionary, then use the default values as described below.
  18. */
  19. APPKIT_EXTERN NSString *NSFontAttributeName;             /* NSFont, default Helvetica 12 */
  20. APPKIT_EXTERN NSString *NSParagraphStyleAttributeName;   /* NSParagraphStyle, default defaultParagraphStyle */
  21. APPKIT_EXTERN NSString *NSForegroundColorAttributeName;  /* NSColor, default blackColor */
  22. APPKIT_EXTERN NSString *NSUnderlineStyleAttributeName;   /* int, default 0: no underline */
  23. APPKIT_EXTERN NSString *NSSuperscriptAttributeName;      /* int, default 0 */
  24. APPKIT_EXTERN NSString *NSBackgroundColorAttributeName;  /* NSColor, default nil: no background */
  25. APPKIT_EXTERN NSString *NSAttachmentAttributeName;       /* NSTextAttachment, default nil */
  26. APPKIT_EXTERN NSString *NSLigatureAttributeName;         /* int, default 1: default ligatures, 0: no ligatures, 2: all ligatures */
  27. APPKIT_EXTERN NSString *NSBaselineOffsetAttributeName;   /* float, in points; offset from baseline, default 0 */
  28. APPKIT_EXTERN NSString *NSKernAttributeName;             /* float, amount to modify default kerning, if 0, kerning off */
  29.  
  30. /* This defines currently supported values for NSUnderlineStyleAttributeName
  31. */
  32. enum {
  33.     NSSingleUnderlineStyle = 1
  34. };
  35.  
  36.  
  37. @interface NSAttributedString (NSAttributedStringKitAdditions)
  38.  
  39. - (NSDictionary *)fontAttributesInRange:(NSRange)range; /* Attributes which should be copied/pasted with "copy font" */
  40. - (NSDictionary *)rulerAttributesInRange:(NSRange)range; /* Attributes which should be copied/pasted with "copy ruler" */
  41.  
  42. - (BOOL)containsAttachments;
  43.  
  44. /* Returns NSNotFound if no line break location found in the specified range; otherwise returns the index of the first character that should go on the NEXT line.
  45. */
  46. - (unsigned)lineBreakBeforeIndex:(unsigned)location withinRange:(NSRange)aRange;
  47. - (NSRange)doubleClickAtIndex:(unsigned)location;
  48. - (unsigned)nextWordFromIndex:(unsigned)location forward:(BOOL)isForward;
  49.  
  50. /* RTF/RTFD methods. If dict is not NULL, the init methods return a dictionary with various document-wide attributes. Similarly the RTF creation methods take an optional dictionary to allow writing out document-wide attributes. Currently supported attributes are @"PaperSize", @"LeftMargin", @"RightMargin", @"TopMargin", @"BottomMargin", and @"HyphenationFactor". The first one is an NSSize (in an NSValue), and the rest are all floats (in NSNumbers).
  51. */
  52. - (id)initWithRTF:(NSData *)data documentAttributes:(NSDictionary **)dict;
  53. - (id)initWithRTFD:(NSData *)data documentAttributes:(NSDictionary **)dict;
  54. - (id)initWithPath:(NSString *)path documentAttributes:(NSDictionary **)dict;
  55. - (id)initWithRTFDFileWrapper:(NSFileWrapper *)wrapper documentAttributes:(NSDictionary **)dict;
  56.  
  57. - (NSData *)RTFFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
  58. - (NSData *)RTFDFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
  59. - (NSFileWrapper *)RTFDFileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict;
  60.  
  61. @end
  62.  
  63.  
  64. @interface NSMutableAttributedString (NSMutableAttributedStringKitAdditions)
  65.  
  66. - (void)superscriptRange:(NSRange)range; /* Increment superscript, make font smaller */
  67. - (void)subscriptRange:(NSRange)range; /* Decrement superscript, make font smaller  */
  68. - (void)unscriptRange:(NSRange)range; /* Undo any superscripting, removing effect of any prior super- or sub-scripting of the range */
  69. - (void)applyFontTraits:(NSFontTraitMask)traitMask range:(NSRange)range; /* Multiple trait changes OK */
  70. - (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
  71.  
  72. /* Methods to "fix" attributes after changes. In the abstract class these are not called automatically. The range arguments are the ranges in the final string.
  73. */
  74. - (void)fixAttributesInRange:(NSRange)range; /* Calls below fix... methods */
  75. - (void)fixFontAttributeInRange:(NSRange)range; /* Make sure the font attribute covers the characters */
  76. - (void)fixParagraphStyleAttributeInRange:(NSRange)range; /* Make sure the paragraph style is valid. Might touch beyond range! */
  77. - (void)fixAttachmentAttributeInRange:(NSRange)range; /* Make sure there are no attachments on non-attachment characters */
  78.  
  79. @end
  80.  
  81. #endif
  82.