Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: AppKit/NSLayoutManager.h
An NSLayoutManager coordinates the layout and display of characters held in an NSTextStorage object. It maps Unicode character codes to glyphs, sets the glyphs in a series of NSTextContainers, and displays them in a series of NSTextViews. In addition to its core function of laying out text, an NSLayoutManager coordinates its NSTextViews, provides services to those NSTextViews to support NSRulerViews for editing paragraph styles, and handles the layout and display of text attributes not inherent in glyphs (such as underline or strikethrough). You can create a subclass of NSLayoutManager to handle additional text attributes, whether inherent or not.
These constants specify how a glyph is laid out relative to
the previous glyph..
Constants | Description |
NSGlyphInscribeBase |
<<Description Forthcoming>> |
NSGlyphInscribeBelow |
<<Description Forthcoming>> |
NSGlyphInscribeAbove |
<<Description Forthcoming>> |
NSGlyphInscribeOverstrike |
<<Description Forthcoming>> |
NSGlyphInscribeOverBelow |
<<Description Forthcoming>> |
<<Description Forthcoming>>
Constants | Description |
NSGlyphAttributeSoft |
<<Description Forthcoming>> |
NSGlyphAttributeElastic |
<<Description Forthcoming>> |
NSGlyphAttributeInscribe |
<<Description Forthcoming>> |
- Creating an instance
- - init
- Setting the text storage
- - setTextStorage:
- - textStorage
- - replaceTextStorage:
- Setting text containers
- - textContainers
- - addTextContainer:
- - insertTextContainer:atIndex:
- - removeTextContainerAtIndex:
- Invalidating glyphs and layout
- - invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:
- - invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:
- - invalidateDisplayForCharacterRange:
- - invalidateDisplayForGlyphRange:
- - textContainerChangedGeometry:
- - textStorage:edited:range:changeInLength:invalidatedRange:
- Turning background layout on/off
- - setBackgroundLayoutEnabled:
- - backgroundLayoutEnabled
- Accessing glyphs
- - insertGlyph:atGlyphIndex:characterIndex:
- - glyphAtIndex:
- - glyphAtIndex:isValidIndex:
- - replaceGlyphAtIndex:withGlyph:
- - getGlyphs:range:
- - deleteGlyphsInRange:
- - numberOfGlyphs
- Mapping characters to glyphs
- - setCharacterIndex:forGlyphAtIndex:
- - characterIndexForGlyphAtIndex:
- - characterRangeForGlyphRange:actualGlyphRange:
- - glyphRangeForCharacterRange:actualCharacterRange:
- Setting glyph attributes
- - setIntAttribute:value:forGlyphAtIndex:
- - intAttribute:forGlyphAtIndex:
- Handling layout for text containers
- - setTextContainer:forGlyphRange:
- - glyphRangeForTextContainer:
- - textContainerForGlyphAtIndex:effectiveRange:
- - usedRectForTextContainer
- Handling line fragment rectangles
- - setLineFragmentRect:forGlyphRange:usedRect:
- - lineFragmentRectForGlyphAtIndex:effectiveRange:
- - lineFragmentUsedRectForGlyphAtIndex:effectiveRange:
- - setExtraLineFragmentRect:usedRect:textContainer:
- - extraLineFragmentRect
- - extraLineFragmentUsedRect
- - extraLineFragmentTextContainer
- - setDrawsOutsideLineFragment:forGlyphAtIndex:
- - drawsOutsideLineFragmentForGlyphAtIndex:
- Layout of glyphs
- - setLocation:forStartOfGlyphRange:
- - locationForGlyphAtIndex:
- - rangeOfNominallySpacedGlyphsContainingIndex:
- - rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount:
- - rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount:
- - boundingRectForGlyphRange:inTextContainer:
- - glyphRangeForBoundingRect:inTextContainer:
- - glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:
- - glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:
- Display of special glyphs
- - setNotShownAttribute:forGlyphAtIndex:
- - notShownAttributeForGlyphAtIndex:
- - setShowsInvisibleCharacters:
- - showsInvisibleCharacters
- - setShowsControlCharacters:
- - showsControlCharacters
- Controlling hyphenation
- - setHyphenationFactor:
- - hyphenationFactor
- Finding unlaid characters/glyphs
- - getFirstUnlaidCharacterIndex:glyphIndex:
- Using screen fonts
- - setUsesScreenFonts:
- - usesScreenFonts
- - substituteFontForFont:
- Handling rulers
- - rulerAccessoryViewForTextView:paragraphStyle:ruler:enabled:
- - rulerMarkersForTextView:paragraphStyle:ruler:
- Managing the responder chain
- - layoutManagerOwnsFirstResponderInWindow:
- - firstTextView
- - textViewForBeginningOfSelection
- Drawing
- - drawBackgroundForGlyphRange:atPoint:
- - drawGlyphsForGlyphRange:atPoint:
- - drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:
- - underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:
- Setting the delegate
- - setDelegate:
- - delegate
- (void)addTextContainer:(NSTextContainer
*)aTextContainer
See Also: - insertTextContainer:atIndex:, - removeTextContainerAtIndex:, - textContainers, - invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:, - invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:
- (BOOL)backgroundLayoutEnabled
YES
if
the receiver generates glyphs and lays out text when the application's
run loop is idle, NO
if it only performs
glyph generation and layout when necessary.See Also: - setBackgroundLayoutEnabled:
- (NSRect)boundingRectForGlyphRange:(NSRange)glyphRange inTextContainer:(NSTextContainer
*)aTextContainer
Performs glyph generation and layout if needed.
See Also: - glyphRangeForTextContainer:, - drawsOutsideLineFragmentForGlyphAtIndex:
- (unsigned int)characterIndexForGlyphAtIndex:(unsigned
int)glyphIndex
Performs glyph generation if needed.
- (NSRange)characterRangeForGlyphRange:(NSRange)glyphRange actualGlyphRange:(NSRange
*)actualGlyphRange
nil
, expands the requested range
as needed so that it identifies all glyphs mapped to those characters
and returns the new range by reference in actualGlyphRange.Suppose
the text store begins with the character "àÒ
"
and the glyph cache contains "O
"
and "¨Æ
". If you
get the character range for the glyph range {0, 1} or {1, 1}, actualGlyphRange is
returned as {0, 2}, indicating that both glyphs are mapped to the
character "àÒ
".
Performs glyph generation if needed.
See Also: - characterIndexForGlyphAtIndex:, - glyphRangeForCharacterRange:actualCharacterRange:
- (id)delegate
See Also: - setDelegate:
- (void)deleteGlyphsInRange:(NSRange)glyphRange
This method is for use by the glyph generation mechanism, and doesn't perform any invalidation or generation of the glyphs or layout. You should never directly invoke this method.
See Also: - insertGlyph:atGlyphIndex:characterIndex:
- (void)drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(NSPoint)containerOrigin
Background marks are such things as selection highlighting, text background color, and any background for marked text.
Performs glyph generation and layout if needed.
See Also: - drawGlyphsForGlyphRange:atPoint:, - glyphRangeForTextContainer:, - textContainerOrigin (NSTextView)
- (void)drawGlyphsForGlyphRange:(NSRange)glyphRange atPoint:(NSPoint)containerOrigin
Performs glyph generation and layout if needed.
See Also: - drawBackgroundForGlyphRange:atPoint:, - glyphRangeForTextContainer:, - textContainerOrigin (NSTextView)
- (BOOL)drawsOutsideLineFragmentForGlyphAtIndex:(unsigned
int)glyphIndex
YES
if
the glyph at glyphIndex exceeds the
bounds of the line fragment where it's laid out, NO
otherwise. This
can happen when text is set at a fixed line height. For example,
if the user specifies a fixed line height of 12 points and sets
the font size to 24 points, the glyphs will exceed their layout
rectangles.Glyphs that draw outside their line fragment rectangles aren't considered when calculating enclosing rectangles with the rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount: and rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount: methods. They are, however, considered by boundingRectForGlyphRange:inTextContainer:
Performs glyph generation and layout if needed.
- (void)drawUnderlineForGlyphRange:(NSRange)glyphRange underlineType:(int)underlineType baselineOffset:(float)baselineOffset lineFragmentRect:(NSRect)lineRect lineFragmentGlyphRange:(NSRange)lineGlyphRange containerOrigin:(NSPoint)containerOrigin
NSSingleUnderlineStyle
,
but subclasses can define their own underline styles. baselineOffset indicates
how far below the text baseline the underline should be drawn; it's
usually a positive value. lineRect is
the line fragment rectangle containing the glyphs to draw underlining
for, and lineGlyphRange is the range of
all glyphs within that line fragment rectangle. containerOrigin is
the origin of the line fragment rectangle's NSTextContainer in
its NSTextView.This method is invoked automatically by underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:; you should rarely need to invoke it directly.
See Also: - textContainerForGlyphAtIndex:effectiveRange:, - textContainerOrigin (NSTextView)
- (NSRect)extraLineFragmentRect
NSZeroRect
if
there is no such rectangle.See Also: - extraLineFragmentUsedRect, - extraLineFragmentTextContainer, - setExtraLineFragmentRect:usedRect:textContainer:
- (NSTextContainer *)extraLineFragmentTextContainer
nil
if
there is no extra line fragment rectangle. This
rectangle is used to display the insertion point for the insertion
point at the end of a text (either in an empty text or after a final
paragraph separator).See Also: - extraLineFragmentRect, - extraLineFragmentUsedRect, - setExtraLineFragmentRect:usedRect:textContainer:
- (NSRect)extraLineFragmentUsedRect
NSZeroRect
if there is no
extra line fragment rectangle.The extra line fragment used rectangle is twice as wide (or tall) as the NSTextContainer's line fragment padding, with the insertion point itself in the middle.
See Also: - extraLineFragmentRect, - extraLineFragmentTextContainer, - setExtraLineFragmentRect:usedRect:textContainer:
- (NSTextView *)firstTextView
- (unsigned int)firstUnlaidCharacterIndex
- (unsigned int)firstUnlaidGlyphIndex
- (float)fractionOfDistanceThroughGlyphForPoint:(NSPoint)aPoint inTextContainer:(NSTextContainer
*)aTextContainer
- (void)getFirstUnlaidCharacterIndex:(unsigned
int *)charIndex glyphIndex:(unsigned
int *)glyphIndex
nil
, in which case
the receiver simply ignores it.As part of its implementation, this method calls firstUnlaidCharacterIndex and firstUnlaidGlyphIndex. To change this method's behavior, override those two methods instead of this one.
- (unsigned int)getGlyphs:(NSGlyph
*)glyphArray range:(NSRange)glyphRange
Performs glyph generation if needed.
See Also: - glyphAtIndex:, - glyphAtIndex:isValidIndex:, - notShownAttributeForGlyphAtIndex:
- (NSGlyph)glyphAtIndex:(unsigned
int)glyphIndex
Performs glyph generation if needed. To avoid an exception with glyphAtIndex: you must first check the glyph index against the number of glyphs, which requires generating all glyphs. Another method, glyphAtIndex:isValidIndex:, generates glyphs only up to the one requested, so using it can be more efficient. <<JPM: Does isValidGlyphIndex: do this for Java?>>
See Also: - getGlyphs:range:
- (NSGlyph)glyphAtIndex:(unsigned
int)glyphIndex isValidIndex:(BOOL
*)flag
YES
. Otherwise
sets flag to NO
(in
which case the return value is meaningless).Performs glyph generation if needed.
See Also: - getGlyphs:range:, - glyphAtIndex:
- (unsigned)glyphIndexForPoint:(NSPoint)aPoint inTextContainer:(NSTextContainer
*)aTextContainer
- (unsigned int)glyphIndexForPoint:(NSPoint)aPoint inTextContainer:(NSTextContainer
*)aTextContainer fractionOfDistanceThroughGlyph:(float
*)partialFraction
nil
the
ratio of the distance into the glyph relative to the next glyph
(in the appropriate sweep direction) is returned by reference in partialFraction.
NSLayoutManager currently supports only left-to-right sweep.For purposes such as dragging out a selection or placing the insertion point, a partial percentage less than or equal to 0.5 indicates that aPoint should be considered as falling before the glyph index returned; a partial percentage greater than 0.5 indicates that it should be considered as falling after the glyph index returned. If the nearest glyph doesn't lie under aPoint at all (for example, if aPoint is beyond the beginning or end of a line) this ratio will be 0 or 1.
Suppose the glyph stream contains the glyphs "A" and "b", with the width of "A" being 13 points. If the user clicks at a location 8 points into "A", partialFraction is 8/13, or 0.615. In this case, the point given should be considered as falling between "A" and "b" for purposes such as dragging out a selection or placing the insertion point. <<needs illo!>>
Performs glyph generation and layout if needed.
As part of its implementation, this method calls fractionOfDistanceThroughGlyphForPoint:inTextContainer: and glyphIndexForPoint:inTextContainer:. To change this method's behavior, override those two methods instead of this one. <<JPM: Last paragraph was not reviewed. Taken from header file.>>
- (NSRange)glyphRangeForBoundingRect:(NSRect)aRect inTextContainer:(NSTextContainer
*)aTextContainer
Performs glyph generation and layout if needed.
See Also: - glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:
- (NSRange)glyphRangeForBoundingRectWithoutAdditionalLayout:(NSRect)bounds inTextContainer:(NSTextContainer
*)container
Unlike glyphRangeForBoundingRect:inTextContainer:, this method doesn't perform glyph generation or layout. Its results, though faster, can be incorrect. This method is primarily for use by NSTextView; you should rarely need to use it yourself.
See Also: - glyphRangeForBoundingRect:inTextContainer:
- (NSRange)glyphRangeForCharacterRange:(NSRange)charRange actualCharacterRange:(NSRange
*)actualCharRange
nil
, expands the requested range
as needed so that it identifies all characters mapped to those glyphs
and returns the new range by reference in actualCharRange.Suppose
the text store contains the characters "n¿™
"
and the glyph cache contains "à±
".
If you get the glyph range for the character range {0, 1} or {1,
1}, actualCharRange is returned as
{0, 2}, indicating both of the characters mapped to the glyph "à±
".
Performs glyph generation if needed.
See Also: - characterIndexForGlyphAtIndex:
- (NSRange)glyphRangeForTextContainer:(NSTextContainer
*)aTextContainer
Performs glyph generation and layout if needed.
- (float)hyphenationFactor
See Also: - setHyphenationFactor:
- (id)init
See Also: - addLayoutManager: (NSTextStorage), - addTextContainer:
- (void)insertGlyph:(NSGlyph)aGlyph atGlyphIndex:(unsigned
int)glyphIndex characterIndex:(unsigned
int)charIndex
This method is for use by the glyph generation mechanism, and doesn't perform any invalidation or generation of the glyphs or layout. You should never directly invoke this method.
See Also: - deleteGlyphsInRange:, - replaceGlyphAtIndex:withGlyph:
- (void)insertTextContainer:(NSTextContainer
*)aTextContainer atIndex:(unsigned
int)index
See Also: - addTextContainer:, - removeTextContainerAtIndex:, - textContainers
- (int)intAttribute:(int)attributeTag forGlyphAtIndex:(unsigned
int)glyphIndex
Subclasses that define their own custom attributes must override this method to access their own storage for the attribute values. Non-negative tags are reserved by Apple; you can define your own attributes with negative tags and set values using setIntAttribute:value:forGlyphAtIndex:.
- (void)invalidateDisplayForCharacterRange:(NSRange)charRange
- (void)invalidateDisplayForGlyphRange:(NSRange)glyphRange
- (void)invalidateGlyphsForCharacterRange:(NSRange)charRange changeInLength:(int)lengthChange actualCharacterRange:(NSRange
*)actualCharRange
nil
, actualCharRange is
set to the range of characters mapped to the glyphs just invalidated.
This can be larger than the range of characters given due to the effect
of context on glyphs and layout.You should rarely need to
invoke this method. It only invalidates glyph information, and performs
no glyph generation or layout. Because invalidating glyphs also
invalidates layout, after invoking this method you should also invoke invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:, passing charRange as
the first argument and NO
as the flag.
- (void)invalidateLayoutForCharacterRange:(NSRange)charRange isSoft:(BOOL)flag actualCharacterRange:(NSRange
*)actualCharRange
YES
,
attempts to save some layout information to avoid recalculation;
if flag is NO
,
saves no layout information. You should typically pass NO
for flag. If
non-nil
, actualCharRange is
set to the range of characters mapped to the glyphs whose layout
information has been invalidated. This can be larger than the range
of characters given due to the effect of context on glyphs and layout.This method only invalidates information; it performs no glyph generation or layout. You should rarely need to invoke this method.
See Also: - invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:
- (BOOL)isValidGlyphIndex:(unsigned)glyphIndex
- (BOOL)layoutManagerOwnsFirstResponderInWindow:(NSWindow
*)aWindow
YES
if
the first responder in aWindow is
an NSTextView associated with the receiver, NO
otherwise.- (NSRect)lineFragmentRectForGlyphAtIndex:(unsigned
int)glyphIndex effectiveRange:(NSRange
*)lineFragmentRange
nil
, lineFragmentRange is
set to contain the range for all glyphs in that line fragment.Performs glyph generation and layout if needed.
See Also: - lineFragmentUsedRectForGlyphAtIndex:effectiveRange:, - setLineFragmentRect:forGlyphRange:usedRect:
- (NSRect)lineFragmentUsedRectForGlyphAtIndex:(unsigned
int)glyphIndex effectiveRange:(NSRange
*)lineFragmentRange
If non-nil
, lineFragmentRange is
set to contain the range for all glyphs in the line fragment.
Performs glyph generation and layout if needed.
See Also: - lineFragmentRectForGlyphAtIndex:effectiveRange:, - setLineFragmentRect:forGlyphRange:usedRect:
- (NSPoint)locationForGlyphAtIndex:(unsigned
int)glyphIndex
Performs glyph generation and layout if needed.
See Also: - lineFragmentRectForGlyphAtIndex:effectiveRange:, - lineFragmentUsedRectForGlyphAtIndex:effectiveRange:
- (BOOL)notShownAttributeForGlyphAtIndex:(unsigned
int)glyphIndex
YES
if
the glyph at glyphIndex isn't shown
(in the sense of the PostScript show
operator), NO
if
it is. For example, a tab, newline, or attachment glyph
doesn't get shown; it just affects the layout of following glyphs
or locates the attachment graphic. Space characters, however, typically
are shown as glyphs with a displacement, though they leave no visible
marks. Raises an NSRangeException if glyphIndex is
out of bounds.Performs glyph generation and layout if needed.
See Also: - setNotShownAttribute:forGlyphAtIndex:
- (unsigned int)numberOfGlyphs
- (NSRange)rangeOfNominallySpacedGlyphsContainingIndex:(unsigned int)glyphIndex
show
operation;
in other words, glyphs with no pairwise kerning or other adjustments
to spacing.Performs glyph generation and layout if needed.
- (NSRect *)rectArrayForCharacterRange:(NSRange)charRange withinSelectedCharacterRange:(NSRange)selCharRange inTextContainer:(NSTextContainer
*)aTextContainer rectCount:(unsigned
int *)rectCount
NSNotFound
.
To calculate the rectangles for drawing highlighting for charRange,
use a selected character range that contains charRange.The number of rectangles returned isn't necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.
The array of rectangles returned is owned by the receiver, and is overwritten by various NSLayoutManager methods. You should never free it, and should copy it if you need to keep the values or use them after sending other messages to the layout manager.
The purpose of this method is to calculate line rectangles for drawing the text background and highlighting. These rectangles don't necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange:inTextContainer: to determine the area that contains all drawing performed for a range of glyphs.
Performs glyph generation and layout if needed.
See Also: - glyphRangeForTextContainer:, - characterRangeForGlyphRange:actualGlyphRange:, - drawsOutsideLineFragmentForGlyphAtIndex:
- (NSRect *)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selGlyphRange inTextContainer:(NSTextContainer
*)aTextContainer rectCount:(unsigned
*)rectCount
The number of rectangles returned isn't necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.
The array of rectangles returned is owned by the receiver, and is overwritten by various NSLayoutManager methods. You should never free it, and should copy it if you need to keep the values or use them after sending other messages to the layout manager.
The purpose of this method is to calculate line rectangles for drawing the text background and highlighting. These rectangles don't necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange:inTextContainer: to determine the area that contains all drawing performed for a range of glyphs.
Performs glyph generation and layout if needed.
See Also: - glyphRangeForTextContainer:, - drawsOutsideLineFragmentForGlyphAtIndex:
- (void)removeTextContainerAtIndex:(unsigned
int)index
See Also: - addTextContainer:, - insertTextContainer:atIndex:, - textContainers, - invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:, - invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:
- (void)replaceGlyphAtIndex:(unsigned
int)glyphIndex withGlyph:(NSGlyph)newGlyph
This method is for use by the glyph generation mechanism, and doesn't perform any invalidation or generation of the glyphs or layout. You should never directly invoke this method
See Also: - setCharacterIndex:forGlyphAtIndex:, - invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:, - invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:
- (void)replaceTextStorage:(NSTextStorage
*)newTextStorage
- (NSView *)rulerAccessoryViewForTextView:(NSTextView
*)aTextView paragraphStyle:(NSParagraphStyle
*)paraStyle ruler:(NSRulerView
*)aRulerView enabled:(BOOL)flag
nil
. If flag is YES
the accessory
view is enabled and accepts mouse and keyboard events; if NO
it's disabled.This method is invoked automatically by the NSTextView object using the layout manager. You should rarely need to invoke it, but you can override it to customize ruler support. If you do this method directly, not that it neither installs the ruler accessory view nor sets the markers for the NSRulerView. You must install the accessory view into the ruler using NSRulerView's setAccessoryView: method. To set the markers, use rulerMarkersForTextView:paragraphStyle:ruler: to get the markers needed and then send setMarkers: to the ruler.
See Also: - horizontalRulerView (NSScrollView)
- (NSArray *)rulerMarkersForTextView:(NSTextView
*)aTextView paragraphStyle:(NSParagraphStyle
*)paraStyle ruler:(NSRulerView
*)aRulerView
This method is invoked automatically by the NSTextView object using the layout manager. You should rarely need to invoke it; but you can override it to add new kinds of markers or otherwise customize ruler support.
See Also: - rulerAccessoryViewForTextView:paragraphStyle:ruler:enabled:
- (void)setBackgroundLayoutEnabled:(BOOL)flag
See Also: - backgroundLayoutEnabled
- (void)setCharacterIndex:(unsigned
int)charIndex forGlyphAtIndex:(unsigned
int)glyphIndex
This method is for use by the glyph generation mechanism, and doesn't perform any invalidation or generation of the glyphs or layout. You should never directly invoke this method.
See Also: - characterIndexForGlyphAtIndex:, - characterRangeForGlyphRange:actualGlyphRange:, - glyphRangeForCharacterRange:actualCharacterRange:
- (void)setDelegate:(id)anObject
See Also: - delegate
- (void)setDrawsOutsideLineFragment:(BOOL)flag forGlyphAtIndex:(unsigned
int)glyphIndex
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - drawsOutsideLineFragmentForGlyphAtIndex:
- (void)setExtraLineFragmentRect:(NSRect)aRect usedRect:(NSRect)usedRect textContainer:(NSTextContainer
*)aTextContainer
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - extraLineFragmentRect, - extraLineFragmentUsedRect, - textContainers
- (void)setHyphenationFactor:(float)factor
See Also: - hyphenationFactor
- (void)setIntAttribute:(int)attributeTag value:(int)anInt forGlyphAtIndex:(unsigned
int)glyphIndex
Subclasses that define their own custom attributes must override this method and provide their own storage for the attribute values. Non-negative tags are reserved by Apple; you can define your own attributes with negative tags and set values using this method.
This method doesn't perform glyph generation or layout. The glyph at glyphIndex must already have been generated.
See Also: - intAttribute:forGlyphAtIndex:
- (void)setLineFragmentRect:(NSRect)fragmentRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRect)usedRect
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - lineFragmentRectForGlyphAtIndex:effectiveRange:, - lineFragmentUsedRectForGlyphAtIndex:effectiveRange:
- (void)setLocation:(NSPoint)aPoint forStartOfGlyphRange:(NSRange)glyphRange
show
operation
(a nominal range). Setting the location for a series of glyphs implies
that the glyphs preceding it can't be included in a single show
operation.Before setting the location for a glyph range, you must specify the text container with setTextContainer:forGlyphRange: and the line fragment rectangle with setLineFragmentRect:forGlyphRange:usedRect:.
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - rangeOfNominallySpacedGlyphsContainingIndex:
- (void)setNotShownAttribute:(BOOL)flag forGlyphAtIndex:(unsigned
int)glyphIndex
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - notShownAttributeForGlyphAtIndex:
- (void)setShowsControlCharacters:(BOOL)flag
YES
,
it substitutes visible glyphs for control characters if the font
and script support it; if flag is NO
it
doesn't.See Also: - setShowsInvisibleCharacters:, - showsControlCharacters
- (void)setShowsInvisibleCharacters:(BOOL)flag
YES
,
it substitutes visible glyphs for invisible characters if the font
and script support it; if flag is NO
it doesn't.See Also: - setShowsControlCharacters:, - showsInvisibleCharacters
- (void)setTextContainer:(NSTextContainer
*)aTextContainer forGlyphRange:(NSRange)glyphRange
This method is used by the layout mechanism; you should never invoke it directly.
See Also: - textContainerForGlyphAtIndex:effectiveRange:
- (void)setTextStorage:(NSTextStorage
*)textStorage
See Also: - addLayoutManager: (NSTextStorage)
- (void)setUsesScreenFonts:(BOOL)flag
See Also: - usesScreenFonts, - substituteFontForFont:
- (void)showAttachmentCell:(NSCell
*)cell inRect:(NSRect)rect characterIndex:(unsigned)attachmentIndex;
- (BOOL)showsControlCharacters
YES
if
the receiver substitutes visible glyphs for control characters if
the font and script support it, NO
if
it doesn't.See Also: - showsInvisibleCharacters, - setShowsControlCharacters:
- (BOOL)showsInvisibleCharacters
YES
if
the receiver substitutes visible glyphs for invisible characters
if the font and script support it, NO
if
it doesn't.See Also: - showsControlCharacters, - setShowsInvisibleCharacters:
- (NSFont *)substituteFontForFont:(NSFont
*)originalFont
See Also: - usesScreenFonts
- (void)textContainerChangedGeometry:(NSTextContainer
*)aTextContainer
- (void)textContainerChangedTextView:(NSTextContainer
*)aTextContainer
- (NSTextContainer *)textContainerForGlyphAtIndex:(unsigned
int)glyphIndex effectiveRange:(NSRange
*)effectiveGlyphRange
nil
, effectiveGlyphRange is
set to the range for all glyphs laid out in that text container.Performs glyph generation and layout if needed.
See Also: - setTextContainer:forGlyphRange:
- (NSArray *)textContainers
See Also: - addTextContainer:, - insertTextContainer:atIndex:, - removeTextContainerAtIndex:
- (NSTextStorage *)textStorage
See Also: - setTextStorage:, - replaceTextStorage:
- (void)textStorage:(NSTextStorage
*)aTextStorage edited:(unsigned
int)mask range:(NSRange)range changeInLength:(int)lengthChange invalidatedRange:(NSRange)invalidatedCharRange
Option | Meaning |
NSTextStorageEditedAttributes |
Attributes were added, removed, or changed. |
NSTextStorageEditedCharacters |
Characters were added, removed, or replaced. |
range indicates the
extent of characters resulting from the edits. If the NSTextStorageEditedCharacters
bit
of mask is set, lengthChange gives
the number of characters added to or removed from the original range
(otherwise its value is irrelevant). For example, after replacing
"The" with "Several" to produce the string "Several files
couldn't be saved", range is
{0, 7} and lengthChange is 4. The
receiver uses this information to update its character-to-glyph
mapping and to update the selection range based on the change.
invalidatedRange represents the range of characters affected after attributes have been fixed. For example, deleting a paragraph separator character invalidates the layout information for all characters in the paragraphs that precede and follow the separator.
textStorage:edited:range:changeInLength:invalidatedRange: messages are sent in a series to each NSLayoutManager associated with the text storage object, so the NSLayoutManagers receiving them shouldn't edit aTextStorage. If one of them does, the range, lengthChange, and invalidatedRange arguments will be incorrect for all following NSLayoutManagers that receive the message.
See Also: - invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:
- (NSTextView *)textViewForBeginningOfSelection
nil
if there's
no selection or there isn't enough layout information to determine
the text view.- (void)underlineGlyphRange:(NSRange)glyphRange underlineType:(int)underlineType lineFragmentRect:(NSRect)lineRect lineFragmentGlyphRange:(NSRange)lineGlyphRange containerOrigin:(NSPoint)containerOrigin
NSSingleUnderlineStyle
,
but subclasses can define their own underline styles. lineRect is
the line fragment rectangle containing the glyphs to draw underlining
for, and lineGlyphRange is the range
of all glyphs within that line fragment rectangle. containerOrigin is
the origin of the line fragment rectangle's NSTextContainer in
its NSTextView.This method determines which glyphs actually
need to be underlined based on underlineType.
With NSSingleUnderlineStyle
, for
example, leading and trailing whitespace isn't underlined, but
whitespace between visible glyphs is. A potential word-underline
style would omit underlining on any whitespace. After determining
which glyphs to draw underlining on, this method invokes drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin: for
each contiguous range of glyphs that requires it.
See Also: - textContainerForGlyphAtIndex:effectiveRange:, - textContainerOrigin (NSTextView)
- (NSRect)usedRectForTextContainer:(NSTextContainer
*)aTextContainer
See Also: - containerSize (NSTextContainer)
- (BOOL)usesScreenFonts
YES
if
the receiver calculates layout and displays text using screen fonts when
possible, NO
otherwise.See Also: - setUsesScreenFonts:, - substituteFontForFont:
- (void)layoutManager:(NSLayoutManager
*)aLayoutManager didCompleteLayoutForTextContainer:(NSTextContainer
*)aTextContainer atEnd:(BOOL)flag
nil
if
there aren't enough containers to hold all the text; the delegate
can use this information as a cue to add another container. If flag is YES
, aLayoutManager is
finished laying out its text-this also means that aTextContainer is
the final text container used by the layout manager. Delegates can
use this information to show an indicator or background or to enable
or disable a button that forces immediate layout of text.- (void)layoutManagerDidInvalidateLayout:(NSLayoutManager
*)aLayoutManager