1 #import "ITButtonCell.h"
3 #define GRAY_EXTRA_PAD_H 60.0
5 @interface ITButtonCell (Private)
6 - (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView;
9 @implementation ITButtonCell
12 if ((self = [super init])) {
18 - (void)setBezelStyle:(NSBezelStyle)bezelStyle {
19 if (bezelStyle == ITGrayRoundedBezelStyle) {
20 _subStyle = bezelStyle;
21 bezelStyle = NSRegularSquareBezelStyle;
25 [super setBezelStyle:bezelStyle];
28 - (void)drawWithFrame:(NSRect)rect inView:(NSView *)controlView {
29 if (_subStyle == ITGrayRoundedBezelStyle) {
30 [self drawGrayRoundedBezelWithFrame:rect inView:controlView];
31 if ([self attributedTitle]) {
34 stringSize = [[self attributedTitle] size];
35 stringOrigin.x = rect.origin.x + (rect.size.width - stringSize.width) / 2;
36 stringOrigin.y = (rect.origin.y + (rect.size.height - stringSize.height) / 2) - 2;
37 [controlView lockFocus];
38 [[self attributedTitle] drawAtPoint:stringOrigin];
39 [controlView unlockFocus];
41 [super drawInteriorWithFrame:rect inView:controlView];
43 [[controlView superview] setNeedsDisplay:YES];
45 [super drawWithFrame:rect inView:controlView];
49 - (void)drawGrayRoundedBezelWithFrame:(NSRect)rect inView:(NSView *)controlView {
50 NSBezierPath *path = [NSBezierPath bezierPath];
51 float ch = rect.size.height;
52 float cw = rect.size.width;
53 float radius = (ch / 2);
54 NSPoint pointA = NSMakePoint((ch / 2), 0.0);
55 NSPoint pointB = NSMakePoint((cw - (ch / 2)), 0.0);
56 // NSPoint pointC = NSMakePoint((cw - (ch / 2)), ch);
57 NSPoint pointD = NSMakePoint((ch / 2), ch);
58 NSPoint lCtr = NSMakePoint((ch / 2), (ch / 2));
59 NSPoint rCtr = NSMakePoint((cw - (ch / 2)), (ch / 2));
62 [path moveToPoint:pointA];
63 [path lineToPoint:pointB];
64 [path appendBezierPathWithArcWithCenter:rCtr radius:radius startAngle:270.0 endAngle:90.0];
65 [path lineToPoint:pointD];
66 [path appendBezierPathWithArcWithCenter:lCtr radius:radius startAngle:90.0 endAngle:270.0];
68 if ([self isHighlighted]) {
72 [[NSColor colorWithCalibratedWhite:0.15 alpha:alpha] set];