On Apr 27, 2008, at 11:44 PM, Adam R. Maxwell wrote:
On Apr 27, 2008, at 9:29 PM, Seth Willits wrote:
On Apr 27, 2008, at 4:03 PM, Kristopher Matthews wrote:
I have an NSPopUpButton populated with some NSMenuItems that have
images. I'm trying to determine the proper dimensions for the
image. I'm getting the image from [NSWorkspace: iconForFile],
which appears to be returning them at 32x32, much too large.
Manually resizing to 16x16 works well, but I don't want to
hardcode that image size.
Why not? If you want them to be 16x16 (which you do) you kinda have
to set them to be 16x16...
Sure, but you have no way of knowing what the correct size is for an
NSMenuItem (assuming you want a normal size). I set all menu item
images to 16x16 since that looks approximately correct, but I'd
rather have NSMenuItem draw the image at the correct size, or have
something like -[NSMenuItem height] to get a nominal, future-proof
size.
NSMenuItem doesn't actually have a "correct size" - it calculates its
size based on its contents. So a large font in an attributed string
title will cause it to have a larger size, as will setting an image
(or NSView for Leopard).
So asking the menu item for the size isn't the right way to do it -
it's going to say "as large as it needs to be to hold everything".
You don't care how big it is - you want the image to look good with
the menu text.
Instead, it since you want the image to match the size of the text, so
you'd probably be better off by getting the font and measuring its
line height.
Glenn Andreas [EMAIL PROTECTED]
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
_______________________________________________
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 [EMAIL PROTECTED]