Re: How does NSButtonCell do its drawing?
Re: How does NSButtonCell do its drawing?
- Subject: Re: How does NSButtonCell do its drawing?
- From: RICKY SHARP <email@hidden>
- Date: Fri, 01 Feb 2008 04:33:16 -0800
On Friday, February 01, 2008, at 05:01AM, "Uli Kusterer" <email@hidden> wrote:
>On 21.01.2008, at 20:15, Ricky Sharp wrote:
>> For me, it was as simple as using NSAttributedString instances,
>> sending a "size" message to get the NSSize and then exactly
>> centering a box of that width/height within my cell's bounds. Then,
>> I just use drawInRect: to do the rendering.
>
> Thanks for the answer, sorry for the delay.
>
> I'm doing something similar for one-line text. The trouble is, I'd
>like to be able to also correctly measure wrapped multi-line text. I
>was hoping that there was a way to just create and cache the text
>system objects and measure those. The -size method is good for un-
>wrapped text, but of course creates and tears down its text system
>objects every time, which I was hoping to be able to avoid, as this
>text is going to be moved around a lot.
Ahh, I should have also posted what I do for multi-line rendering too. I'll write in when I get home this afternoon. Anyhow, my text rendering allows me to do any of the three text alignments along with either single-line or multi-line text.
> It doesn't seem to be as bad at larger text sizes (which is what
>you're using), but in many cases I'm working with the small system
>font. I even tried scaling the CGContext down and drawing at larger
>sizes, hoping that text measurement might be more accurate, but that
>didn't help. I'm really curious why NSButtonCell can do it right, and
>for me it's this iffy. Does it turn off the leading or something?
Not sure. I'll check this out tonight. My UI allows me to use images of any size, so I can easily create a test nib and make buttons the same size as the various Aqua buttons. Then, I'll fill them with single and multi-line text with point sizes say 12 or less. I'll then compare the output in Photoshop to see if I can guess at what metrics are used in rendering.
--
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden