1 #import "ITStatusItem.h"
3 /*************************************************************************/
5 #pragma mark EVIL HACKERY
6 /*************************************************************************/
8 // This stuff is actually implemented by the AppKit.
9 // We declare it here to cancel out warnings.
11 @interface NSStatusBarButton : NSButton
14 @interface NSStatusItem (HACKHACKHACKHACK)
15 - (id)_initInStatusBar:(NSStatusBar*)statusBar
16 withLength:(float)length
17 withPriority:(int)priority;
18 - (NSStatusBarButton*)_button;
21 /*************************************************************************/
23 #pragma mark PRIVATE METHOD DECLARATIONS
24 /*************************************************************************/
26 @interface ITStatusItem (Private)
27 - (void)setImage:(NSImage*)image;
29 - (void)setTitle:(NSString*)title;
30 - (void)setSmallTitle:(NSString*)title;
33 @implementation ITStatusItem
35 /*************************************************************************/
37 #pragma mark INITIALIZATION METHODS
38 /*************************************************************************/
40 - (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length
42 if ( ( self = [super _initInStatusBar:statusBar
44 withPriority:1000] ) ) {
46 //Eliminate the fucking shadow...
47 [[[self _button] cell] setType:NSNullCellType];
49 //Be something other than a dumbshit about highlighting...
50 [self setHighlightMode:YES];
56 /*************************************************************************/
58 #pragma mark ACCESSOR METHODS
59 /*************************************************************************/
61 - (NSImage*)alternateImage {
62 return [[self _button] alternateImage];
65 - (void)setAlternateImage:(NSImage*)image {
66 [[self _button] setAlternateImage:image];
69 - (void)setImage:(NSImage*)image {
70 [super setImage:image];
72 [self setTitle:[self title]];
76 - (void)setTitle:(NSString*)title {
77 if ( [self image] && (title != nil) ) {
78 [self setSmallTitle:title];
80 [super setTitle:title];
85 /*************************************************************************/
87 #pragma mark PRIVATE METHODS
88 /*************************************************************************/
92 - (void)setSmallTitle:(NSString*)title {
93 NSAttributedString *attrTitle = [[[NSAttributedString alloc] initWithString:title attributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Lucida Grande" size:12.0] forKey:NSFontAttributeName]] autorelease];
94 [self setAttributedTitle:attrTitle];