Re: using the text system to implement styles
Re: using the text system to implement styles
- Subject: Re: using the text system to implement styles
- From: j o a r <email@hidden>
- Date: Wed, 6 Jul 2005 21:39:38 +0200
How about applying all the attributes that the user have configured
for the current style, but also a custom attribute that is the name
of the style. If the user later changes the configuration for a
style, you can simply scan over the string and update the formatting
attributes for all matching ranges accordingly. In this way you don't
have to override the drawing system at all.
j o a r
On 6 jul 2005, at 21.29, Todd Ransom wrote:
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.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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