X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/7351b185cf3f32e36745ad0107b2e27a4634127c..35167b10d151b0ae09f0f807670c318bc4d3de53:/ITStatusItem.m diff --git a/ITStatusItem.m b/ITStatusItem.m index 1b51ca2..fcef033 100755 --- a/ITStatusItem.m +++ b/ITStatusItem.m @@ -12,12 +12,23 @@ @end @interface NSStatusItem (HACKHACKHACKHACK) -- (id) _initInStatusBar:(NSStatusBar*)statusBar +- (id)_initInStatusBar:(NSStatusBar*)statusBar withLength:(float)length withPriority:(int)priority; -- (NSStatusBarButton*) _button; +- (NSStatusBarButton*)_button; @end +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHOD DECLARATIONS +/*************************************************************************/ + +@interface ITStatusItem (Private) +- (void)setImage:(NSImage*)image; +- (NSString*) title; +- (void)setTitle:(NSString*)title; +- (void)setSmallTitle:(NSString*)title; +@end @implementation ITStatusItem @@ -47,12 +58,41 @@ #pragma mark ACCESSOR METHODS /*************************************************************************/ -- (NSImage*) alternateImage { +- (NSImage*)alternateImage { return [[self _button] alternateImage]; } -- (void) setAlternateImage:(NSImage*)image { +- (void)setAlternateImage:(NSImage*)image { [[self _button] setAlternateImage:image]; } +- (void)setImage:(NSImage*)image { + [super setImage:image]; + if ( [self title] ) { + [self setTitle:[self title]]; + } +} + +- (void)setTitle:(NSString*)title { + if ( [self image] && (title != nil) ) { + [self setSmallTitle:title]; + } else { + [super setTitle:title]; + } +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHODS +/*************************************************************************/ + + + +- (void)setSmallTitle:(NSString*)title { + NSAttributedString *attrTitle = [[[NSAttributedString alloc] initWithString:title attributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Lucida Grande" size:12.0] forKey:NSFontAttributeName]] autorelease]; + [self setAttributedTitle:attrTitle]; +} + + @end