NSLayoutManager

NSLayoutManager Mac OS X 10.0

NSLayoutManager is responsible for managing how text is laid out. NSLayoutManager objects manage a set of NSTextContainer objects, and supervise how text is laid out in these containers. Additionally, NSLayoutManager is responsible for mapping Unicode character codes into glyphs that will be displayed in an NSTextView object. In terms of the Model-View-Controller design pattern, NSTextStorage is the model, NSTextView the view, and NSLayoutManager and NSTextContainer are controllers between the data layer and the view layer.

figs/cocn_1546.gif

@interface NSLayoutManager : NSObject <NSCoding>
 // Initializers
   - (id)init;
 // Accessor Methods
   - (void)setDelegate:(id)delegate;
   - (id)delegate;
   - (void)setDefaultAttachmentScaling:(NSImageScaling)scaling;
   - (NSImageScaling)defaultAttachmentScaling;
   - (void)setTemporaryAttributes:(NSDictionary *)attrs forCharacterRange:(NSRange)charRange;
   - (void)setAttachmentSize:(NSSize)attachmentSize forGlyphRange:(NSRange)glyphRange;
   - (void)setNotShownAttribute:(BOOL)flag forGlyphAtIndex:(unsigned)glyphIndex;
   - (void)setTypesetter:(NSTypesetter *)typesetter;
   - (NSTypesetter *)typesetter;
   - (void)setLocation:(NSPoint)location forStartOfGlyphRange:(NSRange)glyphRange;
   - (void)setCharacterIndex:(unsigned)charIndex forGlyphAtIndex:(unsigned)glyphIndex;
   - (void)setBackgroundLayoutEnabled:(BOOL)flag;
   - (BOOL)backgroundLayoutEnabled;
   - (void)setExtraLineFragmentRect:(NSRect)fragmentRect usedRect:(NSRect)usedRect
        textContainer:(NSTextContainer *)container;
   - (NSRect)extraLineFragmentRect;
   - (void)setLineFragmentRect:(NSRect)fragmentRect forGlyphRange:(NSRange)glyphRange 
        usedRect:(NSRect)usedRect;
   - (void)setHyphenationFactor:(float)factor;
   - (float)hyphenationFactor;
   - (void)setUsesScreenFonts:(BOOL)flag;
   - (BOOL)usesScreenFonts;
   - (void)setIntAttribute:(int)attributeTag value:(int)val
     forGlyphAtIndex:(unsigned)glyphIndex;
   - (void)setTypesetterBehavior:(NSTypesetterBehavior)theBehavior;
   - (NSTypesetterBehavior)typesetterBehavior;
   - (void)setTextStorage:(NSTextStorage *)textStorage;
   - (NSTextStorage *)textStorage;
   - (void)setShowsControlCharacters:(BOOL)flag;
   - (BOOL)showsControlCharacters;
   - (void)setDrawsOutsideLineFragment:(BOOL)flag forGlyphAtIndex:(unsigned)glyphIndex;
   - (void)setShowsInvisibleCharacters:(BOOL)flag;
   - (BOOL)showsInvisibleCharacters;
   - (void)setTextContainer:(NSTextContainer *)container forGlyphRange:(NSRange)glyphRange;
 // Instance Methods
   - (void)addTemporaryAttributes:(NSDictionary *)attrs forCharacterRange:(NSRange)charRange;
   - (void)addTextContainer:(NSTextContainer *)container;
   - (NSSize)attachmentSizeForGlyphAtIndex:(unsigned)glyphIndex;
   - (NSRect)boundingRectForGlyphRange:(NSRange)glyphRange inTextContainer:(NSTextContainer *)container;
   - (unsigned)characterIndexForGlyphAtIndex:(unsigned)glyphIndex;
   - (NSRange)characterRangeForGlyphRange:(NSRange)glyphRange
        actualGlyphRange:(NSRangePointer)actualGlyphRange;
   - (float)defaultLineHeightForFont:(NSFont *)theFont;
   - (void)deleteGlyphsInRange:(NSRange)glyphRange;
   - (void)drawBackgroundForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin;
   - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin;
   - (void)drawUnderlineForGlyphRange:(NSRange)glyphRange underlineType:(int)underlineVal
        baselineOffset:(float)baselineOffset lineFragmentRect:(NSRect)lineRect
        lineFragmentGlyphRange:(NSRange)lineGlyphRange containerOrigin:(NSPoint)containerOrigin;
   - (BOOL)drawsOutsideLineFragmentForGlyphAtIndex:(unsigned)glyphIndex;
   - (NSTextContainer *)extraLineFragmentTextContainer;
   - (NSRect)extraLineFragmentUsedRect;
   - (NSTextView *)firstTextView;
   - (unsigned)firstUnlaidCharacterIndex;
   - (unsigned)firstUnlaidGlyphIndex;
   - (float)fractionOfDistanceThroughGlyphForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container;
   - (void)getFirstUnlaidCharacterIndex:(unsigned *)charIndex glyphIndex:(unsigned *)glyphIndex;
   - (unsigned)getGlyphs:(NSGlyph *)glyphArray range:(NSRange)glyphRange;
   - (unsigned)getGlyphsInRange:(NSRange)glyphsRange glyphs:(NSGlyph *)glyphBuffer
        characterIndexes:(unsigned *)charIndexBuffer glyphInscriptions:(NSGlyphInscription *)inscribeBuffer
        elasticBits:(BOOL *)elasticBuffer;
   - (unsigned)getGlyphsInRange:(NSRange)glyphsRange glyphs:(NSGlyph *)glyphBuffer
        characterIndexes:(unsigned *)charIndexBuffer glyphInscriptions:(NSGlyphInscription *)inscribeBuffer
        elasticBits:(BOOL *)elasticBuffer bidiLevels:(unsigned char *)bidiLevelBuffer;
   - (NSGlyph)glyphAtIndex:(unsigned)glyphIndex;
   - (NSGlyph)glyphAtIndex:(unsigned)glyphIndex isValidIndex:(BOOL *)isValidIndex;
   - (unsigned)glyphIndexForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container;
   - (unsigned)glyphIndexForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container
        fractionOfDistanceThroughGlyph:(float *)partialFraction;
   - (NSRange)glyphRangeForBoundingRect:(NSRect)bounds inTextContainer:(NSTextContainer *)container;
   - (NSRange)glyphRangeForBoundingRectWithoutAdditionalLayout:(NSRect)bounds
        inTextContainer:(NSTextContainer *)container;
   - (NSRange)glyphRangeForCharacterRange:(NSRange)charRange
        actualCharacterRange:(NSRangePointer)actualCharRange;
   - (NSRange)glyphRangeForTextContainer:(NSTextContainer *)container;
   - (void)insertGlyph:(NSGlyph)glyph atGlyphIndex:(unsigned)glyphIndex characterIndex:(unsigned)charIndex;
   - (void)insertTextContainer:(NSTextContainer *)container atIndex:(unsigned)index;
   - (int)intAttribute:(int)attributeTag forGlyphAtIndex:(unsigned)glyphIndex;
   - (void)invalidateDisplayForCharacterRange:(NSRange)charRange;
   - (void)invalidateDisplayForGlyphRange:(NSRange)glyphRange;
   - (void)invalidateGlyphsForCharacterRange:(NSRange)charRange changeInLength:(int)delta
        actualCharacterRange:(NSRangePointer)actualCharRange;
   - (void)invalidateLayoutForCharacterRange:(NSRange)charRange isSoft:(BOOL)flag
        actualCharacterRange:(NSRangePointer)actualCharRange;
   - (BOOL)isValidGlyphIndex:(unsigned)glyphIndex;
   - (BOOL)layoutManagerOwnsFirstResponderInWindow:(NSWindow *)window;
   - (NSRect)lineFragmentRectForGlyphAtIndex:(unsigned)glyphIndex
        effectiveRange:(NSRangePointer)effectiveGlyphRange;
   - (NSRect)lineFragmentUsedRectForGlyphAtIndex:(unsigned)glyphIndex
        effectiveRange:(NSRangePointer)effectiveGlyphRange;
   - (NSPoint)locationForGlyphAtIndex:(unsigned)glyphIndex;
   - (BOOL)notShownAttributeForGlyphAtIndex:(unsigned)glyphIndex;
   - (unsigned)numberOfGlyphs;
   - (NSRange)rangeOfNominallySpacedGlyphsContainingIndex:(unsigned)glyphIndex;
   - (NSRectArray)rectArrayForCharacterRange:(NSRange)charRange
        withinSelectedCharacterRange:(NSRange)selCharRange inTextContainer:(NSTextContainer *)container
        rectCount:(unsigned *)rectCount;
   - (NSRectArray)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selGlyphRange
        inTextContainer:(NSTextContainer *)container rectCount:(unsigned *)rectCount;
   - (void)removeTemporaryAttribute:(NSString *)name forCharacterRange:(NSRange)charRange;
   - (void)removeTextContainerAtIndex:(unsigned)index;
   - (void)replaceGlyphAtIndex:(unsigned)glyphIndex withGlyph:(NSGlyph)newGlyph;
   - (void)replaceTextStorage:(NSTextStorage *)newTextStorage;
   - (NSView *)rulerAccessoryViewForTextView:(NSTextView *)view paragraphStyle:(NSParagraphStyle *)style
        ruler:(NSRulerView *)ruler enabled:(BOOL)isEnabled;
   - (NSArray *)rulerMarkersForTextView:(NSTextView *)view paragraphStyle:(NSParagraphStyle *)style
        ruler:(NSRulerView *)ruler;
   - (void)showAttachmentCell:(NSCell *)cell inRect:(NSRect)rect characterIndex:(unsigned)attachmentIndex;
   - (void)showPackedGlyphs:(char *)glyphs length:(unsigned)glyphLen glyphRange:(NSRange)glyphRange
        atPoint:(NSPoint)point font:(NSFont *)font color:(NSColor *)color 
        printingAdjustment:(NSSize)printingAdjustment;
   - (NSFont *)substituteFontForFont:(NSFont *)originalFont;
   - (NSDictionary *)temporaryAttributesAtCharacterIndex:(unsigned)charIndex
        effectiveRange:(NSRangePointer)effectiveCharRange;
   - (void)textContainerChangedGeometry:(NSTextContainer *)container;
   - (void)textContainerChangedTextView:(NSTextContainer *)container;
   - (NSTextContainer *)textContainerForGlyphAtIndex:(unsigned)glyphIndex
        effectiveRange:(NSRangePointer)effectiveGlyphRange;
   - (NSArray *)textContainers;
   - (void)textStorage:(NSTextStorage *)str edited:(unsigned)editedMask range:(NSRange)newCharRange
        changeInLength:(int)delta invalidatedRange:(NSRange)invalidatedCharRange;
   - (NSTextView *)textViewForBeginningOfSelection;
   - (void)underlineGlyphRange:(NSRange)glyphRange underlineType:(int)underlineVal
        lineFragmentRect:(NSRect)lineRect lineFragmentGlyphRange:(NSRange)lineGlyphRange
        containerOrigin:(NSPoint)containerOrigin;
   - (NSRect)usedRectForTextContainer:(NSTextContainer *)container;
 // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
// Methods Implemented by the Delegate
   - (void)layoutManager:(NSLayoutManager *)layoutManager
        didCompleteLayoutForTextContainer:(NSTextContainer *)textContainer atEnd:(BOOL)layoutFinishedFlag;
   - (void)layoutManagerDidInvalidateLayout:(NSLayoutManager *)sender;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes