Hello all,

I'm trying to figure out the cleanest method for viewing one NSTextStorage with multiple attributes (mostly font and paragraph attributes). Basically I am developing a text editor program and I would like to have two different views on the same text, one in a non- paginated mode and another in a paginated mode, and I would like to be able to automatically apply a different font and paragraph style for the paginated mode. I'm not worried about the user being able to edit the attributes in this mode, but they should be able to edit the text itself.

I could simply apply and revert the attributes when the user switches between the modes, and in fact this is my current implementation. However, I would like to allow the user to have multiple windows open on the same document, and not necessarily have them in the same mode, and thus with the same formatting.

My initial thought was to subclass NSLayoutManager's attributedString: method, returning a different attributed string for each view. However, this didn't seem to work. It may have been a problem with glyph caching. I tried to invalidate the glyphs and layout, but the text persisted in the original formatting. Should this have worked?

The next thought was to subclass NSTextStorage and have two different text storage classes that passed on primitive calls to each other (such that they stayed in sync). However, this quickly became more complicated and problematic than I would like because I make extensive use of various delegate calls and the multiple text storages caused problems with this.

So I'm wondering if anyone else has solved this problem. I found one reference to this on the list archive, but the solution was essentially to use another solution that doesn't work for me.

Another possible solution would be to have the NSTextStorage send different attributed strings to the different layout managers. However, I'm unclear as to how the text storage object will know which layout manager is querying it, and thus which set of attributes to apply.

It seems like the best place for me to implement this would be somewhere in the layout manager because the layout manager is associated with the particular view and thus knows which set of attributes should be applied. Unfortunately, the layout manager is complex and it's unclear to me what I should override or change to make this happen.

Any help would be greatly appreciated.

Andrew
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to