X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/2ff4127690b3348dd44e8b693f17e741b7c336d2..32440a12defde03dcc52e42cff4aa6300d7d96fb:/ITStatusItem.m diff --git a/ITStatusItem.m b/ITStatusItem.m index 1b51ca2..5e517a0 100755 --- a/ITStatusItem.m +++ b/ITStatusItem.m @@ -18,6 +18,14 @@ - (NSStatusBarButton*) _button; @end +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHOD DECLARATIONS +/*************************************************************************/ + +@interface ITStatusItem (Private) +- (void) setSmallTitle:(NSString*)title; +@end @implementation ITStatusItem @@ -55,4 +63,37 @@ [[self _button] setAlternateImage:image]; } +- (void) setImage:(NSImage*)image { + [super setImage:image]; + if ([self title]) { + [self setSmallTitle:[self title]]; + } +} + +- (NSString*) title { + if ([self image]) { + return [[self attributedTitle] string]; + } else { + [super title]; + } +} + +- (void) setTitle:(NSString*)title { + [super setTitle:title]; + if ([self image]) { + [self setSmallTitle:[self 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]]; + [self setAttributedTitle:attrTitle]; + [attrTitle release]; +} + @end