Re: Customized NSTextView drawing
Re: Customized NSTextView drawing
- Subject: Re: Customized NSTextView drawing
- From: Douglas Davidson <email@hidden>
- Date: Tue, 11 May 2004 11:00:35 -0700
On May 11, 2004, at 9:22 AM, Mark Alldritt wrote:
I would like to experiment with altering attributes other than color
and
underlining. To do this, I think I need to override NSTextStorage's
attributesAtIndex:effectiveRange:. I presume there is some
notification I
need to generate letting the layout manager that it must re-layout a
range
of text. Are there any good code examples showing how to subclass
NSTextStorage? My attempts so far have come to nothing.
In most cases you don't need to do this. You can add custom attributes
to an ordinary text storage in just the same way that you would
AppKit-defined attributes. I presented an example of this at last
year's WWDC, involving additional custom drawing on a per-glyph basis,
specified by custom attributes that were recognized by an
NSLayoutManager subclass in its -drawGlyphsForGlyphRange:atPoint:
method.
The primary reasons for subclassing NSTextStorage are (a) you intend to
use a different storage mechanism than NSAttributedString; (b) you want
to override and alter some text storage-specific functionality such as
attribute fixing; (c) you wish to supply different views of the same
underlying text to different layout managers.
Subclassing NSTextStorage isn't terribly difficult, but there are a
couple of tricky points. I don't have an example ready to hand, but
could probably come up with one if you really do need it.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.