Added a commented-out line, template for when making builds for beta testers.
[MenuTunes.git] / MenuTunesView.m
1 #import "MenuTunesView.h"
2
3 extern NSColor* _NSGetThemePartColorPattern(int, int, int);
4
5 @implementation MenuTunesView
6
7 - (id)initWithFrame:(NSRect)frame
8 {
9     if ( (self = [super initWithFrame:frame]) )
10     {
11         image = [NSImage imageNamed:@"menu"];
12         altImage = [NSImage imageNamed:@"selected_image"];
13         mouseIsPressed = NO;
14     }
15     return self;
16 }
17
18 - (void)drawRect:(NSRect)rect
19 {
20     NSImage *icon;
21     NSColor *background;
22     
23     if ( mouseIsPressed ) {
24         icon = altImage;
25         background = _NSGetThemePartColorPattern(44, 2, 0);
26     } else {
27         icon = image;
28         background = [NSColor clearColor];
29     }
30     [background set];
31     NSRectFill(rect);
32     [icon compositeToPoint:NSMakePoint(((rect.size.width - [icon size].width) / 2), 0)
33                  operation:NSCompositeSourceOver];
34 }
35
36 - (void)mouseDown:(NSEvent *)event
37 {
38     mouseIsPressed = YES;
39     [self setNeedsDisplay:YES];
40     [super mouseDown:event];
41 }
42
43 - (void)mouseUp:(NSEvent *)event
44 {
45     mouseIsPressed = NO;
46     [self setNeedsDisplay:YES];
47     [super mouseUp:event];
48 }
49
50 @end