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;
22 /*************************************************************************/
24 #pragma mark PRIVATE METHOD DECLARATIONS
25 /*************************************************************************/
27 @interface ITStatusItem (Private)
28 - (void)setImage:(NSImage*)image;
30 - (void)setTitle:(NSString*)title;
31 - (void)setSmallTitle:(NSString*)title;
35 @implementation ITStatusItem
37 /*************************************************************************/
39 #pragma mark INITIALIZATION METHODS
40 /*************************************************************************/
42 - (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length
44 if ( ( self = [super _initInStatusBar:statusBar
46 withPriority:1000] ) ) {
48 //Eliminate the fucking shadow...
49 [[[self _button] cell] setType:NSNullCellType];
51 //Be something other than a dumbshit about highlighting...
52 [self setHighlightMode:YES];
58 /*************************************************************************/
60 #pragma mark ACCESSOR METHODS
61 /*************************************************************************/
63 - (NSImage*)alternateImage {
64 return [[self _button] alternateImage];
67 - (void)setAlternateImage:(NSImage*)image {
68 [[self _button] setAlternateImage:image];
71 - (void)setImage:(NSImage*)image {
72 [super setImage:image];
74 [self setTitle:[self title]];
78 - (void)setTitle:(NSString*)title {
79 if ( [self image] && (title != nil) ) {
80 [self setSmallTitle:title];
82 [super setTitle:title];
87 /*************************************************************************/
89 #pragma mark PRIVATE METHODS
90 /*************************************************************************/
92 - (void)setSmallTitle:(NSString*)title {
93 NSAttributedString *attrTitle = [[[NSAttributedString alloc] initWithString:title attributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"LucidaGrande" size:12.0] forKey:NSFontAttributeName]] autorelease];
94 [self setAttributedTitle:attrTitle];