home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / Foundation.framework / Versions / B / Headers / NSAttributedString.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-25  |  3.6 KB  |  68 lines

  1. /*    NSAttributedString.h
  2.     Combines a string with arbitrary attributes assigned to ranges of characters within the string.
  3.     Copyright (c) 1994-1996, NeXT Software, Inc, All rights reserved.
  4. */
  5.  
  6. #ifndef STRICT_OPENSTEP
  7.  
  8. #import <Foundation/NSString.h>
  9. #import <Foundation/NSDictionary.h>
  10.  
  11. /**** NSAttributedString, an abstract class ****/
  12.    
  13. @interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSCoding>        /* The primitive methods */
  14. - (NSString *)string;
  15. - (NSDictionary *)attributesAtIndex:(unsigned)location effectiveRange:(NSRange *)range; /* Can pass NULL for range. Note that range isn't necessarily the longest range for which the attribute values are the same. */
  16. @end
  17.  
  18. @interface NSAttributedString (NSExtendedAttributedString)
  19. - (unsigned)length;
  20. - (id)attribute:(NSString *)attrName atIndex:(unsigned int)location effectiveRange:(NSRange *)range; /* Can pass NULL for range. Note that range isn't necessarily the longest range for which the attribute is the same. */
  21. - (NSAttributedString *)attributedSubstringFromRange:(NSRange)range;
  22.  
  23. /* These methods are the same as attributesAtIndex:effectiveRange: & attribute:atIndex:effectiveRange:; but they compute the longest effective range where the attributes values are the same. Use rangeLimit to limit the search area. The resulting range is clipped to this value.
  24. */
  25. - (NSDictionary *)attributesAtIndex:(unsigned)location longestEffectiveRange:(NSRange *)range inRange:(NSRange)rangeLimit;
  26. - (id)attribute:(NSString *)attrName atIndex:(unsigned int)location longestEffectiveRange:(NSRange *)range inRange:(NSRange)rangeLimit;
  27.  
  28. - (BOOL)isEqualToAttributedString:(NSAttributedString *)other;
  29.  
  30. /* There are no abstract implementations of these init methods; you may optionally implement them in your concrete subclasses. 
  31. */
  32. - (id)initWithString:(NSString *)str;
  33. - (id)initWithString:(NSString *)str attributes:(NSDictionary *)attrs;
  34. - (id)initWithAttributedString:(NSAttributedString *)attrStr;
  35.  
  36. @end
  37.  
  38.  
  39. /**** NSMutableAttributedString, an abstract class ****/
  40.  
  41. @interface NSMutableAttributedString : NSAttributedString    /* The primitive methods */
  42. - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str; /* The newly inserted characters have the attributes of the first replaced character; if none replaced, those of the previous character; if none, from the next character */
  43. - (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range; /* Replaces all attributes in the range */
  44. @end
  45.  
  46.  
  47. @interface NSMutableAttributedString (NSExtendedMutableAttributedString)
  48. - (NSMutableString *)mutableString; /* Deal with the string using the mutable string protocol */
  49.  
  50. - (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)range;    /* Change one attribute */
  51. - (void)addAttributes:(NSDictionary *)attrs range:(NSRange)range; /* Change a bunch of attributes */
  52. - (void)removeAttribute:(NSString *)name range:(NSRange)range; /* Remove one attribute */
  53.  
  54. - (void)replaceCharactersInRange:(NSRange)range withAttributedString:(NSAttributedString *)attrString;
  55. - (void)insertAttributedString:(NSAttributedString *)attrString atIndex:(unsigned)loc;
  56. - (void)appendAttributedString:(NSAttributedString *)attrString;
  57. - (void)deleteCharactersInRange:(NSRange)range;
  58. - (void)setAttributedString:(NSAttributedString *)attrString;    /* Replace the whole thing */
  59.  
  60. /* Subclasses interested in hearing about changes need to implement these methods. Default implementations of these do nothing. All methods which change the attributed string using multiple calls should call these messages to coalesce any post-editing processes.
  61. */
  62. - (void)beginEditing;
  63. - (void)endEditing;
  64.  
  65. @end
  66.  
  67. #endif
  68.