text system architecture
text system architecture
- Subject: text system architecture
- From: johness does <email@hidden>
- Date: Mon, 14 Jul 2003 14:06:59 -0700 (PDT)
This *could* go with my last question ("NSClipView
question (actually two)"), but I thought they had
nothing to do with eachother so I'mn splitting them
up.
First question:
I'm making to text views that show the exact same
thing. I currently have them sharing a text storage
object. Should/can they share any other text system
architecture object (i.e. NSLayoutManager,
TextContainer, etc.) safely? Or is this automatically
done when I use the replaceTextStoreage: message?
Second question:
Using NSLayoutManager I am able to figure out how high
line fragments are etc., but is there any way for me
to QUICKLY figure out what line number a certain point
is at, given I am not using word wrap?
Currently I do this:
NSRange lineRange;
int linenumber= (int)thePoint.origin.y/[layoutManager
lineFragmentRectForGlyphAtIndex: 0 effectiveRange:
&lineRange];
// assume all float to int conversion, dont feel like
typing them out
So basically I choose a random line, assume every line
is that high, then divide the origin of where I'm at
by it to say thats the line number (for example, lets
say I have point (whatever,9) and line height is 3,
I'm at line 3). This seems to work, but I don't know
that it is safe. Is there some crazy font that has
different line sizes? Given that the entire text will
be the same font/size/style and there is NO word wrap,
is this a safe course of action? It is much faster
than starting at the beginning of the text, getting
the line fragment and range, moving to the next, etc.
etc. as suggested in another thread, so I would very
much like to keep this system. If this is NOT safe,
than does anyone else know of some way to figure out
what line number you are one given a specific point?
Thank you in advance,
=====
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
_______________________________________________
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.