X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/671a785b0d869478451bc428ac4e4bf3415253b4..3263678eef57c78d7017185eaa2efb9e644c7f29:/ITStatusItem.m diff --git a/ITStatusItem.m b/ITStatusItem.m old mode 100755 new mode 100644 index 3e2ce57..561ecf2 --- a/ITStatusItem.m +++ b/ITStatusItem.m @@ -1,33 +1,71 @@ -// -// ITStatusItem.m -// iThinkAppKit -// -// Created by Joseph Spiros on Fri Dec 06 2002. -// Copyright (c) 2002 iThink Software. All rights reserved. -// - #import "ITStatusItem.h" +@class NSStatusBarButton; + +@interface NSStatusItem (ITStatusItemHacks) +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority; +- (NSStatusBarButton *)_button; +@end + +@protocol _ITStatusItemNSStatusItemPantherCompatability +- (void)setAlternateImage:(NSImage *)image; +- (NSImage *)alternateImage; +@end @implementation ITStatusItem -- (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length { - statusItem = [statusBar statusItemWithLength:length]; +static BOOL _ITStatusItemShouldKillShadow = NO; + ++ (void)initialize { + if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1) && (floor(NSAppKitVersionNumber) <= 663.6)) { + _ITStatusItemShouldKillShadow = YES; + } } -- (NSStatusItem*) statusItem { - return statusItem; +- (id)initWithStatusBar:(NSStatusBar *)statusBar withLength:(float)length { + return [self _initInStatusBar:statusBar withLength:length withPriority:1000]; } -- (NSImage*) alternateImage { - return [[statusItem _button] alternateImage]; +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority { + if ((self = [super _initInStatusBar:statusBar withLength:length withPriority:priority])) { + if (_ITStatusItemShouldKillShadow) { + [[(NSButton *)[self _button] cell] setType:NSNullCellType]; + } + [self setHighlightMode:YES]; + } + return self; } -- (void) setAlternateImage:(NSImage*)image { - if ([[[[statusItem _button] cell] super] type] != 0) { - [[[statusItem _button] cell] setType:0]; - } - [[statusItem _button] setAlternateImage:image]; +- (NSImage *)alternateImage { + if ([super respondsToSelector:@selector(alternateImage)]) { + return [(id <_ITStatusItemNSStatusItemPantherCompatability>)super alternateImage]; + } + return [(NSButton *)[self _button] alternateImage]; } -@end +- (void)setAlternateImage:(NSImage*)image { + if ([super respondsToSelector:@selector(setAlternateImage:)]) { + [(id <_ITStatusItemNSStatusItemPantherCompatability>)super setAlternateImage:image]; + return; + } + [(NSButton *)[self _button] setAlternateImage:image]; +} + +- (id )menuProvider { + return _menuProvider; +} + +- (void)setMenuProvider:(id )provider { + [_menuProvider autorelease]; + _menuProvider = [provider retain]; +} + +- (NSMenu *)menu { + if (_menuProvider) { + return [_menuProvider menuForStatusItem:self]; + } else { + return [super menu]; + } +} + +@end \ No newline at end of file