-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuCell.m
executable file
·69 lines (52 loc) · 1.83 KB
/
MenuCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// MenuCell.m
// App Pie
//
// Created by Giacomo Trezzi on 26/04/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "MenuCell.h"
@implementation MenuCell
@synthesize cellName,method, menuController, dark;
-(void)mouseDown:(NSEvent *)theEvent{
dark = 0.1;
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)theEvent{
dark = 0;
[self setNeedsDisplay:YES];
[[self superview] mouseUp:theEvent];
[menuController performSelector:self.method];
}
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
dark = 0;
}
return self;
}
- (void)drawRect:(NSRect)rect {
NSBezierPath * roundrect= [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3 yRadius:3];
[[NSColor clearColor] set];
[roundrect fill];
NSGradient* aGradient =
[[[NSGradient alloc]
initWithColorsAndLocations:
[NSColor colorWithDeviceCyan:0.46 magenta:0.38 yellow:0.39 black:0.03 alpha:.8], (CGFloat)0.0,
[NSColor colorWithDeviceCyan:0.24 magenta:0.19 yellow:0.19 black:0 alpha:.8], (CGFloat)1.0,
nil]
autorelease];
//[aGradient drawInBezierPath:roundrect angle:90];
[[NSColor colorWithDeviceCyan:(0.32+dark) magenta:(0.25+dark) yellow:(0.25+dark) black:(0+dark) alpha:1] set];
[roundrect fill];
NSMutableDictionary * attribs = [NSMutableDictionary dictionary];
NSMutableParagraphStyle *pstyle = [[NSMutableParagraphStyle alloc]
init];
[pstyle setParagraphStyle: [NSParagraphStyle defaultParagraphStyle]];
[pstyle setAlignment: NSCenterTextAlignment];
[attribs setObject:[NSFont fontWithName:@"Lucida Grande" size:10] forKey:NSFontAttributeName];
[attribs setObject:pstyle forKey:NSParagraphStyleAttributeName];
[attribs setObject:[NSColor whiteColor] forKey:NSForegroundColorAttributeName];
[cellName drawAtPoint:NSMakePoint(4, 0) withAttributes:attribs];
}
@end