Added functionality to make ITStatusItems which have both an image and a
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Tue, 10 Dec 2002 11:56:11 +0000 (11:56 +0000)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Tue, 10 Dec 2002 11:56:11 +0000 (11:56 +0000)
title defined comply with the psuedo-guidelines created by Apple's PPP.menu

ITStatusItem.h
ITStatusItem.m

index 218926d..382b48c 100755 (executable)
@@ -41,4 +41,9 @@
 - (NSImage*) alternateImage;
 - (void) setAlternateImage:(NSImage*)image;
 
+// The following have been redefined as to supply compliance with Jaguar (10.2)'s MenuExtras that have both titles and images. Continue to use them as though you would on a NSStatusItem, everything will be done for you automatically.
+- (void) setImage:(NSImage*)image;
+- (NSString*) title;
+- (void) setTitle:(NSString*)title;
+
 @end
index 1b51ca2..5e517a0 100755 (executable)
 - (NSStatusBarButton*) _button;
 @end
 
+/*************************************************************************/
+#pragma mark -
+#pragma mark PRIVATE METHOD DECLARATIONS
+/*************************************************************************/
+
+@interface ITStatusItem (Private)
+- (void) setSmallTitle:(NSString*)title;
+@end
 
 @implementation ITStatusItem
 
     [[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