1 #import "ITStatusItem.h"
3 @interface ITStatusItemMenuProxy : NSProxy {
4 id <ITStatusItemMenuProvider> menuProvider;
5 ITStatusItem *statusItem;
8 - (id)initWithMenuProvider:(id <ITStatusItemMenuProvider>)provider statusItem:(ITStatusItem *)item;
12 @implementation ITStatusItemMenuProxy
14 + (BOOL)respondsToSelector:(SEL)aSelector {
15 if (![super respondsToSelector:aSelector]) {
16 return [NSMenu respondsToSelector:aSelector];
21 - (id)initWithMenuProvider:(id <ITStatusItemMenuProvider>)provider statusItem:(ITStatusItem *)item {
22 menuProvider = [provider retain];
23 statusItem = [item retain];
27 - (void)forwardInvocation:(NSInvocation *)anInvocation {
28 NSMenu *temporaryMenu = [[menuProvider menuForStatusItem:statusItem] retain];
29 [anInvocation setTarget:temporaryMenu];
30 [anInvocation invoke];
31 [temporaryMenu release];
34 - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
35 NSMenu *temporaryMenu = [[menuProvider menuForStatusItem:statusItem] retain];
36 NSMethodSignature *signature = [temporaryMenu methodSignatureForSelector:aSelector];
37 [temporaryMenu release];
43 [menuProvider release];
49 @class NSStatusBarButton;
51 @interface NSStatusItem (ITStatusItemHacks)
52 - (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority;
53 - (NSStatusBarButton *)_button;
56 @protocol _ITStatusItemNSStatusItemPantherCompatability
57 - (void)setAlternateImage:(NSImage *)image;
58 - (NSImage *)alternateImage;
61 @implementation ITStatusItem
63 static BOOL _ITStatusItemShouldKillShadow = NO;
66 if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1) && (floor(NSAppKitVersionNumber) <= 663.6)) {
67 _ITStatusItemShouldKillShadow = YES;
71 - (id)initWithStatusBar:(NSStatusBar *)statusBar withLength:(float)length {
72 return [self _initInStatusBar:statusBar withLength:length withPriority:1000];
75 - (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority {
76 if ((self = [super _initInStatusBar:statusBar withLength:length withPriority:priority])) {
77 if (_ITStatusItemShouldKillShadow) {
78 [[(NSButton *)[self _button] cell] setType:NSNullCellType];
80 [self setHighlightMode:YES];
85 - (NSImage *)alternateImage {
86 if ([super respondsToSelector:@selector(alternateImage)]) {
87 return [(id <_ITStatusItemNSStatusItemPantherCompatability>)super alternateImage];
89 return [(NSButton *)[self _button] alternateImage];
92 - (void)setAlternateImage:(NSImage*)image {
93 if ([super respondsToSelector:@selector(setAlternateImage:)]) {
94 [(id <_ITStatusItemNSStatusItemPantherCompatability>)super setAlternateImage:image];
97 [(NSButton *)[self _button] setAlternateImage:image];
100 - (id <ITStatusItemMenuProvider>)menuProvider {
101 return _menuProvider;
104 - (void)setMenuProvider:(id <ITStatusItemMenuProvider>)provider {
105 [_menuProvider autorelease];
106 _menuProvider = [provider retain];
108 [self setMenu:[[ITStatusItemMenuProxy alloc] initWithMenuProvider:_menuProvider statusItem:self]];