using the text system to implement styles
using the text system to implement styles
- Subject: using the text system to implement styles
- From: Todd Ransom <email@hidden>
- Date: Wed, 6 Jul 2005 13:29:03 -0600
Hello,
I am working on an application that consists primarily of a text view
where a user would enter text and assign styles to portions of the
text. Although the text view would contain attributed text, users
would not be able to assign arbitrary attributes to arbitrary text --
most formatting would be handled by assigning a style to the text.
A style consists of anything that can be put in an attributed
string's attributes dictionary plus some other stuff (all caps for
instance). A style can be reconfigured by the user and all text of
that style should adjust to match the new configuration. This leads
me to believe I should store only my custom attributes, adding style
attributes somewhere in the layout process. But I can't seem to
figure out exactly where to do this.
I have looked into subclassing NSLayoutManager and overriding
drawGlyphsForGlyphRange: atPoint: but it is not clear to me how I
should be implementing this method. Do I just use NSString's
drawAtPoint: withAttributes: to draw the string with the attributes I
want?
I have also looked into subclassing NSTextView's drawRect: but I'm
not sure if that's the right thing to do, either. I have seen several
messages that indicate you should avoid overriding drawRect in a text
view if at all possible.
If anyone has any suggestions on the best way to implement this I
would appreciate it.
thanks,
Todd Ransom
Return Self Software
http://returnself.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden