I'm creating a JNI to display an application wide menu bar instead of the JFrame specific one. This allows me to keep a menubar displayed even when no JFrames are present. I've hit a small snag, in my window menu I can't figure out how to display a diamond for the windows that are minimized. As far as I can tell in the standard API there's only three states available On, Off, and Mixed where mixed is a dash. Is there a way to show the minimized diamond using standard API? Or am I going to have to create a diamond image and use that?
views:
100answers:
1
+3
A:
AppKit isn't using a public API to get this image. It's using _NSGetThemeImage which pulls an image out of the old HIToolbox Appearance Manager theme resources and converts it an NSImage. I wan't able to find an equivalent public API.
If you want to mimic how AppKit does it, use:
NSImage* _NSGetThemeImage(int num);
[menuitem setState:NSOnState];
[menuitem setOnStateImage:_NSGetThemeImage(155)];
Better yet, use this code to grab the NSImage, save it to a TIFF file, and then include that TIFF in your program. That way you avoid using private APIs in the shipping code. I doubt Apple would complain that you're stealing their diamond. ;)
Ken Aspeslagh
2010-08-09 01:24:22
+1 There are no public APIs as far is I can see to do this
jrtc27
2010-08-11 15:38:34
Ugh, that sucks. Oh well, at least there's a way to do it. Thanks for the help!
Argothian
2010-08-12 03:35:12
The documentation for `setOnStateImage:` says "Changing state images is currently unsupported in Mac OS X." Does that mean your solution shouldn't work?
JWWalker
2010-08-13 05:57:27
Well, I tried it before posting the answer and so yes it works.
Ken Aspeslagh
2010-08-15 01:16:28