From: Matthew Judy Date: Fri, 6 Dec 2002 10:37:55 +0000 (+0000) Subject: w00t. I have successfully hacked NSStatusItem to look, if not act, like an NSMenuExtra. X-Git-Tag: v1.0~271 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/4f2a1a6b5d25d7cbae4f356eabe754a4f6e98adb w00t. I have successfully hacked NSStatusItem to look, if not act, like an NSMenuExtra. --- diff --git a/MTApplication.h b/MTApplication.h index 0e98995..f2e297b 100755 --- a/MTApplication.h +++ b/MTApplication.h @@ -12,7 +12,6 @@ */ - #import @interface MTApplication : NSApplication diff --git a/MenuInverted.tiff b/MenuInverted.tiff index 37ed1b6..01aef69 100755 Binary files a/MenuInverted.tiff and b/MenuInverted.tiff differ diff --git a/MenuNormal.tiff b/MenuNormal.tiff index 8e94b1d..f8b2d9a 100755 Binary files a/MenuNormal.tiff and b/MenuNormal.tiff differ diff --git a/MenuTunes.h b/MenuTunes.h index a45d814..bdbe402 100755 --- a/MenuTunes.h +++ b/MenuTunes.h @@ -6,7 +6,7 @@ * Original Author : Kent Sutherland * Responsibility : Kent Sutherland * - * Copyright (c) 2002 The iThink Group. + * Copyright (c) 2002 iThink Software. * All Rights Reserved * */ @@ -15,13 +15,14 @@ #import #import -@class MenuTunesView, PreferencesController, StatusWindowController; +//@class MenuTunesView; +@class PreferencesController, StatusWindowController; @interface MenuTunes : NSObject { NSStatusItem *statusItem; NSMenu *menu; - MenuTunesView *view; +// MenuTunesView *view; ComponentInstance asComponent; //Used in updating the menu automatically diff --git a/MenuTunes.m b/MenuTunes.m index 18565b9..6a440ea 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -12,7 +12,7 @@ Things to do: */ #import "MenuTunes.h" -#import "MenuTunesView.h" +// #import "MenuTunesView.h" #import "PreferencesController.h" #import "HotKeyCenter.h" #import "StatusWindowController.h" @@ -66,12 +66,14 @@ Things to do: } statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; - [statusItem setImage:[NSImage imageNamed:@"menu.tiff"]]; + [[[statusItem _button] cell] setType:0]; + [statusItem setImage:[NSImage imageNamed:@"menu"]]; + [[statusItem _button] setAlternateImage:[NSImage imageNamed:@"selected_image"]]; [statusItem setHighlightMode:YES]; [statusItem setMenu:menu]; [statusItem retain]; - view = [[MenuTunesView alloc] initWithFrame:[[statusItem view] frame]]; - //[statusItem setView:view]; +// view = [[MenuTunesView alloc] initWithFrame:[[statusItem view] frame]]; +// [statusItem setView:view]; } @@ -722,7 +724,7 @@ isEqualToString:@"rewinding"]) { CloseComponent(asComponent); [statusItem release]; [menu release]; - [view release]; +// [view release]; [super dealloc]; } diff --git a/MenuTunesView.h b/MenuTunesView.h index a66f794..06658fe 100755 --- a/MenuTunesView.h +++ b/MenuTunesView.h @@ -7,7 +7,7 @@ * Responsibility : Kent Sutherland * Contributors : Matt Judy * - * Copyright (c) 2002 The iThink Group. + * Copyright (c) 2002 iThink Software. * All Rights Reserved * */ @@ -19,7 +19,7 @@ { NSImage *image; NSImage *altImage; - NSImage *curImage; + BOOL mouseIsPressed; } @end diff --git a/MenuTunesView.m b/MenuTunesView.m index 5bfba53..060c9ca 100755 --- a/MenuTunesView.m +++ b/MenuTunesView.m @@ -1,5 +1,7 @@ #import "MenuTunesView.h" +extern NSColor* _NSGetThemePartColorPattern(int, int, int); +// extern NSColor* _NSGetThemePartColorPattern(int imageID, _NSThemeState state, int color); @implementation MenuTunesView @@ -9,26 +11,39 @@ { image = [NSImage imageNamed:@"menu"]; altImage = [NSImage imageNamed:@"selected_image"]; - curImage = image; + mouseIsPressed = NO; } return self; } - (void)drawRect:(NSRect)rect { - [curImage compositeToPoint:NSMakePoint(0, 0) operation:NSCompositeSourceOver]; + NSImage *icon; + NSColor *background; + + if ( mouseIsPressed ) { + icon = altImage; + background = _NSGetThemePartColorPattern(44, 2, 0); + } else { + icon = image; + background = [NSColor clearColor]; + } + [background set]; + NSRectFill(rect); + [icon compositeToPoint:NSMakePoint(((rect.size.width - [icon size].width) / 2), 0) + operation:NSCompositeSourceOver]; } - (void)mouseDown:(NSEvent *)event { - curImage = altImage; + mouseIsPressed = YES; [self setNeedsDisplay:YES]; [super mouseDown:event]; } - (void)mouseUp:(NSEvent *)event { - curImage = image; + mouseIsPressed = NO; [self setNeedsDisplay:YES]; [super mouseUp:event]; } diff --git a/PreferencesController.h b/PreferencesController.h index de0955c..f935a26 100755 --- a/PreferencesController.h +++ b/PreferencesController.h @@ -6,7 +6,7 @@ * Original Author : Kent Sutherland * Responsibility : Kent Sutherland * - * Copyright (c) 2002 The iThink Group. + * Copyright (c) 2002 iThink Software. * All Rights Reserved * */ diff --git a/StatusWindow.h b/StatusWindow.h index d5dfb6e..1d0f552 100755 --- a/StatusWindow.h +++ b/StatusWindow.h @@ -6,7 +6,7 @@ * Original Author : Kent Sutherland * Responsibility : Kent Sutherland * - * Copyright (c) 2002 The iThink Group. + * Copyright (c) 2002 iThink Software. * All Rights Reserved * */ diff --git a/StatusWindowController.h b/StatusWindowController.h index ba70600..826a372 100755 --- a/StatusWindowController.h +++ b/StatusWindowController.h @@ -6,7 +6,7 @@ * Original Author : Kent Sutherland * Responsibility : Kent Sutherland * - * Copyright (c) 2002 The iThink Group. + * Copyright (c) 2002 iThink Software. * All Rights Reserved * */