From 4f2a1a6b5d25d7cbae4f356eabe754a4f6e98adb Mon Sep 17 00:00:00 2001 From: Matthew Judy Date: Fri, 6 Dec 2002 10:37:55 +0000 Subject: [PATCH] w00t. I have successfully hacked NSStatusItem to look, if not act, like an NSMenuExtra. --- MTApplication.h | 1 - MenuInverted.tiff | Bin 16364 -> 15664 bytes MenuNormal.tiff | Bin 16606 -> 15644 bytes MenuTunes.h | 7 ++++--- MenuTunes.m | 12 +++++++----- MenuTunesView.h | 4 ++-- MenuTunesView.m | 23 +++++++++++++++++++---- PreferencesController.h | 2 +- StatusWindow.h | 2 +- StatusWindowController.h | 2 +- 10 files changed, 35 insertions(+), 18 deletions(-) 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 37ed1b6b3f5213a5715b24d1f2fde97c389670ba..01aef69283b7f414604871679ca591dec403b51c 100755 GIT binary patch delta 982 zcmZ`&O=uHA6n>LLtwAKFX#;Jc+igo4b$|1-$&yCf#6zT8g0>(CO1ir>3)$?FY)us< z_M$}uiF5N*^yWojuYzZ<-tA`0T6hhm-GrnZO5?7a8Qd*6KX-tNx#?z{V8MS=4G zFaSfnFdIPOo=gWajovM`i=t>0PLLcT&j=cWppU)POdkgb7JyiY5kw>LAI_p{hy1{M zPa~QnoU4y39-i0%7<8T(5Zc!->~2mU;Mo}x1GqFmitylc_ucjHkmPs>$ph-+Em*E*r z&8d1er-`DJPlPFI-E1`5@_Nlyl-Wexacr66nr*h`oyn?}$&nN%usmm)T%t%e6nw5+ zw$wFKZ#tE7(dWvVr5c)S_p8j=vYJ{^SA>i}D&W=sR8a8b73GMU`zA0SNkVSEqJ*aX z*AnsV5#!~8-@L%6f_I`)x4JyPP$^L~!*O%A-O#C$W!h_w-r~6OQkkkQRIV>kUJu-r zMVg}fU3NMhw&v0OHVLuKRa=&=x14(m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* 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 * */ -- 2.20.1