1 #import "ITCategory-NSMenu.h"
3 extern void _NSGetMenuItemForCommandKeyEvent(NSMenu *menu, void *chicken, void *taco, void *food);
4 extern MenuRef _NSGetCarbonMenu(NSMenu *menu);
6 @interface NSMenu (ITKitCategoryHacks)
10 @protocol _ITKitCategoryNSMenuItemPantherCompatability <NSMenuItem>
11 - (int)indentationLevel;
12 - (void)setIndentationLevel:(int)indentationLevel;
15 @implementation NSMenu (ITKitCategory)
17 - (void)indentItem:(id <NSMenuItem>)item {
18 [self indentItem:item toLevel:1];
21 - (void)indentItemAtIndex:(int)index {
22 [self indentItemAtIndex:index toLevel:1];
25 - (void)indentItem:(id <NSMenuItem>)item toLevel:(int)indentLevel {
26 [self indentItemAtIndex:[self indexOfItem:item] toLevel:indentLevel];
29 - (void)indentItemAtIndex:(int)index toLevel:(int)indentLevel {
30 id <NSMenuItem> theItem = [self itemAtIndex:index];
31 if ([theItem respondsToSelector:@selector(setIndentationLevel:)]) {
32 [(id <_ITKitCategoryNSMenuItemPantherCompatability>)theItem setIndentationLevel:indentLevel];
34 MenuRef carbonMenu = [self menuRef];
36 SetMenuItemIndent(carbonMenu, index + 1, indentLevel);
45 if ([self respondsToSelector:@selector(_menuImpl)]) {
46 (void)[self _menuImpl];
51 _NSGetMenuItemForCommandKeyEvent(self, NULL, &w00t, &m00f);
52 carbonMenu = _NSGetCarbonMenu(self);
56 - (void)removeAllItems {
57 int numOfItems = [self numberOfItems];
61 [self removeItemAtIndex:(i-1)];