Re: Fastest way to push strings to the screen in an NSView?
Re: Fastest way to push strings to the screen in an NSView?
- Subject: Re: Fastest way to push strings to the screen in an NSView?
- From: Scott Ellsworth <email@hidden>
- Date: Thu, 18 Nov 2004 22:22:44 -0800
On Nov 17, 2004, at 6:24 PM, Robbie Haertel wrote:
From the, whatever you call those extra information pages on classes
(http://developer.apple.com/documentation/Cocoa/Conceptual/
AttributedStrings/index.html#//apple_ref/doc/uid/10000036i)
The drawAtPoint: and drawInRect: methods are designed for drawing
small amounts of text or text that must be drawn rarely. They create
and dispose of various supporting text objects every time you call
them. To draw strings repeatedly, it is more efficient to use
NSLayoutManager, as described in "Drawing Strings".
Given that an NSTextStorage is just a subclass of
NSMutableAttributedString, I can use replaceCharactersInRange to change
the strings held in the NSTextStorage. Does everything react
appropriately if I use this to change the characters to be drawn?
(In other words, does my inner draw loop become something as simple as:
[textStorage replaceCharactersInRange:glyphRange
withString:hexNumString];
NSSize numberSize=[textStorage size];
NSRect r=NSMakeRect(2.0*hexSz2-numberSize.width/2, 0, numberSize.width,
numberSize.height);
[layoutManager drawGlyphsForGlyphRange: glyphRange atPoint: r.origin];
)
Scott
_______________________________________________
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