CPAttributedString Class Reference
[Foundation]

A mutable character string with attributes. More...

List of all members.

Public Member Functions

(void) - addAttribute:value:range: [implementation]
(void) - addAttributes:range: [implementation]
(void) - appendAttributedString: [implementation]
(id) - attribute:atIndex:effectiveRange: [implementation]
(id) - attribute:atIndex:longestEffectiveRange:inRange: [implementation]
(CPAttributedString- attributedSubstringFromRange: [implementation]
(CPDictionary- attributesAtIndex:effectiveRange: [implementation]
(CPDictionary- attributesAtIndex:longestEffectiveRange:inRange: [implementation]
(void) - beginEditing [implementation]
(void) - deleteCharactersInRange: [implementation]
(void) - endEditing [implementation]
(id) - initWithAttributedString: [implementation]
(id) - initWithString: [implementation]
(id) - initWithString:attributes: [implementation]
(void) - insertAttributedString:atIndex: [implementation]
(BOOL) - isEqual: [implementation]
(BOOL) - isEqualToAttributedString: [implementation]
(unsigned) - length [implementation]
(CPString- mutableString [implementation]
(void) - removeAttribute:range: [implementation]
(void) - replaceCharactersInRange:withAttributedString: [implementation]
(void) - replaceCharactersInRange:withString: [implementation]
(void) - setAttributedString: [implementation]
(void) - setAttributes:range: [implementation]
(CPString- string [implementation]

Detailed Description

A mutable character string with attributes.

A character string with sets of attributes that apply to single or ranges of characters. The attributes are containted within a CPDictionary class. Attributes can be any name/value pair. The data type of the value is not restricted. This class is mutable.

Note:
Cocoa developers: in Cappuccino CPAttributedString is mutable. It implements functionality from both NSAttributedString and NSMutableAttributedString. However, to ease converting of existing Objective-C code a CPMutableAttributedString alias to this class exists.

Definition at line 44 of file CPAttributedString.j.


Member Function Documentation

- (void) addAttribute: (CPString anAttribute
value: (id)  aValue
range: (CPRange)  aRange 
[implementation]

Add an attribute with the given name and value to the specified character range.

Note:
Attributes currently associated with the characters in the range are untouched. To remove all previous attributes when adding use -setAttributes:range:.
Parameters:
anAttribute a CPString of the attribute name.
aValue a value to assign to the attribute. Can be of any type.
aRange a CPRange indicating the range of characters to add the attribute too.

Definition at line 628 of file CPAttributedString.j.

- (void) addAttributes: (CPDictionary aDictionary
range: (CPRange)  aRange 
[implementation]

Add a collection of attributes to the specified character range.

Note:
Attributes currently associated with the characters in the range are untouched. To remove all previous attributes when adding use -setAttributes:range:.
Parameters:
aDictionary a CPDictionary of attributes (names and values) to add.
aRange a CPRange indicating the range of characters to add the attributes to.

Definition at line 588 of file CPAttributedString.j.

- (void) appendAttributedString: (CPAttributedString aString   [implementation]

Append an attributed string (characters and attributes) on to the end of the receiver.

Parameters:
aString a CPAttributedString to append.

Definition at line 665 of file CPAttributedString.j.

- (id) attribute: (CPString attribute
atIndex: (unsigned)  index
effectiveRange: (CPRangePointer)  aRange 
[implementation]

Returns the specified named attribute for the given character index and, if required, the range over which the attribute applies.

Note:
there is no guarantee that the range returned is in fact the complete range of a particular attribute. To ensure this use -attribute:atIndex:longestEffectiveRange:inRange: instead but note that it may take significantly longer to execute.
Parameters:
attribute the name of the desired attribute.
anIndex is an unsigned integer character index from which to retrieve the attribute. It must lie within the bounds of the string.
aRange is a reference to a CPRange object, that is set upon return to the range over which the named attribute applies. If not required pass nil.
Returns:
the named attribute or nil is the attribute does not exist.

Definition at line 282 of file CPAttributedString.j.

- (id) attribute: (CPString attribute
atIndex: (unsigned)  anIndex
longestEffectiveRange: (CPRangePointer)  aRange
inRange: (CPRange)  rangeLimit 
[implementation]

Returns the specified named attribute for the given character index and the range over which the attribute applies. This is the maximum range both forwards and backwards in the string over which the attribute applies, bounded in both directions by the range limit parameter, rangeLimit.

Note:
this method performs a search to find this range which may be computationally intensive. Use the rangeLimit to limit the search space or use -attribute:atIndex:effectiveRange: but note that it is not guaranteed to return the full range of the current character's named attribute.
Parameters:
attribute the name of the desired attribute.
anIndex is an unsigned integer character index from which to retrieve the attribute. It must lie within the bounds of the string.
aRange is a reference to a CPRange object, that is set upon return to the range over which the named attribute applies.
rangeLimit a range limiting the search for the attribute's applicable range.
Returns:
the named attribute or nil is the attribute does not exist.

Definition at line 319 of file CPAttributedString.j.

- (CPAttributedString) attributedSubstringFromRange: (CPRange)  aRange   [implementation]

Extracts a substring from the receiver, both characters and attributes, within the range given by aRange.

Parameters:
aRange the range of the substring to extract.
Returns:
a CPAttributedString containing the desired substring.
Exceptions:
CPRangeException if the range lies outside the receiver's bounds.

Definition at line 440 of file CPAttributedString.j.

- (CPDictionary) attributesAtIndex: (unsigned)  anIndex
effectiveRange: (CPRangePointer)  aRange 
[implementation]

Returns a dictionary of attributes for the character at a given index. The range in which this character resides in which the attributes are the same, can be returned if desired.

Note:
there is no guarantee that the range returned is in fact the complete range of the particular attributes. To ensure this use attributesAtIndex:longestEffectiveRange:inRange: instead. Note however that it may take significantly longer to execute.
Parameters:
anIndex is an unsigned integer index. It must lie within the bounds of the string.
aRange is a reference to a CPRange object that is set (upon return) to the range over which the attributes are the same as those at index, anIndex. If not required pass nil.
Returns:
a CPDictionary containing the attributes associated with the character at index anIndex. Returns nil if index is out of bounds.

Definition at line 167 of file CPAttributedString.j.

- (CPDictionary) attributesAtIndex: (unsigned)  anIndex
longestEffectiveRange: (CPRangePointer)  aRange
inRange: (CPRange)  rangeLimit 
[implementation]

Returns a dictionary of all attributes for the character at a given index and, by reference, the range over which the attributes apply. This is the maximum range both forwards and backwards in the string over which the attributes apply, bounded in both directions by the range limit parameter, rangeLimit.

Note:
this method performs a search to find this range which may be computationally intensive. Use the rangeLimit to limit the search space or use -attributesAtIndex:effectiveRange: but note that it is not guaranteed to return the full range of the current character's attributes.
Parameters:
anIndex is the unsigned integer index. It must lie within the bounds of the string.
aRange is a reference to a CPRange object that is set (upon return) to the range over which the attributes apply.
rangeLimit a range limiting the search for the attributes' applicable range.
Returns:
a CPDictionary containing the attributes associated with the character at index anIndex. Returns nil if index is out of bounds.

Definition at line 206 of file CPAttributedString.j.

- (void) beginEditing   [implementation]

This function is deliberately empty. It is provided to ease code converting from Cocoa.

Definition at line 800 of file CPAttributedString.j.

- (void) deleteCharactersInRange: (CPRange)  aRange   [implementation]

Deletes a range of characters and their associated attributes.

Parameters:
aRange a CPRange indicating the range of characters to delete.

Definition at line 541 of file CPAttributedString.j.

- (void) endEditing   [implementation]

This function is deliberately empty. It is provided to ease code converting from Cocoa.

Definition at line 809 of file CPAttributedString.j.

- (id) initWithAttributedString: (CPAttributedString aString   [implementation]

Creates a new attributed string from an existing attributed string.

Parameters:
aString is the attributed string to initialise from.
Returns:
a new CPAttributedString containing the string aString.

Definition at line 66 of file CPAttributedString.j.

- (id) initWithString: (CPString aString   [implementation]

Creates a new attributed string from a character string.

Parameters:
aString is the string to initialise from.
Returns:
a new CPAttributedString containing the string aString.

Definition at line 56 of file CPAttributedString.j.

- (id) initWithString: (CPString aString
attributes: (CPDictionary attributes 
[implementation]

Creates a new attributed string from a character string and the specified dictionary of attributes.

Parameters:
aString is the attributed string to initialise from.
attributes is a dictionary of string attributes.
Returns:
a new CPAttributedString containing the string aString with associated attributes, attributes.

Definition at line 83 of file CPAttributedString.j.

- (void) insertAttributedString: (CPAttributedString aString
atIndex: (unsigned)  anIndex 
[implementation]

Inserts an attributed string (characters and attributes) at index, anIndex, into the receiver. The portion of the receiver's attributed string from the specified index to the end is shifted until after the inserted string.

Parameters:
aString a CPAttributedString to insert.
anIndex the index at which the insert is to occur.
Exceptions:
CPRangeException If the index is out of bounds.

Definition at line 679 of file CPAttributedString.j.

- (BOOL) isEqual: (id)  anObject   [implementation]

Determine whether the given object is the same as the receiver. If the specified object is an attributed string then an attributed string compare is performed.

Parameters:
anObject an object to test for equality.
Returns:
a boolean indicating equality.

Definition at line 421 of file CPAttributedString.j.

- (BOOL) isEqualToAttributedString: (CPAttributedString aString   [implementation]

Compares the receiver's characters and attributes to the specified attributed string, aString, and tests for equality.

Parameters:
aString the CPAttributedString to compare.
Returns:
a boolean indicating equality.

Definition at line 387 of file CPAttributedString.j.

- (unsigned) length   [implementation]

Get the length of the string.

Returns:
an unsigned integer equivalent to the number of characters in the string.

Definition at line 122 of file CPAttributedString.j.

- (CPString) mutableString   [implementation]

Returns a string containing the receiver's character data without attributes.

Returns:
a string of type CPString.

Definition at line 112 of file CPAttributedString.j.

- (void) removeAttribute: (CPString anAttribute
range: (CPRange)  aRange 
[implementation]

Remove a named attribute from a character range.

Parameters:
anAttribute a CPString specifying the name of the attribute.
aRange a CPRange indicating the range of character from which the attribute will be removed.

Definition at line 639 of file CPAttributedString.j.

- (void) replaceCharactersInRange: (CPRange)  aRange
withAttributedString: (CPAttributedString aString 
[implementation]

Replaces characters and attributes in the range aRange with those of the given attributed string, aString.

Parameters:
aRange a CPRange object specifying the range of characters and attributes in the object to replace.
aString a CPAttributedString containing the data to be used for replacement.

Definition at line 724 of file CPAttributedString.j.

- (void) replaceCharactersInRange: (CPRange)  aRange
withString: (CPString aString 
[implementation]

Replaces the characters in the receiver with those of the specified string over the range, aRange. If the range has a length of 0 then the specified string is inserted at the range location. The new characters inherit the attributes of the first character in the range that they replace or in the case if a 0 range length, the first character before of after the insert (after if the insert is at location 0).

Note:
the replacement string need not be the same length as the range being replaced. The full aString is inserted and thus the receiver's length changes to match this
Parameters:
aRange the range of characters to replace.
aString the string to replace the specified characters in the receiver.

Definition at line 502 of file CPAttributedString.j.

- (void) setAttributedString: (CPAttributedString aString   [implementation]

Sets the objects characters and attributes to those of aString.

Parameters:
aString is a CPAttributedString from which the contents will be copied.

Definition at line 739 of file CPAttributedString.j.

- (void) setAttributes: (CPDictionary aDictionary
range: (CPRange)  aRange 
[implementation]

Sets the attributes of the specified character range.

Note:
This process removes the attributes already associated with the character range. If you wish to retain the current attributes use -addAttributes:range:.
Parameters:
aDictionary a CPDictionary of attributes (names and values) to set to.
aRange a CPRange indicating the range of characters to set their associated attributes to aDictionary.

Definition at line 558 of file CPAttributedString.j.

- (CPString) string   [implementation]

Returns a string containing the receiver's character data without attributes.

Returns:
a string of type CPString.

Definition at line 102 of file CPAttributedString.j.


The documentation for this class was generated from the following file:

Generated on Fri Apr 9 11:04:20 2010 for Cappuccino API by  doxygen 1.6.1