w00t. I have successfully hacked NSStatusItem to look, if not act, like an NSMenuExtra.
authorMatthew Judy <mjudy@ithinksw.com>
Fri, 6 Dec 2002 10:37:55 +0000 (10:37 +0000)
committerMatthew Judy <mjudy@ithinksw.com>
Fri, 6 Dec 2002 10:37:55 +0000 (10:37 +0000)
MTApplication.h
MenuInverted.tiff
MenuNormal.tiff
MenuTunes.h
MenuTunes.m
MenuTunesView.h
MenuTunesView.m
PreferencesController.h
StatusWindow.h
StatusWindowController.h

index 0e98995..f2e297b 100755 (executable)
@@ -12,7 +12,6 @@
  */
 
 
-
 #import <Cocoa/Cocoa.h>
 
 @interface MTApplication : NSApplication
index 37ed1b6..01aef69 100755 (executable)
Binary files a/MenuInverted.tiff and b/MenuInverted.tiff differ
index 8e94b1d..f8b2d9a 100755 (executable)
Binary files a/MenuNormal.tiff and b/MenuNormal.tiff differ
index a45d814..bdbe402 100755 (executable)
@@ -6,7 +6,7 @@
  *  Original Author : Kent Sutherland <ksuther@ithinksw.com>
  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
  *
- *  Copyright (c) 2002 The iThink Group.
+ *  Copyright (c) 2002 iThink Software.
  *  All Rights Reserved
  *
  */
 #import <Cocoa/Cocoa.h>
 #import <Carbon/Carbon.h>
 
-@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
index 18565b9..6a440ea 100755 (executable)
@@ -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];
 }
 
index a66f794..06658fe 100755 (executable)
@@ -7,7 +7,7 @@
  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
  *     Contributors : Matt Judy <matt@nibfile.com>
  *
- *  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
index 5bfba53..060c9ca 100755 (executable)
@@ -1,5 +1,7 @@
 #import "MenuTunesView.h"
 
+extern NSColor* _NSGetThemePartColorPattern(int, int, int);
+// extern NSColor* _NSGetThemePartColorPattern(int imageID, _NSThemeState state, int color);
 
 @implementation MenuTunesView
 
     {
         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];
 }
index de0955c..f935a26 100755 (executable)
@@ -6,7 +6,7 @@
  *  Original Author : Kent Sutherland <ksuther@ithinksw.com>
  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
  *
- *  Copyright (c) 2002 The iThink Group.
+ *  Copyright (c) 2002 iThink Software.
  *  All Rights Reserved
  *
  */
index d5dfb6e..1d0f552 100755 (executable)
@@ -6,7 +6,7 @@
  *  Original Author : Kent Sutherland <ksuther@ithinksw.com>
  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
  *
- *  Copyright (c) 2002 The iThink Group.
+ *  Copyright (c) 2002 iThink Software.
  *  All Rights Reserved
  *
  */
index ba70600..826a372 100755 (executable)
@@ -6,7 +6,7 @@
  *  Original Author : Kent Sutherland <ksuther@ithinksw.com>
  *   Responsibility : Kent Sutherland <ksuther@ithinksw.com>
  *
- *  Copyright (c) 2002 The iThink Group.
+ *  Copyright (c) 2002 iThink Software.
  *  All Rights Reserved
  *
  */